diff --git a/lib/pages/player/widgets/player_more_sheet.dart b/lib/pages/player/widgets/player_more_sheet.dart index 6764b47..53cf4df 100644 --- a/lib/pages/player/widgets/player_more_sheet.dart +++ b/lib/pages/player/widgets/player_more_sheet.dart @@ -103,10 +103,8 @@ class _PlayerMoreSheetState extends State { ), 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 { ], ); - 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 { ], ); - 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 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 = diff --git a/test/player/player_fullscreen_test.dart b/test/player/player_fullscreen_test.dart index 4c239f9..6db27eb 100644 --- a/test/player/player_fullscreen_test.dart +++ b/test/player/player_fullscreen_test.dart @@ -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( + find.byKey(const Key('player-more-speed')), + ) + .scrollDirection, + Axis.horizontal, + ); + expect( + tester + .widget( + find.byKey(const Key('player-more-quality')), + ) + .scrollDirection, + Axis.horizontal, + ); expect( tester .widget( @@ -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( + find.descendant( + of: find.byKey(const Key('player-more-speed-1.5')), + matching: find.text('1.5x'), + ), + ) + .style + ?.fontWeight, + FontWeight.w700, + ); + expect( + tester + .widget( + 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 {