Skip to content

Commit

Permalink
DEV UPDATE:Upgrade tablet support
Browse files Browse the repository at this point in the history
  • Loading branch information
misakajimmy committed Feb 21, 2023
1 parent 1039ae6 commit 047b83a
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 170 deletions.
Binary file modified assets/banner2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion lib/routes/mainPage.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -40,7 +42,9 @@ class _MainPageState extends State<MainPage> {

@override
void initState() {
AppUpgrade.appUpgrade(context, _checkAppInfo());
if (Platform.isAndroid) {
AppUpgrade.appUpgrade(context, _checkAppInfo(), iosAppId: "1672724508");
}
super.initState();
}

Expand Down
29 changes: 4 additions & 25 deletions lib/routes/picture/pictureList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class _PictureListState extends State<PictureList> {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
return SmartRefresher(
enablePullDown: true,
enablePullUp: true,
Expand Down Expand Up @@ -156,9 +157,9 @@ class _PictureListState extends State<PictureList> {
]),
),
SliverMasonryGrid.count(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: (screenWidth / 200).truncate(),
crossAxisSpacing: 4,
mainAxisSpacing: 4,
childCount: dynamicList.length,
itemBuilder: (context, index) {
return Container(
Expand All @@ -177,28 +178,6 @@ class _PictureListState extends State<PictureList> {
);
},
),
// 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(),
// ),
// ),
// );
// },
// ),
],
));
}
Expand Down
277 changes: 149 additions & 128 deletions lib/routes/video/videoList.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -59,7 +60,7 @@ class _VideoListState extends State<VideoList> {
: VideosCopyright.Reproduced);
if (videos.result.length != 0) {
setState(() {
videoList = [...videoList, ...videos.result];
videoList.addAll(videos.result);
_loading = false;
});
} else {
Expand All @@ -70,147 +71,167 @@ class _VideoListState extends State<VideoList> {
}

_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<ScrollNotification>(
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
Expand Down
Loading

0 comments on commit 047b83a

Please sign in to comment.