embed frontend files

This commit is contained in:
Simon Ding
2024-07-07 12:19:38 +08:00
parent 198e5fd43d
commit edb95df582
18 changed files with 303 additions and 40 deletions

View File

@@ -1,11 +1,20 @@
import 'package:flutter/foundation.dart';
class APIs {
static const _baseUrl = "http://127.0.0.1:8080";
static const searchUrl = "$_baseUrl/api/v1/tv/search";
static const settingsUrl = "$_baseUrl/api/v1/setting/do";
static const watchlistUrl = "$_baseUrl/api/v1/tv/watchlist";
static const seriesDetailUrl = "$_baseUrl/api/v1/tv/series/";
static final _baseUrl = baseUrl();
static final searchUrl = "$_baseUrl/api/v1/tv/search";
static final settingsUrl = "$_baseUrl/api/v1/setting/do";
static final watchlistUrl = "$_baseUrl/api/v1/tv/watchlist";
static final seriesDetailUrl = "$_baseUrl/api/v1/tv/series/";
static const tmdbImgBaseUrl = "https://image.tmdb.org/t/p/w500/";
static const tmdbApiKey = "tmdb_api_key";
static String baseUrl() {
if (kReleaseMode) {
return "";
}
return "http://127.0.0.1:8080";
}
}

View File

@@ -22,29 +22,35 @@ class MyApp extends StatelessWidget {
// GoRouter configuration
final _shellRoute = ShellRoute(
builder: (BuildContext context, GoRouterState state, Widget child) {
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: const Text("Polaris追剧"),
actions: [
IconButton(
onPressed: () => context.go(SystemSettingsPage.route),
icon: const Icon(Icons.settings))
],
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Row(children: <Widget>[
NavDrawer(),
const VerticalDivider(thickness: 1, width: 1),
Expanded(child: child)
])));
return SelectionArea(
child: Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: const Text("Polaris追剧"),
actions: [
IconButton(
tooltip: "搜索剧集",
onPressed: () => context.go(SearchPage.route),
icon: const Icon(Icons.search)),
IconButton(
onPressed: () => context.go(SystemSettingsPage.route),
icon: const Icon(Icons.settings))
],
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Row(children: <Widget>[
NavDrawer(),
const VerticalDivider(thickness: 1, width: 1),
Expanded(child: child)
]))),
);
},
routes: [
GoRoute(
@@ -61,7 +67,8 @@ class MyApp extends StatelessWidget {
),
GoRoute(
path: TvDetailsPage.route,
builder: (context, state) => TvDetailsPage(seriesId: state.pathParameters['id']!),
builder: (context, state) =>
TvDetailsPage(seriesId: state.pathParameters['id']!),
)
],
);
@@ -92,7 +99,8 @@ class MyApp extends StatelessWidget {
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.lightBlueAccent),
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple, brightness: Brightness.dark),
useMaterial3: true,
),
routerConfig: _router,

View File

@@ -5,6 +5,8 @@ import 'package:ui/system_settings.dart';
import 'package:ui/weclome.dart';
class NavDrawer extends StatefulWidget {
const NavDrawer({super.key});
@override
State<StatefulWidget> createState() {
return _NavDrawerState();

View File

@@ -41,9 +41,23 @@ class _TvDetailsPageState extends State<TvDetailsPage> {
for (final ep in details!.episodes!) {
var w = Container(
alignment: Alignment.topLeft,
child: Text(
"${ep.seasonNumber} 季,第 ${ep.episodeNumber} 集:${ep.title}",
textAlign: TextAlign.left,
child: Row(
children: [
SizedBox(
width: 70,
child: Text("${ep.episodeNumber}"),
),
SizedBox(
width: 100,
child: Opacity(
opacity: 0.5,
child: Text("${ep.airDate}"),
),
),
Text("${ep.title}", textAlign: TextAlign.left),
const Expanded(child: Text("")),
IconButton(onPressed: () {}, icon: const Icon(Icons.search))
],
),
);
if (m[ep.seasonNumber] == null) {
@@ -55,7 +69,9 @@ class _TvDetailsPageState extends State<TvDetailsPage> {
for (final k in m.keys) {
bool _customTileExpanded = false;
var seasonList = ExpansionTile(
initiallyExpanded: true,
tilePadding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
childrenPadding: const EdgeInsets.fromLTRB(50, 0, 50, 0),
initiallyExpanded: k == 0 ? false : true,
title: Text("$k"),
trailing: Icon(
_customTileExpanded
@@ -116,6 +132,9 @@ class _TvDetailsPageState extends State<TvDetailsPage> {
}
void _querySeriesDetails(BuildContext context) async {
if (details != null) {
return;
}
var resp = await Dio().get("${APIs.seriesDetailUrl}$seriesId");
var rsp = ServerResponse.fromJson(resp.data);
if (rsp.code != 0 && context.mounted) {