Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
OT-272 No loading indicator while importing contacts #156
Browse files Browse the repository at this point in the history
  • Loading branch information
Boehrsi authored and florianhaar committed Jul 26, 2019
1 parent afb08fd commit c2fc1f8
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 51 deletions.
15 changes: 15 additions & 0 deletions lib/src/contact/contact_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -111,6 +112,7 @@ class _ContactListState extends State<ContactList> {
ContactListBloc _contactListBloc = ContactListBloc();
ContactImportBloc _contactImportBloc = ContactImportBloc();
Navigation navigation = Navigation();
OverlayEntry _progressOverlayEntry;

@override
void initState() {
Expand All @@ -130,6 +132,10 @@ class _ContactListState extends State<ContactList> {
}

handleContactImport(ContactImportState state) {
if (_progressOverlayEntry != null) {
_progressOverlayEntry.remove();
_progressOverlayEntry = null;
}
if (state is ContactsImportSuccess) {
String contactImportSuccess = AppLocalizations.of(context).contactImportSuccess(state.changedCount);
showToast(contactImportSuccess);
Expand Down Expand Up @@ -218,6 +224,15 @@ class _ContactListState extends State<ContactList> {
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),
Expand Down
2 changes: 2 additions & 0 deletions lib/src/l10n/localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
19 changes: 9 additions & 10 deletions lib/src/login/login_manual_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -69,7 +69,6 @@ class LoginManualSettings extends StatefulWidget {

class _LoginManualSettingsState extends State<LoginManualSettings> with ManualSettings {
OverlayEntry _progressOverlayEntry;
FullscreenProgress _progress;
LoginBloc _loginBloc = LoginBloc();

@override
Expand Down Expand Up @@ -150,15 +149,15 @@ class _LoginManualSettingsState extends State<LoginManualSettings> 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,
Expand Down
19 changes: 9 additions & 10 deletions lib/src/login/login_provider_signin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -69,7 +69,6 @@ class ProviderSignIn extends StatefulWidget {
class _ProviderSignInState extends State<ProviderSignIn> {
final _simpleLoginKey = GlobalKey<FormState>();
OverlayEntry _progressOverlayEntry;
FullscreenProgress _progress;
LoginBloc _loginBloc = LoginBloc();
OverlayEntry _overlayEntry;
var _navigation = Navigation();
Expand Down Expand Up @@ -246,15 +245,15 @@ class _ProviderSignInState extends State<ProviderSignIn> {
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));
}
}
Expand Down
21 changes: 10 additions & 11 deletions lib/src/qr/scan_qr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -59,7 +59,6 @@ class ScanQr extends StatefulWidget {

class _ScanQrState extends State<ScanQr> {
QrBloc _qrBloc = QrBloc();
FullscreenProgress _progress;
OverlayEntry _progressOverlayEntry;
bool _qrCodeDetected = false;
Navigation _navigation = Navigation();
Expand Down Expand Up @@ -114,16 +113,16 @@ class _ScanQrState extends State<ScanQr> {
}

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));
}

Expand Down
19 changes: 9 additions & 10 deletions lib/src/settings/settings_security.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -63,7 +63,6 @@ class SettingsSecurity extends StatefulWidget {
class _SettingsSecurityState extends State<SettingsSecurity> {
final Navigation navigation = Navigation();
OverlayEntry _progressOverlayEntry;
FullscreenProgress _progress;
SettingsSecurityBloc _settingsSecurityBloc = SettingsSecurityBloc();
bool _enableBack = true;

Expand Down Expand Up @@ -92,15 +91,15 @@ class _SettingsSecurityState extends State<SettingsSecurity> {
} 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) {
Expand Down
19 changes: 9 additions & 10 deletions lib/src/user/user_account_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -69,7 +69,6 @@ class _UserAccountSettingsState extends State<UserAccountSettings> with ManualSe
LoginBloc _loginBloc = LoginBloc();
Navigation navigation = Navigation();
OverlayEntry _progressOverlayEntry;
FullscreenProgress _progress;
bool _showedErrorDialog = false;

bool _firstBuild = true;
Expand All @@ -88,15 +87,15 @@ class _UserAccountSettingsState extends State<UserAccountSettings> 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());
}
Expand Down

0 comments on commit c2fc1f8

Please sign in to comment.