mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add others
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user