diff --git a/assets/banner2.png b/assets/banner2.png index 0411841..ccfd5e5 100644 Binary files a/assets/banner2.png and b/assets/banner2.png differ diff --git a/lib/routes/mainPage.dart b/lib/routes/mainPage.dart index ec65061..524babb 100644 --- a/lib/routes/mainPage.dart +++ b/lib/routes/mainPage.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:eoeFans/common/Api.dart'; import 'package:eoeFans/common/CompareVersion.dart'; import 'package:eoeFans/common/Global.dart'; @@ -40,7 +42,9 @@ class _MainPageState extends State { @override void initState() { - AppUpgrade.appUpgrade(context, _checkAppInfo()); + if (Platform.isAndroid) { + AppUpgrade.appUpgrade(context, _checkAppInfo(), iosAppId: "1672724508"); + } super.initState(); } diff --git a/lib/routes/picture/pictureList.dart b/lib/routes/picture/pictureList.dart index 0ed2e97..ec48bdd 100644 --- a/lib/routes/picture/pictureList.dart +++ b/lib/routes/picture/pictureList.dart @@ -115,6 +115,7 @@ class _PictureListState extends State { @override Widget build(BuildContext context) { + final screenWidth = MediaQuery.of(context).size.width; return SmartRefresher( enablePullDown: true, enablePullUp: true, @@ -156,9 +157,9 @@ class _PictureListState extends State { ]), ), SliverMasonryGrid.count( - crossAxisCount: 2, - crossAxisSpacing: 10, - mainAxisSpacing: 10, + crossAxisCount: (screenWidth / 200).truncate(), + crossAxisSpacing: 4, + mainAxisSpacing: 4, childCount: dynamicList.length, itemBuilder: (context, index) { return Container( @@ -177,28 +178,6 @@ class _PictureListState extends State { ); }, ), - // MasonryGridView.count( - // crossAxisCount: 2, - // mainAxisSpacing: 2, - // crossAxisSpacing: 4, - // itemCount: dynamicList.length, - // itemBuilder: (context, index) { - // return Container( - // height: 240, - // width: double.infinity, - // child: Card( - // clipBehavior: Clip.antiAliasWithSaveLayer, - // child: PictureSwiper( - // dynamicId: dynamicList[index].dynamic_id.toString(), - // images: dynamicList[index] - // .pictures - // .map((e) => e.img_src) - // .toList(), - // ), - // ), - // ); - // }, - // ), ], )); } diff --git a/lib/routes/video/videoList.dart b/lib/routes/video/videoList.dart index c5c355f..642103b 100644 --- a/lib/routes/video/videoList.dart +++ b/lib/routes/video/videoList.dart @@ -8,6 +8,7 @@ import 'package:eoeFans/routes/video/videoMemberFilter.dart'; import 'package:eoeFans/common/Global.dart'; import 'package:eoeFans/routes/video/videoSwiper.dart'; import 'package:eoeFans/states/ProfileChangeNotifier.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -59,7 +60,7 @@ class _VideoListState extends State { : VideosCopyright.Reproduced); if (videos.result.length != 0) { setState(() { - videoList = [...videoList, ...videos.result]; + videoList.addAll(videos.result); _loading = false; }); } else { @@ -70,147 +71,167 @@ class _VideoListState extends State { } _reloadVideos({int? page}) async { + videoList = []; setState(() { - videoList = []; _page = page ?? 0; }); await _getVideos(); } + void _onRefresh() async { + // monitor network fetch + await _reloadVideos(); + // if failed,use refreshFailed() + setState(() { + _refreshController.refreshCompleted(); + }); + } + + void _onLoading() async { + await _getVideos(); + setState(() { + _refreshController.loadComplete(); + }); + } + @override Widget build(BuildContext context) { - var videos = videoList - .map((video) => StaggeredGridTile.count( - crossAxisCellCount: 2, - mainAxisCellCount: 2, - child: VideoListItem( - video: video, - ), - )) - .toList(); - - videos.insert( - 0, - StaggeredGridTile.count( - crossAxisCellCount: 4, - mainAxisCellCount: 0.5, - child: Container( - margin: const EdgeInsets.only(left: 4), - child: DefaultTextStyle( - style: const TextStyle( - fontSize: 18, - fontWeight: FontWeight.w500, - color: Colors.black, - ), - child: Row( - children: [ - GestureDetector( - onTap: () { - if (_order != VideosRequestOrder.pubdate) { - setState(() { - _order = VideosRequestOrder.pubdate; - _reloadVideos(); - }); - } - }, - child: Text( - '最新发布', - style: TextStyle( - color: _order != VideosRequestOrder.pubdate - ? Colors.black54 - : Colors.black, + final screenWidth = MediaQuery.of(context).size.width; + return Stack( + alignment: Alignment.topCenter, + children: [ + SmartRefresher( + enablePullDown: true, + enablePullUp: true, + header: WaterDropHeader(), + footer: + CustomFooter(builder: (BuildContext context, LoadStatus? mode) { + Widget body; + if (mode == LoadStatus.idle) { + body = Text("上拉加载"); + } else if (mode == LoadStatus.loading) { + body = CupertinoActivityIndicator(); + } else if (mode == LoadStatus.failed) { + body = Text("加载失败!点击重试!"); + } else if (mode == LoadStatus.canLoading) { + body = Text("松手,加载更多!"); + } else { + body = Text("没有更多数据了!"); + } + return Container( + child: Center(child: body), + ); + }), + controller: _refreshController, + onRefresh: _onRefresh, + onLoading: _onLoading, + child: CustomScrollView( + slivers: [ + SliverList( + delegate: SliverChildListDelegate( + [ + Container( + width: double.infinity, + child: AspectRatio( + aspectRatio: 16 / 9, + child: Card( + clipBehavior: Clip.antiAliasWithSaveLayer, + child: VideoSwiper(), + ), ), ), - ), - Container( - margin: const EdgeInsets.only(left: 8), - child: GestureDetector( - onTap: () { - if (_order != VideosRequestOrder.view) { - setState(() { - _order = VideosRequestOrder.view; - _reloadVideos(); - }); - } - }, - child: Text( - '最多播放', - style: TextStyle( - color: _order != VideosRequestOrder.view - ? Colors.black54 - : Colors.black, + Container( + width: double.infinity, + child: AspectRatio( + aspectRatio: 4.9 / 1, + child: VideoMemberFilter( + updateFilterMember: (MemberEnum? value) { + setState(() { + _memberFilter = value; + _reloadVideos(); + }); + }, ), ), ), - ), - ], - )), - ), - ), - ); - - videos.insert( - 0, - StaggeredGridTile.count( - crossAxisCellCount: 4, - mainAxisCellCount: 0.8, - child: VideoMemberFilter( - updateFilterMember: (MemberEnum? value) { - setState(() { - _memberFilter = value; - _reloadVideos(); - }); - }, - ), - ), - ); - videos.insert( - 0, - const StaggeredGridTile.count( - crossAxisCellCount: 4, - mainAxisCellCount: 9 / 4, - child: Card( - clipBehavior: Clip.antiAliasWithSaveLayer, - child: VideoSwiper(), - ), - ), - ); - return Stack( - alignment: Alignment.topCenter, - children: [ - Scrollbar( - child: NotificationListener( - onNotification: (ScrollNotification notification) { - // double progress = notification.metrics.pixels / - // notification.metrics.maxScrollExtent; - // print("${(progress * 100).toInt()}%"); - // print(notification.metrics.maxScrollExtent - notification.metrics.pixels); - //重新构建 - setState(() { - if (notification.metrics.maxScrollExtent - - notification.metrics.pixels < - 1200 && - notification.metrics.maxScrollExtent - - notification.metrics.pixels > - 0 && - !_loading) { - // print(notification.metrics.maxScrollExtent - - // notification.metrics.pixels); - _getVideos(); - } - }); - // print("BottomEdge: ${notification.metrics.extentAfter == 0}"); - return false; - //return true; //放开此行注释后,进度条将失效 - }, - child: SingleChildScrollView( - child: StaggeredGrid.count( - crossAxisCount: 4, - mainAxisSpacing: 0, - crossAxisSpacing: 0, - children: videos, + Container( + width: double.infinity, + height: 32, + child: Container( + margin: const EdgeInsets.only(left: 4), + child: DefaultTextStyle( + style: const TextStyle( + fontSize: 18, + fontWeight: FontWeight.w500, + color: Colors.black, + ), + child: Row( + children: [ + GestureDetector( + onTap: () { + if (_order != VideosRequestOrder.pubdate) { + setState(() { + _order = VideosRequestOrder.pubdate; + _reloadVideos(); + }); + } + }, + child: Text( + '最新发布', + style: TextStyle( + color: _order != VideosRequestOrder.pubdate + ? Colors.black54 + : Colors.black, + ), + ), + ), + Container( + margin: const EdgeInsets.only(left: 8), + child: GestureDetector( + onTap: () { + if (_order != VideosRequestOrder.view) { + setState(() { + _order = VideosRequestOrder.view; + _reloadVideos(); + }); + } + }, + child: Text( + '最多播放', + style: TextStyle( + color: _order != VideosRequestOrder.view + ? Colors.black54 + : Colors.black, + ), + ), + ), + ), + ], + )), + ) + ), + ], + ), + ), + SliverMasonryGrid.count( + crossAxisCount: (screenWidth / 200).truncate(), + crossAxisSpacing: 2, + mainAxisSpacing: 2, + childCount: videoList.length, + itemBuilder: (context, index) { + return Container( + height: 200, + width: double.infinity, + child: Card( + clipBehavior: Clip.antiAliasWithSaveLayer, + child: VideoListItem( + video: videoList[index], + ), + ), + ); + }, ), - ), + ], ), ), _loading diff --git a/lib/routes/video/videoListItem.dart b/lib/routes/video/videoListItem.dart index 6428985..fe72295 100644 --- a/lib/routes/video/videoListItem.dart +++ b/lib/routes/video/videoListItem.dart @@ -12,13 +12,17 @@ class VideoListItem extends StatelessWidget { Widget build(BuildContext context) { return GestureDetector( onTap: () async { - var _url = 'bilibili://video/' + video.bvid; - if (!await launchUrl(Uri.parse(_url))) { - throw 'Could not launch $_url'; + try { + var _url = 'bilibili://video/' + video.bvid; + if (!await launchUrl(Uri.parse(_url))) { + throw 'Could not launch $_url'; + } + } catch (e) { + print(e); } }, - child: Card( - clipBehavior: Clip.antiAliasWithSaveLayer, + child: Container( + // clipBehavior: Clip.antiAliasWithSaveLayer, child: Container( child: Flex( direction: Axis.vertical, @@ -45,13 +49,12 @@ class VideoListItem extends StatelessWidget { child: Container( padding: const EdgeInsets.all(4.0), decoration: new BoxDecoration( - color: Color.fromRGBO(0, 0, 0, .3), - gradient: LinearGradient( - colors: [Colors.transparent, Colors.black], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ) - ), + color: Color.fromRGBO(0, 0, 0, .3), + gradient: LinearGradient( + colors: [Colors.transparent, Colors.black], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + )), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/routes/video/videoSwiper.dart b/lib/routes/video/videoSwiper.dart index 659909d..7823c43 100644 --- a/lib/routes/video/videoSwiper.dart +++ b/lib/routes/video/videoSwiper.dart @@ -9,8 +9,8 @@ const images = [ ]; const urls = [ - 'https://b23.tv/KjrFIG1', - 'bilibili://video/BV1Pv4y1C7TE', + 'bilibili://following/detail/764574685075603457', + '', 'https://b23.tv/kI0MBkx' ]; @@ -30,8 +30,12 @@ class VideoSwiper extends StatelessWidget { }, itemCount: images.length, onTap: (int index) async { - if (!await launchUrl(Uri.parse(urls[index]))) { - throw 'Could not launch ${urls[index]}'; + try { + if (!await launchUrl(Uri.parse(urls[index]))) { + throw 'Could not launch ${urls[index]}'; + } + } catch(e) { + print(e); } }, pagination: const SwiperPagination(