优化搜索框样式,优化任务列表,环境变量等相关页面使用体验
|
Before Width: | Height: | Size: 19 KiB |
BIN
assets/images/dark.png
Normal file
|
After Width: | Height: | Size: 608 B |
BIN
assets/images/faceid.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/figure.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
assets/images/icon_a.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/images/icon_about.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
assets/images/icon_app_set.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/images/icon_b.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/images/icon_check.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/icon_cron.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/icon_cron_checked.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
assets/images/icon_d.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/icon_default_user.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
assets/images/icon_disabled.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/images/icon_enable.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/icon_env.png
Normal file
|
After Width: | Height: | Size: 960 B |
BIN
assets/images/icon_env_checked.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/images/icon_fail.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_file.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/images/icon_file_checked.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/images/icon_history.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
assets/images/icon_idle.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/images/icon_install_fail.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
assets/images/icon_install_success.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/images/icon_login_icon.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/images/icon_other.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/images/icon_other_bg.png
Normal file
|
After Width: | Height: | Size: 400 KiB |
BIN
assets/images/icon_other_checked.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/images/icon_right.png
Normal file
|
After Width: | Height: | Size: 491 B |
BIN
assets/images/icon_running.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
assets/images/icon_s.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/images/icon_safety.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
assets/images/icon_search.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/images/icon_setting.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/images/icon_subsctibe.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/images/icon_success.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_task_disable.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
assets/images/icon_task_log.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/images/icon_uncheck.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/images/icon_vip_bg.png
Normal file
|
After Width: | Height: | Size: 5.7 KiB |
BIN
assets/images/icon_vip_bg_check.png
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 19 KiB |
BIN
assets/images/light.png
Normal file
|
After Width: | Height: | Size: 863 B |
BIN
assets/images/normal.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 16 KiB |
BIN
assets/images/svip.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/images/svip_logo.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
assets/images/vip.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/images/vip_logo.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 20 KiB |
@@ -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:qinglong_app/module/change_account_page.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/env/add_env_page.dart';
|
import 'package:qinglong_app/module/env/add_env_page.dart';
|
||||||
import 'package:qinglong_app/module/env/env_bean.dart';
|
import 'package:qinglong_app/module/env/env_bean.dart';
|
||||||
@@ -41,6 +42,7 @@ class Routes {
|
|||||||
static const String routeUpdatePassword = "/updatePassword";
|
static const String routeUpdatePassword = "/updatePassword";
|
||||||
static const String routeAbout = "/about";
|
static const String routeAbout = "/about";
|
||||||
static const String routeTheme = "/theme";
|
static const String routeTheme = "/theme";
|
||||||
|
static const String routeChangeAccount = "/changeAccount";
|
||||||
|
|
||||||
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
static Route<dynamic>? generateRoute(RouteSettings settings) {
|
||||||
switch (settings.name) {
|
switch (settings.name) {
|
||||||
@@ -55,7 +57,10 @@ class Routes {
|
|||||||
} else {
|
} else {
|
||||||
return MaterialPageRoute(builder: (context) => const LoginPage());
|
return MaterialPageRoute(builder: (context) => const LoginPage());
|
||||||
}
|
}
|
||||||
|
case routeChangeAccount:
|
||||||
|
return CupertinoPageRoute(
|
||||||
|
builder: (context) => const ChangeAccountPage(),
|
||||||
|
);
|
||||||
case routeAddTask:
|
case routeAddTask:
|
||||||
if (settings.arguments != null) {
|
if (settings.arguments != null) {
|
||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(
|
||||||
@@ -66,8 +71,7 @@ class Routes {
|
|||||||
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
return CupertinoPageRoute(builder: (context) => const AddTaskPage());
|
||||||
}
|
}
|
||||||
case routeAddDependency:
|
case routeAddDependency:
|
||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(builder: (context) => const AddDependencyPage());
|
||||||
builder: (context) => const AddDependencyPage());
|
|
||||||
case routeAddEnv:
|
case routeAddEnv:
|
||||||
if (settings.arguments != null) {
|
if (settings.arguments != null) {
|
||||||
return CupertinoPageRoute(
|
return CupertinoPageRoute(
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
secondary: _primaryColor,
|
secondary: _primaryColor,
|
||||||
primary: _primaryColor,
|
primary: _primaryColor,
|
||||||
),
|
),
|
||||||
scaffoldBackgroundColor: const Color(0xfff5f5f5),
|
scaffoldBackgroundColor: const Color(0xffffffff),
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
labelStyle: TextStyle(
|
labelStyle: TextStyle(
|
||||||
color: _primaryColor,
|
color: _primaryColor,
|
||||||
@@ -223,6 +223,8 @@ abstract class ThemeColors {
|
|||||||
|
|
||||||
Color tabBarColor();
|
Color tabBarColor();
|
||||||
|
|
||||||
|
Color blackAndWhite();
|
||||||
|
|
||||||
Color pinColor();
|
Color pinColor();
|
||||||
|
|
||||||
Color buttonBgColor();
|
Color buttonBgColor();
|
||||||
@@ -241,6 +243,11 @@ class LightThemeColors extends ThemeColors {
|
|||||||
return const Color(0xffF7F7F7);
|
return const Color(0xffF7F7F7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color blackAndWhite() {
|
||||||
|
return Colors.white;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, TextStyle> codeEditorTheme() {
|
Map<String, TextStyle> codeEditorTheme() {
|
||||||
return qinglongLightTheme;
|
return qinglongLightTheme;
|
||||||
@@ -288,6 +295,11 @@ class DartThemeColors extends ThemeColors {
|
|||||||
return qinglongDarkTheme;
|
return qinglongDarkTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color blackAndWhite() {
|
||||||
|
return Colors.black;
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color descColor() {
|
Color descColor() {
|
||||||
return const Color(0xff999999);
|
return const Color(0xff999999);
|
||||||
|
|||||||
69
lib/base/ui/search_cell.dart
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
|
import '../theme.dart';
|
||||||
|
|
||||||
|
class SearchCell extends ConsumerStatefulWidget {
|
||||||
|
final TextEditingController controller;
|
||||||
|
|
||||||
|
const SearchCell({
|
||||||
|
Key? key,
|
||||||
|
required this.controller,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState createState() => _SearchCellState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchCellState extends ConsumerState<SearchCell> {
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return CupertinoSearchTextField(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ref.watch(themeProvider).themeColor.blackAndWhite(),
|
||||||
|
border: Border.all(width: 1, color: const Color(0xffC0C4CC)),
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
7,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSuffixTap: () {
|
||||||
|
widget.controller.text = "";
|
||||||
|
setState(() {
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
controller: widget.controller,
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 5,
|
||||||
|
vertical: 5,
|
||||||
|
),
|
||||||
|
suffixInsets: const EdgeInsets.only(
|
||||||
|
right: 15,
|
||||||
|
),
|
||||||
|
prefixIcon: Image.asset(
|
||||||
|
"assets/images/icon_search.png",
|
||||||
|
width: 18,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
prefixInsets: const EdgeInsets.only(
|
||||||
|
left: 10,
|
||||||
|
top: 2,
|
||||||
|
),
|
||||||
|
placeholderStyle: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
placeholder: "请输入内容",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
316
lib/module/change_account_page.dart
Normal file
@@ -0,0 +1,316 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||||
|
import 'package:qinglong_app/base/http/api.dart';
|
||||||
|
import 'package:qinglong_app/base/http/http.dart';
|
||||||
|
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||||
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
|
import 'package:qinglong_app/base/userinfo_viewmodel.dart';
|
||||||
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
import 'package:qinglong_app/utils/login_helper.dart';
|
||||||
|
|
||||||
|
import '../../main.dart';
|
||||||
|
|
||||||
|
class ChangeAccountPage extends ConsumerStatefulWidget {
|
||||||
|
const ChangeAccountPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ChangeAccountPageState createState() => _ChangeAccountPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ChangeAccountPageState extends ConsumerState<ChangeAccountPage> {
|
||||||
|
String isLoginingHost = "";
|
||||||
|
String preHost = "";
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
preHost = getIt<UserInfoViewModel>().historyAccounts.first.host ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: QlAppBar(
|
||||||
|
canBack: true,
|
||||||
|
title: "切换账号",
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height / 10,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"轻触账号以切换登录",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
fontSize: 22,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
child: ListView.separated(
|
||||||
|
shrinkWrap: true,
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
if (index == getIt<UserInfoViewModel>().historyAccounts.length) {
|
||||||
|
return addAccount();
|
||||||
|
}
|
||||||
|
return ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
child: Container(
|
||||||
|
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
||||||
|
child: buildCell(index),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (_, __) {
|
||||||
|
return const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: getIt<UserInfoViewModel>().historyAccounts.length + 1),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildCell(int index) {
|
||||||
|
Widget child = ListTile(
|
||||||
|
title: Text(
|
||||||
|
getIt<UserInfoViewModel>().historyAccounts[index].host ?? "",
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
minVerticalPadding: 10,
|
||||||
|
subtitle: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 10.0),
|
||||||
|
child: Text(
|
||||||
|
getIt<UserInfoViewModel>().historyAccounts[index].userName ?? "",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: index == 0
|
||||||
|
? Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 5,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
border: Border.all(color: ref.watch(themeProvider).primaryColor, width: 1),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"已登录",
|
||||||
|
style: TextStyle(color: ref.watch(themeProvider).primaryColor, fontSize: 12),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: (isLoginingHost.isNotEmpty
|
||||||
|
? SizedBox(
|
||||||
|
width: 15,
|
||||||
|
height: 15,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: ref.watch(themeProvider).primaryColor,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink()),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (getIt<UserInfoViewModel>().historyAccounts[index].host == getIt<UserInfoViewModel>().host) {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Slidable(
|
||||||
|
key: ValueKey(index),
|
||||||
|
endActionPane: ActionPane(
|
||||||
|
motion: const ScrollMotion(),
|
||||||
|
extentRatio: 0.15,
|
||||||
|
children: [
|
||||||
|
SlidableAction(
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
flex: 1,
|
||||||
|
onPressed: (_) {
|
||||||
|
getIt<UserInfoViewModel>().removeHistoryAccount(getIt<UserInfoViewModel>().historyAccounts[index].host);
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
icon: CupertinoIcons.delete,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: () {
|
||||||
|
loginNewByBean(getIt<UserInfoViewModel>().historyAccounts[index]);
|
||||||
|
},
|
||||||
|
child: child),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
LoginHelper? helper;
|
||||||
|
|
||||||
|
void loginNewByBean(UserInfoBean historyAccount) async {
|
||||||
|
isLoginingHost = historyAccount.host ?? "";
|
||||||
|
setState(() {});
|
||||||
|
helper = LoginHelper(
|
||||||
|
historyAccount.useSecretLogined,
|
||||||
|
historyAccount.host ?? "",
|
||||||
|
historyAccount.userName ?? "",
|
||||||
|
historyAccount.password ?? "",
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
var response = await helper!.login();
|
||||||
|
dealLoginResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dealLoginResponse(int response) {
|
||||||
|
if (response == LoginHelper.success) {
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(Routes.routeHomePage, (_) => false);
|
||||||
|
} else if (response == LoginHelper.failed) {
|
||||||
|
loginFailed();
|
||||||
|
} else {
|
||||||
|
twoFact();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loginFailed() {
|
||||||
|
isLoginingHost = "";
|
||||||
|
Http.clear();
|
||||||
|
getIt<UserInfoViewModel>().updateHost(preHost);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
void twoFact() {
|
||||||
|
String twoFact = "";
|
||||||
|
showCupertinoDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => CupertinoAlertDialog(
|
||||||
|
title: const Text("两步验证"),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: TextField(
|
||||||
|
onChanged: (value) {
|
||||||
|
twoFact = value;
|
||||||
|
},
|
||||||
|
maxLines: 1,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
contentPadding: EdgeInsets.fromLTRB(0, 5, 0, 5),
|
||||||
|
hintText: "请输入code",
|
||||||
|
),
|
||||||
|
autofocus: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: const Text(
|
||||||
|
"取消",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Color(0xff999999),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
CupertinoDialogAction(
|
||||||
|
child: Text(
|
||||||
|
"确定",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.of(context).pop(true);
|
||||||
|
if (helper != null) {
|
||||||
|
var response = await helper!.loginTwice(twoFact);
|
||||||
|
dealLoginResponse(response);
|
||||||
|
} else {
|
||||||
|
"状态异常".toast();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)).then((value) {
|
||||||
|
if (value == null) {
|
||||||
|
isLoginingHost = "";
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget addAccount() {
|
||||||
|
return GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||||
|
Routes.routeLogin,
|
||||||
|
(_) => false,
|
||||||
|
arguments: true,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 15,
|
||||||
|
horizontal: 15,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
||||||
|
borderRadius: BorderRadius.circular(15),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(5),
|
||||||
|
border: Border.all(
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Icon(
|
||||||
|
CupertinoIcons.add,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"添加账号",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
486
lib/module/env/env_page.dart
vendored
@@ -8,6 +8,7 @@ import 'package:qinglong_app/base/base_state_widget.dart';
|
|||||||
import 'package:qinglong_app/base/routes.dart';
|
import 'package:qinglong_app/base/routes.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/search_cell.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/extension.dart';
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
@@ -22,6 +23,7 @@ class EnvPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _EnvPageState extends State<EnvPage> {
|
class _EnvPageState extends State<EnvPage> {
|
||||||
final TextEditingController _searchController = TextEditingController();
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
String currentState = EnvViewModel.allStr;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -35,100 +37,158 @@ class _EnvPageState extends State<EnvPage> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BaseStateWidget<EnvViewModel>(
|
return BaseStateWidget<EnvViewModel>(
|
||||||
builder: (ref, model, child) {
|
builder: (ref, model, child) {
|
||||||
|
List<EnvBean> prepareList = [];
|
||||||
List<EnvItemCell> list = [];
|
List<EnvItemCell> list = [];
|
||||||
|
if (currentState == EnvViewModel.allStr) {
|
||||||
|
prepareList = model.list;
|
||||||
|
} else if (currentState == EnvViewModel.enabledStr) {
|
||||||
|
prepareList = model.enabledList;
|
||||||
|
} else {
|
||||||
|
prepareList = model.disabledList;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < model.list.length; i++) {
|
for (int i = 0; i < prepareList.length; i++) {
|
||||||
EnvBean value = model.list[i];
|
EnvBean value = prepareList[i];
|
||||||
if (_searchController.text.isEmpty ||
|
if (_searchController.text.isEmpty ||
|
||||||
(value.name?.contains(_searchController.text) ?? false) ||
|
(value.name?.contains(_searchController.text) ?? false) ||
|
||||||
(value.value?.contains(_searchController.text) ?? false) ||
|
(value.value?.contains(_searchController.text) ?? false) ||
|
||||||
(value.remarks?.contains(_searchController.text) ?? false)) {
|
(value.remarks?.contains(_searchController.text) ?? false)) {
|
||||||
list.add(EnvItemCell(
|
list.add(
|
||||||
value,
|
EnvItemCell(
|
||||||
i,
|
value,
|
||||||
ref,
|
i,
|
||||||
key: ValueKey(value.sId),
|
ref,
|
||||||
));
|
key: ValueKey(value.sId),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.list.isEmpty
|
return model.list.isEmpty
|
||||||
? const EmptyWidget()
|
? const EmptyWidget()
|
||||||
: RefreshIndicator(
|
: RefreshIndicator(
|
||||||
|
notificationPredicate: (_) {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
return model.loadData(false);
|
return model.loadData(false);
|
||||||
},
|
},
|
||||||
child: SlidableAutoCloseBehavior(
|
child: SlidableAutoCloseBehavior(
|
||||||
child: ReorderableListView(
|
child: currentState == EnvViewModel.disabledStr
|
||||||
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
? ListView(
|
||||||
header: searchCell(ref),
|
children: [
|
||||||
onReorder: (int oldIndex, int newIndex) {
|
searchCell(context, ref),
|
||||||
if (list.length != model.list.length) {
|
...list,
|
||||||
"请先清空搜索关键词".toast();
|
],
|
||||||
return;
|
)
|
||||||
}
|
: ReorderableListView(
|
||||||
|
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
|
||||||
|
header: searchCell(context, ref),
|
||||||
|
onReorder: (int oldIndex, int newIndex) {
|
||||||
|
if (list.length != model.list.length) {
|
||||||
|
"请先清空搜索关键词".toast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(
|
||||||
//交换数据
|
() {
|
||||||
if (newIndex > oldIndex) {
|
//交换数据
|
||||||
newIndex -= 1;
|
if (newIndex > oldIndex) {
|
||||||
}
|
newIndex -= 1;
|
||||||
final EnvBean item = model.list.removeAt(oldIndex);
|
}
|
||||||
model.list.insert(newIndex, item);
|
final EnvBean item = model.list.removeAt(oldIndex);
|
||||||
model.update(item.sId ?? "", newIndex, oldIndex);
|
model.list.insert(newIndex, item);
|
||||||
});
|
model.update(item.sId ?? "", newIndex, oldIndex);
|
||||||
},
|
},
|
||||||
children: list,
|
);
|
||||||
),
|
},
|
||||||
|
children: list,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
model: envProvider,
|
model: envProvider,
|
||||||
onReady: (viewModel) {
|
onReady: (viewModel) {
|
||||||
viewModel.loadData();
|
viewModel.loadData(true);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget searchCell(WidgetRef context) {
|
Widget searchCell(BuildContext context, WidgetRef ref) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
horizontal: 15,
|
padding: const EdgeInsets.only(
|
||||||
vertical: 10,
|
left: 15,
|
||||||
),
|
),
|
||||||
child: CupertinoSearchTextField(
|
child: Row(
|
||||||
onSubmitted: (value) {
|
children: [
|
||||||
setState(() {});
|
Expanded(
|
||||||
},
|
child: Padding(
|
||||||
onSuffixTap: () {
|
padding: const EdgeInsets.symmetric(
|
||||||
_searchController.text = "";
|
vertical: 10,
|
||||||
setState(() {});
|
),
|
||||||
},
|
child: SearchCell(
|
||||||
controller: _searchController,
|
controller: _searchController,
|
||||||
borderRadius: BorderRadius.circular(
|
),
|
||||||
30,
|
),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.symmetric(
|
Material(
|
||||||
horizontal: 5,
|
color: Colors.transparent,
|
||||||
vertical: 5,
|
child: PopupMenuButton<String>(
|
||||||
),
|
onSelected: (String result) {
|
||||||
suffixInsets: const EdgeInsets.only(
|
currentState = result;
|
||||||
right: 15,
|
setState(() {});
|
||||||
),
|
},
|
||||||
prefixInsets: EdgeInsets.only(
|
itemBuilder: (BuildContext context) => [
|
||||||
top: Platform.isAndroid ? 10 : 6,
|
PopupMenuItem(
|
||||||
bottom: 6,
|
child: Text(
|
||||||
left: 15,
|
EnvViewModel.allStr,
|
||||||
),
|
style: TextStyle(
|
||||||
placeholderStyle: TextStyle(
|
color: currentState == EnvViewModel.allStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 14,
|
||||||
color: context.watch(themeProvider).themeColor.descColor(),
|
),
|
||||||
),
|
),
|
||||||
style: const TextStyle(
|
value: EnvViewModel.allStr,
|
||||||
fontSize: 16,
|
),
|
||||||
),
|
PopupMenuItem(
|
||||||
placeholder: "搜索",
|
child: Text(
|
||||||
|
EnvViewModel.enabledStr,
|
||||||
|
style: TextStyle(
|
||||||
|
color: currentState == EnvViewModel.enabledStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
value: EnvViewModel.enabledStr,
|
||||||
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(
|
||||||
|
EnvViewModel.disabledStr,
|
||||||
|
style: TextStyle(
|
||||||
|
color:
|
||||||
|
currentState == EnvViewModel.disabledStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
value: EnvViewModel.disabledStr,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"筛选",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -143,91 +203,96 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ColoredBox(
|
return Slidable(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
key: ValueKey(bean.sId),
|
||||||
child: Slidable(
|
endActionPane: ActionPane(
|
||||||
key: ValueKey(bean.sId),
|
motion: const StretchMotion(),
|
||||||
endActionPane: ActionPane(
|
extentRatio: 0.5,
|
||||||
motion: const StretchMotion(),
|
children: [
|
||||||
extentRatio: 0.5,
|
SlidableAction(
|
||||||
|
backgroundColor: const Color(0xff5D5E70),
|
||||||
|
onPressed: (_) {
|
||||||
|
Navigator.of(context).pushNamed(Routes.routeAddEnv, arguments: bean);
|
||||||
|
},
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
icon: CupertinoIcons.pencil_outline,
|
||||||
|
),
|
||||||
|
SlidableAction(
|
||||||
|
backgroundColor: const Color(0xffA356D6),
|
||||||
|
onPressed: (_) {
|
||||||
|
enableEnv(context);
|
||||||
|
},
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
icon: bean.status == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||||
|
),
|
||||||
|
SlidableAction(
|
||||||
|
backgroundColor: const Color(0xffEA4D3E),
|
||||||
|
onPressed: (_) {
|
||||||
|
delEnv(context, ref);
|
||||||
|
},
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
icon: CupertinoIcons.delete,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SlidableAction(
|
Material(
|
||||||
backgroundColor: const Color(0xff5D5E70),
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
onPressed: (_) {
|
child: InkWell(
|
||||||
Navigator.of(context).pushNamed(Routes.routeAddEnv, arguments: bean);
|
onTap: () {
|
||||||
},
|
Navigator.of(context).pushNamed(Routes.routeEnvDetail, arguments: bean);
|
||||||
foregroundColor: Colors.white,
|
},
|
||||||
icon: CupertinoIcons.pencil_outline,
|
child: Container(
|
||||||
),
|
padding: const EdgeInsets.symmetric(
|
||||||
SlidableAction(
|
horizontal: 15,
|
||||||
backgroundColor: const Color(0xffA356D6),
|
vertical: 8,
|
||||||
onPressed: (_) {
|
),
|
||||||
enableEnv(context);
|
child: Column(
|
||||||
},
|
mainAxisSize: MainAxisSize.min,
|
||||||
foregroundColor: Colors.white,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
icon: bean.status == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
),
|
children: [
|
||||||
SlidableAction(
|
Row(
|
||||||
backgroundColor: const Color(0xffEA4D3E),
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
onPressed: (_) {
|
children: [
|
||||||
delEnv(context, ref);
|
Expanded(
|
||||||
},
|
child: Row(
|
||||||
foregroundColor: Colors.white,
|
children: [
|
||||||
icon: CupertinoIcons.delete,
|
bean.status == 1
|
||||||
),
|
? const SizedBox(
|
||||||
],
|
width: 18,
|
||||||
),
|
)
|
||||||
child: SizedBox(
|
: Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
padding: const EdgeInsets.symmetric(
|
||||||
child: Column(
|
horizontal: 5,
|
||||||
mainAxisSize: MainAxisSize.min,
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
decoration: BoxDecoration(
|
||||||
children: [
|
borderRadius: BorderRadius.circular(3),
|
||||||
Material(
|
border: Border.all(color: ref.watch(themeProvider).themeColor.descColor(), width: 1),
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
),
|
||||||
child: InkWell(
|
child: Text(
|
||||||
onTap: () {
|
"${getIndexByIndex(context, index)}",
|
||||||
Navigator.of(context).pushNamed(Routes.routeEnvDetail, arguments: bean);
|
style: TextStyle(
|
||||||
},
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
child: Container(
|
fontSize: 12,
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 15,
|
|
||||||
vertical: 8,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
bean.status == 1
|
|
||||||
? const Icon(
|
|
||||||
Icons.dnd_forwardslash,
|
|
||||||
size: 18,
|
|
||||||
color: Color(0xffEA4D3E),
|
|
||||||
)
|
|
||||||
: Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 5,
|
|
||||||
),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
border: Border.all(color: ref.watch(themeProvider).primaryColor, width: 1),
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
"${getIndexByIndex(context, index)}",
|
|
||||||
style: TextStyle(color: ref.watch(themeProvider).primaryColor, fontSize: 12),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
),
|
||||||
width: 5,
|
const SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints.loose(
|
||||||
|
Size.fromWidth(
|
||||||
|
MediaQuery.of(context).size.width / 2,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Material(
|
child: Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
bean.name ?? "",
|
bean.name ?? "",
|
||||||
@@ -239,73 +304,92 @@ class EnvItemCell extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
),
|
||||||
width: 5,
|
const SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints.loose(
|
||||||
|
Size.fromWidth(
|
||||||
|
MediaQuery.of(context).size.width / 3,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
child: Visibility(
|
||||||
child: Visibility(
|
visible: bean.remarks != null && bean.remarks!.isNotEmpty,
|
||||||
visible: bean.remarks != null && bean.remarks!.isNotEmpty,
|
child: Material(
|
||||||
child: Material(
|
color: Colors.transparent,
|
||||||
color: Colors.transparent,
|
child: Text(
|
||||||
child: Text(
|
"(${bean.remarks})",
|
||||||
"(${bean.remarks})",
|
maxLines: 1,
|
||||||
maxLines: 1,
|
style: TextStyle(
|
||||||
style: TextStyle(
|
height: 1,
|
||||||
height: 1,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
fontSize: 12,
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
width: 15,
|
|
||||||
),
|
|
||||||
Material(
|
|
||||||
color: Colors.transparent,
|
|
||||||
child: Text(
|
|
||||||
Utils.formatGMTTime(bean.timestamp ?? ""),
|
|
||||||
maxLines: 1,
|
|
||||||
style: TextStyle(
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
),
|
width: 7,
|
||||||
],
|
),
|
||||||
),
|
bean.status == 1
|
||||||
const SizedBox(
|
? Image.asset(
|
||||||
height: 15,
|
"assets/images/icon_disabled.png",
|
||||||
),
|
fit: BoxFit.cover,
|
||||||
Material(
|
width: 35,
|
||||||
color: Colors.transparent,
|
)
|
||||||
child: Text(
|
: Image.asset(
|
||||||
bean.value ?? "",
|
"assets/images/icon_enable.png",
|
||||||
maxLines: 1,
|
fit: BoxFit.cover,
|
||||||
style: TextStyle(
|
width: 35,
|
||||||
overflow: TextOverflow.ellipsis,
|
)
|
||||||
color: ref.watch(themeProvider).themeColor.descColor(),
|
],
|
||||||
fontSize: 12,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Text(
|
||||||
|
Utils.formatGMTTime(bean.timestamp ?? ""),
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
Material(
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Text(
|
||||||
|
bean.value ?? "",
|
||||||
|
maxLines: 1,
|
||||||
|
style: TextStyle(
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(
|
),
|
||||||
height: 1,
|
const Divider(
|
||||||
indent: 15,
|
height: 1,
|
||||||
),
|
indent: 15,
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
32
lib/module/env/env_viewmodel.dart
vendored
@@ -8,7 +8,13 @@ import 'package:qinglong_app/utils/extension.dart';
|
|||||||
var envProvider = ChangeNotifierProvider((ref) => EnvViewModel());
|
var envProvider = ChangeNotifierProvider((ref) => EnvViewModel());
|
||||||
|
|
||||||
class EnvViewModel extends BaseViewModel {
|
class EnvViewModel extends BaseViewModel {
|
||||||
|
static const String allStr = "全部";
|
||||||
|
static const String disabledStr = "已禁用";
|
||||||
|
static const String enabledStr = "已启用";
|
||||||
List<EnvBean> list = [];
|
List<EnvBean> list = [];
|
||||||
|
List<EnvBean> disabledList = [];
|
||||||
|
List<EnvBean> enabledList = [];
|
||||||
|
|
||||||
|
|
||||||
Future<void> loadData([isLoading = true]) async {
|
Future<void> loadData([isLoading = true]) async {
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
@@ -17,12 +23,19 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
HttpResponse<List<EnvBean>> result = await Api.envs("");
|
HttpResponse<List<EnvBean>> result = await Api.envs("");
|
||||||
|
|
||||||
|
|
||||||
if (result.success && result.bean != null) {
|
if (result.success && result.bean != null) {
|
||||||
list.clear();
|
list.clear();
|
||||||
list.addAll(result.bean!);
|
list.addAll(result.bean!);
|
||||||
|
disabledList.clear();
|
||||||
|
disabledList.addAll(list.where((element) => element.status == 1).toList());
|
||||||
|
enabledList.clear();
|
||||||
|
enabledList.addAll(list.where((element) => element.status == 0).toList());
|
||||||
success();
|
success();
|
||||||
} else {
|
} else {
|
||||||
list.clear();
|
list.clear();
|
||||||
|
disabledList.clear();
|
||||||
|
enabledList.clear();
|
||||||
failed(result.message, notify: true);
|
failed(result.message, notify: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,23 +44,14 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
HttpResponse<NullResponse> result = await Api.delEnv(id);
|
HttpResponse<NullResponse> result = await Api.delEnv(id);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
"删除成功".toast();
|
"删除成功".toast();
|
||||||
list.removeWhere((element) => element.sId == id);
|
loadData(false);
|
||||||
notifyListeners();
|
|
||||||
} else {
|
} else {
|
||||||
failed(result.message, notify: true);
|
failed(result.message, notify: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateEnv(EnvBean result) {
|
void updateEnv(EnvBean result) {
|
||||||
if (result.sId == null) {
|
loadData(false);
|
||||||
loadData(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
EnvBean bean = list.firstWhere((element) => element.sId == result.sId);
|
|
||||||
bean.name = result.name;
|
|
||||||
bean.remarks = result.remarks;
|
|
||||||
bean.value = result.value;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> enableEnv(String sId, int status) async {
|
Future<void> enableEnv(String sId, int status) async {
|
||||||
@@ -56,8 +60,7 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
"启用成功".toast();
|
"启用成功".toast();
|
||||||
list.firstWhere((element) => element.sId == sId).status = 0;
|
loadData(false);
|
||||||
success();
|
|
||||||
} else {
|
} else {
|
||||||
failToast(response.message, notify: true);
|
failToast(response.message, notify: true);
|
||||||
}
|
}
|
||||||
@@ -66,8 +69,7 @@ class EnvViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
"禁用成功".toast();
|
"禁用成功".toast();
|
||||||
list.firstWhere((element) => element.sId == sId).status = 1;
|
loadData(false);
|
||||||
success();
|
|
||||||
} else {
|
} else {
|
||||||
failToast(response.message, notify: true);
|
failToast(response.message, notify: true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,76 +37,99 @@ class _LoginLogPageState extends ConsumerState<LoginLogPage>
|
|||||||
),
|
),
|
||||||
body: list.isEmpty
|
body: list.isEmpty
|
||||||
? const Center(
|
? const Center(
|
||||||
child: CupertinoActivityIndicator(),
|
child: CupertinoActivityIndicator(),
|
||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.separated(
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
LoginLogBean item = list[index];
|
LoginLogBean item = list[index];
|
||||||
|
|
||||||
return ColoredBox(
|
return Row(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
children: [
|
||||||
child: ListTile(
|
const SizedBox(
|
||||||
isThreeLine: true,
|
width: 15,
|
||||||
title: Text(
|
),
|
||||||
Utils.formatMessageTime(item.timestamp ?? 0),
|
Column(
|
||||||
style: TextStyle(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
fontSize: 16,
|
children: [
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
const SizedBox(
|
||||||
),
|
height: 10,
|
||||||
),
|
|
||||||
subtitle: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
SelectableText(
|
|
||||||
"${item.address}",
|
|
||||||
selectionWidthStyle: BoxWidthStyle.max,
|
|
||||||
selectionHeightStyle: BoxHeightStyle.max,
|
|
||||||
style: TextStyle(
|
|
||||||
color:
|
|
||||||
ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
SelectableText(
|
|
||||||
"${item.ip}",
|
|
||||||
selectionWidthStyle: BoxWidthStyle.max,
|
|
||||||
selectionHeightStyle: BoxHeightStyle.max,
|
|
||||||
style: TextStyle(
|
|
||||||
color:
|
|
||||||
ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 14,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
trailing: item.status == 0
|
|
||||||
? Icon(
|
|
||||||
CupertinoIcons.checkmark_circle,
|
|
||||||
color: ref.watch(themeProvider).primaryColor,
|
|
||||||
size: 16,
|
|
||||||
)
|
|
||||||
: const Icon(
|
|
||||||
CupertinoIcons.clear_circled,
|
|
||||||
color: Colors.red,
|
|
||||||
size: 16,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
Row(
|
||||||
},
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
itemCount: list.length,
|
children: [
|
||||||
),
|
Text(
|
||||||
|
"${item.address}",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref
|
||||||
|
.watch(themeProvider)
|
||||||
|
.themeColor
|
||||||
|
.titleColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 2,
|
||||||
|
),
|
||||||
|
child: Image.asset(
|
||||||
|
item.status == 0
|
||||||
|
? "assets/images/icon_success.png"
|
||||||
|
: "assets/images/icon_fail.png",
|
||||||
|
width: 30,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
SelectableText(
|
||||||
|
"${item.ip}",
|
||||||
|
selectionWidthStyle: BoxWidthStyle.max,
|
||||||
|
selectionHeightStyle: BoxHeightStyle.max,
|
||||||
|
style: TextStyle(
|
||||||
|
color:
|
||||||
|
ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
Text(
|
||||||
|
Utils.formatMessageTime(item.timestamp ?? 0),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
itemCount: list.length,
|
||||||
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
|
return const Divider(
|
||||||
|
indent: 15,
|
||||||
|
height: 1,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadData() async {
|
Future<void> loadData() async {
|
||||||
HttpResponse<List<LoginLogBean>> response = await Api.loginLog();
|
HttpResponse<List<LoginLogBean>> response =
|
||||||
|
await Api.loginLog();
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
if (response.bean == null || response.bean!.isEmpty) {
|
if (response.bean == null || response.bean!.isEmpty) {
|
||||||
|
|||||||
@@ -26,15 +26,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.symmetric(
|
margin: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
|
||||||
vertical: 15,
|
vertical: 15,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
|
||||||
borderRadius: const BorderRadius.all(
|
|
||||||
Radius.circular(15),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -225,15 +218,8 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.symmetric(
|
margin: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
|
||||||
vertical: 15,
|
vertical: 15,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: ref.watch(themeProvider).themeColor.settingBordorColor(),
|
|
||||||
borderRadius: const BorderRadius.all(
|
|
||||||
Radius.circular(15),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -304,6 +290,41 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
const Divider(
|
const Divider(
|
||||||
indent: 15,
|
indent: 15,
|
||||||
),
|
),
|
||||||
|
GestureDetector(
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pushNamed(Routes.routeChangeAccount);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 15,
|
||||||
|
right: 15,
|
||||||
|
top: 5,
|
||||||
|
bottom: 5,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"切换账号",
|
||||||
|
style: TextStyle(
|
||||||
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Spacer(),
|
||||||
|
const Icon(
|
||||||
|
CupertinoIcons.right_chevron,
|
||||||
|
size: 16,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
indent: 15,
|
||||||
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:qinglong_app/base/ql_app_bar.dart';
|
|||||||
import 'package:qinglong_app/base/routes.dart';
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
import 'package:qinglong_app/base/theme.dart';
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
import 'package:qinglong_app/base/ui/lazy_load_state.dart';
|
import 'package:qinglong_app/base/ui/lazy_load_state.dart';
|
||||||
|
import 'package:qinglong_app/base/ui/search_cell.dart';
|
||||||
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
import 'package:qinglong_app/module/others/scripts/script_bean.dart';
|
||||||
import 'package:qinglong_app/utils/extension.dart';
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
|
||||||
@@ -170,39 +171,7 @@ class _ScriptPageState extends ConsumerState<ScriptPage> with LazyLoadState<Scri
|
|||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
vertical: 10,
|
vertical: 10,
|
||||||
),
|
),
|
||||||
child: CupertinoSearchTextField(
|
child:SearchCell(controller: _searchController,),
|
||||||
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(
|
|
||||||
right: 15,
|
|
||||||
),
|
|
||||||
prefixInsets: const EdgeInsets.only(
|
|
||||||
top: 6,
|
|
||||||
bottom: 6,
|
|
||||||
left: 15,
|
|
||||||
),
|
|
||||||
placeholderStyle: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: context.watch(themeProvider).themeColor.descColor(),
|
|
||||||
),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
placeholder: "搜索",
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import 'package:qinglong_app/base/ql_app_bar.dart';
|
|||||||
import 'package:qinglong_app/base/routes.dart';
|
import 'package:qinglong_app/base/routes.dart';
|
||||||
import 'package:qinglong_app/base/theme.dart';
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
import 'package:qinglong_app/base/ui/lazy_load_state.dart';
|
import 'package:qinglong_app/base/ui/lazy_load_state.dart';
|
||||||
|
import 'package:qinglong_app/base/ui/search_cell.dart';
|
||||||
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
import 'package:qinglong_app/module/others/task_log/task_log_bean.dart';
|
||||||
import 'package:qinglong_app/utils/extension.dart';
|
import 'package:qinglong_app/utils/extension.dart';
|
||||||
|
|
||||||
@@ -20,6 +21,27 @@ class TaskLogPage extends ConsumerStatefulWidget {
|
|||||||
|
|
||||||
class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<TaskLogPage> {
|
class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<TaskLogPage> {
|
||||||
List<TaskLogBean> list = [];
|
List<TaskLogBean> list = [];
|
||||||
|
final TextEditingController _searchController = TextEditingController();
|
||||||
|
|
||||||
|
Widget searchCell(WidgetRef context) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 15,
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
child: SearchCell(
|
||||||
|
controller: _searchController,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_searchController.addListener(() {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -37,72 +59,79 @@ class _TaskLogPageState extends ConsumerState<TaskLogPage> with LazyLoadState<Ta
|
|||||||
)
|
)
|
||||||
: ListView.builder(
|
: ListView.builder(
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
TaskLogBean item = list[index];
|
if (index == 0) {
|
||||||
|
return searchCell(ref);
|
||||||
|
}
|
||||||
|
TaskLogBean item = list[index - 1];
|
||||||
|
if (_searchController.text.isNotEmpty && !(item.name?.contains(_searchController.text) ?? false)) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: (item.isDir ?? false)
|
child: (item.isDir ?? false)
|
||||||
? ExpansionTile(
|
? ExpansionTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
item.name ?? "",
|
item.name ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
children: (item.files?.isNotEmpty ?? false)
|
children: (item.files?.isNotEmpty ?? false)
|
||||||
? item.files!
|
? item.files!
|
||||||
.map((e) => ListTile(
|
.map((e) => ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
||||||
"path": item.name,
|
"path": item.name,
|
||||||
"title": e,
|
"title": e,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: Text(
|
title: Text(
|
||||||
e,
|
e,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.toList()
|
.toList()
|
||||||
: (item.children ?? [])
|
: (item.children ?? [])
|
||||||
.map((e) => ListTile(
|
.map((e) => ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
||||||
"path": item.name,
|
"path": item.name,
|
||||||
"title": e.title,
|
"title": e.title,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
title: Text(
|
title: Text(
|
||||||
e.title ?? "",
|
e.title ?? "",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
)
|
)
|
||||||
: ListTile(
|
: ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (item.isDir ?? false) {
|
if (item.isDir ?? false) {
|
||||||
"该文件夹为空".toast();
|
"该文件夹为空".toast();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskLogDetail, arguments: item.name);
|
"path": "",
|
||||||
},
|
"title": item.name,
|
||||||
title: Text(
|
});
|
||||||
item.name ?? "",
|
},
|
||||||
style: TextStyle(
|
title: Text(
|
||||||
color: ref.watch(themeProvider).themeColor.titleColor(),
|
item.name ?? "",
|
||||||
fontSize: 16,
|
style: TextStyle(
|
||||||
),
|
color: ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
),
|
fontSize: 16,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
itemCount: list.length,
|
itemCount: list.length,
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ class InTimeLogPage extends StatefulWidget {
|
|||||||
final String cronId;
|
final String cronId;
|
||||||
final bool needTimer;
|
final bool needTimer;
|
||||||
|
|
||||||
const InTimeLogPage(this.cronId, this.needTimer, {Key? key})
|
const InTimeLogPage(this.cronId, this.needTimer, {Key? key}) : super(key: key);
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_InTimeLogPageState createState() => _InTimeLogPageState();
|
_InTimeLogPageState createState() => _InTimeLogPageState();
|
||||||
@@ -25,28 +24,28 @@ class _InTimeLogPageState extends State<InTimeLogPage> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
_timer = Timer.periodic(
|
||||||
if (widget.needTimer) {
|
const Duration(seconds: 2),
|
||||||
_timer = Timer.periodic(
|
(timer) {
|
||||||
const Duration(seconds: 2),
|
|
||||||
(timer) {
|
|
||||||
getLogData();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
|
||||||
getLogData();
|
getLogData();
|
||||||
});
|
},
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isRequest = false;
|
||||||
|
bool canRequest = true;
|
||||||
|
|
||||||
getLogData() async {
|
getLogData() async {
|
||||||
|
if (!canRequest) return;
|
||||||
|
if (isRequest) return;
|
||||||
|
isRequest = true;
|
||||||
HttpResponse<String> response = await Api.inTimeLog(widget.cronId);
|
HttpResponse<String> response = await Api.inTimeLog(widget.cronId);
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
content = response.bean;
|
content = response.bean;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
isRequest = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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/routes.dart';
|
||||||
import 'package:qinglong_app/base/theme.dart';
|
import 'package:qinglong_app/base/theme.dart';
|
||||||
|
import 'package:qinglong_app/base/ui/search_cell.dart';
|
||||||
import 'package:qinglong_app/module/task/intime_log/intime_log_page.dart';
|
import 'package:qinglong_app/module/task/intime_log/intime_log_page.dart';
|
||||||
import 'package:qinglong_app/module/task/task_bean.dart';
|
import 'package:qinglong_app/module/task/task_bean.dart';
|
||||||
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
import 'package:qinglong_app/module/task/task_viewmodel.dart';
|
||||||
@@ -50,7 +51,7 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
return model.loadData( false);
|
return model.loadData(false);
|
||||||
},
|
},
|
||||||
child: IconTheme(
|
child: IconTheme(
|
||||||
data: const IconThemeData(
|
data: const IconThemeData(
|
||||||
@@ -100,45 +101,20 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
|
|
||||||
Widget searchCell(WidgetRef context) {
|
Widget searchCell(WidgetRef context) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
horizontal: 15,
|
padding: const EdgeInsets.only(
|
||||||
vertical: 10,
|
left: 15,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: CupertinoSearchTextField(
|
child: Padding(
|
||||||
onSubmitted: (value) {
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
onSuffixTap: () {
|
|
||||||
_searchController.text = "";
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
controller: _searchController,
|
|
||||||
borderRadius: BorderRadius.circular(
|
|
||||||
30,
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 5,
|
vertical: 10,
|
||||||
vertical: 5,
|
|
||||||
),
|
),
|
||||||
suffixInsets: const EdgeInsets.only(
|
child: SearchCell(
|
||||||
right: 15,
|
controller: _searchController,
|
||||||
),
|
),
|
||||||
prefixInsets: EdgeInsets.only(
|
|
||||||
top: Platform.isAndroid ? 10 : 6,
|
|
||||||
bottom: 6,
|
|
||||||
left: 15,
|
|
||||||
),
|
|
||||||
placeholderStyle: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: context.watch(themeProvider).themeColor.descColor(),
|
|
||||||
),
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
),
|
|
||||||
placeholder: "搜索",
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Material(
|
Material(
|
||||||
@@ -164,7 +140,7 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
TaskViewModel.runningStr,
|
TaskViewModel.runningStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color:
|
||||||
currentState == TaskViewModel.runningStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
currentState == TaskViewModel.runningStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -202,15 +178,16 @@ class _TaskPageState extends ConsumerState<TaskPage> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
color:
|
color:
|
||||||
currentState == TaskViewModel.disableStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
currentState == TaskViewModel.disableStr ? ref.watch(themeProvider).primaryColor : ref.watch(themeProvider).themeColor.titleColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
value: TaskViewModel.disableStr,
|
value: TaskViewModel.disableStr,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.symmetric(
|
||||||
left: 10,
|
horizontal: 15,
|
||||||
|
vertical: 10,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
"筛选",
|
"筛选",
|
||||||
@@ -258,7 +235,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ColoredBox(
|
return ColoredBox(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: Slidable(
|
child: Slidable(
|
||||||
key: ValueKey(bean.sId),
|
key: ValueKey(bean.sId),
|
||||||
endActionPane: ActionPane(
|
endActionPane: ActionPane(
|
||||||
@@ -268,7 +245,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xff5D5E70),
|
backgroundColor: const Color(0xff5D5E70),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance?.endOfFrame.then((timeStamp) {
|
||||||
Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean);
|
Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -278,19 +255,15 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xffF19A39),
|
backgroundColor: const Color(0xffF19A39),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
pinTask(context);
|
||||||
pinTask(context);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: bean.isPinned! == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash,
|
icon: (bean.isPinned ?? 0) == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash,
|
||||||
),
|
),
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xffA356D6),
|
backgroundColor: const Color(0xffA356D6),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
enableTask(context);
|
||||||
enableTask(context);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
icon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||||
@@ -298,9 +271,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xffEA4D3E),
|
backgroundColor: const Color(0xffEA4D3E),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
delTask(context, ref);
|
||||||
delTask(context, ref);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: CupertinoIcons.delete,
|
icon: CupertinoIcons.delete,
|
||||||
@@ -314,13 +285,17 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xffD25535),
|
backgroundColor: const Color(0xffD25535),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
if (bean.status! == 1) {
|
||||||
if (bean.status! == 1) {
|
startCron(
|
||||||
startCron(context, ref);
|
context,
|
||||||
} else {
|
ref,
|
||||||
stopCron(context, ref);
|
);
|
||||||
}
|
} else {
|
||||||
});
|
stopCron(
|
||||||
|
context,
|
||||||
|
ref,
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle,
|
icon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle,
|
||||||
@@ -328,7 +303,10 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
SlidableAction(
|
SlidableAction(
|
||||||
backgroundColor: const Color(0xff606467),
|
backgroundColor: const Color(0xff606467),
|
||||||
onPressed: (_) {
|
onPressed: (_) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
Future.delayed(
|
||||||
|
const Duration(
|
||||||
|
milliseconds: 250,
|
||||||
|
), () {
|
||||||
logCron(context, ref);
|
logCron(context, ref);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -338,14 +316,14 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Material(
|
child: Material(
|
||||||
color: ref.watch(themeProvider).themeColor.settingBgColor(),
|
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : ref.watch(themeProvider).themeColor.settingBgColor(),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(Routes.routeTaskDetail, arguments: bean);
|
Navigator.of(context).pushNamed(Routes.routeTaskDetail, arguments: bean);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent,
|
color: Colors.transparent,
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
vertical: 8,
|
vertical: 8,
|
||||||
@@ -363,30 +341,12 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
bean.isDisabled == 1
|
ConstrainedBox(
|
||||||
? const Icon(
|
constraints: BoxConstraints.loose(
|
||||||
Icons.dnd_forwardslash,
|
Size.fromWidth(
|
||||||
size: 18,
|
MediaQuery.of(context).size.width / 2,
|
||||||
color: Color(0xffEA4D3E),
|
),
|
||||||
)
|
),
|
||||||
: const SizedBox.shrink(),
|
|
||||||
SizedBox(
|
|
||||||
width: bean.isDisabled == 1 ? 5 : 0,
|
|
||||||
),
|
|
||||||
bean.status == 1
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: SizedBox(
|
|
||||||
width: 13,
|
|
||||||
height: 13,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 2,
|
|
||||||
color: ref.watch(themeProvider).primaryColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: bean.status == 1 ? 0 : 5,
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Material(
|
child: Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -401,6 +361,30 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 7,
|
||||||
|
),
|
||||||
|
bean.status == 0
|
||||||
|
? Image.asset(
|
||||||
|
"assets/images/icon_running.png",
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
width: 45,
|
||||||
|
)
|
||||||
|
: Image.asset(
|
||||||
|
"assets/images/icon_idle.png",
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
width: 45,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 7,
|
||||||
|
),
|
||||||
|
bean.isDisabled == 1
|
||||||
|
? Image.asset(
|
||||||
|
"assets/images/icon_task_disable.png",
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
width: 45,
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -459,52 +443,50 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startCron(BuildContext context, WidgetRef ref) async {
|
startCron(BuildContext context, WidgetRef ref) async {
|
||||||
await ref.read(taskProvider).runCrons( bean.sId!);
|
await ref.read(taskProvider).runCrons(bean.sId!);
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
Future.delayed(const Duration(milliseconds: 250), () {
|
||||||
logCron(context, ref);
|
logCron(context, ref);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
stopCron(BuildContext context, WidgetRef ref) {
|
stopCron(BuildContext context, WidgetRef ref) {
|
||||||
ref.read(taskProvider).stopCrons( bean.sId!);
|
ref.read(taskProvider).stopCrons(bean.sId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
logCron(BuildContext context, WidgetRef ref) {
|
logCron(BuildContext context, WidgetRef ref) {
|
||||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
showCupertinoDialog(
|
||||||
showCupertinoDialog(
|
useRootNavigator: false,
|
||||||
useRootNavigator: false,
|
builder: (BuildContext context) {
|
||||||
builder: (BuildContext context) {
|
return CupertinoAlertDialog(
|
||||||
return CupertinoAlertDialog(
|
title: Text(
|
||||||
title: Text(
|
"${bean.name}运行日志",
|
||||||
"${bean.name}运行日志",
|
maxLines: 1,
|
||||||
maxLines: 1,
|
style: const TextStyle(overflow: TextOverflow.ellipsis),
|
||||||
style: const TextStyle(overflow: TextOverflow.ellipsis),
|
),
|
||||||
),
|
content: InTimeLogPage(bean.sId!, bean.status == 0),
|
||||||
content: InTimeLogPage(bean.sId!, bean.status == 0),
|
actions: [
|
||||||
actions: [
|
CupertinoDialogAction(
|
||||||
CupertinoDialogAction(
|
child: Text(
|
||||||
child: Text(
|
"知道了",
|
||||||
"知道了",
|
style: TextStyle(color: Theme.of(context).primaryColor),
|
||||||
style: TextStyle(color: Theme.of(context).primaryColor),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
ref.read(taskProvider).loadData( false);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
onPressed: () {
|
||||||
);
|
Navigator.of(context).pop();
|
||||||
},
|
ref.read(taskProvider).loadData(false);
|
||||||
context: context);
|
},
|
||||||
});
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
context: context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableTask(BuildContext context) {
|
void enableTask(BuildContext context) {
|
||||||
ref.read(taskProvider).enableTask( bean.sId!, bean.isDisabled!);
|
ref.read(taskProvider).enableTask(bean.sId!, bean.isDisabled!);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pinTask(BuildContext context) {
|
void pinTask(BuildContext context) {
|
||||||
ref.read(taskProvider).pinTask( bean.sId!, bean.isPinned!);
|
ref.read(taskProvider).pinTask(bean.sId!, bean.isPinned!);
|
||||||
}
|
}
|
||||||
|
|
||||||
void delTask(BuildContext context, WidgetRef ref) {
|
void delTask(BuildContext context, WidgetRef ref) {
|
||||||
|
|||||||