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,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:back_button_interceptor/back_button_interceptor.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// @author newtab on 2021/7/16
|
||||
@@ -13,6 +14,22 @@ class CommonDialog extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget loading;
|
||||
|
||||
if (commonDialogState == CommonDialogState.FAILED) {
|
||||
loading = const Icon(
|
||||
CupertinoIcons.clear_circled,
|
||||
size: 50,
|
||||
);
|
||||
} else if (commonDialogState == CommonDialogState.SUCCESS) {
|
||||
loading = const Icon(
|
||||
CupertinoIcons.checkmark_alt,
|
||||
size: 50,
|
||||
);
|
||||
} else {
|
||||
loading = LoadingIcon();
|
||||
}
|
||||
|
||||
Widget result = Material(
|
||||
color: Colors.transparent,
|
||||
child: Align(
|
||||
@@ -36,7 +53,7 @@ class CommonDialog extends StatelessWidget {
|
||||
color: Colors.white,
|
||||
size: 40.0,
|
||||
),
|
||||
child: LoadingIcon()),
|
||||
child: loading),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
@@ -132,7 +149,7 @@ HideCallback showCommonDialog(
|
||||
}, zIndex: backButtonIndex, name: backButtonName);
|
||||
backButtonIndex++;
|
||||
|
||||
if (overlay != null) {
|
||||
if (overlay != null && overlay!.mounted) {
|
||||
overlay?.remove();
|
||||
overlay = null;
|
||||
}
|
||||
@@ -146,11 +163,13 @@ HideCallback showCommonDialog(
|
||||
},
|
||||
child: CommonDialog(
|
||||
text: text,
|
||||
commonDialogState: commonDialogState,
|
||||
),
|
||||
),
|
||||
);
|
||||
result.complete(() {
|
||||
overlay?.remove();
|
||||
overlay = null;
|
||||
BackButtonInterceptor.removeByName(backButtonName);
|
||||
});
|
||||
if (overlay != null) {
|
||||
|
||||
@@ -34,8 +34,11 @@ class Api {
|
||||
return await Http.get<String>(Url.INTIME_LOG(cron), null);
|
||||
}
|
||||
|
||||
|
||||
static Future<HttpResponse<TaskDetailBean>> taskDetail(String cron) async {
|
||||
return await Http.get<TaskDetailBean>(Url.TASK_DETAIL+cron, null);
|
||||
return await Http.get<TaskDetailBean>(Url.TASK_DETAIL + cron, null);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<TaskDetailBean>> addTask(String name, String command, String cron, {String? id}) async {
|
||||
return await Http.put<TaskDetailBean>(Url.ADD_TASK, {"name": name, "command": command, "schedule": cron, "_id": id});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ class Url {
|
||||
static const RUN_TASKS = "/api/crons/run";
|
||||
static const STOP_TASKS = "/api/crons/stop";
|
||||
static const TASK_DETAIL = "/api/crons/";
|
||||
static const ADD_TASK = "/api/crons";
|
||||
|
||||
static INTIME_LOG(String cronId) {
|
||||
return "/api/crons/$cronId/log";
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qinglong_app/module/home/home_page.dart';
|
||||
import 'package:qinglong_app/module/task/add_task_page.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
|
||||
class Routes {
|
||||
static const String route_HomePage = "/home/homepage";
|
||||
static const String route_AddTask = "/task/add";
|
||||
|
||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
case route_HomePage:
|
||||
return MaterialPageRoute(builder: (context) => const HomePage());
|
||||
case route_AddTask:
|
||||
if (settings.arguments != null) {
|
||||
return CupertinoPageRoute(
|
||||
builder: (context) => AddTaskPage(
|
||||
taskBean: settings.arguments as TaskBean,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user