Files
ShowenV2/clients/flutter/lib/screens/playback_screen.dart
showen 8ed9cb2d9d feat: Flutter APK 编译成功 + Gradle 配置修复 + APK 下载部署 + 待优化清单
- 通过 qemu-user-static 实现 ARM64 主机编译 Android APK (51MB)
- 修复 Gradle: Aliyun 镜像 + PREFER_SETTINGS + JVM 内存 1536M
- 部署 APK 到 configs/downloads/, Web 下载接口已验证 (HTTP 200)
- 新增 Flutter TODO.md: 10项待优化 (P0/P1/P2 分级)
- 新增 pm_soul.md, 更新 routes.rs APK 下载路由

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 06:43:55 +08:00

183 lines
6.4 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: 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.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,
),
),
),
);
}),
],
),
);
}
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);
}
}