- 新增 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>
147 lines
5.6 KiB
Dart
147 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../providers/device_provider.dart';
|
|
import '../providers/player_provider.dart';
|
|
import '../providers/wifi_provider.dart';
|
|
import '../theme/app_colors.dart';
|
|
import '../widgets/control_button.dart';
|
|
import '../widgets/status_card.dart';
|
|
|
|
class HomeScreen extends StatelessWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final deviceProvider = context.watch<DeviceProvider>();
|
|
final playerProvider = context.watch<PlayerProvider>();
|
|
final wifiProvider = context.watch<WifiProvider>();
|
|
final device = deviceProvider.status;
|
|
final player = playerProvider.status;
|
|
final wifi = wifiProvider.status;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('ShowenV2 控制台')),
|
|
body: RefreshIndicator(
|
|
onRefresh: () async {
|
|
await Future.wait<void>([
|
|
context.read<DeviceProvider>().refresh(),
|
|
context.read<PlayerProvider>().bootstrap(),
|
|
context.read<WifiProvider>().bootstrap(),
|
|
]);
|
|
},
|
|
child: ListView(
|
|
padding: const EdgeInsets.all(AppSpacing.md),
|
|
children: [
|
|
StatusCard(
|
|
title: '设备连接',
|
|
value: device.connected ? '已连接' : '未连接',
|
|
subtitle: '${device.ipAddress ?? deviceProvider.deviceIp} · ${device.connectionType.toUpperCase()}',
|
|
icon: Icons.devices_rounded,
|
|
accentColor: device.connected ? AppColors.success : AppColors.warning,
|
|
),
|
|
const SizedBox(height: AppSpacing.md),
|
|
StatusCard(
|
|
title: '当前播放状态',
|
|
value: player.currentVideo ?? '暂无播放视频',
|
|
subtitle: player.running
|
|
? (player.paused ? '已暂停' : '播放中')
|
|
: '等待播放',
|
|
icon: Icons.play_circle_outline_rounded,
|
|
accentColor: player.paused ? AppColors.warning : AppColors.primary,
|
|
),
|
|
const SizedBox(height: AppSpacing.md),
|
|
StatusCard(
|
|
title: 'WiFi 摘要',
|
|
value: wifi.connected ? (wifi.ssid ?? '已连接') : '未连接网络',
|
|
subtitle: wifi.ip ?? '可通过热点或 BLE 配网',
|
|
icon: Icons.wifi_rounded,
|
|
accentColor: wifi.connected ? AppColors.info : AppColors.border,
|
|
),
|
|
const SizedBox(height: AppSpacing.lg),
|
|
Text('快捷控制', style: Theme.of(context).textTheme.headlineSmall),
|
|
const SizedBox(height: AppSpacing.md),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: ControlButton(
|
|
label: player.running && !player.paused ? '暂停' : '播放',
|
|
icon: player.running && !player.paused
|
|
? Icons.pause_rounded
|
|
: Icons.play_arrow_rounded,
|
|
onPressed: playerProvider.isLoading
|
|
? null
|
|
: () => context.read<PlayerProvider>().togglePlayPause(),
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.md),
|
|
Expanded(
|
|
child: ControlButton(
|
|
label: '上一个',
|
|
icon: Icons.skip_previous_rounded,
|
|
isFilled: false,
|
|
onPressed: playerProvider.isLoading
|
|
? null
|
|
: () => context.read<PlayerProvider>().previous(),
|
|
),
|
|
),
|
|
const SizedBox(width: AppSpacing.md),
|
|
Expanded(
|
|
child: ControlButton(
|
|
label: '下一个',
|
|
icon: Icons.skip_next_rounded,
|
|
isFilled: false,
|
|
onPressed: playerProvider.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),
|
|
_InfoRow(label: '设备 IP', value: device.ipAddress ?? deviceProvider.deviceIp),
|
|
_InfoRow(label: '连接方式', value: device.connectionType.toUpperCase()),
|
|
_InfoRow(
|
|
label: '实时通道',
|
|
value: deviceProvider.webSocketConnected ? 'WebSocket 已连接' : 'WebSocket 重连中',
|
|
),
|
|
_InfoRow(label: '播放索引', value: '${player.currentIndex + 1}/${player.playlistLength}'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _InfoRow extends StatelessWidget {
|
|
const _InfoRow({required this.label, required this.value});
|
|
|
|
final String label;
|
|
final String value;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(bottom: AppSpacing.sm),
|
|
child: Row(
|
|
children: [
|
|
Expanded(child: Text(label, style: Theme.of(context).textTheme.bodyMedium)),
|
|
Text(value, style: Theme.of(context).textTheme.bodyLarge),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|