feat: Flutter 客户端 App + Web UI APK 下载入口
- 新增 Flutter 跨平台客户端项目 (clients/flutter/)
- 29 个 Dart 文件: 服务层/状态管理/5个页面/BLE配网
- BLE 蓝牙配网: 扫描设备、写入WiFi凭据、配网状态监听
- HTTP API 客户端: 覆盖全部端点 (播放/场景/WiFi/视频/配置/文件/插件)
- WebSocket 实时通信: 事件流 + 自动重连
- 暗色主题 Material 3 UI, 中文界面
- Android 配置: minSdkVersion 21, BLE/网络权限
- PRD 产品需求文档 + 开发任务看板
- Web UI 添加 APK 下载入口 (routes.rs)
- 下载弹窗 + 二维码 + /download/{filename} 静态文件路由
- BLE 插件增加自动重连循环 (ble/mod.rs)
- BLE 默认设备名修正为 'Showen' (config.rs)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
182
clients/flutter/lib/screens/playback_screen.dart
Normal file
182
clients/flutter/lib/screens/playback_screen.dart
Normal file
@@ -0,0 +1,182 @@
|
||||
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: ListView(
|
||||
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.withOpacity(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,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user