merge: 合并 K29.7 更多面板单行排列
This commit is contained in:
commit
3b2bdb8e5a
2 files changed
+118
-25
No files matched your search
@@ -103,10 +103,8 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_header(l10n),
|
_header(l10n),
|
||||||
_sectionTitle(l10n.playbackSpeed),
|
|
||||||
_speedPicker(),
|
_speedPicker(),
|
||||||
const SizedBox(height: _groupGap),
|
const SizedBox(height: 4),
|
||||||
_sectionTitle(l10n.playbackQuality),
|
|
||||||
_qualityPicker(l10n),
|
_qualityPicker(l10n),
|
||||||
const SizedBox(height: _groupGap),
|
const SizedBox(height: _groupGap),
|
||||||
_actionRow(
|
_actionRow(
|
||||||
@@ -153,23 +151,12 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _sectionTitle(String title) => Padding(
|
Widget _speedPicker() => _optionRow(
|
||||||
padding: const EdgeInsets.only(bottom: 8, top: 2),
|
rowKey: const Key('player-more-speed-row'),
|
||||||
child: Text(
|
optionsKey: const Key('player-more-speed'),
|
||||||
title,
|
icon: Icons.speed_rounded,
|
||||||
style: const TextStyle(
|
title: widget.l10n.playbackSpeed,
|
||||||
color: AppColors.muted,
|
options: [
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _speedPicker() => Wrap(
|
|
||||||
key: const Key('player-more-speed'),
|
|
||||||
spacing: _segmentGap,
|
|
||||||
runSpacing: _segmentGap,
|
|
||||||
children: [
|
|
||||||
for (final value in _speedOptions)
|
for (final value in _speedOptions)
|
||||||
_SegmentButton(
|
_SegmentButton(
|
||||||
key: Key('player-more-speed-$value'),
|
key: Key('player-more-speed-$value'),
|
||||||
@@ -183,15 +170,69 @@ class _PlayerMoreSheetState extends State<PlayerMoreSheet> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _qualityPicker(AppLocalizations l10n) => Wrap(
|
Widget _qualityPicker(AppLocalizations l10n) => _optionRow(
|
||||||
key: const Key('player-more-quality'),
|
rowKey: const Key('player-more-quality-row'),
|
||||||
spacing: _segmentGap,
|
optionsKey: const Key('player-more-quality'),
|
||||||
runSpacing: _segmentGap,
|
icon: Icons.high_quality_rounded,
|
||||||
children: [
|
title: l10n.playbackQuality,
|
||||||
|
options: [
|
||||||
for (final quality in _qualityOptions) _qualitySegment(l10n, quality),
|
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) {
|
Widget _qualitySegment(AppLocalizations l10n, String quality) {
|
||||||
final enabled = widget.state.qualities.contains(quality);
|
final enabled = widget.state.qualities.contains(quality);
|
||||||
final selected =
|
final selected =
|
||||||
|
|||||||
@@ -398,6 +398,30 @@ void main() {
|
|||||||
tester.getSize(find.byKey(const Key('player-more-speed-1.0'))).height,
|
tester.getSize(find.byKey(const Key('player-more-speed-1.0'))).height,
|
||||||
28,
|
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(
|
expect(
|
||||||
tester
|
tester
|
||||||
.widget<Text>(
|
.widget<Text>(
|
||||||
@@ -410,6 +434,34 @@ void main() {
|
|||||||
?.fontSize,
|
?.fontSize,
|
||||||
12,
|
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 {
|
testWidgets('should_disable_quality_not_supplied_by_ticket', (tester) async {
|
||||||
|
|||||||
Reference in new issue
Block a user