logOut show loading

This commit is contained in:
csf 2022-10-09 19:57:38 +09:00
parent 8d23c11312
commit 715d837f54
2 changed files with 17 additions and 14 deletions

View File

@ -383,22 +383,23 @@ class OverlayDialogManager {
"[OverlayDialogManager] Failed to show dialog, _overlayState is null, call [setOverlayState] first");
}
final _tag;
final String dialogTag;
if (tag != null) {
_tag = tag;
dialogTag = tag;
} else {
_tag = _tagCount.toString();
dialogTag = _tagCount.toString();
_tagCount++;
}
final dialog = Dialog<T>();
_dialogs[_tag] = dialog;
_dialogs[dialogTag] = dialog;
final close = ([res]) {
_dialogs.remove(_tag);
close([res]) {
_dialogs.remove(dialogTag);
dialog.complete(res);
BackButtonInterceptor.removeByName(_tag);
};
BackButtonInterceptor.removeByName(dialogTag);
}
dialog.entry = OverlayEntry(builder: (_) {
bool innerClicked = false;
return Listener(
@ -423,14 +424,16 @@ class OverlayDialogManager {
close();
}
return true;
}, name: _tag);
}, name: dialogTag);
return dialog.completer.future;
}
void showLoading(String text,
String showLoading(String text,
{bool clickMaskDismiss = false,
bool showCancel = true,
VoidCallback? onCancel}) {
final tag = _tagCount.toString();
_tagCount++;
show((setState, close) {
cancel() {
dismissAll();
@ -465,7 +468,8 @@ class OverlayDialogManager {
])),
onCancel: showCancel ? cancel : null,
);
});
}, tag: tag);
return tag;
}
void resetMobileActionsOverlay({FFI? ffi}) {

View File

@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
@ -83,8 +82,7 @@ class UserModel {
}
Future<void> logOut() async {
// TODO show toast
debugPrint("start logout");
final tag = gFFI.dialogManager.showLoading(translate('Waiting'));
final url = await bind.mainGetApiServer();
final _ = await http.post(Uri.parse("$url/api/logout"),
body: {
@ -99,6 +97,7 @@ class UserModel {
]);
parent.target?.abModel.clear();
userName.value = "";
gFFI.dialogManager.dismissByTag(tag);
}
Future<Map<String, dynamic>> login(String userName, String pass) async {