fix:按html的假数据demo

This commit is contained in:
jingyun
2026-06-05 11:12:55 +08:00
parent b4272b5ec9
commit 9727b906c6
28 changed files with 2159 additions and 711 deletions
+167 -60
View File
@@ -1,6 +1,9 @@
import 'package:flutter/material.dart';
import '../data/models/models.dart';
import '../theme/app_icons.dart';
import '../theme/yanting_text.dart';
import '../theme/yanting_tokens.dart';
import '../theme/wise_tokens.dart';
import 'app_card.dart';
@@ -47,11 +50,7 @@ class PlayerStateModel {
}
class MiniPlayer extends StatelessWidget {
const MiniPlayer({
required this.player,
required this.onToggle,
super.key,
});
const MiniPlayer({required this.player, required this.onToggle, super.key});
final PlayerStateModel player;
final VoidCallback onToggle;
@@ -59,54 +58,87 @@ class MiniPlayer extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (!player.hasAudio) return const SizedBox.shrink();
final ratio = player.durationSec == 0 ? 0.0 : player.positionSec / player.durationSec;
return Padding(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
child: AppCard(
padding: const EdgeInsets.all(12),
color: WiseColors.primary,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
final ratio = player.durationSec == 0
? 0.0
: player.positionSec / player.durationSec;
return DecoratedBox(
decoration: const BoxDecoration(
color: YantingColors.secondary,
border: Border(top: BorderSide(color: YantingColors.border)),
),
child: Stack(
children: [
Positioned(
top: 0,
left: 0,
right: 0,
child: Align(
alignment: Alignment.centerLeft,
child: FractionallySizedBox(
widthFactor: ratio.clamp(0, 1),
child: const SizedBox(
height: 2,
child: ColoredBox(color: YantingColors.primary),
),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 10, 16, 10),
child: Row(
children: [
IconButton.filled(
onPressed: onToggle,
icon: Icon(player.playing ? Icons.pause : Icons.play_arrow),
style: IconButton.styleFrom(
backgroundColor: WiseColors.secondary,
foregroundColor: WiseColors.primary,
Container(
width: 38,
height: 38,
decoration: BoxDecoration(
color: YantingColors.primary,
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
AppIcons.disc,
color: YantingColors.primaryForeground,
size: 20,
),
),
const SizedBox(width: WiseSpacing.x2),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
player.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w800),
style: YantingText.meta.copyWith(
color: YantingColors.foreground,
fontWeight: FontWeight.w600,
fontFeatures: null,
),
),
const SizedBox(height: 2),
Text(
'${formatDuration(player.positionSec)} / ${formatDuration(player.durationSec)} · ${player.speed.toStringAsFixed(1)}x',
style: const TextStyle(color: Color(0xCCFFFFFF), fontSize: 12),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: YantingText.meta.copyWith(fontSize: 11),
),
],
),
),
IconButton(
onPressed: onToggle,
icon: Icon(
player.playing ? AppIcons.pause : AppIcons.playCircle,
size: player.playing ? 24 : 28,
),
color: YantingColors.foreground,
visualDensity: VisualDensity.compact,
),
],
),
const SizedBox(height: WiseSpacing.x2),
LinearProgressIndicator(
value: ratio.clamp(0, 1),
minHeight: 4,
backgroundColor: const Color(0x33FFFFFF),
color: WiseColors.secondary,
),
],
),
),
],
),
);
}
@@ -138,51 +170,126 @@ class PlayerCard extends StatelessWidget {
final position = active ? player.positionSec : 0;
final ratio = durationSec == 0 ? 0.0 : position / durationSec;
return AppCard(
color: WiseColors.secondary200,
color: YantingColors.secondary,
borderColor: YantingColors.border,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('音频解读', style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: WiseSpacing.x2),
Text(title, style: Theme.of(context).textTheme.bodyMedium),
const SizedBox(height: WiseSpacing.x3),
Text('音频解读', style: YantingText.listTitle),
const SizedBox(height: 6),
Text(
title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: YantingText.meta.copyWith(fontSize: 12.5),
),
const SizedBox(height: 16),
LinearProgressIndicator(
value: ratio.clamp(0, 1),
minHeight: 6,
backgroundColor: Colors.white,
color: WiseColors.accent,
minHeight: 4,
borderRadius: BorderRadius.circular(YantingRadius.pill),
backgroundColor: YantingColors.border,
color: YantingColors.primary,
),
const SizedBox(height: WiseSpacing.x2),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(formatDuration(position), style: Theme.of(context).textTheme.bodySmall),
Text(formatDuration(durationSec), style: Theme.of(context).textTheme.bodySmall),
],
),
const SizedBox(height: WiseSpacing.x3),
Row(
children: [
IconButton.outlined(onPressed: () => onSeek(-15), icon: const Icon(Icons.replay_10)),
IconButton.filled(
onPressed: active ? onToggle : onStart,
icon: Icon(active && player.playing ? Icons.pause : Icons.play_arrow),
style: IconButton.styleFrom(
backgroundColor: WiseColors.primary,
foregroundColor: Colors.white,
),
Text(
formatDuration(position),
style: YantingText.meta.copyWith(fontSize: 11),
),
Text(
formatDuration(durationSec),
style: YantingText.meta.copyWith(fontSize: 11),
),
IconButton.outlined(onPressed: () => onSeek(15), icon: const Icon(Icons.forward_10)),
const Spacer(),
TextButton(onPressed: onSpeed, child: Text('${player.speed.toStringAsFixed(1)}x')),
],
),
const SizedBox(height: 18),
SizedBox(
height: 56,
child: Stack(
alignment: Alignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_SkipButton(label: '-15', onPressed: () => onSeek(-15)),
const SizedBox(width: 26),
IconButton.filled(
onPressed: active ? onToggle : onStart,
icon: Icon(
active && player.playing
? AppIcons.pause
: AppIcons.play,
size: 28,
),
style: IconButton.styleFrom(
backgroundColor: YantingColors.primary,
foregroundColor: YantingColors.primaryForeground,
fixedSize: const Size(56, 56),
),
),
const SizedBox(width: 26),
_SkipButton(label: '+15', onPressed: () => onSeek(15)),
],
),
Align(
alignment: Alignment.centerRight,
child: TextButton(
onPressed: onSpeed,
style: TextButton.styleFrom(
backgroundColor: YantingColors.background,
foregroundColor: YantingColors.foreground,
side: const BorderSide(color: YantingColors.border),
shape: const StadiumBorder(),
padding: const EdgeInsets.symmetric(horizontal: 12),
),
child: Text(
'${player.speed.toStringAsFixed(1)}x',
style: YantingText.meta.copyWith(
color: YantingColors.foreground,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
),
const SizedBox(height: 16),
Text(
'真实音频流待 /audio/{id}/stream 接入,当前为本地进度占位。',
style: Theme.of(context).textTheme.bodySmall,
style: YantingText.meta.copyWith(fontSize: 11.5, height: 1.6),
),
],
),
);
}
}
class _SkipButton extends StatelessWidget {
const _SkipButton({required this.label, required this.onPressed});
final String label;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
return TextButton(
onPressed: onPressed,
style: TextButton.styleFrom(
foregroundColor: YantingColors.foreground,
minimumSize: const Size(40, 40),
padding: EdgeInsets.zero,
),
child: Text(
label,
style: YantingText.meta.copyWith(
color: YantingColors.foreground,
fontWeight: FontWeight.w600,
),
),
);
}
}