add others

This commit is contained in:
jyuesong
2022-01-17 16:42:46 +08:00
parent 105d6172b6
commit ad141e4bd1
18 changed files with 291 additions and 128 deletions

View File

@@ -5,9 +5,11 @@ class ViewModel extends ChangeNotifier {}
class BaseViewModel extends ViewModel {
PageState currentState = PageState.START;
String? failReason;
String? failedToast;
void loading({bool notify = false}) {
failReason = null;
failedToast = null;
currentState = PageState.LOADING;
if (notify) {
notifyListeners();
@@ -16,6 +18,7 @@ class BaseViewModel extends ViewModel {
void success({bool notify = true}) {
failReason = null;
failedToast = null;
currentState = PageState.CONTENT;
if (notify) {
notifyListeners();
@@ -25,24 +28,28 @@ class BaseViewModel extends ViewModel {
void failed(String? reason, {bool notify = false}) {
currentState = PageState.FAILED;
failReason = reason;
failedToast = null;
if (notify) {
notifyListeners();
}
}
void failToast(String? reason, {bool notify = false}) {
currentState = PageState.CONTENT;
failedToast = reason;
failReason = reason;
if (notify) {
notifyListeners();
}
}
void clearToast(){
failReason = null;
void clearToast() {
failedToast = null;
}
void empty({bool notify = false}) {
failReason = null;
failedToast = null;
currentState = PageState.EMPTY;
if (notify) {
notifyListeners();