From bda052d6f3e363f7d5dc9ad15bda95eb31bae066 Mon Sep 17 00:00:00 2001 From: misakajimmy Date: Thu, 16 Feb 2023 12:42:24 +0800 Subject: [PATCH] DEV UPDATE:1.6.2 --- lib/routes/picture/pictureList.dart | 126 +++++++++++----- lib/routes/picture/pictureMemberFilter.dart | 20 ++- lib/routes/picture/picturePage.dart | 2 +- lib/routes/picture/pictureSwiper.dart | 159 +++++++++++--------- lib/routes/video/videoSwiper.dart | 4 +- pubspec.yaml | 3 +- 6 files changed, 190 insertions(+), 124 deletions(-) diff --git a/lib/routes/picture/pictureList.dart b/lib/routes/picture/pictureList.dart index 19f3ea9..8b54231 100644 --- a/lib/routes/picture/pictureList.dart +++ b/lib/routes/picture/pictureList.dart @@ -8,6 +8,7 @@ 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'; +import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; class PictureList extends StatefulWidget { @@ -27,13 +28,35 @@ class _PictureListState extends State { bool _loading = false; MemberEnum? _memberFilter; List dynamicList = []; + List listWidgets = []; @override void initState() { _getPictures(); + _initListWidgets(); super.initState(); } + _initListWidgets() { + listWidgets = [ + StaggeredGridTile.count( + crossAxisCellCount: 4, + mainAxisCellCount: 1, + child: Center( + child: Container( + child: PictureMemberFilter( + filter: _memberFilter, + updateFilterMember: (MemberEnum? value) { + _memberFilter = value; + _reloadPictures(); + }, + ), + ), + ), + ) + ]; + } + _getPictures() async { setState(() { _loading = true; @@ -68,6 +91,24 @@ class _PictureListState extends State { if (pictures.result.length != 0) { setState(() { dynamicList = [...dynamicList, ...pictures.result]; + listWidgets = [ + ...listWidgets, + ...pictures.result.map( + (e) { + return StaggeredGridTile.count( + crossAxisCellCount: 2, + mainAxisCellCount: 3, + child: Card( + clipBehavior: Clip.antiAliasWithSaveLayer, + child: PictureSwiper( + dynamicId: e.dynamic_id.toString(), + images: e.pictures.map((e) => e.img_src).toList(), + ), + ), + ); + }, + ).toList() + ]; _loading = false; }); } else { @@ -79,6 +120,9 @@ class _PictureListState extends State { _reloadPictures({int? page}) async { dynamicList = []; + setState(() { + _initListWidgets(); + }); _page = page ?? 0; await _getPictures(); } @@ -121,45 +165,51 @@ class _PictureListState extends State { controller: _refreshController, onRefresh: _onRefresh, onLoading: _onLoading, - child: ListView.builder( - 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( - // image: CachedNetworkImageProvider(dynamicList[i].pictures[0].img_src), - // fit: BoxFit.fitWidth, - // width: double.infinity, - // ), - // ), - ), - itemCount: dynamicList.length, + child: StaggeredGrid.count( + crossAxisCount: 4, + mainAxisSpacing: 4, + crossAxisSpacing: 4, + children: listWidgets, ), + // child: ListView.builder( + // 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( + // // image: CachedNetworkImageProvider(dynamicList[i].pictures[0].img_src), + // // fit: BoxFit.fitWidth, + // // width: double.infinity, + // // ), + // // ), + // ), + // itemCount: dynamicList.length, + // ), ); } } diff --git a/lib/routes/picture/pictureMemberFilter.dart b/lib/routes/picture/pictureMemberFilter.dart index 58c2295..7479fc5 100644 --- a/lib/routes/picture/pictureMemberFilter.dart +++ b/lib/routes/picture/pictureMemberFilter.dart @@ -26,12 +26,14 @@ class _PictureMemberFilterState extends State { @override Widget build(BuildContext context) { return Container( - child: GridView.count( - crossAxisCount: 5, - childAspectRatio: 1.0, - children: MemberEnum.values - .map( - (m) => GestureDetector( + child: Center( + child: GridView.count( + shrinkWrap: true, + crossAxisCount: 5, + childAspectRatio: 1.0, + children: MemberEnum.values + .map( + (m) => GestureDetector( onTap: () { setState(() { if (widget.filter == m) { @@ -79,7 +81,9 @@ class _PictureMemberFilterState extends State { ), ), ) - .toList(), - )); + .toList(), + ), + ), + ); } } diff --git a/lib/routes/picture/picturePage.dart b/lib/routes/picture/picturePage.dart index 54aee89..4360eb9 100644 --- a/lib/routes/picture/picturePage.dart +++ b/lib/routes/picture/picturePage.dart @@ -67,7 +67,7 @@ class _PicturePageState extends State { ), ), body: Container( - padding: const EdgeInsets.only(left: 4, right: 4, top: 8, bottom: 40), + padding: const EdgeInsets.only(left: 4, right: 4, bottom: 40), child: const TabBarView( children: [ PictureList(pageType: PicturePageType.recommend), diff --git a/lib/routes/picture/pictureSwiper.dart b/lib/routes/picture/pictureSwiper.dart index 76be036..98f2e2a 100644 --- a/lib/routes/picture/pictureSwiper.dart +++ b/lib/routes/picture/pictureSwiper.dart @@ -2,6 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:eoe_fans/routes/picture/pictureDetail.dart'; import 'package:extended_image/extended_image.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -13,89 +14,99 @@ class PictureSwiper extends StatelessWidget { @override Widget build(BuildContext context) { - return Stack( - children: [ - Swiper( - itemBuilder: (BuildContext context, int index) { - var image = CachedNetworkImageProvider(images[index]); - return Stack( - children: [ - Positioned( - top: 0, - bottom: 0, - left: 0, - right: 0, - child: GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return PictureDetail(index: index, images: images); - }, + return GestureDetector( + onLongPress: () { + HapticFeedback.heavyImpact(); + // showMaterialModalBottomSheet( + // context: context, + // builder: (context) => Container(), + // ); + print('long press'); + }, + child: Stack( + children: [ + Swiper( + itemBuilder: (BuildContext context, int index) { + var image = CachedNetworkImageProvider(images[index]); + return Stack( + children: [ + Positioned( + top: 0, + bottom: 0, + left: 0, + right: 0, + child: GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return PictureDetail(index: index, images: images); + }, + ), + ); + }, + child: Container( + child: ExtendedImage( + image: image, + fit: BoxFit.cover, ), - ); - }, - child: Container( - child: ExtendedImage( - image: image, - fit: BoxFit.cover, ), ), ), - ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - height: 40, - decoration: new BoxDecoration( - color: Color.fromRGBO(0, 0, 0, .3), - gradient: LinearGradient( - colors: [Colors.transparent, Colors.black], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( + height: 40, + decoration: new BoxDecoration( + color: Color.fromRGBO(0, 0, 0, .3), + gradient: LinearGradient( + colors: [Colors.transparent, Colors.black], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + ), ), ), - ), - ) - ], - ); - }, - itemCount: images.length, - onTap: (int index) async {}, - pagination: const SwiperPagination( - alignment: Alignment.bottomLeft, - builder: DotSwiperPaginationBuilder( - color: Colors.white30, // 其他点的颜色 - activeColor: Colors.white, - space: 2, // 点与点之间的距离 - activeSize: 15, // 当前点的大小 + ) + ], + ); + }, + itemCount: images.length, + onTap: (int index) async {}, + pagination: const SwiperPagination( + alignment: Alignment.bottomLeft, + builder: DotSwiperPaginationBuilder( + color: Colors.white30, // 其他点的颜色 + activeColor: Colors.white, + space: 2, // 点与点之间的距离 + activeSize: 15, // 当前点的大小 + ), ), + autoplay: false, ), - autoplay: false, - ), - Positioned( - bottom: -4, - right: 8, - child: IconButton( - icon: Icon( - Icons.arrow_forward_ios, - size: 16, - color: Colors.white, - ), - onPressed: () async { - if (dynamicId != null) { - var _url = 'bilibili://following/detail/' + dynamicId!; - if (!await launchUrl(Uri.parse(_url))) { - throw 'Could not launch $_url'; + Positioned( + bottom: -4, + right: 8, + child: IconButton( + icon: Icon( + Icons.arrow_forward_ios, + size: 16, + color: Colors.white, + ), + onPressed: () async { + if (dynamicId != null) { + var _url = 'bilibili://following/detail/' + dynamicId!; + if (!await launchUrl(Uri.parse(_url))) { + throw 'Could not launch $_url'; + } } - } - }, - ), - ) - ], + }, + ), + ) + ], + ), ); } } diff --git a/lib/routes/video/videoSwiper.dart b/lib/routes/video/videoSwiper.dart index 66a92d2..659909d 100644 --- a/lib/routes/video/videoSwiper.dart +++ b/lib/routes/video/videoSwiper.dart @@ -3,13 +3,13 @@ import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart'; import 'package:url_launcher/url_launcher.dart'; const images = [ - 'assets/banner1.jpg', + 'assets/banner1.png', 'assets/banner2.png', 'assets/banner3.png', ]; const urls = [ - 'https://b23.tv/GI9EDCl', + 'https://b23.tv/KjrFIG1', 'bilibili://video/BV1Pv4y1C7TE', 'https://b23.tv/kI0MBkx' ]; diff --git a/pubspec.yaml b/pubspec.yaml index 26a5068..ae81660 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.6.0+1 +version: 1.6.2+1 environment: sdk: '>=2.18.6 <3.0.0' @@ -52,6 +52,7 @@ dependencies: extended_image: ^6.3.4 image_gallery_saver: ^1.7.1 fluttertoast: ^8.1.2 + modal_bottom_sheet: ^2.1.2 dev_dependencies: flutter_test: