提交 10e54730 authored 作者: yueweilu's avatar yueweilu

目录标识当前读到的章节

上级 8b08f2b4
......@@ -595,9 +595,11 @@ class SearchAllModel {
class PopBackModel {
PopBackModel({
required this.chapterId,
required this.back
required this.back,
required this.chapterName
});
String chapterId;
String chapterName;
bool back;
}
......@@ -144,7 +144,7 @@ class _BuildItemState extends State<BuildItem> {
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.currentRead?AppTheme.primary:chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Gaps.hGaps5,
chapterModel.isReading == 1? Container(
margin: const EdgeInsets.fromLTRB(0, 6, 0, 0),
......
......@@ -5,7 +5,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
final String bookId;
BookDetailController(this.bookId);
late TabController tabController;
final PageController pageController = PageController(initialPage: 0);
List <Widget>tabs = [
const Tab(text: '目录',),
......@@ -13,6 +13,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
const Tab(text: '简介',),
const Tab(text: '本书信息',),
];
late TabController tabController = TabController(length: tabs.length, vsync: this);
num currentChapterId = 0;
......@@ -24,7 +25,6 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
@override
void onInit() {
tabController = TabController(length: tabs.length, vsync: this);
super.onInit();
}
......@@ -53,6 +53,11 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
/// 设置当前读的章节id
void setCurrentReadChapterId(){
for(ChapterModel chapterModel in chapters){
chapterModel.currentRead = false;
if(chapterModel.id == currentChapterId){
chapterModel.currentRead = true;
chapterModel.selected = true;
}
writeCurrentReadChapterIdToData(chapterModel);
}
......@@ -66,7 +71,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
cModel.selected = true;
chapterModel.selected = true;
}
writeCurrentReadChapterIdToData(chapterModel);
writeCurrentReadChapterIdToData(cModel);
}
}
......
......@@ -27,16 +27,16 @@ class _ReadPageState extends State<ReadPage> {
}
@override
Widget build(BuildContext context) {
PopBackModel backModel = PopBackModel(chapterId: widget.chapterId,back: true);
return WillPopScope(
return GetBuilder(
init: ReadController(bookId: widget.bookId, chapterId: widget.chapterId,chapterName: widget.chapterName,bookDetailModel: widget.bookDetailModel,noteId: widget.noteId),
builder: (readController) => WillPopScope(
onWillPop: () async {
PopBackModel backModel = PopBackModel(chapterId: readController.chapterId,back: true,chapterName: readController.chapterId);
context.pop(backModel);
CustomToast.dismiss();
return false;
},
child: GetBuilder<ReadController>(
init: ReadController(bookId: widget.bookId, chapterId: widget.chapterId,chapterName: widget.chapterName,bookDetailModel: widget.bookDetailModel,noteId: widget.noteId),
builder: (readController) => Scaffold(
child:Scaffold(
appBar: CustomAppBar(
titleSpacing: 0,
title: Align(
......@@ -409,6 +409,7 @@ class _ReadPageState extends State<ReadPage> {
controller.chooseTool(model);
// 选择了新的章节 刷新 webview
controller.webViewController.reload();
controller.setCurrentReadChapterId();
},
);
}
......
......@@ -100,6 +100,7 @@ class _BuildItemState extends State<BuildItem> {
onTap: (){
if(chapterModel.children!.isEmpty){
widget.onTapChapter(chapterModel);
chapterModel.currentRead= true;
}
else{
setState(() {
......@@ -130,7 +131,7 @@ class _BuildItemState extends State<BuildItem> {
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.currentRead ?AppTheme.primary: chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Gaps.hGaps5,
chapterModel.isReading == 1? Container(
margin: const EdgeInsets.fromLTRB(0, 6, 0, 0),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论