Files
ShowenV2/clients/flutter/lib/screens/playback_screen.dart
showen d30c111c71 feat: M1.1 完成 + M1.2 启动 — 全量更新
M1.1 收尾:
- 24项 P0/P1/P2 bug 修复 (Rust 107 tests + Flutter 15 tests)
- Flutter App v0.3: cupertino_icons 修复, 单元测试, 调试面板, APK 52.6MB
- 示例插件完善: manifest.json + 请求/响应示范 + 7个测试
- API 文档重写 (以 routes.rs 为唯一权威)
- MILESTONES.md 更新至 100%

M1.2 启动:
- P0: 插件管理 API 闭环 (handle_manager_message Custom 分支 + broadcast_plugin_states)
- ServiceManager 集成测试 8/8 (tests/m1_2_service_manager.rs)
- M1.2 测试计划 (docs/M1.2_TEST_PLAN.md, 18个E2E场景)
- 动态插件系统: auto_rollback + version_manager GC + 路径穿越防护

总计: Rust 115/115 测试, Flutter 15/15 测试, 零 warning

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 18:12:42 +08:00

195 lines
6.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/player_provider.dart';
import '../theme/app_colors.dart';
import '../widgets/control_button.dart';
class PlaybackScreen extends StatefulWidget {
const PlaybackScreen({super.key});
@override
State<PlaybackScreen> createState() => _PlaybackScreenState();
}
class _PlaybackScreenState extends State<PlaybackScreen> {
final TextEditingController _indexController = TextEditingController();
@override
void dispose() {
_indexController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final provider = context.watch<PlayerProvider>();
final status = provider.status;
final playlist = provider.playlist;
return Scaffold(
appBar: AppBar(title: const Text('播放控制')),
body: RefreshIndicator(
onRefresh: _handleRefresh,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
padding: const EdgeInsets.all(AppSpacing.md),
children: [
Card(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.lg),
child: Column(
children: [
Text(
status.currentVideo ?? '暂无播放内容',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(height: AppSpacing.lg),
SizedBox(
width: 132,
height: 132,
child: DecoratedBox(
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: AppColors.primaryGradient,
),
child: IconButton(
onPressed: provider.isLoading
? null
: () => context.read<PlayerProvider>().togglePlayPause(),
iconSize: 56,
color: Colors.white,
icon: Icon(
status.running && !status.paused
? Icons.pause_rounded
: Icons.play_arrow_rounded,
),
),
),
),
const SizedBox(height: AppSpacing.md),
Text(
status.running ? (status.paused ? '已暂停' : '播放中') : '未开始播放',
style: Theme.of(context).textTheme.bodyMedium,
),
],
),
),
),
const SizedBox(height: AppSpacing.md),
Row(
children: [
Expanded(
child: ControlButton(
label: '上一个',
icon: Icons.skip_previous_rounded,
isFilled: false,
onPressed: provider.isLoading
? null
: () => context.read<PlayerProvider>().previous(),
),
),
const SizedBox(width: AppSpacing.md),
Expanded(
child: ControlButton(
label: '下一个',
icon: Icons.skip_next_rounded,
isFilled: false,
onPressed: provider.isLoading
? null
: () => context.read<PlayerProvider>().next(),
),
),
],
),
const SizedBox(height: AppSpacing.lg),
Card(
child: Padding(
padding: const EdgeInsets.all(AppSpacing.md),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('跳转到指定索引', style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: AppSpacing.md),
Row(
children: [
Expanded(
child: TextField(
controller: _indexController,
keyboardType: TextInputType.number,
decoration: const InputDecoration(
labelText: '输入 0 开始的索引',
),
),
),
const SizedBox(width: AppSpacing.md),
FilledButton(
onPressed: provider.isLoading ? null : _handleGoto,
child: const Text('跳转'),
),
],
),
],
),
),
),
const SizedBox(height: AppSpacing.lg),
Text('播放列表', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: AppSpacing.md),
if (playlist.isEmpty)
const Card(
child: Padding(
padding: EdgeInsets.all(AppSpacing.md),
child: Text('当前没有可播放视频'),
),
),
...playlist.asMap().entries.map((entry) {
final selected = entry.key == status.currentIndex;
return Padding(
padding: const EdgeInsets.only(bottom: AppSpacing.sm),
child: Card(
color: selected ? AppColors.primary.withValues(alpha: 0.16) : null,
child: ListTile(
onTap: provider.isLoading
? null
: () => context.read<PlayerProvider>().gotoIndex(entry.key),
leading: CircleAvatar(
backgroundColor: selected ? AppColors.primary : AppColors.border,
child: Text('${entry.key + 1}'),
),
title: Text(entry.value),
subtitle: Text(selected ? '当前播放' : '点击跳转'),
trailing: Icon(
selected ? Icons.equalizer_rounded : Icons.chevron_right_rounded,
),
),
),
);
}),
],
),
),
);
}
Future<void> _handleRefresh() async {
final provider = context.read<PlayerProvider>();
await Future.wait<void>([
provider.fetchStatus(),
provider.fetchPlaylist(),
]);
}
void _handleGoto() {
final index = int.tryParse(_indexController.text.trim());
if (index == null) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('请输入有效索引')),
);
return;
}
context.read<PlayerProvider>().gotoIndex(index);
}
}