提交 0bbfc72e authored 作者: yueweilu's avatar yueweilu

图书馆界面优化

上级 62702350
...@@ -64,7 +64,8 @@ abstract class LibraryAPI { ...@@ -64,7 +64,8 @@ abstract class LibraryAPI {
final result = await HttpService.to.post( final result = await HttpService.to.post(
'/v1/book/category/getBookList', '/v1/book/category/getBookList',
params: params params: params,
showLoading: true
); );
if (result.data is! Map && result.data['list'] is! List) return []; if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){ return List.generate(result.data['list'].length, (index){
......
...@@ -33,7 +33,7 @@ class _BuildItemState extends State<BuildItem> { ...@@ -33,7 +33,7 @@ class _BuildItemState extends State<BuildItem> {
Row( Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
Text(widget.model.name??'',style: TextStyle(fontSize: 14.w,color: widget.model.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 1.4),), 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, Gaps.hGaps5,
widget.model.isReading == 1? Container( widget.model.isReading == 1? Container(
height: 17, height: 17,
...@@ -76,7 +76,7 @@ class _BuildItemState extends State<BuildItem> { ...@@ -76,7 +76,7 @@ class _BuildItemState extends State<BuildItem> {
return Container( return Container(
color: Colors.white, color: Colors.white,
padding: const EdgeInsets.only(left: 60), padding: const EdgeInsets.only(left: 60),
child: Text(model.name??'',style:TextStyle(fontSize: 12,color: model.seen ==0? Colours.c3:Colours.c9,height: 1.6),), child: Text(model.name??'',style:TextStyle(fontSize: 12,color: model.seen ==0? Colours.c3:Colours.c9,height: 2),),
); );
} }
} }
...@@ -15,15 +15,15 @@ class BuildItem extends StatelessWidget { ...@@ -15,15 +15,15 @@ class BuildItem extends StatelessWidget {
padding: EdgeInsets.only(left: 15.w, top: 15.w,right: 10.w,bottom: 15.w), padding: EdgeInsets.only(left: 15.w, top: 15.w,right: 10.w,bottom: 15.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
boxShadow: const [ boxShadow: [
BoxShadow( BoxShadow(
color: Colours.cC7, color: Colours.cC7.withOpacity(0.5),
offset: Offset(0, 3), offset: Offset(3.w, 0.w),
blurRadius: 4, blurRadius: 4.w,
spreadRadius: 0, spreadRadius: 0,
), ),
], ],
borderRadius: BorderRadius.circular(8) borderRadius: BorderRadius.circular(8.w)
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
...@@ -31,13 +31,13 @@ class BuildItem extends StatelessWidget { ...@@ -31,13 +31,13 @@ class BuildItem extends StatelessWidget {
Row( Row(
children: [ children: [
Container( Container(
width: 35, width: 35.w,
height: 35, height: 35.w,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.cyan, color: Colors.cyan,
borderRadius: BorderRadius.circular(17.5) borderRadius: BorderRadius.circular(17.5.w)
), ),
child: CustomImage.network(url: model.usersImg??''), child: CustomImage.network(url: model.usersImg??'',radius: 17.5.w,),
), ),
Gaps.hGaps10, Gaps.hGaps10,
Expanded( Expanded(
...@@ -47,9 +47,9 @@ class BuildItem extends StatelessWidget { ...@@ -47,9 +47,9 @@ class BuildItem extends StatelessWidget {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(model.users??'',style: const TextStyle(fontSize: 12,height: 1.3,color: Colours.c9),), Text(model.users??'',style: TextStyle(fontSize: 12.w,height: 1.3,color: Colours.c9),),
// Spacer(), // Spacer(),
Text(model.createTime??'',style: const TextStyle(fontSize: 12,height: 1.3,color: Colours.c9),) Text(model.createTime??'',style: TextStyle(fontSize: 12.w,height: 1.3,color: Colours.c9),)
], ],
), ),
AbsorbPointer( AbsorbPointer(
...@@ -57,10 +57,10 @@ class BuildItem extends StatelessWidget { ...@@ -57,10 +57,10 @@ class BuildItem extends StatelessWidget {
child: CustomRating( child: CustomRating(
max: 5, max: 5,
score:model.rating!.toDouble() , score:model.rating!.toDouble() ,
star: const Star( star: Star(
progress: 7, progress: 7,
fillColor: AppTheme.primary, fillColor: AppTheme.primary,
size: 12, size: 12.w,
emptyColor: Colours.cE2, emptyColor: Colours.cE2,
), onRating: (double ) {}, ), onRating: (double ) {},
), ),
...@@ -71,7 +71,7 @@ class BuildItem extends StatelessWidget { ...@@ -71,7 +71,7 @@ class BuildItem extends StatelessWidget {
], ],
), ),
Gaps.vGaps15, Gaps.vGaps15,
Text(model.comments??'',style: const TextStyle(fontSize: 14,height: 1.5,color: Colours.c3),) Text(model.comments??'',style: TextStyle(fontSize: 14.w,height: 1.5,color: Colours.c3),)
], ],
), ),
), ),
......
...@@ -82,6 +82,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -82,6 +82,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
// 获取标签数据 // 获取标签数据
_getLabels(); _getLabels();
_getAds(); _getAds();
onRefresh();
super.onReady(); super.onReady();
} }
...@@ -154,7 +155,16 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -154,7 +155,16 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
} }
model.selected = true; model.selected = true;
selectedLabel = model; selectedLabel = model;
update(); onRefresh();
}
void selectCategory(FilterModel model){
for (FilterModel m in filterCategories){
m.selected = false;
}
model.selected = true;
selectedCategory = model;
onRefresh();
} }
/// 获取广告数据 /// 获取广告数据
......
...@@ -35,16 +35,52 @@ class _LibraryPageState extends State<LibraryPage> { ...@@ -35,16 +35,52 @@ class _LibraryPageState extends State<LibraryPage> {
return Stack( return Stack(
children: [ children: [
Column( Column(
mainAxisSize: MainAxisSize.max,
children: [ children: [
_buildTab(controller), // _buildTab(controller),
Row(
children: [
Expanded(child: _buildCategory()),
GestureDetector(
onTap: (){
controller.setShow(controller.show);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w),
alignment: Alignment.center,
height: 38.w,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 12.w,
height: 12.w,
// color: Colors.red,
alignment: Alignment.center,
child: Image.asset(
'assets/images/filter.png',
),
),
Gaps.hGaps5,
Text('筛选',style: TextStyle(color: Colours.c9,fontSize: 14.w,height: 1.5),)
],
),
// width: 75,
),
)
],
),
_buildLabel(), _buildLabel(),
Expanded( Container(
// color: Colors.red,
child: Expanded(
child: CustomPullScrollView( child: CustomPullScrollView(
controller: controller.refreshController, controller: controller.refreshController,
onRefresh: controller.onRefresh, // onRefresh: controller.onRefresh,
onLoading: controller.onLoading, onLoading: controller.onLoading,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
mainAxisSize: MainAxisSize.max,
children: [ children: [
controller.ads.isNotEmpty?Container( controller.ads.isNotEmpty?Container(
color: Colors.cyan, color: Colors.cyan,
...@@ -56,6 +92,7 @@ class _LibraryPageState extends State<LibraryPage> { ...@@ -56,6 +92,7 @@ class _LibraryPageState extends State<LibraryPage> {
), ),
), ),
), ),
),
) )
], ],
), ),
...@@ -97,6 +134,33 @@ class _LibraryPageState extends State<LibraryPage> { ...@@ -97,6 +134,33 @@ class _LibraryPageState extends State<LibraryPage> {
); );
} }
Widget _buildCategory(){
return Container(
height: 38,
child: GetBuilder<LibraryController>(
init: LibraryController(),
builder: (controller) =>ListView.builder(
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index){
FilterModel model = controller.filterCategories[index];
return GestureDetector(
onTap: (){
controller.selectCategory(model);
},
child: Container(
padding: EdgeInsets.symmetric(vertical: 10.w,horizontal: 10.w),
color: model.selected?const Color(0xFFC02D55).withOpacity(0.08):Colors.white,
alignment: Alignment.center,
child: Text(model.name??'',style: model.selected?TextStyle(fontSize: 14.w,color: AppTheme.primary,fontWeight: Fonts.medium,):TextStyle(fontSize: 14.w,color: Colours.c9,),),
),
);
},
itemCount: controller.filterCategories.length
)
),
);
}
PreferredSizeWidget _buildTab(LibraryController controller){ PreferredSizeWidget _buildTab(LibraryController controller){
return PreferredSize( return PreferredSize(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论