mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add homepage
This commit is contained in:
41
lib/base/base_viewmodel.dart
Normal file
41
lib/base/base_viewmodel.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class BaseViewModel extends ChangeNotifier {
|
||||
PageState currentState = PageState.START;
|
||||
|
||||
void loading({bool notify = false}) {
|
||||
currentState = PageState.LOADING;
|
||||
if (notify) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void success({bool notify = true}) {
|
||||
currentState = PageState.CONTENT;
|
||||
if (notify) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void failed({bool notify = false}) {
|
||||
currentState = PageState.FAILED;
|
||||
if (notify) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void empty({bool notify = false}) {
|
||||
currentState = PageState.EMPTY;
|
||||
if (notify) {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum PageState {
|
||||
START,
|
||||
LOADING,
|
||||
EMPTY,
|
||||
CONTENT,
|
||||
FAILED,
|
||||
}
|
||||
Reference in New Issue
Block a user