diff --git a/lib/src/contact/contact_list.dart b/lib/src/contact/contact_list.dart index c2749df8..e398e55f 100644 --- a/lib/src/contact/contact_list.dart +++ b/lib/src/contact/contact_list.dart @@ -56,6 +56,7 @@ import 'package:ox_coi/src/ui/color.dart'; import 'package:ox_coi/src/ui/dimensions.dart'; import 'package:ox_coi/src/utils/dialog_builder.dart'; import 'package:ox_coi/src/utils/toast.dart'; +import 'package:ox_coi/src/widgets/fullscreen_progress.dart'; import 'package:ox_coi/src/widgets/search.dart'; import 'package:ox_coi/src/widgets/state_info.dart'; import 'package:rxdart/rxdart.dart'; @@ -111,6 +112,7 @@ class _ContactListState extends State { ContactListBloc _contactListBloc = ContactListBloc(); ContactImportBloc _contactImportBloc = ContactImportBloc(); Navigation navigation = Navigation(); + OverlayEntry _progressOverlayEntry; @override void initState() { @@ -130,6 +132,10 @@ class _ContactListState extends State { } handleContactImport(ContactImportState state) { + if (_progressOverlayEntry != null) { + _progressOverlayEntry.remove(); + _progressOverlayEntry = null; + } if (state is ContactsImportSuccess) { String contactImportSuccess = AppLocalizations.of(context).contactImportSuccess(state.changedCount); showToast(contactImportSuccess); @@ -218,6 +224,15 @@ class _ContactListState extends State { content: content, positiveButton: importPositive, positiveAction: () { + _progressOverlayEntry = OverlayEntry( + builder: (context) => FullscreenProgress( + bloc: _contactListBloc, + text: AppLocalizations.of(context).contactImportProgress, + showProgressValues: false, + showCancelButton: false, + ), + ); + Overlay.of(context).insert(_progressOverlayEntry); _contactImportBloc.dispatch(PerformImport()); }, navigatable: Navigatable(Type.contactImportDialog), diff --git a/lib/src/l10n/localizations.dart b/lib/src/l10n/localizations.dart index e066d39d..4daa10fe 100644 --- a/lib/src/l10n/localizations.dart +++ b/lib/src/l10n/localizations.dart @@ -478,6 +478,8 @@ class AppLocalizations { String get contactImportDialogContentExtensionRepeat => Intl.message('Re-importing your contacts will not create duplicates.', name: 'contactImportDialogContent'); + String get contactImportProgress => Intl.message('Contact import running, please wait', name: 'contactImportProgress'); + String contactImportSuccess(count) => Intl.message('$count system contacts imported', name: 'contactImportSuccess', args: [count]); String get contactImportFailure => Intl.message('Import failed, missing permissions', name: 'contactImportFailure'); diff --git a/lib/src/login/login_manual_settings.dart b/lib/src/login/login_manual_settings.dart index d5c2b0bf..fb412f4a 100644 --- a/lib/src/login/login_manual_settings.dart +++ b/lib/src/login/login_manual_settings.dart @@ -49,7 +49,7 @@ import 'package:ox_coi/src/ui/color.dart'; import 'package:ox_coi/src/ui/dimensions.dart'; import 'package:ox_coi/src/utils/core.dart'; import 'package:ox_coi/src/utils/dialog_builder.dart'; -import 'package:ox_coi/src/widgets/progress_handler.dart'; +import 'package:ox_coi/src/widgets/fullscreen_progress.dart'; import 'package:rxdart/rxdart.dart'; import 'login_bloc.dart'; @@ -69,7 +69,6 @@ class LoginManualSettings extends StatefulWidget { class _LoginManualSettingsState extends State with ManualSettings { OverlayEntry _progressOverlayEntry; - FullscreenProgress _progress; LoginBloc _loginBloc = LoginBloc(); @override @@ -150,15 +149,15 @@ class _LoginManualSettingsState extends State with ManualSe bool loginIsValid = formKey.currentState.validate(); if (loginIsValid) { - _progress = FullscreenProgress( - bloc: _loginBloc, - text: AppLocalizations.of(context).loginProgressMessage, - showProgressValues: true, - showCancelButton: false, + _progressOverlayEntry = OverlayEntry( + builder: (context) => FullscreenProgress( + bloc: _loginBloc, + text: AppLocalizations.of(context).loginProgressMessage, + showProgressValues: true, + showCancelButton: false, + ), ); - _progressOverlayEntry = OverlayEntry(builder: (context) => _progress); - OverlayState overlayState = Overlay.of(context); - overlayState.insert(_progressOverlayEntry); + Overlay.of(context).insert(_progressOverlayEntry); _loginBloc.dispatch(LoginButtonPressed( email: email, password: password, diff --git a/lib/src/login/login_provider_signin.dart b/lib/src/login/login_provider_signin.dart index 7b9f10ce..db0f225b 100644 --- a/lib/src/login/login_provider_signin.dart +++ b/lib/src/login/login_provider_signin.dart @@ -48,7 +48,7 @@ import 'package:ox_coi/src/navigation/navigation.dart'; import 'package:ox_coi/src/ui/color.dart'; import 'package:ox_coi/src/ui/dimensions.dart'; import 'package:ox_coi/src/utils/dialog_builder.dart'; -import 'package:ox_coi/src/widgets/progress_handler.dart'; +import 'package:ox_coi/src/widgets/fullscreen_progress.dart'; import 'package:ox_coi/src/widgets/validatable_text_form_field.dart'; import 'package:rxdart/rxdart.dart'; @@ -69,7 +69,6 @@ class ProviderSignIn extends StatefulWidget { class _ProviderSignInState extends State { final _simpleLoginKey = GlobalKey(); OverlayEntry _progressOverlayEntry; - FullscreenProgress _progress; LoginBloc _loginBloc = LoginBloc(); OverlayEntry _overlayEntry; var _navigation = Navigation(); @@ -246,15 +245,15 @@ class _ProviderSignInState extends State { var password = passwordField.controller.text; if (simpleLoginIsValid) { - _progress = FullscreenProgress( - bloc: _loginBloc, - text: AppLocalizations.of(context).loginProgressMessage, - showProgressValues: true, - showCancelButton: false, + _progressOverlayEntry = OverlayEntry( + builder: (context) => FullscreenProgress( + bloc: _loginBloc, + text: AppLocalizations.of(context).loginProgressMessage, + showProgressValues: true, + showCancelButton: false, + ), ); - _progressOverlayEntry = OverlayEntry(builder: (context) => _progress); - OverlayState overlayState = Overlay.of(context); - overlayState.insert(_progressOverlayEntry); + Overlay.of(context).insert(_progressOverlayEntry); _loginBloc.dispatch(ProviderLoginButtonPressed(email: email, password: password, provider: widget.provider)); } } diff --git a/lib/src/qr/scan_qr.dart b/lib/src/qr/scan_qr.dart index c4bdc33d..1d995470 100644 --- a/lib/src/qr/scan_qr.dart +++ b/lib/src/qr/scan_qr.dart @@ -48,7 +48,7 @@ import 'package:ox_coi/src/navigation/navigation.dart'; import 'package:ox_coi/src/qr/qr_bloc.dart'; import 'package:ox_coi/src/qr/qr_event_state.dart'; import 'package:ox_coi/src/utils/toast.dart'; -import 'package:ox_coi/src/widgets/progress_handler.dart'; +import 'package:ox_coi/src/widgets/fullscreen_progress.dart'; import 'package:qr_mobile_vision/qr_camera.dart'; import 'package:rxdart/rxdart.dart'; @@ -59,7 +59,6 @@ class ScanQr extends StatefulWidget { class _ScanQrState extends State { QrBloc _qrBloc = QrBloc(); - FullscreenProgress _progress; OverlayEntry _progressOverlayEntry; bool _qrCodeDetected = false; Navigation _navigation = Navigation(); @@ -114,16 +113,16 @@ class _ScanQrState extends State { } void checkAndJoinQr(String qrString) { - _progress = FullscreenProgress( - bloc: _qrBloc, - text: AppLocalizations.of(context).qrProgressInfoText, - showProgressValues: false, - showCancelButton: true, - cancelPressed: _cancelPressed, + _progressOverlayEntry = OverlayEntry( + builder: (context) => FullscreenProgress( + bloc: _qrBloc, + text: AppLocalizations.of(context).qrProgressInfoText, + showProgressValues: false, + showCancelButton: true, + cancelPressed: _cancelPressed, + ), ); - _progressOverlayEntry = OverlayEntry(builder: (context) => _progress); - OverlayState overlayState = Overlay.of(context); - overlayState.insert(_progressOverlayEntry); + Overlay.of(context).insert(_progressOverlayEntry); _qrBloc.dispatch(CheckQr(qrText: qrString)); } diff --git a/lib/src/settings/settings_security.dart b/lib/src/settings/settings_security.dart index b5ab15fc..32780f16 100644 --- a/lib/src/settings/settings_security.dart +++ b/lib/src/settings/settings_security.dart @@ -52,7 +52,7 @@ import 'package:ox_coi/src/utils/clipboard.dart'; import 'package:ox_coi/src/utils/dialog_builder.dart'; import 'package:ox_coi/src/utils/text.dart'; import 'package:ox_coi/src/utils/toast.dart'; -import 'package:ox_coi/src/widgets/progress_handler.dart'; +import 'package:ox_coi/src/widgets/fullscreen_progress.dart'; import 'package:rxdart/rxdart.dart'; class SettingsSecurity extends StatefulWidget { @@ -63,7 +63,6 @@ class SettingsSecurity extends StatefulWidget { class _SettingsSecurityState extends State { final Navigation navigation = Navigation(); OverlayEntry _progressOverlayEntry; - FullscreenProgress _progress; SettingsSecurityBloc _settingsSecurityBloc = SettingsSecurityBloc(); bool _enableBack = true; @@ -92,15 +91,15 @@ class _SettingsSecurityState extends State { } else if (state.type == SettingsSecurityType.initiateKeyTransfer) { text = AppLocalizations.of(context).securitySettingsInitiateKeyTransferPerforming; } - _progress = FullscreenProgress( - bloc: _settingsSecurityBloc, - text: text, - showProgressValues: false, - showCancelButton: false, + _progressOverlayEntry = OverlayEntry( + builder: (context) => FullscreenProgress( + bloc: _settingsSecurityBloc, + text: text, + showProgressValues: false, + showCancelButton: false, + ), ); - _progressOverlayEntry = OverlayEntry(builder: (context) => _progress); - OverlayState overlayState = Overlay.of(context); - overlayState.insert(_progressOverlayEntry); + Overlay.of(context).insert(_progressOverlayEntry); } else if (state is SettingsSecurityStateSuccess || state is SettingsSecurityStateFailure) { _enableBack = true; if (_progressOverlayEntry != null) { diff --git a/lib/src/user/user_account_settings.dart b/lib/src/user/user_account_settings.dart index 1ce959c9..215635a4 100644 --- a/lib/src/user/user_account_settings.dart +++ b/lib/src/user/user_account_settings.dart @@ -56,7 +56,7 @@ import 'package:ox_coi/src/user/user_change_event_state.dart'; import 'package:ox_coi/src/utils/core.dart'; import 'package:ox_coi/src/utils/dialog_builder.dart'; import 'package:ox_coi/src/utils/toast.dart'; -import 'package:ox_coi/src/widgets/progress_handler.dart'; +import 'package:ox_coi/src/widgets/fullscreen_progress.dart'; import 'package:rxdart/rxdart.dart'; class UserAccountSettings extends StatefulWidget { @@ -69,7 +69,6 @@ class _UserAccountSettingsState extends State with ManualSe LoginBloc _loginBloc = LoginBloc(); Navigation navigation = Navigation(); OverlayEntry _progressOverlayEntry; - FullscreenProgress _progress; bool _showedErrorDialog = false; bool _firstBuild = true; @@ -88,15 +87,15 @@ class _UserAccountSettingsState extends State with ManualSe _handleUserChangeStateChange(UserChangeState state) { if (state is UserChangeStateApplied) { - _progress = FullscreenProgress( - bloc: _loginBloc, - text: AppLocalizations.of(context).accountSettingsDataProgressMessage, - showProgressValues: true, - showCancelButton: false, + _progressOverlayEntry = OverlayEntry( + builder: (context) => FullscreenProgress( + bloc: _loginBloc, + text: AppLocalizations.of(context).accountSettingsDataProgressMessage, + showProgressValues: true, + showCancelButton: false, + ), ); - _progressOverlayEntry = OverlayEntry(builder: (context) => _progress); - OverlayState overlayState = Overlay.of(context); - overlayState.insert(_progressOverlayEntry); + Overlay.of(context).insert(_progressOverlayEntry); _showedErrorDialog = false; _loginBloc.dispatch(EditButtonPressed()); } diff --git a/lib/src/widgets/progress_handler.dart b/lib/src/widgets/fullscreen_progress.dart similarity index 100% rename from lib/src/widgets/progress_handler.dart rename to lib/src/widgets/fullscreen_progress.dart