From 5c76e1c2fabe59ab90cf8139fa73386b662209de Mon Sep 17 00:00:00 2001 From: misakajimmy Date: Sat, 14 Jan 2023 20:02:08 +0800 Subject: [PATCH] DEV UPDATE:Add member filter --- lib/routes/video/videoList.dart | 13 +++++++++---- lib/routes/video/videoPage.dart | 5 ++--- pubspec.lock | 7 +++++++ pubspec.yaml | 1 + 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/routes/video/videoList.dart b/lib/routes/video/videoList.dart index cc01188..4152e4c 100644 --- a/lib/routes/video/videoList.dart +++ b/lib/routes/video/videoList.dart @@ -1,3 +1,4 @@ +import 'dart:math'; import 'package:eoe_fans/common/Api.dart'; import 'package:eoe_fans/models/member.dart'; import 'package:eoe_fans/models/video.dart'; @@ -8,6 +9,7 @@ import 'package:eoe_fans/routes/video/videoMemberFilter.dart'; import 'package:eoe_fans/common/Global.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:flutter/material.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; class VideoList extends StatefulWidget { const VideoList({Key? key, this.origin}) : super(key: key); @@ -19,6 +21,8 @@ class VideoList extends StatefulWidget { } class _VideoListState extends State { + final RefreshController _refreshController = + RefreshController(initialRefresh: true); late final bool? origin; int _page = -1; @@ -29,7 +33,7 @@ class _VideoListState extends State { @override void initState() { - print('object'); + // print('object'); _getVideos(); super.initState(); } @@ -56,16 +60,17 @@ class _VideoListState extends State { }); } - _reloadVideos() async { + _reloadVideos({int? page}) async { setState(() { videoList = []; - _page = -1; - _getVideos(); + _page = page ?? -1; }); + await _getVideos(); } @override Widget build(BuildContext context) { + var videos = videoList .map((video) => StaggeredGridTile.count( crossAxisCellCount: 2, diff --git a/lib/routes/video/videoPage.dart b/lib/routes/video/videoPage.dart index d0f8975..2d191cf 100644 --- a/lib/routes/video/videoPage.dart +++ b/lib/routes/video/videoPage.dart @@ -63,9 +63,8 @@ class _VideoPageState extends State { ), ), body: Container( - padding: const EdgeInsets.only( - left: 4, right: 4, top: 4), - child: const TabBarView( + padding: const EdgeInsets.only(left: 4, right: 4, top: 4), + child: const TabBarView( children: [ VideoList(origin: false), VideoList(origin: true), diff --git a/pubspec.lock b/pubspec.lock index e47e38f..9a67a1e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -520,6 +520,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" + pull_to_refresh: + dependency: "direct main" + description: + name: pull_to_refresh + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" rxdart: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index f6f0456..ee5fa0b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,6 +44,7 @@ dependencies: flutter_staggered_grid_view: ^0.6.2 cached_network_image: ^3.2.3 hexcolor: ^3.0.1 + pull_to_refresh: ^2.0.0 dev_dependencies: flutter_test: