Add text to indicate syncing state

This commit is contained in:
Vishnu Mohandas 2020-06-06 19:18:29 +05:30
parent bda277693b
commit ecb5c2f437
3 changed files with 35 additions and 5 deletions

View file

@ -4,9 +4,11 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:photos/models/photo.dart';
import 'package:photos/photo_sync_manager.dart';
import 'package:photos/ui/detail_page.dart';
import 'package:photos/ui/thumbnail_widget.dart';
import 'package:photos/utils/date_time_util.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class Gallery extends StatefulWidget {
final List<Photo> photos;
@ -27,6 +29,8 @@ class _GalleryState extends State<Gallery> {
final List<List<Photo>> _collatedPhotos = List<List<Photo>>();
Set<Photo> _selectedPhotos = HashSet<Photo>();
List<Photo> _photos;
RefreshController _refreshController =
RefreshController(initialRefresh: false);
@override
Widget build(BuildContext context) {
@ -36,11 +40,29 @@ class _GalleryState extends State<Gallery> {
_deduplicatePhotos();
_collatePhotos();
return ListView.builder(
itemCount: _collatedPhotos.length,
itemBuilder: _buildListItem,
controller: _scrollController,
cacheExtent: 1000,
return SmartRefresher(
controller: _refreshController,
enablePullUp: true,
child: ListView.builder(
itemCount: _collatedPhotos.length,
itemBuilder: _buildListItem,
controller: _scrollController,
cacheExtent: 1000,
),
header: ClassicHeader(
idleText: "Pull down to sync.",
refreshingText: "Syncing...",
releaseText: "Release to sync.",
completeText: "Sync completed.",
failedText: "Sync unsuccessful.",
),
onRefresh: () async {
PhotoSyncManager.instance.sync().then((value) {
_refreshController.refreshCompleted();
}).catchError((e) {
_refreshController.refreshFailed();
});
},
);
}

View file

@ -331,6 +331,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
pull_to_refresh:
dependency: "direct main"
description:
name: pull_to_refresh
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.8"
quiver:
dependency: transitive
description:

View file

@ -48,6 +48,7 @@ dependencies:
logging: ^0.11.4
flutter_image_compress: ^0.6.5+1
flutter_typeahead: ^1.8.1
pull_to_refresh: ^1.5.7
dev_dependencies:
flutter_test: