mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add enable
This commit is contained in:
@@ -59,4 +59,12 @@ class Api {
|
|||||||
static Future<HttpResponse<NullResponse>> unpinTask(String cron) async {
|
static Future<HttpResponse<NullResponse>> unpinTask(String cron) async {
|
||||||
return await Http.put<NullResponse>(Url.UNPIN_TASK, [cron]);
|
return await Http.put<NullResponse>(Url.UNPIN_TASK, [cron]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<NullResponse>> enableTask(String cron) async {
|
||||||
|
return await Http.put<NullResponse>(Url.ENABLE_TASK, [cron]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Future<HttpResponse<NullResponse>> disableTask(String cron) async {
|
||||||
|
return await Http.put<NullResponse>(Url.DISABLE_TASK, [cron]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ class Url {
|
|||||||
static const ADD_TASK = "/api/crons";
|
static const ADD_TASK = "/api/crons";
|
||||||
static const PIN_TASK = "/api/crons/pin";
|
static const PIN_TASK = "/api/crons/pin";
|
||||||
static const UNPIN_TASK = "/api/crons/unpin";
|
static const UNPIN_TASK = "/api/crons/unpin";
|
||||||
|
static const ENABLE_TASK = "/api/crons/enable";
|
||||||
|
static const DISABLE_TASK = "/api/crons/disable";
|
||||||
|
|
||||||
static INTIME_LOG(String cronId) {
|
static INTIME_LOG(String cronId) {
|
||||||
return "/api/crons/$cronId/log";
|
return "/api/crons/$cronId/log";
|
||||||
|
|||||||
@@ -31,7 +31,10 @@ ThemeData lightTheme = ThemeData.light().copyWith(
|
|||||||
|
|
||||||
abstract class ThemeColors {
|
abstract class ThemeColors {
|
||||||
Color taskTitleColor();
|
Color taskTitleColor();
|
||||||
|
|
||||||
Color searchBarBg();
|
Color searchBarBg();
|
||||||
|
|
||||||
|
Color pinColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
class LightartThemeColors extends ThemeColors {
|
class LightartThemeColors extends ThemeColors {
|
||||||
@@ -40,11 +43,15 @@ class LightartThemeColors extends ThemeColors {
|
|||||||
return Color(0xff333333);
|
return Color(0xff333333);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color searchBarBg() {
|
Color searchBarBg() {
|
||||||
return const Color(0xffF7F7F7);
|
return const Color(0xffF7F7F7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color pinColor() {
|
||||||
|
return const Color(0xffF7F7F7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DartThemeColors extends ThemeColors {
|
class DartThemeColors extends ThemeColors {
|
||||||
@@ -53,10 +60,13 @@ class DartThemeColors extends ThemeColors {
|
|||||||
return Colors.white;
|
return Colors.white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color searchBarBg() {
|
Color searchBarBg() {
|
||||||
return const Color(0xff2E312E);
|
return const Color(0xff2E312E);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color pinColor() {
|
||||||
|
return Colors.black12;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Container(
|
||||||
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.searchBarBg() : Colors.transparent,
|
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
vertical: 8,
|
vertical: 8,
|
||||||
@@ -310,6 +310,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
child: Text(bean.isDisabled! == 1 ? "启用" : "禁用"),
|
child: Text(bean.isDisabled! == 1 ? "启用" : "禁用"),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
enableTask();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
CupertinoActionSheetAction(
|
CupertinoActionSheetAction(
|
||||||
@@ -331,6 +332,10 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableTask() {
|
||||||
|
ref.read(taskProvider).enableTask(bean.sId!, bean.isDisabled!);
|
||||||
|
}
|
||||||
|
|
||||||
void pinTask() {
|
void pinTask() {
|
||||||
ref.read(taskProvider).pinTask(bean.sId!, bean.isPinned!);
|
ref.read(taskProvider).pinTask(bean.sId!, bean.isPinned!);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,4 +108,28 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableTask(String sId, int isDisabled) async {
|
||||||
|
if (isDisabled == 0) {
|
||||||
|
HttpResponse<NullResponse> response = await Api.disableTask(sId);
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
list.firstWhere((element) => element.sId == sId).isDisabled = 1;
|
||||||
|
sortList();
|
||||||
|
success();
|
||||||
|
} else {
|
||||||
|
failToast(response.message, notify: true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
HttpResponse<NullResponse> response = await Api.enableTask(sId);
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
list.firstWhere((element) => element.sId == sId).isDisabled = 0;
|
||||||
|
sortList();
|
||||||
|
success();
|
||||||
|
} else {
|
||||||
|
failToast(response.message, notify: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user