From f990d77da3a4af7f60ad08eb99efaa36ef5c5add Mon Sep 17 00:00:00 2001 From: Simon Ding Date: Mon, 15 Jul 2024 16:44:35 +0800 Subject: [PATCH] feat: change layout and periodically refresh api --- ui/lib/providers/activity.dart | 2 + ui/lib/tv_details.dart | 144 +++++++++++++++++---------------- 2 files changed, 78 insertions(+), 68 deletions(-) diff --git a/ui/lib/providers/activity.dart b/ui/lib/providers/activity.dart index 5ab75db..c9e8449 100644 --- a/ui/lib/providers/activity.dart +++ b/ui/lib/providers/activity.dart @@ -11,6 +11,8 @@ var activitiesDataProvider = class ActivityData extends AutoDisposeAsyncNotifier> { @override FutureOr> build() async { + Timer(const Duration(seconds: 5), ref.invalidateSelf);//Periodically Refresh + final dio = await APIs.getDio(); var resp = await dio.get(APIs.activityUrl); final sp = ServerResponse.fromJson(resp.data); diff --git a/ui/lib/tv_details.dart b/ui/lib/tv_details.dart index 9879f45..91c911d 100644 --- a/ui/lib/tv_details.dart +++ b/ui/lib/tv_details.dart @@ -113,77 +113,85 @@ class _TvDetailsPageState extends ConsumerState { Card( margin: const EdgeInsets.all(4), clipBehavior: Clip.hardEdge, - child: Row( - children: [ - Flexible( - flex: 1, - child: Image.network( - "${APIs.imagesUrl}/${details.id}/poster.jpg", - fit: BoxFit.contain, - headers: APIs.authHeaders, + child: Padding( + padding: const EdgeInsets.all(10), + child: Row( + children: [ + Flexible( + flex: 1, + child: Padding( + padding: EdgeInsets.all(10), + child: Image.network( + "${APIs.imagesUrl}/${details.id}/poster.jpg", + fit: BoxFit.contain, + headers: APIs.authHeaders, + ), + ), ), - ), - Expanded( - flex: 6, - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text("${details.resolution}"), - const SizedBox( - width: 30, - ), - storage.when( - data: (value) { - for (final s in value) { - if (s.id == details.storageId) { - return Text( - "${s.name}(${s.implementation})"); + Expanded( + flex: 6, + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text("${details.resolution}"), + const SizedBox( + width: 30, + ), + storage.when( + data: (value) { + for (final s in value) { + if (s.id == + details.storageId) { + return Text( + "${s.name}(${s.implementation})"); + } } - } - return const Text("未知存储"); - }, - error: (error, stackTrace) => - Text("$error"), - loading: () => - const MyProgressIndicator()), - ], - ), - const Divider(thickness: 1, height: 1), - Text( - "${details.name} (${details.airDate!.split("-")[0]})", - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold), - ), - const Text(""), - Text( - details!.overview!, - ), - ], - )), - Column( - children: [ - IconButton( - onPressed: () { - ref - .read(seriesDetailsProvider( - seriesId) - .notifier) - .delete(); - context.go(WelcomePage.route); - }, - icon: const Icon(Icons.delete)) - ], - ) - ], + return const Text("未知存储"); + }, + error: (error, stackTrace) => + Text("$error"), + loading: () => + const MyProgressIndicator()), + ], + ), + const Divider(thickness: 1, height: 1), + Text( + "${details.name} (${details.airDate!.split("-")[0]})", + style: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold), + ), + const Text(""), + Text( + details!.overview!, + ), + ], + )), + Column( + children: [ + IconButton( + onPressed: () { + ref + .read(seriesDetailsProvider( + seriesId) + .notifier) + .delete(); + context.go(WelcomePage.route); + }, + icon: const Icon(Icons.delete)) + ], + ) + ], + ), ), - ), - ], + ], + ), ), ), Column(