mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add detail page
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'base_viewmodel.dart';
|
||||
|
||||
class BaseStateWidget<T extends BaseViewModel> extends ConsumerStatefulWidget {
|
||||
final Widget Function(BuildContext context, T value, Widget? child) builder;
|
||||
final Widget Function(WidgetRef context, T value, Widget? child) builder;
|
||||
final ProviderBase<T> model;
|
||||
final Widget? child;
|
||||
final Function(T)? onReady;
|
||||
@@ -37,7 +37,7 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
|
||||
Widget build(BuildContext context) {
|
||||
var viewModel = ref.watch<T>(widget.model);
|
||||
if (viewModel.currentState == PageState.CONTENT) {
|
||||
return widget.builder(context, viewModel, widget.child);
|
||||
return widget.builder(ref, viewModel, widget.child);
|
||||
}
|
||||
|
||||
if (viewModel.currentState == PageState.LOADING) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'dart:ffi';
|
||||
|
||||
import 'package:qinglong_app/base/http/http.dart';
|
||||
import 'package:qinglong_app/module/login/login_bean.dart';
|
||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||
import 'package:qinglong_app/module/task/task_detail/task_detail_bean.dart';
|
||||
|
||||
import 'url.dart';
|
||||
|
||||
@@ -18,4 +21,21 @@ class Api {
|
||||
static Future<HttpResponse<List<TaskBean>>> crons() async {
|
||||
return await Http.get<List<TaskBean>>(Url.TASKS, {"searchValue": ""});
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> startTasks(List<String> crons) async {
|
||||
return await Http.put<NullResponse>(Url.RUN_TASKS, crons);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<NullResponse>> stopTasks(List<String> crons) async {
|
||||
return await Http.put<NullResponse>(Url.RUN_TASKS, crons);
|
||||
}
|
||||
|
||||
static Future<HttpResponse<String>> inTimeLog(String cron) async {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio_log/dio_log.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:qinglong_app/base/http/token_interceptor.dart';
|
||||
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
||||
import 'package:qinglong_app/main.dart';
|
||||
|
||||
import '../../json.jc.dart';
|
||||
|
||||
@@ -36,7 +35,7 @@ class Http {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<HttpResponse<T>> get<T>(String uri, Map<String, String> json, {bool compute = true}) async {
|
||||
static Future<HttpResponse<T>> get<T>(String uri, Map<String, String>? json, {bool compute = true}) async {
|
||||
_init();
|
||||
var response = await _dio!.get(uri, queryParameters: json);
|
||||
|
||||
@@ -74,7 +73,7 @@ class Http {
|
||||
try {
|
||||
if (response.data["code"] == 200) {
|
||||
if (response.data["data"] != null) {
|
||||
if (T is Void) {
|
||||
if (T == NullResponse) {
|
||||
return HttpResponse<T>(
|
||||
success: true,
|
||||
code: 200,
|
||||
@@ -83,7 +82,7 @@ class Http {
|
||||
|
||||
dynamic data = response.data["data"];
|
||||
T t;
|
||||
if (T is String) {
|
||||
if (T == String) {
|
||||
if (data is String) {
|
||||
t = data as T;
|
||||
} else {
|
||||
@@ -109,7 +108,7 @@ class Http {
|
||||
}
|
||||
} else {
|
||||
return HttpResponse<T>(
|
||||
success: false,
|
||||
success: true,
|
||||
code: 200,
|
||||
);
|
||||
}
|
||||
@@ -173,3 +172,5 @@ class CronBean with BaseBean<CronBean> {
|
||||
void decode<T>() async {
|
||||
compute(DeserializeAction.invokeJson, DeserializeAction<T>({}));
|
||||
}
|
||||
|
||||
class NullResponse{}
|
||||
@@ -1,4 +1,11 @@
|
||||
class Url {
|
||||
static const LOGIN = "/api/user/login";
|
||||
static const TASKS = "/api/crons";
|
||||
static const RUN_TASKS = "/api/crons/run";
|
||||
static const STOP_TASKS = "/api/crons/stop";
|
||||
static const TASK_DETAIL = "/api/crons/";
|
||||
|
||||
static INTIME_LOG(String cronId) {
|
||||
return "/api/crons/$cronId/log";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class Routes {
|
||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||
switch (settings.name) {
|
||||
case route_HomePage:
|
||||
return CupertinoPageRoute(builder: (context) => const HomePage());
|
||||
return MaterialPageRoute(builder: (context) => const HomePage());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -22,14 +22,16 @@ class ThemeViewModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
ThemeData darkTheme = ThemeData.dark().copyWith(
|
||||
primaryColor: Color(0xffffffff),
|
||||
primaryColor: const Color(0xffffffff),
|
||||
);
|
||||
ThemeData lightTheme = ThemeData.light().copyWith(
|
||||
primaryColor: Color(0xFF0F77FE),
|
||||
primaryColor: const Color(0xFF0F77FE),
|
||||
scaffoldBackgroundColor: Colors.white,
|
||||
);
|
||||
|
||||
abstract class ThemeColors {
|
||||
Color taskTitleColor();
|
||||
Color searchBarBg();
|
||||
}
|
||||
|
||||
class LightartThemeColors extends ThemeColors {
|
||||
@@ -37,6 +39,12 @@ class LightartThemeColors extends ThemeColors {
|
||||
Color taskTitleColor() {
|
||||
return Color(0xff333333);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Color searchBarBg() {
|
||||
return const Color(0xffF7F7F7);
|
||||
}
|
||||
}
|
||||
|
||||
class DartThemeColors extends ThemeColors {
|
||||
@@ -44,4 +52,11 @@ class DartThemeColors extends ThemeColors {
|
||||
Color taskTitleColor() {
|
||||
return Colors.white;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Color searchBarBg() {
|
||||
return const Color(0xff2E312E);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user