mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
add checkbox
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
String sp_UserINfo = "userinfo";
|
String spUserInfo = "userinfo";
|
||||||
String sp_Host = "host";
|
String spHost = "host";
|
||||||
String sp_Theme = "dart_mode";
|
String spUserName = "username";
|
||||||
|
String spPassWord = "password";
|
||||||
|
String spTheme = "dart_mode";
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isInDartMode() {
|
bool isInDartMode() {
|
||||||
return SpUtil.getBool(sp_Theme, defValue: false);
|
return SpUtil.getBool(spTheme, defValue: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeThemeReal(bool dark, [bool notify = true]) {
|
void changeThemeReal(bool dark, [bool notify = true]) {
|
||||||
SpUtil.putBool(sp_Theme, dark);
|
SpUtil.putBool(spTheme, dark);
|
||||||
if (!dark) {
|
if (!dark) {
|
||||||
currentTheme = lightTheme;
|
currentTheme = lightTheme;
|
||||||
themeColor = LightThemeColors();
|
themeColor = LightThemeColors();
|
||||||
@@ -39,7 +39,7 @@ class ThemeViewModel extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void changeTheme() {
|
void changeTheme() {
|
||||||
changeThemeReal(!SpUtil.getBool(sp_Theme, defValue: false), true);
|
changeThemeReal(!SpUtil.getBool(spTheme, defValue: false), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +76,20 @@ ThemeData darkTheme = ThemeData.dark().copyWith(
|
|||||||
secondary: _primaryColor,
|
secondary: _primaryColor,
|
||||||
primary: _primaryColor,
|
primary: _primaryColor,
|
||||||
),
|
),
|
||||||
|
toggleableActiveColor: _primaryColor,
|
||||||
|
checkboxTheme: CheckboxThemeData(
|
||||||
|
checkColor: MaterialStateProperty.resolveWith(
|
||||||
|
(Set<MaterialState> states) {
|
||||||
|
if (states.contains(MaterialState.disabled)) {
|
||||||
|
return Colors.transparent;
|
||||||
|
}
|
||||||
|
if (states.contains(MaterialState.selected)) {
|
||||||
|
return Colors.white;
|
||||||
|
}
|
||||||
|
return Colors.white;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
ThemeData lightTheme = ThemeData.light().copyWith(
|
ThemeData lightTheme = ThemeData.light().copyWith(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
@@ -122,6 +136,20 @@ ThemeData lightTheme = ThemeData.light().copyWith(
|
|||||||
borderSide: BorderSide(color: _primaryColor),
|
borderSide: BorderSide(color: _primaryColor),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
toggleableActiveColor: _primaryColor,
|
||||||
|
checkboxTheme: CheckboxThemeData(
|
||||||
|
checkColor: MaterialStateProperty.resolveWith(
|
||||||
|
(Set<MaterialState> states) {
|
||||||
|
if (states.contains(MaterialState.disabled)) {
|
||||||
|
return Colors.transparent;
|
||||||
|
}
|
||||||
|
if (states.contains(MaterialState.selected)) {
|
||||||
|
return Colors.white;
|
||||||
|
}
|
||||||
|
return Colors.black;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
abstract class ThemeColors {
|
abstract class ThemeColors {
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ import 'sp_const.dart';
|
|||||||
class UserInfoViewModel {
|
class UserInfoViewModel {
|
||||||
String? _token;
|
String? _token;
|
||||||
String? _host = "";
|
String? _host = "";
|
||||||
|
String? _userName;
|
||||||
|
String? _passWord;
|
||||||
|
|
||||||
UserInfoViewModel() {
|
UserInfoViewModel() {
|
||||||
String userInfoJson = SpUtil.getString(sp_UserINfo);
|
String userInfoJson = SpUtil.getString(spUserInfo);
|
||||||
_host = SpUtil.getString(sp_Host, defValue: "http://49.234.59.95:5700");
|
_userName = SpUtil.getString(spUserName);
|
||||||
|
_passWord = SpUtil.getString(spPassWord);
|
||||||
|
_host = SpUtil.getString(spHost, defValue: "http://49.234.59.95:5700");
|
||||||
if (userInfoJson.isNotEmpty) {
|
if (userInfoJson.isNotEmpty) {
|
||||||
_token = userInfoJson;
|
_token = userInfoJson;
|
||||||
}
|
}
|
||||||
@@ -16,18 +20,29 @@ class UserInfoViewModel {
|
|||||||
|
|
||||||
void updateToken(String token) {
|
void updateToken(String token) {
|
||||||
_token = token;
|
_token = token;
|
||||||
SpUtil.putString(sp_UserINfo, token);
|
SpUtil.putString(spUserInfo, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateUserName(String userName, String password) {
|
||||||
|
_userName = userName;
|
||||||
|
_passWord = password;
|
||||||
|
SpUtil.putString(spUserName, userName);
|
||||||
|
SpUtil.putString(spPassWord, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateHost(String host) {
|
void updateHost(String host) {
|
||||||
_host = host;
|
_host = host;
|
||||||
SpUtil.putString(sp_Host, host);
|
SpUtil.putString(spHost, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
String? get token => _token;
|
String? get token => _token;
|
||||||
|
|
||||||
String? get host => _host;
|
String? get host => _host;
|
||||||
|
|
||||||
|
String? get userName => _userName;
|
||||||
|
|
||||||
|
String? get passWord => _passWord;
|
||||||
|
|
||||||
bool isLogined() {
|
bool isLogined() {
|
||||||
return token != null && token!.isNotEmpty;
|
return token != null && token!.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|||||||
4
lib/module/env/add_env_page.dart
vendored
4
lib/module/env/add_env_page.dart
vendored
@@ -67,7 +67,8 @@ class _AddEnvPageState extends ConsumerState<AddEnvPage> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: Column(
|
body: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
@@ -172,6 +173,7 @@ class _AddEnvPageState extends ConsumerState<AddEnvPage> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,25 @@ class LoginPage extends ConsumerStatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LoginPageState extends ConsumerState<LoginPage> {
|
class _LoginPageState extends ConsumerState<LoginPage> {
|
||||||
final TextEditingController _hostController =
|
final TextEditingController _hostController = TextEditingController(text: getIt<UserInfoViewModel>().host);
|
||||||
TextEditingController(text: getIt<UserInfoViewModel>().host);
|
|
||||||
final TextEditingController _userNameController = TextEditingController();
|
final TextEditingController _userNameController = TextEditingController();
|
||||||
final TextEditingController _passwordController = TextEditingController();
|
final TextEditingController _passwordController = TextEditingController();
|
||||||
|
|
||||||
|
bool rememberPassword = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
if (getIt<UserInfoViewModel>().userName != null && getIt<UserInfoViewModel>().userName!.isNotEmpty) {
|
||||||
|
_userNameController.text = getIt<UserInfoViewModel>().userName!;
|
||||||
|
rememberPassword = true;
|
||||||
|
} else {
|
||||||
|
rememberPassword = false;
|
||||||
|
}
|
||||||
|
if (getIt<UserInfoViewModel>().passWord != null && getIt<UserInfoViewModel>().passWord!.isNotEmpty) {
|
||||||
|
_passwordController.text = getIt<UserInfoViewModel>().passWord!;
|
||||||
|
}
|
||||||
getIt<UserInfoViewModel>().updateToken("");
|
getIt<UserInfoViewModel>().updateToken("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +107,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: MediaQuery.of(context).size.height / 10,
|
height: MediaQuery.of(context).size.height / 15,
|
||||||
),
|
),
|
||||||
const Text(
|
const Text(
|
||||||
"域名:",
|
"域名:",
|
||||||
@@ -105,9 +116,6 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
TextField(
|
TextField(
|
||||||
onChanged: (_) {
|
onChanged: (_) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -120,7 +128,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
autofocus: false,
|
autofocus: false,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 15,
|
||||||
),
|
),
|
||||||
const Text(
|
const Text(
|
||||||
"用户名:",
|
"用户名:",
|
||||||
@@ -129,9 +137,6 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
TextField(
|
TextField(
|
||||||
onChanged: (_) {
|
onChanged: (_) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -144,7 +149,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
autofocus: false,
|
autofocus: false,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 15,
|
||||||
),
|
),
|
||||||
const Text(
|
const Text(
|
||||||
"密码:",
|
"密码:",
|
||||||
@@ -153,9 +158,6 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
TextField(
|
TextField(
|
||||||
onChanged: (_) {
|
onChanged: (_) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
@@ -168,28 +170,41 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
),
|
),
|
||||||
autofocus: false,
|
autofocus: false,
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Checkbox(
|
||||||
|
value: rememberPassword,
|
||||||
|
onChanged: (checked) {
|
||||||
|
rememberPassword = checked ?? false;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"记住密码",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 30,
|
height: 30,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: MediaQuery.of(context).size.width - 80,
|
width: MediaQuery.of(context).size.width - 80,
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
ignoring: _hostController.text.isEmpty ||
|
ignoring: _hostController.text.isEmpty || _userNameController.text.isEmpty || _passwordController.text.isEmpty || isLoading,
|
||||||
_userNameController.text.isEmpty ||
|
|
||||||
_passwordController.text.isEmpty ||
|
|
||||||
isLoading,
|
|
||||||
child: CupertinoButton(
|
child: CupertinoButton(
|
||||||
color: (_hostController.text.isNotEmpty &&
|
padding: const EdgeInsets.symmetric(
|
||||||
_userNameController.text.isNotEmpty &&
|
vertical: 5,
|
||||||
_passwordController.text.isNotEmpty &&
|
),
|
||||||
!isLoading)
|
color:
|
||||||
? ref
|
(_hostController.text.isNotEmpty && _userNameController.text.isNotEmpty && _passwordController.text.isNotEmpty && !isLoading)
|
||||||
.watch(themeProvider)
|
? ref.watch(themeProvider).themeColor.buttonBgColor()
|
||||||
.themeColor
|
: Theme.of(context).primaryColor.withOpacity(0.4),
|
||||||
.buttonBgColor()
|
|
||||||
: Theme.of(context)
|
|
||||||
.primaryColor
|
|
||||||
.withOpacity(0.4),
|
|
||||||
child: isLoading
|
child: isLoading
|
||||||
? const CupertinoActivityIndicator()
|
? const CupertinoActivityIndicator()
|
||||||
: const Text(
|
: const Text(
|
||||||
@@ -199,12 +214,14 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
if (rememberPassword) {
|
||||||
|
getIt<UserInfoViewModel>().updateUserName(_userNameController.text, _passwordController.text);
|
||||||
|
}
|
||||||
|
|
||||||
Http.pushedLoginPage = false;
|
Http.pushedLoginPage = false;
|
||||||
Utils.hideKeyBoard(context);
|
Utils.hideKeyBoard(context);
|
||||||
getIt<UserInfoViewModel>()
|
getIt<UserInfoViewModel>().updateHost(_hostController.text);
|
||||||
.updateHost(_hostController.text);
|
login(_userNameController.text, _passwordController.text);
|
||||||
login(_userNameController.text,
|
|
||||||
_passwordController.text);
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -204,6 +204,7 @@ class _OtherPageState extends ConsumerState<OtherPage> {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width - 40,
|
width: MediaQuery.of(context).size.width - 40,
|
||||||
child: CupertinoButton(
|
child: CupertinoButton(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 5,),
|
||||||
color: ref.watch(themeProvider).themeColor.buttonBgColor(),
|
color: ref.watch(themeProvider).themeColor.buttonBgColor(),
|
||||||
child: const Text(
|
child: const Text(
|
||||||
"退出登录",
|
"退出登录",
|
||||||
|
|||||||
@@ -104,8 +104,7 @@ class _TaskPageState extends State<TaskPage> {
|
|||||||
if (_searchController.text.isEmpty ||
|
if (_searchController.text.isEmpty ||
|
||||||
(item.name?.contains(_searchController.text) ?? false) ||
|
(item.name?.contains(_searchController.text) ?? false) ||
|
||||||
(item.command?.contains(_searchController.text) ?? false) ||
|
(item.command?.contains(_searchController.text) ?? false) ||
|
||||||
(item.schedule?.contains(_searchController.text) ??
|
(item.schedule?.contains(_searchController.text) ?? false)) {
|
||||||
false)) {
|
|
||||||
return TaskItemCell(item, ref);
|
return TaskItemCell(item, ref);
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
@@ -175,9 +174,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
bean.status! == 1 ? "运行" : "停止运行",
|
bean.status! == 1 ? "运行" : "停止运行",
|
||||||
),
|
),
|
||||||
trailingIcon: bean.status! == 1
|
trailingIcon: bean.status! == 1 ? CupertinoIcons.memories : CupertinoIcons.stop_circle,
|
||||||
? CupertinoIcons.memories
|
|
||||||
: CupertinoIcons.stop_circle,
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
startCron(context, ref);
|
startCron(context, ref);
|
||||||
@@ -195,8 +192,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
child: const Text("编辑"),
|
child: const Text("编辑"),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context)
|
Navigator.of(context).pushNamed(Routes.routeAddTask, arguments: bean);
|
||||||
.pushNamed(Routes.routeAddTask, arguments: bean);
|
|
||||||
},
|
},
|
||||||
trailingIcon: CupertinoIcons.pencil_outline,
|
trailingIcon: CupertinoIcons.pencil_outline,
|
||||||
),
|
),
|
||||||
@@ -206,9 +202,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
pinTask();
|
pinTask();
|
||||||
},
|
},
|
||||||
trailingIcon: bean.isPinned! == 0
|
trailingIcon: bean.isPinned! == 0 ? CupertinoIcons.pin : CupertinoIcons.pin_slash,
|
||||||
? CupertinoIcons.pin
|
|
||||||
: CupertinoIcons.pin_slash,
|
|
||||||
),
|
),
|
||||||
QLCupertinoContextMenuAction(
|
QLCupertinoContextMenuAction(
|
||||||
child: Text(bean.isDisabled! == 0 ? "禁用" : "启用"),
|
child: Text(bean.isDisabled! == 0 ? "禁用" : "启用"),
|
||||||
@@ -217,9 +211,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
enableTask();
|
enableTask();
|
||||||
},
|
},
|
||||||
isDestructiveAction: true,
|
isDestructiveAction: true,
|
||||||
trailingIcon: bean.isDisabled! == 0
|
trailingIcon: bean.isDisabled! == 0 ? Icons.dnd_forwardslash : Icons.check_circle_outline_sharp,
|
||||||
? Icons.dnd_forwardslash
|
|
||||||
: Icons.check_circle_outline_sharp,
|
|
||||||
),
|
),
|
||||||
QLCupertinoContextMenuAction(
|
QLCupertinoContextMenuAction(
|
||||||
child: const Text("删除"),
|
child: const Text("删除"),
|
||||||
@@ -233,20 +225,33 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
previewBuilder: (context, anima, child) {
|
previewBuilder: (context, anima, child) {
|
||||||
return IntrinsicWidth(
|
return IntrinsicWidth(
|
||||||
child: Material(
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
bean.name ?? "",
|
bean.name ?? "",
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: bean.isDisabled == 1
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
? const Color(0xffF85152)
|
|
||||||
: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
bean.isDisabled == 1
|
||||||
|
? const Icon(
|
||||||
|
Icons.dnd_forwardslash,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.red,
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -254,9 +259,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
color: bean.isPinned == 1
|
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent,
|
||||||
? ref.watch(themeProvider).themeColor.pinColor()
|
|
||||||
: Colors.transparent,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 15,
|
horizontal: 15,
|
||||||
vertical: 8,
|
vertical: 8,
|
||||||
@@ -276,12 +279,7 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color: bean.isDisabled == 1
|
color: ref.watch(themeProvider).themeColor.taskTitleColor(),
|
||||||
? const Color(0xffF85152)
|
|
||||||
: ref
|
|
||||||
.watch(themeProvider)
|
|
||||||
.themeColor
|
|
||||||
.taskTitleColor(),
|
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -302,16 +300,11 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
Material(
|
Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
(bean.lastExecutionTime == null ||
|
(bean.lastExecutionTime == null || bean.lastExecutionTime == 0) ? "-" : Utils.formatMessageTime(bean.lastExecutionTime!),
|
||||||
bean.lastExecutionTime == 0)
|
|
||||||
? "-"
|
|
||||||
: Utils.formatMessageTime(
|
|
||||||
bean.lastExecutionTime!),
|
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
color:
|
color: ref.watch(themeProvider).themeColor.descColor(),
|
||||||
ref.watch(themeProvider).themeColor.descColor(),
|
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -321,6 +314,8 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8,
|
height: 8,
|
||||||
),
|
),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
Material(
|
Material(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -333,6 +328,18 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
bean.isDisabled == 1
|
||||||
|
? const Icon(
|
||||||
|
Icons.dnd_forwardslash,
|
||||||
|
size: 12,
|
||||||
|
color: Colors.red,
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -424,46 +431,6 @@ class TaskItemCell extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
more(BuildContext context, WidgetRef ref) {
|
|
||||||
showCupertinoModalPopup<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) => CupertinoActionSheet(
|
|
||||||
title: const Text('更多操作'),
|
|
||||||
actions: <CupertinoActionSheetAction>[
|
|
||||||
CupertinoActionSheetAction(
|
|
||||||
child: const Text('编辑'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushNamed(Routes.routeAddTask, arguments: bean);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CupertinoActionSheetAction(
|
|
||||||
child: Text(bean.isDisabled! == 1 ? "启用" : "禁用"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
enableTask();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CupertinoActionSheetAction(
|
|
||||||
child: const Text('删除'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
delTask(context, ref);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
CupertinoActionSheetAction(
|
|
||||||
child: Text(bean.isPinned! == 0 ? "置顶" : "取消置顶"),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
pinTask();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void enableTask() {
|
void enableTask() {
|
||||||
ref.read(taskProvider).enableTask(bean.sId!, bean.isDisabled!);
|
ref.read(taskProvider).enableTask(bean.sId!, bean.isDisabled!);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,17 @@ class TaskViewModel extends BaseViewModel {
|
|||||||
list.sort((a, b) {
|
list.sort((a, b) {
|
||||||
return b.created!.compareTo(a.created!);
|
return b.created!.compareTo(a.created!);
|
||||||
});
|
});
|
||||||
list.sort((a, b) {
|
// list.sort((a, b) {
|
||||||
return b.isPinned!.compareTo(a.isPinned!);
|
// return b.isPinned!.compareTo(a.isPinned!);
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
for (int i = 0; i < list.length; i++) {
|
||||||
|
if (list[i].isPinned == 1) {
|
||||||
|
final TaskBean item = list.removeAt(i);
|
||||||
|
list.insert(0, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
running.clear();
|
running.clear();
|
||||||
running.addAll(list.where((element) => element.status == 0));
|
running.addAll(list.where((element) => element.status == 0));
|
||||||
disabled.clear();
|
disabled.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user