mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
improve history
This commit is contained in:
@@ -151,7 +151,8 @@
|
|||||||
"Sort": "排序",
|
"Sort": "排序",
|
||||||
"Name": "名称",
|
"Name": "名称",
|
||||||
"Date": "日期",
|
"Date": "日期",
|
||||||
"Date Desc": "日期降序"
|
"Date Desc": "日期降序",
|
||||||
|
"Start": "开始"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Home": "首頁",
|
"Home": "首頁",
|
||||||
@@ -305,6 +306,7 @@
|
|||||||
"Sort": "排序",
|
"Sort": "排序",
|
||||||
"Name": "名稱",
|
"Name": "名稱",
|
||||||
"Date": "日期",
|
"Date": "日期",
|
||||||
"Date Desc": "日期降序"
|
"Date Desc": "日期降序",
|
||||||
|
"Start": "開始"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -42,12 +42,41 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
|
|
||||||
bool isDownloaded = false;
|
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
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
scrollController.addListener(onScroll);
|
scrollController.addListener(onScroll);
|
||||||
|
HistoryManager().addListener(updateHistory);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
scrollController.removeListener(onScroll);
|
||||||
|
HistoryManager().removeListener(updateHistory);
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void update() {
|
void update() {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -205,6 +234,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
|
|
||||||
Widget buildActions() {
|
Widget buildActions() {
|
||||||
bool isMobile = context.width < changePoint;
|
bool isMobile = context.width < changePoint;
|
||||||
|
bool hasHistory = history != null && (history!.ep > 1 || history!.page > 1);
|
||||||
return SliverToBoxAdapter(
|
return SliverToBoxAdapter(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@@ -212,17 +242,17 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
children: [
|
children: [
|
||||||
if (history != null && (history!.ep > 1 || history!.page > 1))
|
if (hasHistory && !isMobile)
|
||||||
_ActionButton(
|
_ActionButton(
|
||||||
icon: const Icon(Icons.menu_book),
|
icon: const Icon(Icons.menu_book),
|
||||||
text: 'Continue'.tl,
|
text: 'Continue'.tl,
|
||||||
onPressed: continueRead,
|
onPressed: continueRead,
|
||||||
iconColor: context.useTextColor(Colors.yellow),
|
iconColor: context.useTextColor(Colors.yellow),
|
||||||
),
|
),
|
||||||
if (!isMobile)
|
if(!isMobile || hasHistory)
|
||||||
_ActionButton(
|
_ActionButton(
|
||||||
icon: const Icon(Icons.play_circle_outline),
|
icon: const Icon(Icons.play_circle_outline),
|
||||||
text: 'Read'.tl,
|
text: 'Start'.tl,
|
||||||
onPressed: read,
|
onPressed: read,
|
||||||
iconColor: context.useTextColor(Colors.orange),
|
iconColor: context.useTextColor(Colors.orange),
|
||||||
),
|
),
|
||||||
@@ -278,7 +308,10 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(
|
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),
|
).paddingHorizontal(16).paddingVertical(8),
|
||||||
@@ -770,6 +803,7 @@ class _ActionButton extends StatelessWidget {
|
|||||||
this.isLoading,
|
this.isLoading,
|
||||||
this.iconColor,
|
this.iconColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Widget icon;
|
final Widget icon;
|
||||||
|
|
||||||
final Widget? activeIcon;
|
final Widget? activeIcon;
|
||||||
@@ -783,6 +817,7 @@ class _ActionButton extends StatelessWidget {
|
|||||||
final bool? isLoading;
|
final bool? isLoading;
|
||||||
|
|
||||||
final Color? iconColor;
|
final Color? iconColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
Reference in New Issue
Block a user