Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
dcee668e
提交
dcee668e
authored
2月 07, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
跳转逻辑
上级
54541654
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
322 行增加
和
107 行删除
+322
-107
index.dart
lib/pages/book_category/index.dart
+3
-0
view.dart
lib/pages/book_category/view.dart
+6
-2
item.dart
lib/pages/book_category/widgets/item.dart
+32
-6
view.dart
lib/pages/book_detail/view.dart
+4
-4
view.dart
lib/pages/book_info/view.dart
+24
-9
controller.dart
lib/pages/read_web/controller.dart
+11
-5
discuss_controller.dart
lib/pages/read_web/discuss_controller.dart
+6
-2
index.dart
lib/pages/read_web/index.dart
+3
-2
note_controller.dart
lib/pages/read_web/note_controller.dart
+6
-3
view.dart
lib/pages/read_web/view.dart
+61
-56
book.dart
lib/pages/read_web/widgets/book.dart
+8
-4
category.dart
lib/pages/read_web/widgets/category.dart
+14
-9
discuss.dart
lib/pages/read_web/widgets/discuss.dart
+7
-2
item.dart
lib/pages/read_web/widgets/item.dart
+101
-0
note.dart
lib/pages/read_web/widgets/note.dart
+7
-2
routes.dart
lib/routes/routes.dart
+1
-0
oss.dart
lib/utils/oss.dart
+1
-1
tools.dart
lib/utils/tools.dart
+27
-0
没有找到文件。
lib/pages/book_category/index.dart
浏览文件 @
dcee668e
...
...
@@ -4,8 +4,10 @@ import 'package:flutter/material.dart';
import
'package:flutter_book/theme.dart'
;
import
'package:flutter_book/utils/index.dart'
;
import
'package:flutter_screenutil/flutter_screenutil.dart'
;
import
'package:go_router/go_router.dart'
;
import
'../../models/index.dart'
;
import
'../../routes/index.dart'
;
part
'view.dart'
;
part
'widgets/item.dart'
;
\ No newline at end of file
lib/pages/book_category/view.dart
浏览文件 @
dcee668e
...
...
@@ -3,9 +3,13 @@ part of book_category;
class
BookCategoryPage
extends
StatefulWidget
{
final
List
<
ChapterModel
>
chapters
;
final
String
bookId
;
final
BookDetailModel
bookDetails
;
const
BookCategoryPage
({
Key
?
key
,
required
this
.
chapters
required
this
.
chapters
,
required
this
.
bookId
,
required
this
.
bookDetails
})
:
super
(
key:
key
);
@override
...
...
@@ -20,7 +24,7 @@ class _BookCategoryPageState extends State<BookCategoryPage> {
Expanded
(
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
return
BuildItem
(
model:
widget
.
chapters
[
index
],);
return
BuildItem
(
model:
widget
.
chapters
[
index
],
bookId:
widget
.
bookId
,
bookDetails:
widget
.
bookDetails
,
);
},
itemCount:
widget
.
chapters
.
length
,
),
...
...
lib/pages/book_category/widgets/item.dart
浏览文件 @
dcee668e
...
...
@@ -2,9 +2,13 @@ part of book_category;
class
BuildItem
extends
StatefulWidget
{
final
ChapterModel
model
;
final
String
bookId
;
final
BookDetailModel
bookDetails
;
const
BuildItem
({
Key
?
key
,
required
this
.
model
required
this
.
model
,
required
this
.
bookId
,
required
this
.
bookDetails
})
:
super
(
key:
key
);
@override
...
...
@@ -19,9 +23,13 @@ class _BuildItemState extends State<BuildItem> {
/// 章节名称容器
GestureDetector
(
onTap:
(){
setState
(()
{
widget
.
model
.
selected
=
!
widget
.
model
.
selected
;
});
// 如果章下面没有节 点击才会跳转
if
(
widget
.
model
.
children
!.
isEmpty
){
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
widget
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
widget
.
model
.
id
.
toString
(),
'chapter_name'
:
widget
.
model
.
name
.
toString
()},
extra:
widget
.
bookDetails
);
}
// setState(() {
// widget.model.selected = !widget.model.selected;
// });
},
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
...
...
@@ -49,7 +57,19 @@ class _BuildItemState extends State<BuildItem> {
),
Transform
.
rotate
(
angle:
widget
.
model
.
selected
?
0
:-
90
*
(
3.141592653589793
/
180
),
child:
Image
.
asset
(
'assets/images/down.png'
)
child:
GestureDetector
(
onTap:
(){
setState
(()
{
widget
.
model
.
selected
=
!
widget
.
model
.
selected
;
});
},
child:
Container
(
width:
20
,
height:
20
,
// color: Colors.red,
child:
Image
.
asset
(
'assets/images/down.png'
)
),
)
)
],
...
...
@@ -63,7 +83,13 @@ class _BuildItemState extends State<BuildItem> {
shrinkWrap:
true
,
physics:
const
NeverScrollableScrollPhysics
(),
itemBuilder:
(
BuildContext
context
,
int
index
){
return
_buildSection
(
widget
.
model
.
children
![
index
]);
ChapterModel
model
=
widget
.
model
.
children
![
index
];
return
GestureDetector
(
onTap:
(){
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
widget
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
model
.
id
.
toString
(),
'chapter_name'
:
model
.
name
.
toString
()},
extra:
widget
.
bookDetails
);
},
child:
_buildSection
(
model
)
);
},
itemCount:
widget
.
model
.
children
!.
length
,
)
...
...
lib/pages/book_detail/view.dart
浏览文件 @
dcee668e
...
...
@@ -75,7 +75,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
child:
TabBarView
(
controller:
controller
.
tabController
,
children:
[
BookCategoryPage
(
chapters:
controller
.
chapters
,),
BookCategoryPage
(
chapters:
controller
.
chapters
,
bookId:
controller
.
bookId
,
bookDetails:
controller
.
bookDetails
,
),
Container
(
padding:
EdgeInsets
.
only
(
left:
15
.
w
,
right:
15
.
w
,
top:
12
.
w
),
color:
Colors
.
white
,
...
...
@@ -128,7 +128,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
// 1免费 0 不免费
if
(
controller
.
bookDetails
.
isFree
==
1
){
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
controller
.
bookDetails
.
chapterId
.
toString
(),
'chapter_name'
:
controller
.
bookDetails
.
chapterName
.
toString
}
);
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
controller
.
bookDetails
.
chapterId
.
toString
(),
'chapter_name'
:
controller
.
bookDetails
.
chapterName
.
toString
()},
extra:
controller
.
bookDetails
);
}
else
{
// 没有购买
...
...
@@ -154,11 +154,11 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
}
}
else
{
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
controller
.
bookDetails
.
chapterId
.
toString
(),
'chapter_name'
:
controller
.
bookDetails
.
chapterName
.
toString
()});
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
controller
.
bookDetails
.
chapterId
.
toString
(),
'chapter_name'
:
controller
.
bookDetails
.
chapterName
.
toString
()}
,
extra:
controller
.
bookDetails
);
}
}
else
{
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
controller
.
bookDetails
.
chapterId
.
toString
(),
'chapter_name'
:
controller
.
bookDetails
.
chapterName
.
toString
()});
context
.
pushNamed
(
Routes
.
web
,
queryParameters:
{
'book_id'
:
controller
.
bookDetails
.
bookId
.
toString
(),
'chapter_id'
:
controller
.
bookDetails
.
chapterId
.
toString
(),
'chapter_name'
:
controller
.
bookDetails
.
chapterName
.
toString
()}
,
extra:
controller
.
bookDetails
);
}
}
},
...
...
lib/pages/book_info/view.dart
浏览文件 @
dcee668e
...
...
@@ -45,6 +45,7 @@ class BookInfoPage extends StatelessWidget {
Container
(
margin:
EdgeInsets
.
symmetric
(
vertical:
10
.
w
),
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
...
...
@@ -71,17 +72,24 @@ class BookInfoPage extends StatelessWidget {
height:
90
,
// color: Colors.green,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
end
,
children:
List
.
generate
(
model
.
ratingList
!.
length
,
(
index
){
return
_buildProgrss
(
5
-
index
.
toDouble
(),
model
.
ratingList
![
index
].
toDouble
()/
model
.
ratingCount
!);
}).
toList
()
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
end
,
children:
List
.
generate
(
model
.
ratingList
!.
length
,
(
index
){
return
_buildProgrss
(
5
-
index
.
toDouble
(),
model
.
ratingList
![
index
].
toDouble
()/
model
.
ratingCount
!);
}).
toList
()
),
Text
(
'
${model.ratingCount}
个评分'
,
style:
TextStyle
(
fontSize:
9
.
w
,
height:
1.4
,
color:
Colours
.
c9
),)
],
),
),
)
)
,
],
),
)
)
,
],
),
Container
(
height:
1
,
width:
double
.
infinity
,
color:
Colours
.
cF2
,),
...
...
@@ -90,19 +98,26 @@ class BookInfoPage extends StatelessWidget {
Column
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
'书名'
,
'作者'
,
'分类'
,
'出品方'
,
'出版社'
,
'上架时间'
].
map
((
item
){
children:
[
{
'name'
:
'书名'
,
'value'
:
model
.
bookName
},
{
'name'
:
'作者'
,
'value'
:
model
.
authors
},
{
'name'
:
'分类'
,
'value'
:
model
.
categoryName
},
{
'name'
:
'出品方'
,
'value'
:
model
.
producersName
},
{
'name'
:
'出版社'
,
'value'
:
model
.
pressName
},
{
'name'
:
'上架时间'
,
'value'
:
Tools
.
dateFromMS
(
model
.
onsaleTime
!.
toInt
(),
pattern:
'yyyy年MM月dd日'
)},
].
map
((
item
){
return
Row
(
children:
[
Container
(
// color: Colors.cyan,
alignment:
Alignment
.
centerRight
,
width:
50
,
child:
Text
(
item
,
style:
const
TextStyle
(
fontSize:
11
,
height:
2.1
,
color:
Colours
.
c3
),),
child:
Text
(
item
[
'name'
].
toString
()
,
style:
const
TextStyle
(
fontSize:
11
,
height:
2.1
,
color:
Colours
.
c3
),),
),
Gaps
.
hGaps20
,
Container
(
alignment:
Alignment
.
centerLeft
,
child:
Text
(
item
,
style:
const
TextStyle
(
fontSize:
11
,
height:
2.1
,
color:
Colours
.
c9
),
textAlign:
TextAlign
.
end
,),
child:
Text
(
item
[
'value'
].
toString
()
,
style:
const
TextStyle
(
fontSize:
11
,
height:
2.1
,
color:
Colours
.
c9
),
textAlign:
TextAlign
.
end
,),
),
],
);
...
...
lib/pages/read_web/controller.dart
浏览文件 @
dcee668e
...
...
@@ -3,9 +3,10 @@ part of web;
class
ReadController
extends
FullLifeCycleController
with
GetSingleTickerProviderStateMixin
{
final
String
bookId
;
final
String
chapterId
;
final
String
chapterName
;
ReadController
({
required
this
.
bookId
,
required
this
.
chapterId
,
required
this
.
chapterName
});
String
chapterId
;
String
chapterName
;
final
BookDetailModel
bookDetailModel
;
ReadController
({
required
this
.
bookId
,
required
this
.
chapterId
,
required
this
.
chapterName
,
required
this
.
bookDetailModel
});
// 目录
List
<
ChapterModel
>
chapters
=
[];
...
...
@@ -84,6 +85,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
update
();
}
// 选择了某个章节
void
selectChapter
(
ChapterModel
model
)
{
chapterName
=
model
.
name
??
''
;
chapterId
=
model
.
id
.
toString
();
update
();
}
// 初始化录音组件
Future
<
void
>
openTheRecorder
()
async
{
// 获取权限
...
...
@@ -326,8 +334,6 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void
chooseTool
(
ToolModel
selectedModel
){
for
(
var
model
in
tools
)
{
// 如果当前遍历到的工具是选中的,并且不是点击的工具,则取消选中
...
...
lib/pages/read_web/discuss_controller.dart
浏览文件 @
dcee668e
part of
web
;
class
DiscussController
extends
GetxController
{
final
BookDetailModel
bookDetailModel
;
// 当前的章节id
final
String
chapterId
;
DiscussController
({
required
this
.
bookDetailModel
,
required
this
.
chapterId
});
List
<
DiscussModel
>
discuss
=
[];
final
EasyRefreshController
refreshController
=
EasyRefreshController
(
controlFinishLoad:
true
,
...
...
@@ -32,8 +36,8 @@ class DiscussController extends GetxController {
final
result
=
await
LibraryAPI
.
discussList
(
page:
_page
,
limit:
_limit
,
bookId:
'110'
,
chapterId:
'1'
bookId:
bookDetailModel
.
bookId
.
toString
()
,
chapterId:
chapterId
);
// 如果是刷新 清理数据
if
(
isRefresh
)
discuss
.
clear
();
...
...
lib/pages/read_web/index.dart
浏览文件 @
dcee668e
...
...
@@ -40,4 +40,5 @@ part 'widgets/note.dart';
part
'widgets/book.dart'
;
part
'note_controller.dart'
;
part
'discuss_controller.dart'
;
part
'widgets/input_discuss.dart'
;
\ No newline at end of file
part
'widgets/input_discuss.dart'
;
part
'widgets/item.dart'
;
\ No newline at end of file
lib/pages/read_web/note_controller.dart
浏览文件 @
dcee668e
part of
web
;
class
NoteController
extends
GetxController
{
final
BookDetailModel
bookDetailModel
;
// 当前的章节id
final
String
chapterId
;
NoteController
({
required
this
.
bookDetailModel
,
required
this
.
chapterId
});
List
<
NoteModel
>
notes
=
[];
final
EasyRefreshController
refreshController
=
EasyRefreshController
(
...
...
@@ -34,8 +37,8 @@ class NoteController extends GetxController {
final
result
=
await
LibraryAPI
.
noteList
(
page:
_page
,
limit:
_limit
,
bookId:
'110'
,
chapterId:
'1'
bookId:
bookDetailModel
.
bookId
.
toString
()
,
chapterId:
chapterId
);
// 如果是刷新 清理数据
if
(
isRefresh
)
notes
.
clear
();
...
...
lib/pages/read_web/view.dart
浏览文件 @
dcee668e
...
...
@@ -4,11 +4,13 @@ class ReadPage extends StatefulWidget {
final
String
bookId
;
final
String
chapterId
;
final
String
chapterName
;
final
BookDetailModel
bookDetailModel
;
const
ReadPage
({
Key
?
key
,
required
this
.
bookId
,
required
this
.
chapterId
,
required
this
.
chapterName
,
required
this
.
bookDetailModel
})
:
super
(
key:
key
);
@override
...
...
@@ -16,6 +18,7 @@ class ReadPage extends StatefulWidget {
}
class
_ReadPageState
extends
State
<
ReadPage
>
{
late
InAppWebViewController
_webViewController
;
@override
void
initState
()
{
...
...
@@ -24,25 +27,25 @@ class _ReadPageState extends State<ReadPage> {
@override
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
ReadController
>(
init:
ReadController
(
bookId:
widget
.
bookId
,
chapterId:
widget
.
chapterId
,
chapterName:
widget
.
chapterName
),
init:
ReadController
(
bookId:
widget
.
bookId
,
chapterId:
widget
.
chapterId
,
chapterName:
widget
.
chapterName
,
bookDetailModel:
widget
.
bookDetailModel
),
builder:
(
readController
)
=>
Scaffold
(
appBar:
CustomAppBar
(
title:
Text
(
widget
.
chapterName
),
title:
Text
(
readController
.
chapterName
),
centerTitle:
false
,
actions:
[
GestureDetector
(
onTap:
()
{
readController
.
getBookDown
();
},
child:
Text
(
'离线阅读'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
),
))
onTap:
()
{
readController
.
getBookDown
();
},
child:
Text
(
'离线阅读'
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
Colours
.
c3
),
))
],
),
resizeToAvoidBottomInset:
false
,
floatingActionButton:
readController
.
show
?
GestureDetector
(
floatingActionButton:
readController
.
show
&&
!
readController
.
toolModel
.
selected
?
GestureDetector
(
onTap:
(){
readController
.
setShowChat
(
true
);
readController
.
noteTitle
=
'你好你问你你等您第五年对哦in我ID呢哦win地哦为内地那打卡你打困哪'
;
...
...
@@ -56,11 +59,11 @@ class _ReadPageState extends State<ReadPage> {
color:
Colors
.
white
,
child:
Stack
(
children:
[
Container
(
height:
40
,
width:
double
.
infinity
,
color:
Colors
.
lightBlue
,
),
//
Container(
//
height: 40,
//
width: double.infinity,
//
color: Colors.lightBlue,
//
),
InAppWebView
(
initialUrlRequest:
URLRequest
(
url:
Uri
.
parse
(
'http://150.158.138.40:9200/read.html'
),
...
...
@@ -68,11 +71,14 @@ class _ReadPageState extends State<ReadPage> {
contextMenu:
ContextMenu
(
options:
ContextMenuOptions
(
hideDefaultSystemContextMenuItems:
true
),
),
onWebViewCreated:
(
InAppWebViewController
controller
){
_webViewController
=
controller
;
},
onLoadStop:
(
controller
,
url
)
{
// flutter 主动给 js 传参数
Map
<
String
,
dynamic
>
param
=
{
'book_id'
:
widget
.
bookId
,
'chapter_id'
:
widget
.
chapterId
,
'book_id'
:
readController
.
bookId
,
'chapter_id'
:
readController
.
chapterId
,
'token'
:
UserStore
.
to
.
token
};
controller
.
evaluateJavascript
(
source
:
'callbackInFlutterComponent("
$param
");'
);
...
...
@@ -232,57 +238,56 @@ class _ReadPageState extends State<ReadPage> {
);
}
/// 目录、评论、笔记
Widget
detail
(
ReadController
controller
,
ToolModel
model
){
if
(
model
.
tag
==
0
){
return
ReadCategoryPage
(
controller:
controller
,
onTap:
(){
controller
.
chooseTool
(
model
);
},
onTapChapter:
(
ChapterModel
chapterModel
){
print
(
'-----------选择的章节-------------
${chapterModel.name}
--------'
);
// 配置选择的章节
controller
.
selectChapter
(
chapterModel
);
// 取消选中 tool
controller
.
chooseTool
(
model
);
// 选择了新的章节 刷新 webview
_webViewController
.
reload
();
},
);
}
else
if
(
model
.
tag
==
1
){
return
ReadNotePage
(
onTap:
(){
controller
.
chooseTool
(
model
);
},
bookDetailModel:
controller
.
bookDetailModel
,
chapterId:
controller
.
chapterId
,);
}
else
if
(
model
.
tag
==
2
){
return
ReadDiscussPage
(
onTap:
(){
controller
.
chooseTool
(
model
);
},
bookDetailModel:
controller
.
bookDetailModel
,
chapterId:
controller
.
chapterId
,);
}
return
const
SizedBox
();
}
/// 目录、评论、笔记 背景
Widget
_showContent
(
ReadController
controller
,
ToolModel
model
)
{
Console
.
log
(
'++++++++++++++++++++++++
${model.tag}
'
);
if
(
controller
.
show
){
if
(
model
.
tag
==
0
){
return
model
.
selected
?
Container
(
if
(
model
.
selected
){
return
Container
(
color:
const
Color
(
0xFF000000
).
withOpacity
(
0.5
),
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.2
),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
8
.
w
),
topLeft:
Radius
.
circular
(
8
.
w
)),
child:
Container
(
color:
Colors
.
white
,
child:
ReadCategoryPage
(
controller:
controller
,
onTap:
(){
controller
.
chooseTool
(
model
);
},),
child:
detail
(
controller
,
model
)
),
),
// child: ReadCategoryPage(),
):
const
SizedBox
();
}
else
if
(
model
.
tag
==
1
){
return
model
.
selected
?
Container
(
color:
const
Color
(
0xFF000000
).
withOpacity
(
0.5
),
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.2
),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
8
.
w
),
topLeft:
Radius
.
circular
(
8
.
w
)),
child:
Container
(
color:
Colors
.
white
,
child:
ReadNotePage
(
onTap:
(){
controller
.
chooseTool
(
model
);
},),
),
),
// child: ReadCategoryPage(),
):
const
SizedBox
();
);
}
else
if
(
model
.
tag
==
2
){
return
model
.
selected
?
Container
(
color:
const
Color
(
0xFF000000
).
withOpacity
(
0.5
),
padding:
EdgeInsets
.
only
(
top:
MediaQuery
.
of
(
context
).
size
.
height
*
0.2
),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
8
.
w
),
topLeft:
Radius
.
circular
(
8
.
w
)),
child:
Container
(
color:
Colors
.
white
,
child:
ReadDiscussPage
(
onTap:
(){
controller
.
chooseTool
(
model
);
},),
),
),
// child: ReadCategoryPage(),
):
const
SizedBox
();
else
{
return
const
SizedBox
();
}
}
return
const
SizedBox
();
...
...
lib/pages/read_web/widgets/book.dart
浏览文件 @
dcee668e
part of
web
;
class
BuildBook
extends
StatelessWidget
{
const
BuildBook
({
Key
?
key
})
:
super
(
key:
key
);
final
BookDetailModel
bookDetailModel
;
const
BuildBook
({
Key
?
key
,
required
this
.
bookDetailModel
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -18,7 +22,7 @@ class BuildBook extends StatelessWidget {
CustomCard
(
width:
72
.
w
,
height:
86
.
w
,
url:
''
,
url:
bookDetailModel
.
img
??
''
,
),
Container
(
height:
87
.
w
,
...
...
@@ -31,8 +35,8 @@ class BuildBook extends StatelessWidget {
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'书名
'
,
style:
TextStyle
(
fontSize:
14
.
w
,
height:
1.5
,
fontWeight:
Fonts
.
medium
,
color:
Colours
.
c3
),),
Text
(
'作者
'
,
style:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c6
),),
Text
(
bookDetailModel
.
bookName
??
'
'
,
style:
TextStyle
(
fontSize:
14
.
w
,
height:
1.5
,
fontWeight:
Fonts
.
medium
,
color:
Colours
.
c3
),),
Text
(
bookDetailModel
.
authors
??
'
'
,
style:
TextStyle
(
fontSize:
12
.
w
,
height:
1.5
,
color:
Colours
.
c6
),),
],
),
],
...
...
lib/pages/read_web/widgets/category.dart
浏览文件 @
dcee668e
...
...
@@ -3,10 +3,12 @@ part of web;
class
ReadCategoryPage
extends
StatefulWidget
{
final
ReadController
controller
;
final
void
Function
()?
onTap
;
final
Function
(
ChapterModel
chapterModel
)
onTapChapter
;
const
ReadCategoryPage
({
Key
?
key
,
required
this
.
controller
,
required
this
.
onTap
,
required
this
.
onTapChapter
})
:
super
(
key:
key
);
@override
...
...
@@ -60,15 +62,18 @@ class _ReadCategoryPageState extends State<ReadCategoryPage> {
),
),
),
BuildBook
(),
// Expanded(
// child: ListView.builder(
// itemBuilder:(BuildContext context, int index){
// return BuildItem(model: widget.controller.chapters[index],);
// },
// itemCount: widget.controller.chapters.length,
// ),
// ),
BuildBook
(
bookDetailModel:
widget
.
controller
.
bookDetailModel
,),
Expanded
(
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
return
BuildItem
(
model:
widget
.
controller
.
chapters
[
index
],
onTapChapter:
(
ChapterModel
chapterModel
){
widget
.
onTapChapter
(
chapterModel
);
widget
.
onTap
;
},);
},
itemCount:
widget
.
controller
.
chapters
.
length
,
),
),
],
),
);
...
...
lib/pages/read_web/widgets/discuss.dart
浏览文件 @
dcee668e
...
...
@@ -2,9 +2,14 @@ part of web;
class
ReadDiscussPage
extends
StatefulWidget
{
final
void
Function
()?
onTap
;
final
BookDetailModel
bookDetailModel
;
// 当前的章节id
final
String
chapterId
;
const
ReadDiscussPage
({
Key
?
key
,
required
this
.
onTap
,
required
this
.
bookDetailModel
,
required
this
.
chapterId
})
:
super
(
key:
key
);
@override
...
...
@@ -16,7 +21,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
@override
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
DiscussController
>(
init:
DiscussController
(),
init:
DiscussController
(
bookDetailModel:
widget
.
bookDetailModel
,
chapterId:
widget
.
chapterId
),
builder:
(
controller
)
=>
Scaffold
(
resizeToAvoidBottomInset:
false
,
body:
Column
(
...
...
@@ -58,7 +63,7 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
),
),
),
BuildBook
(),
BuildBook
(
bookDetailModel:
widget
.
bookDetailModel
,
),
Expanded
(
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
...
...
lib/pages/read_web/widgets/item.dart
0 → 100644
浏览文件 @
dcee668e
part of
web
;
class
BuildItem
extends
StatefulWidget
{
final
ChapterModel
model
;
final
Function
(
ChapterModel
chapterModel
)
onTapChapter
;
const
BuildItem
({
Key
?
key
,
required
this
.
model
,
required
this
.
onTapChapter
})
:
super
(
key:
key
);
@override
State
<
BuildItem
>
createState
()
=>
_BuildItemState
();
}
class
_BuildItemState
extends
State
<
BuildItem
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Column
(
children:
[
/// 章节名称容器
GestureDetector
(
onTap:
(){
if
(
widget
.
model
.
children
!.
isEmpty
){
widget
.
onTapChapter
(
widget
.
model
);
}
},
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
15
.
w
),
height:
30
.
w
,
color:
Colors
.
white
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Text
(
widget
.
model
.
name
??
''
,
style:
TextStyle
(
fontSize:
14
.
w
,
color:
widget
.
model
.
seen
==
0
?
Colours
.
c3
:
Colours
.
c9
,
fontWeight:
Fonts
.
medium
,
height:
2
),),
Gaps
.
hGaps5
,
widget
.
model
.
isReading
==
1
?
Container
(
height:
17
,
width:
17
,
alignment:
Alignment
.
center
,
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
8.5
.
w
),
border:
Border
.
all
(
width:
1
,
color:
AppTheme
.
primary
)
),
child:
Text
(
'试'
,
style:
TextStyle
(
fontSize:
12
.
w
,
color:
AppTheme
.
primary
),),
):
const
SizedBox
(),
],
),
Transform
.
rotate
(
angle:
widget
.
model
.
selected
?
0
:-
90
*
(
3.141592653589793
/
180
),
child:
GestureDetector
(
onTap:
(){
setState
(()
{
widget
.
model
.
selected
=
!
widget
.
model
.
selected
;
});
},
child:
SizedBox
(
width:
20
,
height:
20
,
child:
Image
.
asset
(
'assets/images/down.png'
)
),
)
)
],
)
),
),
/// 节的名称容器
Visibility
(
visible:
widget
.
model
.
selected
,
child:
ListView
.
builder
(
shrinkWrap:
true
,
physics:
const
NeverScrollableScrollPhysics
(),
itemBuilder:
(
BuildContext
context
,
int
index
){
ChapterModel
model
=
widget
.
model
.
children
![
index
];
return
GestureDetector
(
onTap:
(){
widget
.
onTapChapter
(
model
);
},
child:
_buildSection
(
model
)
);
},
itemCount:
widget
.
model
.
children
!.
length
,
)
)
],
);
}
Widget
_buildSection
(
ChapterModel
model
){
return
Container
(
color:
Colors
.
white
,
padding:
const
EdgeInsets
.
only
(
left:
60
),
child:
Text
(
model
.
name
??
''
,
style:
TextStyle
(
fontSize:
12
,
color:
model
.
seen
==
0
?
Colours
.
c3
:
Colours
.
c9
,
height:
2
),),
);
}
}
lib/pages/read_web/widgets/note.dart
浏览文件 @
dcee668e
part of
web
;
class
ReadNotePage
extends
StatefulWidget
{
final
BookDetailModel
bookDetailModel
;
// 当前的章节id
final
String
chapterId
;
final
void
Function
()?
onTap
;
const
ReadNotePage
({
Key
?
key
,
required
this
.
onTap
,
required
this
.
bookDetailModel
,
required
this
.
chapterId
})
:
super
(
key:
key
);
@override
...
...
@@ -16,7 +21,7 @@ class _ReadNotePageState extends State<ReadNotePage> {
@override
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
NoteController
>(
init:
NoteController
(),
init:
NoteController
(
bookDetailModel:
widget
.
bookDetailModel
,
chapterId:
widget
.
chapterId
),
builder:
(
controller
)
=>
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
end
,
children:
[
...
...
@@ -56,7 +61,7 @@ class _ReadNotePageState extends State<ReadNotePage> {
),
),
),
BuildBook
(),
BuildBook
(
bookDetailModel:
widget
.
bookDetailModel
,
),
Expanded
(
child:
ListView
.
builder
(
itemBuilder:
(
BuildContext
context
,
int
index
){
...
...
lib/routes/routes.dart
浏览文件 @
dcee668e
...
...
@@ -187,6 +187,7 @@ abstract class Routes {
bookId:
state
.
uri
.
queryParameters
[
'book_id'
].
toString
(),
chapterId:
state
.
uri
.
queryParameters
[
'chapter_id'
].
toString
(),
chapterName:
state
.
uri
.
queryParameters
[
'chapter_name'
].
toString
(),
bookDetailModel:
state
.
extra
as
BookDetailModel
,
)
)
),
...
...
lib/utils/oss.dart
浏览文件 @
dcee668e
...
...
@@ -12,7 +12,7 @@ class OssTool {
void
initOss
(
String
bucketName
)
async
{
Client
.
init
(
ossEndpoint:
'
zijingebook
.com'
,
bucketName:
bucketName
,
authGetter:
_authGetter
);
Client
.
init
(
ossEndpoint:
'
https://oss-cn-beijing.aliyuncs
.com'
,
bucketName:
bucketName
,
authGetter:
_authGetter
);
}
// 获取临时凭证
...
...
lib/utils/tools.dart
浏览文件 @
dcee668e
...
...
@@ -5,4 +5,31 @@ abstract class Tools {
static
void
unfocus
()
{
WidgetsBinding
.
instance
.
focusManager
.
primaryFocus
?.
unfocus
();
}
static
String
dateFromMS
(
int
timestamp
,
{
String
pattern
=
'yyyy-MM-dd'
,
bool
humanize
=
false
,
})
{
final
dateTime
=
DateTime
.
fromMillisecondsSinceEpoch
(
timestamp
*
1000
);
if
(
humanize
)
{
final
now
=
DateTime
.
now
();
final
difference
=
now
.
difference
(
dateTime
);
if
(
difference
.
inMinutes
<
60
)
{
if
(
difference
.
inMinutes
<
1
)
return
'刚刚'
;
return
'
${difference.inMinutes}
分钟前'
;
}
else
if
(
difference
.
inHours
<
24
)
{
return
'
${difference.inHours}
小时前'
;
}
else
if
(
difference
.
inDays
<
30
)
{
return
'
${difference.inDays}
天前'
;
}
else
if
(
now
.
year
==
dateTime
.
year
)
{
return
DateFormat
(
'MM-dd'
).
format
(
dateTime
);
}
}
return
DateFormat
(
pattern
).
format
(
dateTime
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论