为什么:客户端原型在 14d7bd3 之后又做了一轮(页面分层、发现页、分类滑动、播放器控件等),
一直留在工作区没入库。下一批账号链路要改其中的 app.dart / home_view / player_view / mine_view,
先归档这批既存改动,本批的实际 diff 才说得清边界。
只归档,不改行为:当前工作区 flutter analyze 0 问题、flutter test 148 全过。
173 lines
5.4 KiB
Dart
173 lines
5.4 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../core/data/models/drama.dart';
|
|
import '../../core/data/services/catalog_controller.dart';
|
|
import '../../core/formatting/localized_content.dart';
|
|
import '../../core/widgets/remote_image.dart';
|
|
import '../../l10n/app_localizations.dart';
|
|
import 'drama_detail_binding.dart';
|
|
import 'drama_detail_logic.dart';
|
|
|
|
class DramaDetailPage extends StatefulWidget {
|
|
const DramaDetailPage({super.key, required this.drama});
|
|
final Drama drama;
|
|
|
|
@override
|
|
State<DramaDetailPage> createState() => _DramaDetailPageState();
|
|
}
|
|
|
|
class _DramaDetailPageState extends State<DramaDetailPage> {
|
|
late final DramaDetailLogic logic;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
logic = DramaDetailBinding().create(drama: widget.drama);
|
|
_load();
|
|
}
|
|
|
|
void _load() {
|
|
unawaited(
|
|
logic.load(
|
|
() => context.read<CatalogController>().requireDetail(widget.drama),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
logic.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListenableBuilder(
|
|
listenable: logic,
|
|
builder: (context, _) => _page(context),
|
|
);
|
|
}
|
|
|
|
Widget _page(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
if (logic.loading) {
|
|
return const Scaffold(
|
|
backgroundColor: Color(0xFF111111),
|
|
body: Center(child: CircularProgressIndicator()),
|
|
);
|
|
}
|
|
if (logic.failed) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF111111),
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 32),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
logic.failureMessage ?? l10n.detailError,
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(color: Colors.white70),
|
|
),
|
|
const SizedBox(height: 16),
|
|
FilledButton(onPressed: _load, child: Text(l10n.retry)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
final drama = logic.drama;
|
|
return Scaffold(
|
|
body: CustomScrollView(
|
|
slivers: [
|
|
SliverAppBar(
|
|
expandedHeight: 300,
|
|
pinned: true,
|
|
backgroundColor: const Color(0xFF111111),
|
|
foregroundColor: Colors.white,
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
background: RemoteImage(drama.posterUrl),
|
|
),
|
|
),
|
|
SliverPadding(
|
|
padding: const EdgeInsets.fromLTRB(24, 24, 24, 40),
|
|
sliver: SliverList(
|
|
delegate: SliverChildListDelegate([
|
|
Text(
|
|
l10n.technicalDemoCount(drama.episodes.length),
|
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
|
letterSpacing: 1.4,
|
|
color: const Color(0xFF2F7BFF),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
localizedDramaTitle(l10n, drama),
|
|
style: Theme.of(context).textTheme.headlineLarge?.copyWith(
|
|
fontWeight: FontWeight.w800,
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
localizedDramaSynopsis(l10n, drama),
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
FilledButton.icon(
|
|
onPressed: () =>
|
|
logic.openPlayer(context, logic.continueIndex ?? 0),
|
|
icon: const Icon(Icons.play_arrow_rounded),
|
|
label: Text(
|
|
logic.continueIndex == null
|
|
? l10n.watchEpisodeOne
|
|
: l10n.continueEpisode(logic.continueIndex! + 1),
|
|
),
|
|
),
|
|
const SizedBox(height: 30),
|
|
Text(
|
|
l10n.episodes,
|
|
style: Theme.of(
|
|
context,
|
|
).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.bold),
|
|
),
|
|
]),
|
|
),
|
|
),
|
|
SliverPadding(
|
|
padding: const EdgeInsets.fromLTRB(24, 0, 24, 40),
|
|
sliver: SliverList.builder(
|
|
itemCount: drama.episodes.length,
|
|
itemBuilder: (context, index) {
|
|
final episode = drama.episodes[index];
|
|
return Card(
|
|
margin: const EdgeInsets.only(bottom: 10),
|
|
child: ListTile(
|
|
minTileHeight: 76,
|
|
leading: CircleAvatar(
|
|
backgroundColor: const Color(
|
|
0xFF2F7BFF,
|
|
).withValues(alpha: 0.18),
|
|
child: Text('${episode.number}'),
|
|
),
|
|
title: Text(l10n.episodeLabel(episode.number)),
|
|
trailing: const Icon(Icons.play_circle_outline_rounded),
|
|
onTap: () => logic.openPlayer(context, index),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|