mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-26 17:04:43 +01:00
Add pull to refresh to people browser
This commit is contained in:
parent
a4018cd3f3
commit
368026fab8
4 changed files with 53 additions and 23 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:copy_with/copy_with.dart';
|
import 'package:copy_with/copy_with.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -95,7 +97,12 @@ class _WrappedPeopleBrowserState extends State<_WrappedPeopleBrowser>
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
CustomScrollView(
|
RefreshIndicator(
|
||||||
|
onRefresh: () async {
|
||||||
|
_bloc.add(const _Reload());
|
||||||
|
await _bloc.stream.first;
|
||||||
|
},
|
||||||
|
child: CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
const _AppBar(),
|
const _AppBar(),
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
|
@ -113,13 +120,15 @@ class _WrappedPeopleBrowserState extends State<_WrappedPeopleBrowser>
|
||||||
context,
|
context,
|
||||||
CollectionBrowser.routeName,
|
CollectionBrowser.routeName,
|
||||||
arguments: CollectionBrowserArguments(
|
arguments: CollectionBrowserArguments(
|
||||||
CollectionBuilder.byPerson(_bloc.account, item.person),
|
CollectionBuilder.byPerson(
|
||||||
|
_bloc.account, item.person),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -88,6 +88,13 @@ extension _$_LoadPersonsToString on _LoadPersons {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension _$_ReloadToString on _Reload {
|
||||||
|
String _$toString() {
|
||||||
|
// ignore: unnecessary_string_interpolations
|
||||||
|
return "_Reload {}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension _$_TransformItemsToString on _TransformItems {
|
extension _$_TransformItemsToString on _TransformItems {
|
||||||
String _$toString() {
|
String _$toString() {
|
||||||
// ignore: unnecessary_string_interpolations
|
// ignore: unnecessary_string_interpolations
|
||||||
|
|
|
@ -7,6 +7,7 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
||||||
required this.personsController,
|
required this.personsController,
|
||||||
}) : super(_State.init()) {
|
}) : super(_State.init()) {
|
||||||
on<_LoadPersons>(_onLoad);
|
on<_LoadPersons>(_onLoad);
|
||||||
|
on<_Reload>(_onReload);
|
||||||
on<_TransformItems>(_onTransformItems);
|
on<_TransformItems>(_onTransformItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +32,11 @@ class _Bloc extends Bloc<_Event, _State> with BlocLogger {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onReload(_Reload ev, Emitter<_State> emit) {
|
||||||
|
_log.info(ev);
|
||||||
|
unawaited(personsController.reload());
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _onTransformItems(
|
Future<void> _onTransformItems(
|
||||||
_TransformItems ev, Emitter<_State> emit) async {
|
_TransformItems ev, Emitter<_State> emit) async {
|
||||||
_log.info("[_onTransformItems] $ev");
|
_log.info("[_onTransformItems] $ev");
|
||||||
|
|
|
@ -37,6 +37,14 @@ class _LoadPersons implements _Event {
|
||||||
String toString() => _$toString();
|
String toString() => _$toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@toString
|
||||||
|
class _Reload implements _Event {
|
||||||
|
const _Reload();
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() => _$toString();
|
||||||
|
}
|
||||||
|
|
||||||
/// Transform the [Person] list (e.g., filtering, sorting, etc)
|
/// Transform the [Person] list (e.g., filtering, sorting, etc)
|
||||||
@toString
|
@toString
|
||||||
class _TransformItems implements _Event {
|
class _TransformItems implements _Event {
|
||||||
|
|
Loading…
Add table
Reference in a new issue