This commit is contained in:
jyuesong
2022-01-13 16:45:44 +08:00
parent d29c9e73f7
commit e8956e5ff1
11 changed files with 156 additions and 33 deletions

View File

@@ -7,6 +7,7 @@ class BaseViewModel extends ViewModel {
String? failReason;
void loading({bool notify = false}) {
failReason = null;
currentState = PageState.LOADING;
if (notify) {
notifyListeners();
@@ -14,6 +15,7 @@ class BaseViewModel extends ViewModel {
}
void success({bool notify = true}) {
failReason = null;
currentState = PageState.CONTENT;
if (notify) {
notifyListeners();
@@ -27,8 +29,20 @@ class BaseViewModel extends ViewModel {
notifyListeners();
}
}
void failToast(String? reason, {bool notify = false}) {
currentState = PageState.CONTENT;
failReason = reason;
if (notify) {
notifyListeners();
}
}
void clearToast(){
failReason = null;
}
void empty({bool notify = false}) {
failReason = null;
currentState = PageState.EMPTY;
if (notify) {
notifyListeners();