135 lines
4.4 KiB
Dart
135 lines
4.4 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../core/data/models/drama.dart';
|
|
import '../../core/formatting/localized_content.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);
|
|
logic.loadContinue();
|
|
}
|
|
|
|
@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)!;
|
|
final drama = logic.drama;
|
|
return Scaffold(
|
|
body: CustomScrollView(
|
|
slivers: [
|
|
SliverAppBar(
|
|
expandedHeight: 300,
|
|
pinned: true,
|
|
backgroundColor: const Color(0xFF111111),
|
|
foregroundColor: Colors.white,
|
|
flexibleSpace: FlexibleSpaceBar(
|
|
background: Image.asset(drama.posterAsset, fit: BoxFit.cover),
|
|
),
|
|
),
|
|
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(0xFF9278EA),
|
|
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(
|
|
0xFFFF6B45,
|
|
).withValues(alpha: 0.18),
|
|
child: Text('${episode.number}'),
|
|
),
|
|
title: Text(l10n.episodeLabel(episode.number)),
|
|
subtitle: Text(l10n.freeTestMedia),
|
|
trailing: const Icon(Icons.play_circle_outline_rounded),
|
|
onTap: () => logic.openPlayer(context, index),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|