diff --git a/assets/translation.json b/assets/translation.json index 309c9d1..20be28f 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -151,7 +151,8 @@ "Sort": "排序", "Name": "名称", "Date": "日期", - "Date Desc": "日期降序" + "Date Desc": "日期降序", + "Start": "开始" }, "zh_TW": { "Home": "首頁", @@ -305,6 +306,7 @@ "Sort": "排序", "Name": "名稱", "Date": "日期", - "Date Desc": "日期降序" + "Date Desc": "日期降序", + "Start": "開始" } } \ No newline at end of file diff --git a/lib/pages/comic_page.dart b/lib/pages/comic_page.dart index 6c3f22b..6f04bfd 100644 --- a/lib/pages/comic_page.dart +++ b/lib/pages/comic_page.dart @@ -42,12 +42,41 @@ class _ComicPageState extends LoadingState bool isDownloaded = false; + void updateHistory() async { + var newHistory = await HistoryManager() + .find(widget.id, ComicType(widget.sourceKey.hashCode)); + if(newHistory?.ep != history?.ep || newHistory?.page != history?.page) { + history = newHistory; + update(); + } + } + + @override + Widget buildLoading() { + return Column( + children: [ + const Appbar(title: Text("")), + Expanded( + child: super.buildLoading(), + ), + ], + ); + } + @override void initState() { scrollController.addListener(onScroll); + HistoryManager().addListener(updateHistory); super.initState(); } + @override + void dispose() { + scrollController.removeListener(onScroll); + HistoryManager().removeListener(updateHistory); + super.dispose(); + } + @override void update() { setState(() {}); @@ -205,6 +234,7 @@ class _ComicPageState extends LoadingState Widget buildActions() { bool isMobile = context.width < changePoint; + bool hasHistory = history != null && (history!.ep > 1 || history!.page > 1); return SliverToBoxAdapter( child: Column( children: [ @@ -212,17 +242,17 @@ class _ComicPageState extends LoadingState scrollDirection: Axis.horizontal, padding: const EdgeInsets.symmetric(horizontal: 8), children: [ - if (history != null && (history!.ep > 1 || history!.page > 1)) + if (hasHistory && !isMobile) _ActionButton( icon: const Icon(Icons.menu_book), text: 'Continue'.tl, onPressed: continueRead, iconColor: context.useTextColor(Colors.yellow), ), - if (!isMobile) + if(!isMobile || hasHistory) _ActionButton( icon: const Icon(Icons.play_circle_outline), - text: 'Read'.tl, + text: 'Start'.tl, onPressed: read, iconColor: context.useTextColor(Colors.orange), ), @@ -278,7 +308,10 @@ class _ComicPageState extends LoadingState ), const SizedBox(width: 16), Expanded( - child: FilledButton(onPressed: read, child: Text("Read".tl)), + child: hasHistory + ? FilledButton( + onPressed: continueRead, child: Text("Continue".tl)) + : FilledButton(onPressed: read, child: Text("Read".tl)), ) ], ).paddingHorizontal(16).paddingVertical(8), @@ -398,23 +431,23 @@ class _ComicPageState extends LoadingState Text(comic.stars!.toStringAsFixed(2)), ], ).paddingLeft(16).paddingVertical(8), - for (var e in comic.tags.entries) - buildWrap( - children: [ - if(e.value.isNotEmpty) + for (var e in comic.tags.entries) + buildWrap( + children: [ + if (e.value.isNotEmpty) buildTag(text: e.key.ts(comicSource.key), isTitle: true), - for (var tag in e.value) - buildTag( - text: enableTranslation - ? TagsTranslation.translationTagWithNamespace( - tag, - e.key.toLowerCase(), - ) - : tag, - onTap: () => onTapTag(tag, e.key), - ), - ], - ), + for (var tag in e.value) + buildTag( + text: enableTranslation + ? TagsTranslation.translationTagWithNamespace( + tag, + e.key.toLowerCase(), + ) + : tag, + onTap: () => onTapTag(tag, e.key), + ), + ], + ), if (comic.uploader != null) buildWrap( children: [ @@ -458,7 +491,7 @@ class _ComicPageState extends LoadingState } Widget buildRecommend() { - if (comic.recommend == null||comic.recommend!.isEmpty) { + if (comic.recommend == null || comic.recommend!.isEmpty) { return const SliverPadding(padding: EdgeInsets.zero); } return SliverMainAxisGroup(slivers: [ @@ -770,6 +803,7 @@ class _ActionButton extends StatelessWidget { this.isLoading, this.iconColor, }); + final Widget icon; final Widget? activeIcon; @@ -783,6 +817,7 @@ class _ActionButton extends StatelessWidget { final bool? isLoading; final Color? iconColor; + @override Widget build(BuildContext context) { return Container(