mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add others
This commit is contained in:
@@ -37,9 +37,9 @@ class _BaseStateWidgetState<T extends BaseViewModel> extends ConsumerState<BaseS
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var viewModel = ref.watch<T>(widget.model);
|
var viewModel = ref.watch<T>(widget.model);
|
||||||
if (viewModel.failReason != null) {
|
if (viewModel.failedToast != null) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||||
failDialog(context, viewModel.failReason!);
|
failDialog(context, viewModel.failedToast!);
|
||||||
viewModel.clearToast();
|
viewModel.clearToast();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ class ViewModel extends ChangeNotifier {}
|
|||||||
class BaseViewModel extends ViewModel {
|
class BaseViewModel extends ViewModel {
|
||||||
PageState currentState = PageState.START;
|
PageState currentState = PageState.START;
|
||||||
String? failReason;
|
String? failReason;
|
||||||
|
String? failedToast;
|
||||||
|
|
||||||
void loading({bool notify = false}) {
|
void loading({bool notify = false}) {
|
||||||
failReason = null;
|
failReason = null;
|
||||||
|
failedToast = null;
|
||||||
currentState = PageState.LOADING;
|
currentState = PageState.LOADING;
|
||||||
if (notify) {
|
if (notify) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -16,6 +18,7 @@ class BaseViewModel extends ViewModel {
|
|||||||
|
|
||||||
void success({bool notify = true}) {
|
void success({bool notify = true}) {
|
||||||
failReason = null;
|
failReason = null;
|
||||||
|
failedToast = null;
|
||||||
currentState = PageState.CONTENT;
|
currentState = PageState.CONTENT;
|
||||||
if (notify) {
|
if (notify) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -25,12 +28,15 @@ class BaseViewModel extends ViewModel {
|
|||||||
void failed(String? reason, {bool notify = false}) {
|
void failed(String? reason, {bool notify = false}) {
|
||||||
currentState = PageState.FAILED;
|
currentState = PageState.FAILED;
|
||||||
failReason = reason;
|
failReason = reason;
|
||||||
|
failedToast = null;
|
||||||
if (notify) {
|
if (notify) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void failToast(String? reason, {bool notify = false}) {
|
void failToast(String? reason, {bool notify = false}) {
|
||||||
currentState = PageState.CONTENT;
|
currentState = PageState.CONTENT;
|
||||||
|
failedToast = reason;
|
||||||
failReason = reason;
|
failReason = reason;
|
||||||
if (notify) {
|
if (notify) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -38,11 +44,12 @@ class BaseViewModel extends ViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearToast() {
|
void clearToast() {
|
||||||
failReason = null;
|
failedToast = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void empty({bool notify = false}) {
|
void empty({bool notify = false}) {
|
||||||
failReason = null;
|
failReason = null;
|
||||||
|
failedToast = null;
|
||||||
currentState = PageState.EMPTY;
|
currentState = PageState.EMPTY;
|
||||||
if (notify) {
|
if (notify) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import 'package:dio_log/dio_log.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:qinglong_app/base/http/token_interceptor.dart';
|
import 'package:qinglong_app/base/http/token_interceptor.dart';
|
||||||
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
||||||
|
import 'package:qinglong_app/utils/QlNavigatorObserver.dart';
|
||||||
|
|
||||||
import '../../json.jc.dart';
|
import '../../json.jc.dart';
|
||||||
import '../../main.dart';
|
import '../../main.dart';
|
||||||
|
import '../routes.dart';
|
||||||
|
|
||||||
class Http {
|
class Http {
|
||||||
static const int NOT_LOGIN = 1000;
|
static const int NOT_LOGIN = 1000;
|
||||||
@@ -43,6 +45,9 @@ class Http {
|
|||||||
|
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(response, compute);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
|
if (e.response?.statusCode == 401) {
|
||||||
|
exitLogin();
|
||||||
|
}
|
||||||
return HttpResponse(success: false, message: e.message, code: 0);
|
return HttpResponse(success: false, message: e.message, code: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +59,9 @@ class Http {
|
|||||||
|
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(response, compute);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
|
if (e.response?.statusCode == 401) {
|
||||||
|
exitLogin();
|
||||||
|
}
|
||||||
return HttpResponse(success: false, message: e.message, code: 0);
|
return HttpResponse(success: false, message: e.message, code: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,6 +73,9 @@ class Http {
|
|||||||
|
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(response, compute);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
|
if (e.response?.statusCode == 401) {
|
||||||
|
exitLogin();
|
||||||
|
}
|
||||||
return HttpResponse(success: false, message: e.message, code: 0);
|
return HttpResponse(success: false, message: e.message, code: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,16 +86,27 @@ class Http {
|
|||||||
var response = await _dio!.put(uri, data: json);
|
var response = await _dio!.put(uri, data: json);
|
||||||
return decodeResponse<T>(response, compute);
|
return decodeResponse<T>(response, compute);
|
||||||
} on DioError catch (e) {
|
} on DioError catch (e) {
|
||||||
|
if (e.response?.statusCode == 401) {
|
||||||
|
exitLogin();
|
||||||
|
}
|
||||||
return HttpResponse(success: false, message: e.message, code: 0);
|
return HttpResponse(success: false, message: e.message, code: 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool pushedLoginPage = false;
|
||||||
|
|
||||||
|
static void exitLogin() {
|
||||||
|
if (!pushedLoginPage) {
|
||||||
|
pushedLoginPage = true;
|
||||||
|
navigatorState.currentState?.pushReplacementNamed(Routes.route_LOGIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static HttpResponse<T> decodeResponse<T>(
|
static HttpResponse<T> decodeResponse<T>(
|
||||||
Response<dynamic> response,
|
Response<dynamic> response,
|
||||||
bool compute,
|
bool compute,
|
||||||
) {
|
) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
if (response.data["code"] == 200) {
|
if (response.data["code"] == 200) {
|
||||||
@@ -191,3 +213,5 @@ void decode<T>() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NullResponse {}
|
class NullResponse {}
|
||||||
|
|
||||||
|
class NotLoginException implements Exception {}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import '../userinfo_viewmodel.dart';
|
|||||||
class TokenInterceptor extends Interceptor {
|
class TokenInterceptor extends Interceptor {
|
||||||
@override
|
@override
|
||||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||||
if (getIt<UserInfoViewModel>().token != null) {
|
if (getIt<UserInfoViewModel>().token != null && getIt<UserInfoViewModel>().token!.isNotEmpty) {
|
||||||
options.headers["Authorization"] = "Bearer " + getIt<UserInfoViewModel>().token!;
|
options.headers["Authorization"] = "Bearer " + getIt<UserInfoViewModel>().token!;
|
||||||
}
|
}
|
||||||
options.queryParameters["t"] = (DateTime.now().millisecondsSinceEpoch~/1000).toString();
|
options.queryParameters["t"] = (DateTime.now().millisecondsSinceEpoch~/1000).toString();
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ class Url {
|
|||||||
static const ENVS = "/api/envs";
|
static const ENVS = "/api/envs";
|
||||||
static const ADD_ENV = "/api/envs";
|
static const ADD_ENV = "/api/envs";
|
||||||
static const DEL_ENV = "/api/envs";
|
static const DEL_ENV = "/api/envs";
|
||||||
static const DISABLE_ENVS = "/api/disable";
|
static const DISABLE_ENVS = "/api/envs/disable";
|
||||||
static const ENABLE_ENVS = "/api/enable";
|
static const ENABLE_ENVS = "/api/envs/enable";
|
||||||
|
|
||||||
static INTIME_LOG(String cronId) {
|
static INTIME_LOG(String cronId) {
|
||||||
return "/api/crons/$cronId/log";
|
return "/api/crons/$cronId/log";
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:qinglong_app/module/config/config_edit_page.dart';
|
import 'package:qinglong_app/module/config/config_edit_page.dart';
|
||||||
import 'package:qinglong_app/module/home/home_page.dart';
|
import 'package:qinglong_app/module/home/home_page.dart';
|
||||||
|
import 'package:qinglong_app/module/login/login_page.dart';
|
||||||
import 'package:qinglong_app/module/task/add_task_page.dart';
|
import 'package:qinglong_app/module/task/add_task_page.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
|
|
||||||
class Routes {
|
class Routes {
|
||||||
static const String route_HomePage = "/home/homepage";
|
static const String route_HomePage = "/home/homepage";
|
||||||
|
static const String route_LOGIN = "/login";
|
||||||
static const String route_AddTask = "/task/add";
|
static const String route_AddTask = "/task/add";
|
||||||
static const String route_ConfigEdit = "/config/edit";
|
static const String route_ConfigEdit = "/config/edit";
|
||||||
|
|
||||||
@@ -14,6 +16,8 @@ class Routes {
|
|||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
case route_HomePage:
|
case route_HomePage:
|
||||||
return MaterialPageRoute(builder: (context) => const HomePage());
|
return MaterialPageRoute(builder: (context) => const HomePage());
|
||||||
|
case route_LOGIN:
|
||||||
|
return MaterialPageRoute(builder: (context) => const LoginPage());
|
||||||
case route_AddTask:
|
case route_AddTask:
|
||||||
if (settings.arguments != null) {
|
if (settings.arguments != null) {
|
||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
|
|
||||||
ThemeData darkTheme = ThemeData.dark().copyWith(
|
ThemeData darkTheme = ThemeData.dark().copyWith(
|
||||||
primaryColor: const Color(0xffffffff),
|
primaryColor: const Color(0xffffffff),
|
||||||
|
appBarTheme: const AppBarTheme(
|
||||||
|
backgroundColor: Colors.black,
|
||||||
|
),
|
||||||
inputDecorationTheme: const InputDecorationTheme(
|
inputDecorationTheme: const InputDecorationTheme(
|
||||||
labelStyle: TextStyle(color: _primaryColor),
|
labelStyle: TextStyle(color: _primaryColor),
|
||||||
focusedBorder: UnderlineInputBorder(
|
focusedBorder: UnderlineInputBorder(
|
||||||
@@ -42,11 +45,13 @@ ThemeData darkTheme = ThemeData.dark().copyWith(
|
|||||||
),
|
),
|
||||||
labelColor: Color(0xffffffff),
|
labelColor: Color(0xffffffff),
|
||||||
unselectedLabelColor: Color(0xff999999),
|
unselectedLabelColor: Color(0xff999999),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
colorScheme: const ColorScheme.light(secondary: _primaryColor,primary: _primaryColor,),
|
||||||
);
|
);
|
||||||
ThemeData lightTheme = ThemeData.light().copyWith(
|
ThemeData lightTheme = ThemeData.light().copyWith(
|
||||||
primaryColor: _primaryColor,
|
primaryColor: _primaryColor,
|
||||||
|
|
||||||
|
colorScheme: const ColorScheme.light(secondary: _primaryColor,primary: _primaryColor,),
|
||||||
scaffoldBackgroundColor: Colors.white,
|
scaffoldBackgroundColor: Colors.white,
|
||||||
inputDecorationTheme: const InputDecorationTheme(
|
inputDecorationTheme: const InputDecorationTheme(
|
||||||
labelStyle: TextStyle(color: _primaryColor),
|
labelStyle: TextStyle(color: _primaryColor),
|
||||||
@@ -85,6 +90,7 @@ ThemeData lightTheme = ThemeData.light().copyWith(
|
|||||||
|
|
||||||
abstract class ThemeColors {
|
abstract class ThemeColors {
|
||||||
Color taskTitleColor();
|
Color taskTitleColor();
|
||||||
|
|
||||||
Color descColor();
|
Color descColor();
|
||||||
|
|
||||||
Color searchBarBg();
|
Color searchBarBg();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:get_it/get_it.dart';
|
|||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
import 'package:qinglong_app/base/theme.dart';
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
import 'package:qinglong_app/module/login/login_page.dart';
|
import 'package:qinglong_app/module/login/login_page.dart';
|
||||||
|
import 'package:qinglong_app/utils/QlNavigatorObserver.dart';
|
||||||
import 'package:qinglong_app/utils/sp_utils.dart';
|
import 'package:qinglong_app/utils/sp_utils.dart';
|
||||||
|
|
||||||
import 'base/routes.dart';
|
import 'base/routes.dart';
|
||||||
@@ -23,6 +24,7 @@ void main() async {
|
|||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await SpUtil.getInstance();
|
await SpUtil.getInstance();
|
||||||
getIt.registerSingleton<UserInfoViewModel>(UserInfoViewModel());
|
getIt.registerSingleton<UserInfoViewModel>(UserInfoViewModel());
|
||||||
|
getIt.registerSingleton<QlNavigatorObserver>(QlNavigatorObserver());
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
ProviderScope(
|
ProviderScope(
|
||||||
@@ -39,7 +41,6 @@ void main() async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends ConsumerWidget {
|
class MyApp extends ConsumerWidget {
|
||||||
|
|
||||||
const MyApp({Key? key}) : super(key: key);
|
const MyApp({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -50,6 +51,7 @@ class MyApp extends ConsumerWidget {
|
|||||||
FocusScope.of(context).requestFocus(FocusNode());
|
FocusScope.of(context).requestFocus(FocusNode());
|
||||||
},
|
},
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
|
navigatorObservers: [getIt<QlNavigatorObserver>()],
|
||||||
navigatorKey: navigatorState,
|
navigatorKey: navigatorState,
|
||||||
theme: ref.watch<ThemeViewModel>(themeProvider).currentTheme,
|
theme: ref.watch<ThemeViewModel>(themeProvider).currentTheme,
|
||||||
onGenerateRoute: (setting) {
|
onGenerateRoute: (setting) {
|
||||||
|
|||||||
154
lib/module/env/env_page.dart
vendored
154
lib/module/env/env_page.dart
vendored
@@ -1,14 +1,14 @@
|
|||||||
|
import 'package:drag_and_drop_lists/drag_and_drop_lists.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||||
import 'package:qinglong_app/base/base_state_widget.dart';
|
import 'package:qinglong_app/base/base_state_widget.dart';
|
||||||
import 'package:qinglong_app/base/routes.dart';
|
import 'package:qinglong_app/base/common_dialog.dart';
|
||||||
import 'package:qinglong_app/base/theme.dart';
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
import 'package:qinglong_app/base/ui/empty_widget.dart';
|
import 'package:qinglong_app/base/ui/empty_widget.dart';
|
||||||
import 'package:qinglong_app/base/ui/menu.dart';
|
|
||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
import 'package:qinglong_app/module/env/env_viewmodel.dart';
|
import 'package:qinglong_app/module/env/env_viewmodel.dart';
|
||||||
import 'package:qinglong_app/utils/utils.dart';
|
|
||||||
|
|
||||||
class EnvPage extends StatefulWidget {
|
class EnvPage extends StatefulWidget {
|
||||||
const EnvPage({Key? key}) : super(key: key);
|
const EnvPage({Key? key}) : super(key: key);
|
||||||
@@ -18,27 +18,51 @@ class EnvPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _EnvPageState extends State<EnvPage> {
|
class _EnvPageState extends State<EnvPage> {
|
||||||
String _searchKey = "";
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BaseStateWidget<EnvViewModel>(
|
return BaseStateWidget<EnvViewModel>(
|
||||||
builder: (ref, model, child) {
|
builder: (ref, model, child) {
|
||||||
return RefreshIndicator(
|
List<EnvItemCell> list = [];
|
||||||
|
|
||||||
|
for (var value in model.list) {
|
||||||
|
if (_searchController.text.isEmpty ||
|
||||||
|
(value.name?.contains(_searchController.text) ?? false) ||
|
||||||
|
(value.value?.contains(_searchController.text) ?? false) ||
|
||||||
|
(value.remarks?.contains(_searchController.text) ?? false)) {
|
||||||
|
list.add(EnvItemCell(value, ref,key: ValueKey(value.sId),));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return model.list.isEmpty
|
||||||
|
? const EmptyWidget()
|
||||||
|
: RefreshIndicator(
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
return model.loadData(false);
|
return model.loadData(false);
|
||||||
},
|
},
|
||||||
child: model.list.isEmpty
|
child: ReorderableListView(
|
||||||
? const EmptyWidget()
|
header: searchCell(ref),
|
||||||
: ListView.builder(
|
onReorder: (int oldIndex, int newIndex) {
|
||||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
if (list.length != model.list.length) {
|
||||||
itemBuilder: (context, index) {
|
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||||
EnvBean item = model.list[index];
|
failDialog(context, "请先清空搜索关键词");
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return EnvItemCell(item, ref);
|
setState(() {
|
||||||
|
//交换数据
|
||||||
|
if (newIndex > oldIndex) {
|
||||||
|
newIndex -= 1;
|
||||||
|
}
|
||||||
|
final EnvBean item = model.list.removeAt(oldIndex);
|
||||||
|
model.list.insert(newIndex, item);
|
||||||
|
model.update();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
itemCount: model.list.length,
|
children: list,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -48,6 +72,50 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget searchCell(WidgetRef context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
child: CupertinoSearchTextField(
|
||||||
|
onSubmitted: (value) {
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onSuffixTap: () {
|
||||||
|
_searchController.text = "";
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
controller: _searchController,
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
30,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 5,
|
||||||
|
vertical: 5,
|
||||||
|
),
|
||||||
|
suffixInsets: const EdgeInsets.only(
|
||||||
|
top: 8,
|
||||||
|
bottom: 8,
|
||||||
|
right: 15,
|
||||||
|
),
|
||||||
|
prefixInsets: const EdgeInsets.only(
|
||||||
|
top: 10,
|
||||||
|
bottom: 6,
|
||||||
|
left: 15,
|
||||||
|
),
|
||||||
|
placeholderStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: context.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
placeholder: "搜索",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EnvItemCell extends StatelessWidget {
|
class EnvItemCell extends StatelessWidget {
|
||||||
@@ -58,51 +126,39 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CupertinoContextMenu(
|
return Slidable(
|
||||||
actions: [
|
key: ValueKey(bean.sId),
|
||||||
QLCupertinoContextMenuAction(
|
endActionPane: ActionPane(
|
||||||
child: const Text("编辑"),
|
motion: const ScrollMotion(),
|
||||||
onPressed: () {
|
extentRatio: 0.45,
|
||||||
Navigator.of(context).pop();
|
children: [
|
||||||
Navigator.of(context).pushNamed(Routes.route_AddTask, arguments: bean);
|
SlidableAction(
|
||||||
},
|
backgroundColor: Colors.grey,
|
||||||
trailingIcon: CupertinoIcons.pencil_outline,
|
flex: 1,
|
||||||
|
onPressed: (_) {},
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
icon: CupertinoIcons.pencil_outline,
|
||||||
),
|
),
|
||||||
QLCupertinoContextMenuAction(
|
SlidableAction(
|
||||||
child: Text(bean.status! == 0 ? "禁用" : "启用"),
|
backgroundColor: Colors.orange,
|
||||||
onPressed: () {
|
flex: 1,
|
||||||
Navigator.of(context).pop();
|
onPressed: (_) {
|
||||||
enableEnv();
|
enableEnv();
|
||||||
},
|
},
|
||||||
isDestructiveAction: true,
|
foregroundColor: Colors.white,
|
||||||
trailingIcon: bean.status! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
icon: bean.status == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||||
),
|
),
|
||||||
QLCupertinoContextMenuAction(
|
SlidableAction(
|
||||||
child: const Text("删除"),
|
backgroundColor: Colors.red,
|
||||||
onPressed: () {
|
flex: 1,
|
||||||
Navigator.of(context).pop();
|
onPressed: (_) {
|
||||||
delEnv(context, ref);
|
delEnv(context, ref);
|
||||||
},
|
},
|
||||||
isDestructiveAction: true,
|
foregroundColor: Colors.white,
|
||||||
trailingIcon: CupertinoIcons.delete,
|
icon: CupertinoIcons.delete,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
previewBuilder: (context, anima, child) {
|
|
||||||
return IntrinsicWidth(
|
|
||||||
child: Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Text(
|
|
||||||
bean.name ?? "",
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
color: bean.status == 0 ? const Color(0xffF85152) : ref.watch(themeProvider).themeColor.taskTitleColor(),
|
|
||||||
fontSize: 18,
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|||||||
7
lib/module/env/env_viewmodel.dart
vendored
7
lib/module/env/env_viewmodel.dart
vendored
@@ -60,7 +60,7 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
HttpResponse<NullResponse> response = await Api.enableEnv(sId);
|
HttpResponse<NullResponse> response = await Api.enableEnv(sId);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
list.firstWhere((element) => element.sId == sId).status = 1;
|
list.firstWhere((element) => element.sId == sId).status = 0;
|
||||||
sortList();
|
sortList();
|
||||||
success();
|
success();
|
||||||
} else {
|
} else {
|
||||||
@@ -70,7 +70,7 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
HttpResponse<NullResponse> response = await Api.disableEnv(sId);
|
HttpResponse<NullResponse> response = await Api.disableEnv(sId);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
list.firstWhere((element) => element.sId == sId).status = 0;
|
list.firstWhere((element) => element.sId == sId).status = 1;
|
||||||
sortList();
|
sortList();
|
||||||
success();
|
success();
|
||||||
} else {
|
} else {
|
||||||
@@ -78,4 +78,7 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void update(){
|
||||||
|
// update
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,12 +89,20 @@ class _HomePageState extends ConsumerState<HomePage> {
|
|||||||
body: IndexedStack(
|
body: IndexedStack(
|
||||||
index: _index,
|
index: _index,
|
||||||
children: [
|
children: [
|
||||||
const TaskPage(),
|
const Positioned.fill(
|
||||||
const EnvPage(),
|
child: TaskPage(),
|
||||||
ConfigPage(
|
),
|
||||||
|
const Positioned.fill(
|
||||||
|
child: EnvPage(),
|
||||||
|
),
|
||||||
|
Positioned.fill(
|
||||||
|
child: ConfigPage(
|
||||||
key: configKey,
|
key: configKey,
|
||||||
),
|
),
|
||||||
const OtherPage(),
|
),
|
||||||
|
const Positioned.fill(
|
||||||
|
child: OtherPage(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'package:dio_log/dio_log.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:qinglong_app/base/common_dialog.dart';
|
import 'package:qinglong_app/base/common_dialog.dart';
|
||||||
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
import 'package:qinglong_app/base/routes.dart';
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
||||||
import 'package:qinglong_app/main.dart';
|
import 'package:qinglong_app/main.dart';
|
||||||
@@ -24,6 +24,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
getIt<UserInfoViewModel>().updateToken("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -197,6 +198,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
Http.pushedLoginPage = false;
|
||||||
Utils.hideKeyBoard(context);
|
Utils.hideKeyBoard(context);
|
||||||
getIt<UserInfoViewModel>().updateHost(_hostController.text);
|
getIt<UserInfoViewModel>().updateHost(_hostController.text);
|
||||||
model.login(_userNameController.text, _passwordController.text);
|
model.login(_userNameController.text, _passwordController.text);
|
||||||
@@ -207,7 +209,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
|
||||||
class OtherPage extends StatefulWidget {
|
class OtherPage extends StatefulWidget {
|
||||||
const OtherPage({Key? key}) : super(key: key);
|
const OtherPage({Key? key}) : super(key: key);
|
||||||
@@ -10,6 +11,14 @@ class OtherPage extends StatefulWidget {
|
|||||||
class _OtherPageState extends State<OtherPage> {
|
class _OtherPageState extends State<OtherPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold();
|
return SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_highlight/theme_map.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:qinglong_app/base/base_state_widget.dart';
|
import 'package:qinglong_app/base/base_state_widget.dart';
|
||||||
import 'package:qinglong_app/base/routes.dart';
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
@@ -32,7 +33,12 @@ class _TaskPageState extends State<TaskPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BaseStateWidget<TaskViewModel>(
|
return BaseStateWidget<TaskViewModel>(
|
||||||
builder: (ref, model, child) {
|
builder: (ref, model, child) {
|
||||||
return DefaultTabController(
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
searchCell(ref),
|
||||||
|
Expanded(
|
||||||
|
child: DefaultTabController(
|
||||||
length: 3,
|
length: 3,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -68,6 +74,9 @@ class _TaskPageState extends State<TaskPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
model: taskProvider,
|
model: taskProvider,
|
||||||
@@ -103,36 +112,43 @@ class _TaskPageState extends State<TaskPage> {
|
|||||||
|
|
||||||
Widget searchCell(WidgetRef context) {
|
Widget searchCell(WidgetRef context) {
|
||||||
return Container(
|
return Container(
|
||||||
color: context.watch(themeProvider).themeColor.searchBarBg(),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
vertical: 10,
|
vertical: 10,
|
||||||
),
|
),
|
||||||
child: CupertinoSearchTextField(
|
child: CupertinoSearchTextField(
|
||||||
onSubmitted: (value) {
|
onSubmitted: (value) {
|
||||||
setState(() {
|
setState(() {});
|
||||||
_searchKey = value;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
onSuffixTap: () {
|
onSuffixTap: () {
|
||||||
_searchController.text = "";
|
_searchController.text = "";
|
||||||
setState(() {
|
setState(() {});
|
||||||
_searchKey = "";
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
borderRadius: BorderRadius.circular(
|
borderRadius: BorderRadius.circular(
|
||||||
30,
|
30,
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
horizontal: 5,
|
||||||
vertical: 5,
|
vertical: 5,
|
||||||
),
|
),
|
||||||
|
suffixInsets: const EdgeInsets.only(
|
||||||
|
top: 8,
|
||||||
|
bottom: 8,
|
||||||
|
right: 15,
|
||||||
|
),
|
||||||
prefixInsets: const EdgeInsets.only(
|
prefixInsets: const EdgeInsets.only(
|
||||||
top: 10,
|
top: 10,
|
||||||
bottom: 6,
|
bottom: 6,
|
||||||
left: 15,
|
left: 15,
|
||||||
),
|
),
|
||||||
|
placeholderStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: context.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
placeholder: "搜索",
|
placeholder: "搜索",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -364,7 +380,10 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
content: InTimeLogPage(bean.sId!, bean.status == 0),
|
content: InTimeLogPage(bean.sId!, bean.status == 0),
|
||||||
actions: [
|
actions: [
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: const Text("知道了"),
|
child: Text(
|
||||||
|
"知道了",
|
||||||
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
list.firstWhere((element) => element.sId == cron).status = 0;
|
list.firstWhere((element) => element.sId == cron).status = 0;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} else {
|
} else {
|
||||||
failed(result.message, notify: true);
|
failToast(result.message, notify: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
list.firstWhere((element) => element.sId == cron).status = 1;
|
list.firstWhere((element) => element.sId == cron).status = 1;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} else {
|
} else {
|
||||||
failed(result.message, notify: true);
|
failToast(result.message, notify: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
list.removeWhere((element) => element.sId == id);
|
list.removeWhere((element) => element.sId == id);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} else {
|
} else {
|
||||||
failed(result.message, notify: true);
|
failToast(result.message, notify: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
lib/utils/QlNavigatorObserver.dart
Normal file
16
lib/utils/QlNavigatorObserver.dart
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
|
|
||||||
|
class QlNavigatorObserver extends NavigatorObserver {
|
||||||
|
bool isInLoginPage = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didPush(Route route, Route? previousRoute) {
|
||||||
|
super.didPush(route, previousRoute);
|
||||||
|
if (Routes.route_LOGIN == route.settings.name) {
|
||||||
|
isInLoginPage = true;
|
||||||
|
} else {
|
||||||
|
isInLoginPage = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -204,6 +204,13 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.2"
|
version: "2.0.2"
|
||||||
|
drag_and_drop_lists:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: drag_and_drop_lists
|
||||||
|
url: "https://pub.flutter-io.cn"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.2+2"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ dependencies:
|
|||||||
intl: ^0.17.0
|
intl: ^0.17.0
|
||||||
get_it: ^7.2.0
|
get_it: ^7.2.0
|
||||||
flutter_highlight: ^0.7.0
|
flutter_highlight: ^0.7.0
|
||||||
|
drag_and_drop_lists: ^0.3.2+2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_native_splash: ^1.3.3
|
flutter_native_splash: ^1.3.3
|
||||||
|
|||||||
Reference in New Issue
Block a user