fix: Improve loading dialogs

This commit is contained in:
Christian Pauly 2020-10-02 14:44:05 +02:00
parent fe649e5a62
commit 41ceb84b47
2 changed files with 60 additions and 19 deletions

View file

@ -43,7 +43,7 @@ PODS:
- Flutter
- firebase_core_web (0.1.0):
- Flutter
- firebase_messaging (7.0.0):
- firebase_messaging (7.0.2):
- Firebase/CoreOnly (~> 6.26.0)
- Firebase/Messaging (~> 6.26.0)
- firebase_core
@ -138,6 +138,8 @@ PODS:
- Flutter
- path_provider_macos (0.0.1):
- Flutter
- path_provider_windows (0.0.1):
- Flutter
- PromisesObjC (1.2.10)
- Protobuf (3.13.0)
- receive_sharing_intent (0.0.1):
@ -158,6 +160,24 @@ PODS:
- SQLCipher/common (4.4.0)
- SQLCipher/standard (4.4.0):
- SQLCipher/common
- sqlite3 (3.32.3):
- sqlite3/common (= 3.32.3)
- sqlite3/common (3.32.3)
- sqlite3/fts5 (3.32.3):
- sqlite3/common
- sqlite3/json1 (3.32.3):
- sqlite3/common
- sqlite3/perf-threadsafe (3.32.3):
- sqlite3/common
- sqlite3/rtree (3.32.3):
- sqlite3/common
- sqlite3_flutter_libs (0.0.1):
- Flutter
- sqlite3 (~> 3.32.3)
- sqlite3/fts5
- sqlite3/json1
- sqlite3/perf-threadsafe
- sqlite3/rtree
- url_launcher (0.0.1):
- Flutter
- url_launcher_linux (0.0.1):
@ -166,6 +186,8 @@ PODS:
- Flutter
- url_launcher_web (0.0.1):
- Flutter
- url_launcher_windows (0.0.1):
- Flutter
- webview_flutter (0.0.1):
- Flutter
@ -187,14 +209,17 @@ DEPENDENCIES:
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_linux (from `.symlinks/plugins/path_provider_linux/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- path_provider_windows (from `.symlinks/plugins/path_provider_windows/ios`)
- receive_sharing_intent (from `.symlinks/plugins/receive_sharing_intent/ios`)
- share (from `.symlinks/plugins/share/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- SQLCipher
- sqlite3_flutter_libs (from `.symlinks/plugins/sqlite3_flutter_libs/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
- url_launcher_linux (from `.symlinks/plugins/url_launcher_linux/ios`)
- url_launcher_macos (from `.symlinks/plugins/url_launcher_macos/ios`)
- url_launcher_web (from `.symlinks/plugins/url_launcher_web/ios`)
- url_launcher_windows (from `.symlinks/plugins/url_launcher_windows/ios`)
- webview_flutter (from `.symlinks/plugins/webview_flutter/ios`)
SPEC REPOS:
@ -220,6 +245,7 @@ SPEC REPOS:
- SDWebImage
- SDWebImageFLPlugin
- SQLCipher
- sqlite3
EXTERNAL SOURCES:
file_picker:
@ -256,12 +282,16 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_linux/ios"
path_provider_macos:
:path: ".symlinks/plugins/path_provider_macos/ios"
path_provider_windows:
:path: ".symlinks/plugins/path_provider_windows/ios"
receive_sharing_intent:
:path: ".symlinks/plugins/receive_sharing_intent/ios"
share:
:path: ".symlinks/plugins/share/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
sqlite3_flutter_libs:
:path: ".symlinks/plugins/sqlite3_flutter_libs/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"
url_launcher_linux:
@ -270,6 +300,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/url_launcher_macos/ios"
url_launcher_web:
:path: ".symlinks/plugins/url_launcher_web/ios"
url_launcher_windows:
:path: ".symlinks/plugins/url_launcher_windows/ios"
webview_flutter:
:path: ".symlinks/plugins/webview_flutter/ios"
@ -280,7 +312,7 @@ SPEC CHECKSUMS:
Firebase: 7cf5f9c67f03cb3b606d1d6535286e1080e57eb6
firebase_core: 3134fe79d257d430f163b558caf52a10a87efe8a
firebase_core_web: d501d8b946b60c8af265428ce483b0fff5ad52d1
firebase_messaging: 6061cbdfe4463502a0d4d7049820c25d1757a095
firebase_messaging: 2844c37f9ce87c0904b38fe435223161b1a71528
FirebaseAnalyticsInterop: 3f86269c38ae41f47afeb43ebf32a001f58fcdae
FirebaseCore: f42e5e5f382cdcf6b617ed737bf6c871a6947b17
FirebaseCoreDiagnostics: 7415bfb3883b3500c5a95c42b6ba66baae78f600
@ -307,6 +339,7 @@ SPEC CHECKSUMS:
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
path_provider_linux: 4d630dc393e1f20364f3e3b4a2ff41d9674a84e4
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
path_provider_windows: a2b81600c677ac1959367280991971cb9a1edb3b
PromisesObjC: b14b1c6b68e306650688599de8a45e49fae81151
Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748
receive_sharing_intent: c0d87310754e74c0f9542947e7cbdf3a0335a3b1
@ -315,10 +348,13 @@ SPEC CHECKSUMS:
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0
SQLCipher: e434ed542b24f38ea7b36468a13f9765e1b5c072
sqlite3: 8f7d2078ae27778699a622a94b853285793422a2
sqlite3_flutter_libs: 5651f8ff48e3b44d910863c4ea5916085b1b245f
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
url_launcher_linux: ac237cb7a8058736e4aae38bdbcc748a4b394cc0
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
url_launcher_windows: 683d7c283894db8d1914d3ab2223b20cc1ad95d5
webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96
PODFILE CHECKSUM: 4b647f92a1fa32e6a4287abfd67897564ceda4e9

View file

@ -138,11 +138,26 @@ class SimpleDialogs {
Future<dynamic> tryRequestWithLoadingDialog(Future<dynamic> request,
{Function(MatrixException) onAdditionalAuth}) async {
showLoadingDialog(context);
final dynamic = await tryRequestWithErrorToast(request,
onAdditionalAuth: onAdditionalAuth);
Navigator.of(context)?.pop();
return dynamic;
var completed = false;
final futureResult = tryRequestWithErrorToast(
request,
onAdditionalAuth: onAdditionalAuth,
).whenComplete(() => completed = true);
await Future.delayed(Duration(seconds: 1));
if (completed) return futureResult;
return showDialog<dynamic>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
futureResult.then(
(result) => Navigator.of(context).pop<dynamic>(result),
);
return AlertDialog(
title: Text(L10n.of(context).loadingPleaseWait),
content: LinearProgressIndicator(),
);
},
);
}
Future<dynamic> tryRequestWithErrorToast(Future<dynamic> request,
@ -167,18 +182,8 @@ class SimpleDialogs {
context: context,
barrierDismissible: false,
builder: (BuildContext context) => AlertDialog(
content: Row(
children: <Widget>[
CircularProgressIndicator(),
SizedBox(width: 16),
Expanded(
child: Text(
L10n.of(context).loadingPleaseWait,
overflow: TextOverflow.ellipsis,
maxLines: 1,
)),
],
),
title: Text(L10n.of(context).loadingPleaseWait),
content: LinearProgressIndicator(),
),
);
}