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

目录标识当前读到的章节

上级 8b08f2b4
...@@ -595,9 +595,11 @@ class SearchAllModel { ...@@ -595,9 +595,11 @@ class SearchAllModel {
class PopBackModel { class PopBackModel {
PopBackModel({ PopBackModel({
required this.chapterId, required this.chapterId,
required this.back required this.back,
required this.chapterName
}); });
String chapterId; String chapterId;
String chapterName;
bool back; bool back;
} }
...@@ -144,7 +144,7 @@ class _BuildItemState extends State<BuildItem> { ...@@ -144,7 +144,7 @@ class _BuildItemState extends State<BuildItem> {
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ 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, Gaps.hGaps5,
chapterModel.isReading == 1? Container( chapterModel.isReading == 1? Container(
margin: const EdgeInsets.fromLTRB(0, 6, 0, 0), margin: const EdgeInsets.fromLTRB(0, 6, 0, 0),
......
...@@ -5,7 +5,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -5,7 +5,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
final String bookId; final String bookId;
BookDetailController(this.bookId); BookDetailController(this.bookId);
late TabController tabController;
final PageController pageController = PageController(initialPage: 0); final PageController pageController = PageController(initialPage: 0);
List <Widget>tabs = [ List <Widget>tabs = [
const Tab(text: '目录',), const Tab(text: '目录',),
...@@ -13,6 +13,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -13,6 +13,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
const Tab(text: '简介',), const Tab(text: '简介',),
const Tab(text: '本书信息',), const Tab(text: '本书信息',),
]; ];
late TabController tabController = TabController(length: tabs.length, vsync: this);
num currentChapterId = 0; num currentChapterId = 0;
...@@ -24,7 +25,6 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -24,7 +25,6 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
@override @override
void onInit() { void onInit() {
tabController = TabController(length: tabs.length, vsync: this);
super.onInit(); super.onInit();
} }
...@@ -53,6 +53,11 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -53,6 +53,11 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
/// 设置当前读的章节id /// 设置当前读的章节id
void setCurrentReadChapterId(){ void setCurrentReadChapterId(){
for(ChapterModel chapterModel in chapters){ for(ChapterModel chapterModel in chapters){
chapterModel.currentRead = false;
if(chapterModel.id == currentChapterId){
chapterModel.currentRead = true;
chapterModel.selected = true;
}
writeCurrentReadChapterIdToData(chapterModel); writeCurrentReadChapterIdToData(chapterModel);
} }
...@@ -66,7 +71,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -66,7 +71,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
cModel.selected = true; cModel.selected = true;
chapterModel.selected = true; chapterModel.selected = true;
} }
writeCurrentReadChapterIdToData(chapterModel); writeCurrentReadChapterIdToData(cModel);
} }
} }
......
...@@ -100,6 +100,7 @@ class _BuildItemState extends State<BuildItem> { ...@@ -100,6 +100,7 @@ class _BuildItemState extends State<BuildItem> {
onTap: (){ onTap: (){
if(chapterModel.children!.isEmpty){ if(chapterModel.children!.isEmpty){
widget.onTapChapter(chapterModel); widget.onTapChapter(chapterModel);
chapterModel.currentRead= true;
} }
else{ else{
setState(() { setState(() {
...@@ -130,7 +131,7 @@ class _BuildItemState extends State<BuildItem> { ...@@ -130,7 +131,7 @@ class _BuildItemState extends State<BuildItem> {
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ 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, Gaps.hGaps5,
chapterModel.isReading == 1? Container( chapterModel.isReading == 1? Container(
margin: const EdgeInsets.fromLTRB(0, 6, 0, 0), margin: const EdgeInsets.fromLTRB(0, 6, 0, 0),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论