2024-01-08 14:30:32 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:release_schedule/model/movie.dart';
|
|
|
|
|
|
|
|
class Heading extends StatelessWidget {
|
|
|
|
final String text;
|
|
|
|
|
|
|
|
const Heading(this.text, {super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 20, bottom: 10),
|
|
|
|
child: Text(
|
|
|
|
text,
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MoviePage extends StatelessWidget {
|
|
|
|
final MovieData movie;
|
|
|
|
|
|
|
|
const MoviePage(this.movie, {super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AnimatedBuilder(
|
|
|
|
animation: movie,
|
|
|
|
builder: (context, child) {
|
|
|
|
return Scaffold(
|
2024-01-10 23:50:43 +01:00
|
|
|
appBar: AppBar(title: Text(movie.title ?? "-"), actions: [
|
2024-01-08 21:48:13 +01:00
|
|
|
IconButton(
|
|
|
|
icon: Icon(movie.bookmarked
|
|
|
|
? Icons.bookmark_added
|
|
|
|
: Icons.bookmark_outline),
|
|
|
|
onPressed: () => movie.setDetails(bookmarked: !movie.bookmarked),
|
|
|
|
),
|
|
|
|
]),
|
2024-01-08 14:30:32 +01:00
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Padding(
|
2024-01-10 23:50:43 +01:00
|
|
|
padding: const EdgeInsets.all(18.0),
|
2024-01-08 14:30:32 +01:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Wrap(
|
|
|
|
spacing: 10,
|
|
|
|
runSpacing: 10,
|
2024-01-10 23:50:43 +01:00
|
|
|
children: movie.genres?.value
|
2024-01-08 14:30:32 +01:00
|
|
|
?.map((genre) => Chip(label: Text(genre)))
|
|
|
|
.toList() ??
|
|
|
|
[],
|
|
|
|
),
|
2024-01-10 23:50:43 +01:00
|
|
|
const Heading("About"),
|
|
|
|
Text(
|
|
|
|
movie.description?.value?.trim().replaceAll("\n", "\n\n") ??
|
|
|
|
"-",
|
|
|
|
textAlign: TextAlign.justify,
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
|
|
height: 1.6,
|
|
|
|
),
|
|
|
|
),
|
2024-01-08 14:30:32 +01:00
|
|
|
const Heading("Titles"),
|
|
|
|
Table(
|
|
|
|
border: TableBorder.symmetric(
|
|
|
|
inside: BorderSide(
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
),
|
|
|
|
),
|
2024-01-10 23:50:43 +01:00
|
|
|
children: movie.titles?.value?.map((title) {
|
2024-01-08 14:30:32 +01:00
|
|
|
return TableRow(
|
|
|
|
children: [
|
|
|
|
TableCell(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Text(title.language),
|
|
|
|
)),
|
|
|
|
TableCell(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
2024-01-10 23:50:43 +01:00
|
|
|
child: Text(title.text),
|
2024-01-08 14:30:32 +01:00
|
|
|
))
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}).toList() ??
|
|
|
|
[],
|
|
|
|
),
|
|
|
|
const Heading("Release Dates"),
|
|
|
|
Table(
|
|
|
|
border: TableBorder.symmetric(
|
|
|
|
inside: BorderSide(
|
|
|
|
color: Theme.of(context).dividerColor,
|
|
|
|
),
|
|
|
|
),
|
2024-01-10 23:50:43 +01:00
|
|
|
children: movie.releaseDates?.value?.map((releaseDate) {
|
2024-01-08 14:30:32 +01:00
|
|
|
return TableRow(
|
|
|
|
children: [
|
|
|
|
TableCell(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: Text(releaseDate.country),
|
|
|
|
)),
|
|
|
|
TableCell(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
2024-01-09 14:48:36 +01:00
|
|
|
child: Text(
|
|
|
|
releaseDate.dateWithPrecision.toString(),
|
|
|
|
),
|
2024-01-08 14:30:32 +01:00
|
|
|
))
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}).toList() ??
|
|
|
|
[],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|