diff --git a/lib/routes/picture/pictureDetail.dart b/lib/routes/picture/pictureDetail.dart index 8d4b9e2..6471107 100644 --- a/lib/routes/picture/pictureDetail.dart +++ b/lib/routes/picture/pictureDetail.dart @@ -27,6 +27,7 @@ class _PictureDetailState extends State { @override void initState() { currentIndex = widget.index; + print(currentIndex); super.initState(); } @@ -107,9 +108,9 @@ class _PictureDetailState extends State { onPageChanged: (int index) { currentIndex = index; }, - // controller: PageController( - // initialPage: currentIndex, - // ), + controller: ExtendedPageController( + initialPage: widget.index, + ), scrollDirection: Axis.horizontal, ), ), diff --git a/lib/routes/picture/pictureList.dart b/lib/routes/picture/pictureList.dart index a7261cc..0a8a34b 100644 --- a/lib/routes/picture/pictureList.dart +++ b/lib/routes/picture/pictureList.dart @@ -2,7 +2,9 @@ import 'dart:math'; import 'package:eoe_fans/common/Api.dart'; import 'package:eoe_fans/models/index.dart'; +import 'package:eoe_fans/models/member.dart'; import 'package:eoe_fans/models/picturesRequest.dart'; +import 'package:eoe_fans/routes/picture/pictureMemberFilter.dart'; import 'package:eoe_fans/routes/picture/pictureSwiper.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -23,6 +25,7 @@ class _PictureListState extends State { int _page = 0; bool _loading = false; + MemberEnum? _memberFilter; List dynamicList = []; @override @@ -36,9 +39,29 @@ class _PictureListState extends State { _loading = true; _page++; }); + PicturesTopic topic = PicturesTopic.all; + switch (_memberFilter) { + case MemberEnum.zao: + topic = PicturesTopic.zao; + break; + case MemberEnum.mi: + topic = PicturesTopic.mi; + break; + case MemberEnum.wan: + topic = PicturesTopic.wan; + break; + case MemberEnum.mo: + topic = PicturesTopic.mo; + break; + case MemberEnum.un: + topic = PicturesTopic.un; + break; + default: + topic = PicturesTopic.all; + } PicturesRequest param = PicturesRequest() ..page = _page - ..topic_id = PicturesTopic.all; + ..topic_id = topic; Pictures pictures = widget.pageType == PicturePageType.recommend ? await Api(context).picturesRecommend(param) : await Api(context).picturesLatest(param); @@ -55,10 +78,8 @@ class _PictureListState extends State { } _reloadPictures({int? page}) async { - setState(() { - dynamicList = []; - _page = page ?? 0; - }); + dynamicList = []; + _page = page ?? 0; await _getPictures(); } @@ -101,16 +122,33 @@ class _PictureListState extends State { onRefresh: _onRefresh, onLoading: _onLoading, child: ListView.builder( - itemBuilder: (c, i) => Card( - clipBehavior: Clip.antiAliasWithSaveLayer, - child: SizedBox( - width: double.infinity, - height: 480, - child: PictureSwiper( - dynamicId: dynamicList[i].dynamic_id.toString(), - images: dynamicList[i].pictures.map((e) => e.img_src).toList(), - ), - ), + itemBuilder: (c, i) => Container( + child: i == 0 + ? SizedBox( + width: double.infinity, + height: 84, + child: PictureMemberFilter( + filter: _memberFilter, + updateFilterMember: (MemberEnum? value) { + _memberFilter = value; + _reloadPictures(); + }, + ), + ) + : SizedBox( + width: double.infinity, + height: 480, + child: Card( + clipBehavior: Clip.antiAliasWithSaveLayer, + child: PictureSwiper( + dynamicId: dynamicList[i].dynamic_id.toString(), + images: dynamicList[i] + .pictures + .map((e) => e.img_src) + .toList(), + ), + ), + ), // child: Center( // child: Image( @@ -120,7 +158,7 @@ class _PictureListState extends State { // ), // ), ), - itemCount: dynamicList.length, + itemCount: dynamicList.length + 1, ), ); } diff --git a/lib/routes/picture/pictureMemberFilter.dart b/lib/routes/picture/pictureMemberFilter.dart new file mode 100644 index 0000000..58c2295 --- /dev/null +++ b/lib/routes/picture/pictureMemberFilter.dart @@ -0,0 +1,85 @@ +import 'package:eoe_fans/common/Global.dart'; +import 'package:eoe_fans/models/member.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class PictureMemberFilter extends StatefulWidget { + const PictureMemberFilter( + {Key? key, required this.filter, required this.updateFilterMember}) + : super(key: key); + + final ValueChanged updateFilterMember; + final MemberEnum? filter; + + @override + State createState() => _PictureMemberFilterState(); +} + +class _PictureMemberFilterState extends State { + @override + void initState() { + print('reload'); + // TODO: implement initState + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + child: GridView.count( + crossAxisCount: 5, + childAspectRatio: 1.0, + children: MemberEnum.values + .map( + (m) => GestureDetector( + onTap: () { + setState(() { + if (widget.filter == m) { + widget.updateFilterMember(null); + } else { + widget.updateFilterMember(m); + } + }); + }, + child: Card( + elevation: widget.filter == m ? 6 : 1, + shadowColor: widget.filter == m + ? HexColor(Global.members[m]?.color ?? '#66CCFF') + : null, + child: Container( + padding: EdgeInsets.all(4), + child: Center( + child: Flex( + direction: Axis.vertical, + children: [ + Expanded( + flex: 3, + child: Image( + image: AssetImage( + 'assets/${Global.themes.firstWhere((e) => e.id == m.name, orElse: () => Global.themes.first).filter}', + ), + fit: BoxFit.contain, + // fit: BoxFit.fitWidth + ), + ), + Expanded( + flex: 1, + child: Text( + Global.members[m]?.firstName ?? m.name, + style: const TextStyle( + fontSize: 12, + color: Colors.black54, + ), + ), + ), + ], + ), + ), + ), + ), + ), + ) + .toList(), + )); + } +} diff --git a/lib/routes/picture/picturePage.dart b/lib/routes/picture/picturePage.dart index 7eacaf9..54aee89 100644 --- a/lib/routes/picture/picturePage.dart +++ b/lib/routes/picture/picturePage.dart @@ -37,7 +37,7 @@ class _PicturePageState extends State { centerTitle: true, title: Container( width: 300, - padding: const EdgeInsets.only(left: 20, right: 20), + padding: const EdgeInsets.only(left: 20, right: 40), child: const TabBar( tabs: [ Tab( @@ -50,12 +50,12 @@ class _PicturePageState extends State { ), ), actions: [ - IconButton( - icon: const Icon( - Icons.search, - ), - onPressed: () {}, - ), + // IconButton( + // icon: const Icon( + // Icons.search, + // ), + // onPressed: () {}, + // ), ], flexibleSpace: Container( height: double.maxFinite, diff --git a/lib/routes/video/videoSearchPage.dart b/lib/routes/video/videoSearchPage.dart index d979be6..30733fb 100644 --- a/lib/routes/video/videoSearchPage.dart +++ b/lib/routes/video/videoSearchPage.dart @@ -26,6 +26,7 @@ class _VideoSearchPageState extends State { String searchString = ''; int _page = 0; + VideosRequestOrder _order = VideosRequestOrder.score; List