fix(flutter): 更多面板倍速清晰度改为单行排列
This commit is contained in:
1 parent
1e3e5b64dc
commit
f083a161e6
2 files changed
+118
-25
No files matched your search
@@ -103,10 +103,8 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_header(l10n),
|
||||
_sectionTitle(l10n.playbackSpeed),
|
||||
_speedPicker(),
|
||||
const SizedBox(height: _groupGap),
|
||||
_sectionTitle(l10n.playbackQuality),
|
||||
const SizedBox(height: 4),
|
||||
_qualityPicker(l10n),
|
||||
const SizedBox(height: _groupGap),
|
||||
_actionRow(
|
||||
@@ -153,23 +151,12 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
|
||||
],
|
||||
);
|
||||
|
||||
Widget _sectionTitle(String title) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8, top: 2),
|
||||
child: Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Widget _speedPicker() => Wrap(
|
||||
key: const Key('player-more-speed'),
|
||||
spacing: _segmentGap,
|
||||
runSpacing: _segmentGap,
|
||||
children: [
|
||||
Widget _speedPicker() => _optionRow(
|
||||
rowKey: const Key('player-more-speed-row'),
|
||||
optionsKey: const Key('player-more-speed'),
|
||||
icon: Icons.speed_rounded,
|
||||
title: widget.l10n.playbackSpeed,
|
||||
options: [
|
||||
for (final value in _speedOptions)
|
||||
_SegmentButton(
|
||||
key: Key('player-more-speed-$value'),
|
||||
@@ -183,15 +170,69 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
|
||||
],
|
||||
);
|
||||
|
||||
Widget _qualityPicker(AppLocalizations l10n) => Wrap(
|
||||
key: const Key('player-more-quality'),
|
||||
spacing: _segmentGap,
|
||||
runSpacing: _segmentGap,
|
||||
children: [
|
||||
Widget _qualityPicker(AppLocalizations l10n) => _optionRow(
|
||||
rowKey: const Key('player-more-quality-row'),
|
||||
optionsKey: const Key('player-more-quality'),
|
||||
icon: Icons.high_quality_rounded,
|
||||
title: l10n.playbackQuality,
|
||||
options: [
|
||||
for (final quality in _qualityOptions) _qualitySegment(l10n, quality),
|
||||
],
|
||||
);
|
||||
|
||||
Widget _optionRow({
|
||||
required Key rowKey,
|
||||
required Key optionsKey,
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required List<Widget> options,
|
||||
}) {
|
||||
return SizedBox(
|
||||
key: rowKey,
|
||||
height: _rowHeight,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 88,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: AppColors.muted, size: 18),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
key: optionsKey,
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
for (var index = 0; index < options.length; index++) ...[
|
||||
if (index > 0) const SizedBox(width: _segmentGap),
|
||||
options[index],
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _qualitySegment(AppLocalizations l10n, String quality) {
|
||||
final enabled = widget.state.qualities.contains(quality);
|
||||
final selected =
|
||||
|
||||
@@ -398,6 +398,30 @@ void main() {
|
||||
tester.getSize(find.byKey(const Key('player-more-speed-1.0'))).height,
|
||||
28,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-speed-row'))).height,
|
||||
44,
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('player-more-quality-row'))).height,
|
||||
44,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<SingleChildScrollView>(
|
||||
find.byKey(const Key('player-more-speed')),
|
||||
)
|
||||
.scrollDirection,
|
||||
Axis.horizontal,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<SingleChildScrollView>(
|
||||
find.byKey(const Key('player-more-quality')),
|
||||
)
|
||||
.scrollDirection,
|
||||
Axis.horizontal,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(
|
||||
@@ -410,6 +434,34 @@ void main() {
|
||||
?.fontSize,
|
||||
12,
|
||||
);
|
||||
await tester.ensureVisible(find.byKey(const Key('player-more-speed-1.5')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('player-more-speed-1.5')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-more-speed-1.5')),
|
||||
matching: find.text('1.5x'),
|
||||
),
|
||||
)
|
||||
.style
|
||||
?.fontWeight,
|
||||
FontWeight.w700,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<Text>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-more-speed-1.0')),
|
||||
matching: find.text('1.0x'),
|
||||
),
|
||||
)
|
||||
.style
|
||||
?.fontWeight,
|
||||
FontWeight.w500,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_disable_quality_not_supplied_by_ticket', (tester) async {
|
||||
|
||||
Reference in new issue
Block a user