Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
book-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
book-app
Commits
3cef8b26
提交
3cef8b26
authored
1月 16, 2024
作者:
yueweilu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
图书界面 问题还未解决
上级
83f8ae84
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
247 行增加
和
51 行删除
+247
-51
library.dart
lib/apis/library.dart
+6
-0
library.dart
lib/models/library.dart
+3
-0
controller.dart
lib/pages/library/controller.dart
+14
-0
index.dart
lib/pages/library/index.dart
+1
-0
view.dart
lib/pages/library/view.dart
+32
-6
content.dart
lib/pages/library/widgets/content.dart
+18
-41
subject.dart
lib/pages/library/widgets/subject.dart
+12
-4
controller.dart
lib/pages/library_content/controller.dart
+90
-0
index.dart
lib/pages/library_content/index.dart
+18
-0
view.dart
lib/pages/library_content/view.dart
+53
-0
没有找到文件。
lib/apis/library.dart
浏览文件 @
3cef8b26
...
@@ -34,12 +34,18 @@ abstract class LibraryAPI {
...
@@ -34,12 +34,18 @@ abstract class LibraryAPI {
static
Future
<
List
<
CourseModel
>>
books
({
static
Future
<
List
<
CourseModel
>>
books
({
int
page
=
1
,
int
page
=
1
,
int
limit
=
10
,
int
limit
=
10
,
String
sortField
=
''
,
String
sort
=
''
,
String
isFree
=
''
,
})
async
{
})
async
{
final
result
=
await
HttpService
.
to
.
post
(
final
result
=
await
HttpService
.
to
.
post
(
'/v1/book/category/getBookList'
,
'/v1/book/category/getBookList'
,
params:
{
params:
{
'page'
:
page
,
'page'
:
page
,
'page_size'
:
limit
,
'page_size'
:
limit
,
// 'sort_field':sortField,
// 'sort':sort,
// 'is_free':isFree
},
},
);
);
if
(
result
.
data
is
!
Map
&&
result
.
data
[
'list'
]
is
!
List
)
return
[];
if
(
result
.
data
is
!
Map
&&
result
.
data
[
'list'
]
is
!
List
)
return
[];
...
...
lib/models/library.dart
浏览文件 @
3cef8b26
...
@@ -33,14 +33,17 @@ class LabelModel {
...
@@ -33,14 +33,17 @@ class LabelModel {
LabelModel
({
LabelModel
({
this
.
labelId
,
this
.
labelId
,
this
.
name
,
this
.
name
,
this
.
selected
=
false
,
});
});
LabelModel
.
fromJson
(
dynamic
json
)
{
LabelModel
.
fromJson
(
dynamic
json
)
{
labelId
=
json
[
'label_id'
];
labelId
=
json
[
'label_id'
];
name
=
json
[
'name'
];
name
=
json
[
'name'
];
selected
=
false
;
}
}
num
?
labelId
;
num
?
labelId
;
String
?
name
;
String
?
name
;
late
bool
selected
;
LabelModel
copyWith
({
num
?
labelId
,
LabelModel
copyWith
({
num
?
labelId
,
String
?
name
,
String
?
name
,
})
=>
LabelModel
(
labelId:
labelId
??
this
.
labelId
,
})
=>
LabelModel
(
labelId:
labelId
??
this
.
labelId
,
...
...
lib/pages/library/controller.dart
浏览文件 @
3cef8b26
...
@@ -16,6 +16,8 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
...
@@ -16,6 +16,8 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
// 广告数组
// 广告数组
List
<
AdModel
>
ads
=
[];
List
<
AdModel
>
ads
=
[];
late
LabelModel
selectedLabel
=
LabelModel
();
late
TabController
tabController
=
TabController
(
length:
categories
.
length
,
vsync:
this
);
late
TabController
tabController
=
TabController
(
length:
categories
.
length
,
vsync:
this
);
final
int
_limit
=
20
;
final
int
_limit
=
20
;
...
@@ -61,6 +63,16 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
...
@@ -61,6 +63,16 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
onRefresh
();
onRefresh
();
}
}
}
}
//
void
selectLabel
(
LabelModel
model
){
for
(
LabelModel
m
in
labels
){
m
.
selected
=
false
;
}
model
.
selected
=
true
;
selectedLabel
=
model
;
update
();
}
/// 获取广告数据
/// 获取广告数据
void
_getAds
()
async
{
void
_getAds
()
async
{
...
@@ -79,6 +91,8 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
...
@@ -79,6 +91,8 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
/// 获取标签数据
/// 获取标签数据
void
_getLabels
()
async
{
void
_getLabels
()
async
{
labels
=
await
LibraryAPI
.
labels
();
labels
=
await
LibraryAPI
.
labels
();
selectedLabel
=
labels
.
first
;
selectedLabel
.
selected
=
true
;
update
();
update
();
}
}
...
...
lib/pages/library/index.dart
浏览文件 @
3cef8b26
...
@@ -14,6 +14,7 @@ import '../../models/index.dart';
...
@@ -14,6 +14,7 @@ import '../../models/index.dart';
import
'../../routes/index.dart'
;
import
'../../routes/index.dart'
;
import
'../../widgets/index.dart'
;
import
'../../widgets/index.dart'
;
import
'../course/index.dart'
;
import
'../course/index.dart'
;
import
'../library_content/index.dart'
;
import
'../study/index.dart'
;
import
'../study/index.dart'
;
...
...
lib/pages/library/view.dart
浏览文件 @
3cef8b26
...
@@ -7,7 +7,7 @@ class LibraryPage extends StatefulWidget {
...
@@ -7,7 +7,7 @@ class LibraryPage extends StatefulWidget {
State
<
LibraryPage
>
createState
()
=>
_LibraryPageState
();
State
<
LibraryPage
>
createState
()
=>
_LibraryPageState
();
}
}
class
_LibraryPageState
extends
State
<
LibraryPage
>
with
SingleTickerProviderStateMixin
{
class
_LibraryPageState
extends
State
<
LibraryPage
>
with
AutomaticKeepAliveClientMixin
{
//AutomaticKeepAliveClientMixin
//AutomaticKeepAliveClientMixin
@override
@override
...
@@ -84,19 +84,45 @@ class _LibraryPageState extends State<LibraryPage> with SingleTickerProviderStat
...
@@ -84,19 +84,45 @@ class _LibraryPageState extends State<LibraryPage> with SingleTickerProviderStat
),
),
),
),
),
),
body:
Column
(
body:
TabBarView
(
children:
[
Container
(
height:
43
,
color:
Colours
.
cF9
,
child:
ListView
.
builder
(
scrollDirection:
Axis
.
horizontal
,
itemBuilder:
(
BuildContext
context
,
int
index
){
return
GestureDetector
(
child:
BuildLabelWidget
(
model:
controller
.
labels
[
index
],),
onTap:
(){
controller
.
selectLabel
(
controller
.
labels
[
index
]);
},
);
},
itemCount:
controller
.
labels
.
length
,
),
),
Container
(
color:
Colors
.
transparent
,
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
),
child:
BuildBanner
(
items:
controller
.
ads
,),
),
Expanded
(
child:
TabBarView
(
controller:
controller
.
tabController
,
controller:
controller
.
tabController
,
children:
List
.
generate
(
controller
.
categories
.
length
,
(
index
){
children:
List
.
generate
(
controller
.
categories
.
length
,
(
index
){
print
(
'=======================================
$index
'
);
return
LibraryContentPage
(
controller:
controller
,);
return
LibraryContentPage
(
controller:
controller
,);
})
})
),
),
),
),
],
),
),
);
);
}
}
// @override
@override
// // TODO: implement wantKeepAlive
bool
get
wantKeepAlive
=>
true
;
// bool get wantKeepAlive => true;
}
}
lib/pages/library/widgets/content.dart
浏览文件 @
3cef8b26
...
@@ -13,49 +13,27 @@ class LibraryContentPage extends StatefulWidget {
...
@@ -13,49 +13,27 @@ class LibraryContentPage extends StatefulWidget {
State
<
LibraryContentPage
>
createState
()
=>
_LibraryContentPageState
();
State
<
LibraryContentPage
>
createState
()
=>
_LibraryContentPageState
();
}
}
class
_LibraryContentPageState
extends
State
<
LibraryContentPage
>
{
class
_LibraryContentPageState
extends
State
<
LibraryContentPage
>
with
AutomaticKeepAliveClientMixin
{
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Column
(
return
CustomPullScrollView
(
children:
[
SizedBox
(
height:
43
,
// color: Colors.green,
child:
ListView
.
builder
(
scrollDirection:
Axis
.
horizontal
,
itemBuilder:
(
BuildContext
context
,
int
index
){
return
GestureDetector
(
child:
BuildLabelWidget
(
model:
widget
.
controller
.
labels
[
index
],),
onTap:
(){
},
);
},
itemCount:
widget
.
controller
.
labels
.
length
,
),
),
Expanded
(
child:
CustomPullScrollView
(
controller:
widget
.
controller
.
refreshController
,
controller:
widget
.
controller
.
refreshController
,
onRefresh:
widget
.
controller
.
onRefresh
,
onRefresh:
widget
.
controller
.
onRefresh
,
onLoading:
widget
.
controller
.
onLoading
,
onLoading:
widget
.
controller
.
onLoading
,
child:
NestedScrollView
(
child:
ListView
.
builder
(
headerSliverBuilder:
(
BuildContext
context
,
bool
innerBoxIsScrolled
){
// shrinkWrap: true,
return
[
// physics: NeverScrollableScrollPhysics(),
SliverList
(
scrollDirection:
Axis
.
vertical
,
delegate:
SliverChildListDelegate
([
Container
(
color:
Colors
.
transparent
,
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
10
),
child:
BuildBanner
(
items:
widget
.
controller
.
ads
,),
),
])
)
];
},
body:
ListView
.
builder
(
itemCount:
widget
.
controller
.
books
.
length
,
itemCount:
widget
.
controller
.
books
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
itemBuilder:
(
BuildContext
context
,
int
index
)
{
// if (index == 0){
// return Container(
// color: Colors.transparent,
// padding: const EdgeInsets.symmetric(horizontal: 10),
// child: BuildBanner(items: widget.controller.ads,),
// );
// }
// else {
CourseModel
model
=
widget
.
controller
.
books
[
index
];
CourseModel
model
=
widget
.
controller
.
books
[
index
];
return
GestureDetector
(
return
GestureDetector
(
onTap:
(){
onTap:
(){
...
@@ -65,12 +43,11 @@ class _LibraryContentPageState extends State<LibraryContentPage> {
...
@@ -65,12 +43,11 @@ class _LibraryContentPageState extends State<LibraryContentPage> {
widget
.
controller
.
love
(
bookId:
model
.
bookId
.
toString
(),
isCollection:
model
.
isCollection
!);
widget
.
controller
.
love
(
bookId:
model
.
bookId
.
toString
(),
isCollection:
model
.
isCollection
!);
},),
},),
);
);
},
}
),
// },
),
),
),
),
],
);
);
}
}
@override
bool
get
wantKeepAlive
=>
true
;
}
}
lib/pages/library/widgets/subject.dart
浏览文件 @
3cef8b26
...
@@ -12,7 +12,7 @@ class BuildLabelWidget extends StatelessWidget {
...
@@ -12,7 +12,7 @@ class BuildLabelWidget extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Container
(
return
Container
(
margin:
const
EdgeInsets
.
only
(
left:
10
),
margin:
const
EdgeInsets
.
only
(
left:
10
),
color:
Colors
.
white
,
color:
Colors
.
transparent
,
width:
65
,
width:
65
,
padding:
const
EdgeInsets
.
only
(
top:
10
,
bottom:
10
),
padding:
const
EdgeInsets
.
only
(
top:
10
,
bottom:
10
),
child:
Container
(
child:
Container
(
...
@@ -22,10 +22,18 @@ class BuildLabelWidget extends StatelessWidget {
...
@@ -22,10 +22,18 @@ class BuildLabelWidget extends StatelessWidget {
height:
23
,
height:
23
,
decoration:
BoxDecoration
(
decoration:
BoxDecoration
(
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
12.5
)),
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
12.5
)),
border:
Border
.
all
(
color:
AppTheme
.
primary
,
width:
0.5
,
style:
BorderStyle
.
solid
),
border:
model
.
selected
?
Border
.
all
(
color:
AppTheme
.
primary
,
width:
0.5
,
style:
BorderStyle
.
solid
):
null
,
// color: widget.model.selected == true?Colours.book_app_main:Colors.white,
color:
Colors
.
white
,
boxShadow:
model
.
selected
?[
BoxShadow
(
color:
AppTheme
.
primary
.
withOpacity
(
0.3
),
offset:
const
Offset
(
0
,
1
),
blurRadius:
2
.
w
,
spreadRadius:
0
.
w
,
),
]:
null
,
),
),
child:
Text
(
model
.
name
??
''
,
style:
const
TextStyle
(
fontSize:
13
,
height:
1.5
,
color:
AppTheme
.
primary
,
fontWeight:
Fonts
.
medium
),)
child:
Text
(
model
.
name
??
''
,
style:
TextStyle
(
fontSize:
13
,
height:
1.5
,
color:
model
.
selected
?
AppTheme
.
primary
:
Colours
.
c9
,
fontWeight:
Fonts
.
medium
),)
),
),
);
);
}
}
...
...
lib/pages/library_content/controller.dart
0 → 100644
浏览文件 @
3cef8b26
part of
library_content
;
class
LibraryContentController
extends
GetxController
{
final
EasyRefreshController
refreshController
=
EasyRefreshController
(
controlFinishLoad:
true
,
controlFinishRefresh:
true
,
);
final
int
_limit
=
10
;
int
_page
=
1
;
bool
_noMore
=
false
;
// 图书列表数据
List
<
CourseModel
>
books
=
[];
@override
void
onReady
()
{
super
.
onReady
();
}
@override
void
onClose
()
{
refreshController
.
dispose
();
super
.
onClose
();
}
/// 收藏 与 取消收藏
void
love
({
required
String
bookId
,
required
num
isCollection
})
async
{
if
(
isCollection
==
0
){
isCollection
=
1
;
}
else
{
isCollection
=
0
;
}
bool
result
=
await
CommonAPI
.
love
(
bookId:
bookId
,
love:
isCollection
.
toString
());
if
(
result
)
{
onRefresh
();
}
}
/// 获取图书列表数据
Future
<
void
>
_getBooks
([
bool
isRefresh
=
false
])
async
{
if
(
isRefresh
)
_page
=
1
;
// 网路请求
final
result
=
await
LibraryAPI
.
books
(
page:
_page
,
limit:
_limit
);
// 如果是刷新 清理数据
if
(
isRefresh
)
books
.
clear
();
books
.
addAll
(
result
);
_page
++;
_noMore
=
result
.
length
<
_limit
;
update
();
}
void
onRefresh
()
async
{
try
{
await
_getBooks
(
true
);
refreshController
.
finishRefresh
(
IndicatorResult
.
success
);
refreshController
.
resetFooter
();
}
catch
(
error
)
{
refreshController
.
finishRefresh
(
IndicatorResult
.
fail
);
}
}
void
onLoading
()
async
{
if
(
_noMore
)
{
refreshController
.
finishLoad
(
IndicatorResult
.
noMore
);
return
;
}
try
{
await
_getBooks
();
refreshController
.
finishLoad
();
}
catch
(
error
)
{
refreshController
.
finishLoad
(
IndicatorResult
.
fail
);
}
}
}
\ No newline at end of file
lib/pages/library_content/index.dart
0 → 100644
浏览文件 @
3cef8b26
library
library_content
;
import
'package:easy_refresh/easy_refresh.dart'
;
import
'package:flutter/material.dart'
;
import
'package:get/get.dart'
;
import
'package:get/get_state_manager/src/simple/get_controllers.dart'
;
import
'package:go_router/go_router.dart'
;
import
'../../apis/index.dart'
;
import
'../../models/index.dart'
;
import
'../../routes/index.dart'
;
import
'../../widgets/index.dart'
;
import
'../course/index.dart'
;
import
'../library/index.dart'
;
part
'view.dart'
;
part
'controller.dart'
;
\ No newline at end of file
lib/pages/library_content/view.dart
0 → 100644
浏览文件 @
3cef8b26
part of
library_content
;
class
LibraryContentPage
extends
StatefulWidget
{
final
CategoryModel
categoryModel
;
final
LabelModel
labelModel
;
const
LibraryContentPage
({
Key
?
key
,
required
this
.
categoryModel
,
required
this
.
labelModel
})
:
super
(
key:
key
);
@override
State
<
LibraryContentPage
>
createState
()
=>
_LibraryContentPageState
();
}
class
_LibraryContentPageState
extends
State
<
LibraryContentPage
>
with
AutomaticKeepAliveClientMixin
{
@override
Widget
build
(
BuildContext
context
)
{
return
GetBuilder
<
LibraryContentController
>(
init:
LibraryContentController
(),
builder:
(
controller
)
=>
CustomPullScrollView
(
controller:
controller
.
refreshController
,
onRefresh:
controller
.
onRefresh
,
onLoading:
controller
.
onLoading
,
child:
ListView
.
builder
(
itemCount:
controller
.
books
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
// if (index == 0){
// return Container(
// color: Colors.transparent,
// padding: const EdgeInsets.symmetric(horizontal: 10),
// child: BuildBanner(items: controller.ads,),
// );
// }
// else {
CourseModel
model
=
controller
.
books
[
index
];
return
GestureDetector
(
onTap:
(){
context
.
pushNamed
(
Routes
.
bookDetail
,
queryParameters:
{
'book_id'
:
model
.
bookId
.
toString
()});
},
child:
LibraryCell
(
model:
model
,
onTap:
(){
controller
.
love
(
bookId:
model
.
bookId
.
toString
(),
isCollection:
model
.
isCollection
!);
},),
);
}
// },
),
),
);
}
@override
bool
get
wantKeepAlive
=>
true
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论