mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add task
This commit is contained in:
@@ -1,31 +1,37 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:qinglong_app/base/base_viewmodel.dart';
|
||||
import 'package:qinglong_app/base/http/api.dart';
|
||||
import 'package:qinglong_app/base/http/http.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
|
||||
var taskProvider = ChangeNotifierProvider((ref) => TaskViewModel());
|
||||
|
||||
class TaskViewModel extends BaseViewModel {
|
||||
List<String> list = [];
|
||||
List<TaskBean> list = [];
|
||||
|
||||
void loadData() {
|
||||
loading(notify: true);
|
||||
Future<void> loadData([isLoading = true]) async {
|
||||
if (isLoading) {
|
||||
loading(notify: true);
|
||||
}
|
||||
|
||||
HttpResponse<List<TaskBean>> result = await Api.crons();
|
||||
|
||||
if (result.success && result.bean != null) {
|
||||
list.clear();
|
||||
list.addAll(result.bean!);
|
||||
|
||||
list.sort((a, b) {
|
||||
return a.isDisabled! - b.isDisabled!;
|
||||
});
|
||||
|
||||
list.sort((a, b) {
|
||||
return a.status! - b.status!;
|
||||
});
|
||||
|
||||
Future.delayed(Duration(seconds: 2), () {
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
list.add("sdfsf");
|
||||
success();
|
||||
});
|
||||
} else {
|
||||
list.clear();
|
||||
failed(result.message, notify: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user