Show loading
This commit is contained in:
parent
401121f1de
commit
68c60a29ba
|
|
@ -275,6 +275,8 @@ Middleware<AppState> _createCompany(AuthRepository repository) {
|
||||||
store.dispatch(SelectCompany(companyIndex: state.companies.length));
|
store.dispatch(SelectCompany(companyIndex: state.companies.length));
|
||||||
store.dispatch(ViewDashboard(
|
store.dispatch(ViewDashboard(
|
||||||
navigator: Navigator.of(action.context), force: true));
|
navigator: Navigator.of(action.context), force: true));
|
||||||
|
|
||||||
|
action.completer.complete();
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,10 @@ class SaveCompanyFailure implements StopSaving {
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddCompany implements StartSaving {
|
class AddCompany implements StartSaving {
|
||||||
AddCompany(this.context);
|
AddCompany({this.context, this.completer});
|
||||||
|
|
||||||
final BuildContext context;
|
final BuildContext context;
|
||||||
|
final Completer completer;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AddCompanySuccess implements StopSaving {}
|
class AddCompanySuccess implements StopSaving {}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
|
|
@ -7,6 +8,8 @@ import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
import 'package:invoiceninja_flutter/redux/company/company_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/app_builder.dart';
|
import 'package:invoiceninja_flutter/ui/app/app_builder.dart';
|
||||||
|
import 'package:invoiceninja_flutter/ui/app/dialogs/loading_dialog.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/completers.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/dialogs.dart';
|
import 'package:invoiceninja_flutter/utils/dialogs.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
import 'package:redux/redux.dart';
|
import 'package:redux/redux.dart';
|
||||||
|
|
@ -97,8 +100,20 @@ class MenuDrawerVM {
|
||||||
confirmCallback(
|
confirmCallback(
|
||||||
context: context,
|
context: context,
|
||||||
message: AppLocalization.of(context).addCompany,
|
message: AppLocalization.of(context).addCompany,
|
||||||
callback: () {
|
callback: () async {
|
||||||
store.dispatch(AddCompany(context));
|
final completer = snackBarCompleter<Null>(
|
||||||
|
context, AppLocalization.of(context).addedCompany,
|
||||||
|
shouldPop: true);
|
||||||
|
|
||||||
|
store
|
||||||
|
.dispatch(AddCompany(context: context, completer: completer));
|
||||||
|
|
||||||
|
await showDialog<AlertDialog>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) => SimpleDialog(
|
||||||
|
children: <Widget>[LoadingDialog()],
|
||||||
|
));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ Completer<T> snackBarCompleter<T>(BuildContext context, String message,
|
||||||
}
|
}
|
||||||
|
|
||||||
completer.future.then((_) {
|
completer.future.then((_) {
|
||||||
if (shouldPop) {
|
if (shouldPop && Navigator.of(context).canPop()) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
if (scaffold != null) {
|
if (scaffold != null) {
|
||||||
|
|
@ -47,7 +47,7 @@ Completer<T> snackBarCompleter<T>(BuildContext context, String message,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}).catchError((Object error) {
|
}).catchError((Object error) {
|
||||||
if (shouldPop) {
|
if (shouldPop && Navigator.of(context).canPop()) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
showDialog<ErrorDialog>(
|
showDialog<ErrorDialog>(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue