style(app): 格式化并拆分长函数
This commit is contained in:
1 parent
2b2b7e9913
commit
7850dfc746
31 files changed
+388
-318
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// Author: fruit.com.cn
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -26,54 +26,60 @@ class QualitySheet extends StatelessWidget {
|
||||
key: const Key('player-quality-sheet'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 2, 20, 8),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
l10n.playbackQuality,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
for (final quality in qualities)
|
||||
ListTile(
|
||||
key: Key('player-quality-$quality'),
|
||||
dense: true,
|
||||
title: Text(
|
||||
_label(l10n, quality),
|
||||
style: TextStyle(
|
||||
color: quality == selected ? AppColors.blue : AppColors.cream,
|
||||
fontSize: 13,
|
||||
fontWeight: quality == selected
|
||||
? FontWeight.w700
|
||||
: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
trailing: quality == selected
|
||||
? const Icon(
|
||||
Icons.check_rounded,
|
||||
color: AppColors.blue,
|
||||
size: 18,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 6, 20, 14),
|
||||
child: Text(
|
||||
l10n.qualityAutoHint,
|
||||
style: const TextStyle(color: AppColors.muted, fontSize: 11),
|
||||
),
|
||||
),
|
||||
_header(l10n),
|
||||
for (final quality in qualities) _qualityTile(l10n, quality),
|
||||
_hint(l10n),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _header(AppLocalizations l10n) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 2, 20, 8),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
l10n.playbackQuality,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _qualityTile(AppLocalizations l10n, String quality) {
|
||||
final active = quality == selected;
|
||||
return ListTile(
|
||||
key: Key('player-quality-$quality'),
|
||||
dense: true,
|
||||
title: Text(
|
||||
_label(l10n, quality),
|
||||
style: TextStyle(
|
||||
color: active ? AppColors.blue : AppColors.cream,
|
||||
fontSize: 13,
|
||||
fontWeight: active ? FontWeight.w700 : FontWeight.w500,
|
||||
),
|
||||
),
|
||||
trailing: active
|
||||
? const Icon(Icons.check_rounded, color: AppColors.blue, size: 18)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _hint(AppLocalizations l10n) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(20, 6, 20, 14),
|
||||
child: Text(
|
||||
l10n.qualityAutoHint,
|
||||
style: const TextStyle(color: AppColors.muted, fontSize: 11),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _label(AppLocalizations l10n, String quality) =>
|
||||
quality == autoQuality ? l10n.qualityAuto : quality;
|
||||
}
|
||||
Reference in new issue
Block a user