feat(flutter): 完成 K28-A1 四 Tab 首页
This commit is contained in:
1 parent
f981f88e0d
commit
49f3e63ed0
25 files changed
+606
-689
No files matched your search
@@ -15,17 +15,25 @@ class ContinueWatchingCard extends StatelessWidget {
|
||||
required this.drama,
|
||||
required this.record,
|
||||
required this.onResume,
|
||||
this.cardKey = const Key('mine-continue-watching'),
|
||||
this.playButtonKey = const Key('mine-continue-play'),
|
||||
this.progressKey,
|
||||
this.showRemaining = false,
|
||||
});
|
||||
|
||||
final Drama drama;
|
||||
final WatchProgress record;
|
||||
final VoidCallback onResume;
|
||||
final Key cardKey;
|
||||
final Key playButtonKey;
|
||||
final Key? progressKey;
|
||||
final bool showRemaining;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
return Container(
|
||||
key: const Key('mine-continue-watching'),
|
||||
key: cardKey,
|
||||
margin: const EdgeInsets.symmetric(horizontal: 14),
|
||||
padding: const EdgeInsets.all(9),
|
||||
decoration: BoxDecoration(
|
||||
@@ -45,7 +53,7 @@ class ContinueWatchingCard extends StatelessWidget {
|
||||
width: 60,
|
||||
height: 28,
|
||||
child: FilledButton(
|
||||
key: const Key('mine-continue-play'),
|
||||
key: playButtonKey,
|
||||
onPressed: onResume,
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: AppColors.blue,
|
||||
@@ -90,6 +98,7 @@ class ContinueWatchingCard extends StatelessWidget {
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
_progressText(l10n),
|
||||
key: progressKey,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(color: Color(0xFFBBBBBB), fontSize: 9),
|
||||
@@ -100,6 +109,14 @@ class ContinueWatchingCard extends StatelessWidget {
|
||||
|
||||
String _progressText(AppLocalizations l10n) {
|
||||
final episode = drama.episodes.where((item) => item.id == record.episodeId);
|
||||
if (showRemaining) {
|
||||
final number = episode.isEmpty ? 1 : episode.first.number;
|
||||
final remaining = record.duration - record.position;
|
||||
final minutes = remaining.inSeconds <= 0
|
||||
? 0
|
||||
: (remaining.inSeconds / Duration.secondsPerMinute).ceil();
|
||||
return l10n.episodeRemaining(number, minutes);
|
||||
}
|
||||
final label = episode.isEmpty
|
||||
? l10n.episodeCount(drama.episodeCount)
|
||||
: l10n.episodeOfTotal(episode.first.number, drama.episodeCount);
|
||||
|
||||
Reference in new issue
Block a user