Fix pull to refresh

This commit is contained in:
Hillel Coren 2020-06-03 21:26:15 +03:00
parent fd0057a33c
commit b65cb1590c
4 changed files with 70 additions and 63 deletions

View File

@ -69,40 +69,42 @@ class _ClientViewState extends State<ClientView>
), ),
], ],
), ),
body: Column( body: Builder(builder: (context) {
children: <Widget>[ return Column(
Expanded( children: <Widget>[
child: TabBarView( Expanded(
controller: _controller, child: TabBarView(
children: <Widget>[ controller: _controller,
RefreshIndicator( children: <Widget>[
onRefresh: () => viewModel.onRefreshed(context), RefreshIndicator(
child: ClientOverview( onRefresh: () => viewModel.onRefreshed(context),
viewModel: viewModel, child: ClientOverview(
isFilter: widget.isFilter, viewModel: viewModel,
isFilter: widget.isFilter,
),
), ),
), RefreshIndicator(
RefreshIndicator( onRefresh: () => viewModel.onRefreshed(context),
onRefresh: () => viewModel.onRefreshed(context), child: ClientViewDetails(client: viewModel.client),
child: ClientViewDetails(client: viewModel.client),
),
RefreshIndicator(
onRefresh: () => viewModel.onRefreshed(context),
child: ClientViewActivity(
viewModel: viewModel,
key: ValueKey(viewModel.client.id),
), ),
), RefreshIndicator(
], onRefresh: () => viewModel.onRefreshed(context),
child: ClientViewActivity(
viewModel: viewModel,
key: ValueKey(viewModel.client.id),
),
),
],
),
), ),
), BottomButtons(
BottomButtons( entity: client,
entity: client, action1: EntityAction.settings,
action1: EntityAction.settings, action2: EntityAction.newInvoice,
action2: EntityAction.newInvoice, ),
), ],
], );
), }),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
heroTag: 'client_view_fab', heroTag: 'client_view_fab',
backgroundColor: Theme.of(context).primaryColorDark, backgroundColor: Theme.of(context).primaryColorDark,

View File

@ -68,24 +68,26 @@ class _ExpenseViewState extends State<ExpenseView>
), ),
], ],
), ),
body: TabBarView( body: Builder(builder: (context) {
controller: _controller, return TabBarView(
children: <Widget>[ controller: _controller,
RefreshIndicator( children: <Widget>[
onRefresh: () => viewModel.onRefreshed(context), RefreshIndicator(
child: ExpenseOverview(viewModel: viewModel), onRefresh: () => viewModel.onRefreshed(context),
), child: ExpenseOverview(viewModel: viewModel),
RefreshIndicator( ),
onRefresh: () => viewModel.onRefreshed(context), RefreshIndicator(
child: ExpenseViewDetails(expense: viewModel.expense), onRefresh: () => viewModel.onRefreshed(context),
), child: ExpenseViewDetails(expense: viewModel.expense),
RefreshIndicator( ),
onRefresh: () => viewModel.onRefreshed(context), RefreshIndicator(
child: ExpenseViewDocuments( onRefresh: () => viewModel.onRefreshed(context),
viewModel: viewModel, expense: viewModel.expense), child: ExpenseViewDocuments(
), viewModel: viewModel, expense: viewModel.expense),
], ),
), ],
);
}),
floatingActionButton: company.isEnterprisePlan floatingActionButton: company.isEnterprisePlan
? Builder(builder: (BuildContext context) { ? Builder(builder: (BuildContext context) {
return FloatingActionButton( return FloatingActionButton(

View File

@ -56,19 +56,21 @@ class _VendorViewState extends State<VendorView>
), ),
], ],
), ),
body: TabBarView( body: Builder(builder: (context) {
controller: _controller, return TabBarView(
children: <Widget>[ controller: _controller,
RefreshIndicator( children: <Widget>[
onRefresh: () => viewModel.onRefreshed(context), RefreshIndicator(
child: VendorOverview(viewModel: viewModel), onRefresh: () => viewModel.onRefreshed(context),
), child: VendorOverview(viewModel: viewModel),
RefreshIndicator( ),
onRefresh: () => viewModel.onRefreshed(context), RefreshIndicator(
child: VendorViewDetails(vendor: viewModel.vendor), onRefresh: () => viewModel.onRefreshed(context),
), child: VendorViewDetails(vendor: viewModel.vendor),
], ),
), ],
);
}),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
heroTag: 'vendor_view_fab', heroTag: 'vendor_view_fab',
backgroundColor: Theme.of(context).primaryColorDark, backgroundColor: Theme.of(context).primaryColorDark,

View File

@ -29,12 +29,13 @@ Completer<Null> refreshCompleter(BuildContext context) {
Completer<T> snackBarCompleter<T>(BuildContext context, String message, Completer<T> snackBarCompleter<T>(BuildContext context, String message,
{bool shouldPop = false}) { {bool shouldPop = false}) {
final Completer<T> completer = Completer<T>(); final Completer<T> completer = Completer<T>();
final scaffold = Scaffold.of(context);
completer.future.then((_) { completer.future.then((_) {
if (shouldPop) { if (shouldPop) {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
Scaffold.of(context).showSnackBar(SnackBar( scaffold.showSnackBar(SnackBar(
content: SnackBarRow( content: SnackBarRow(
message: message, message: message,
))); )));