优化样式

This commit is contained in:
jyuesong
2022-01-20 13:33:52 +08:00
parent 4f8285fcf1
commit 130459d646
13 changed files with 241 additions and 66 deletions

View File

@@ -235,13 +235,23 @@ class _TaskDetailPageState extends ConsumerState<EnvDetailPage> {
content: Text("确认删除环境变量 ${widget.envBean.name ?? ""}"),
actions: [
CupertinoDialogAction(
child: const Text("取消"),
child: const Text(
"取消",
style: TextStyle(
color: Color(0xff999999),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoDialogAction(
child: const Text("确定"),
child: Text(
"确定",
style: TextStyle(
color: primaryColor,
),
),
onPressed: () async {
Navigator.of(context).pop();
await ref.read(envProvider).delEnv(widget.envBean.sId!);

View File

@@ -208,17 +208,6 @@ class EnvItemCell extends StatelessWidget {
),
),
),
const SizedBox(
width: 5,
),
bean.status == 1
? const Icon(
Icons.dnd_forwardslash,
size: 16,
color: Colors.red,
)
: const SizedBox.shrink(),
const Spacer(),
],
),
),
@@ -259,21 +248,30 @@ class EnvItemCell extends StatelessWidget {
const SizedBox(
width: 5,
),
Expanded(
child: Material(
color: Colors.transparent,
child: Text(
bean.remarks ?? "-",
maxLines: 1,
style: TextStyle(
height: 1,
overflow: TextOverflow.ellipsis,
color: ref.watch(themeProvider).themeColor.descColor(),
fontSize: 12,
),
Material(
color: Colors.transparent,
child: Text(
bean.remarks ?? "-",
maxLines: 1,
style: TextStyle(
height: 1,
overflow: TextOverflow.ellipsis,
color: ref.watch(themeProvider).themeColor.descColor(),
fontSize: 12,
),
),
),
const SizedBox(
width: 5,
),
bean.status == 1
? const Icon(
Icons.dnd_forwardslash,
size: 12,
color: Colors.red,
)
: const SizedBox.shrink(),
const Spacer(),
],
),
),
@@ -319,13 +317,23 @@ class EnvItemCell extends StatelessWidget {
content: Text("确认删除环境变量 ${bean.name ?? ""}"),
actions: [
CupertinoDialogAction(
child: const Text("取消"),
child: const Text(
"取消",
style: TextStyle(
color: Color(0xff999999),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoDialogAction(
child: const Text("确定"),
child: Text(
"确定",
style: TextStyle(
color: primaryColor,
),
),
onPressed: () {
Navigator.of(context).pop();
ref.read(envProvider).delEnv(bean.sId!);

View File

@@ -362,37 +362,95 @@ class _LoginPageState extends ConsumerState<LoginPage> {
response = await Api.loginByClientId(userName, password);
}
if (response.success) {
getIt<UserInfoViewModel>().updateToken(response.bean?.token ?? "");
getIt<UserInfoViewModel>().useSecretLogin(!loginByUserName());
if (rememberPassword) {
getIt<UserInfoViewModel>().updateUserName(userName, password);
}
if (!loginByUserName()) {
Navigator.of(context).pushReplacementNamed(Routes.routeHomePage);
} else {
HttpResponse<UserBean> userResponse = await Api.user();
if (userResponse.success) {
if (userResponse.bean != null && userResponse.bean!.twoFactorActivated != null && userResponse.bean!.twoFactorActivated!) {
("你已开启两步验证,App暂不支持").toast();
loginSuccess(response, userName, password);
} else {
print(response.code);
(response.message ?? "请检查网络情况").toast();
//420代表需要2步验证
if (response.code == 420) {
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: primaryColor,
),
),
onPressed: () async {
Navigator.of(context).pop(true);
HttpResponse<LoginBean> response = await Api.loginTwo(userName, password, twoFact);
if (response.success) {
loginSuccess(response, userName, password);
} else {
loginFailed(response);
}
},
),
],
)).then((value) {
if (value == null) {
isLoading = false;
setState(() {});
} else {
Navigator.of(context).pushReplacementNamed(Routes.routeHomePage);
}
} else {
(response.message ?? "请检查网络情况").toast();
isLoading = false;
setState(() {});
}
});
} else {
isLoading = false;
setState(() {});
}
} else {
(response.message ?? "请检查网络情况").toast();
isLoading = false;
setState(() {});
}
}
void loginFailed(HttpResponse<LoginBean> response) {
(response.message ?? "请检查网络情况").toast();
isLoading = false;
setState(() {});
}
void loginSuccess(HttpResponse<LoginBean> response, String userName, String password) {
getIt<UserInfoViewModel>().updateToken(response.bean?.token ?? "");
getIt<UserInfoViewModel>().useSecretLogin(!loginByUserName());
if (rememberPassword) {
getIt<UserInfoViewModel>().updateUserName(userName, password);
}
Navigator.of(context).pushReplacementNamed(Routes.routeHomePage);
}
bool canClickLoginBtn() {
if (isLoading) return false;

View File

@@ -334,13 +334,23 @@ class DependencyCell extends ConsumerWidget {
content: Text("确认删除依赖 ${bean.name ?? ""}"),
actions: [
CupertinoDialogAction(
child: const Text("取消"),
child: const Text(
"取消",
style: TextStyle(
color: Color(0xff999999),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoDialogAction(
child: const Text("确定"),
child: Text(
"确定",
style: TextStyle(
color: primaryColor,
),
),
onPressed: () {
Navigator.of(context).pop();
ref.read(dependencyProvider).del(type.name.toLowerCase(), sId ?? "");

View File

@@ -297,16 +297,26 @@ class _OtherPageState extends ConsumerState<OtherPage> {
showCupertinoDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
title: const Text("退出登录吗?"),
title: const Text("退出登录吗?"),
actions: [
CupertinoDialogAction(
child: const Text("取消"),
child: const Text(
"取消",
style: TextStyle(
color: Color(0xff999999),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoDialogAction(
child: const Text("确定"),
child: Text(
"确定",
style: TextStyle(
color: primaryColor,
),
),
onPressed: () {
getIt<UserInfoViewModel>().updateToken("");
Navigator.of(context).pushReplacementNamed(Routes.routeLogin);

View File

@@ -84,13 +84,23 @@ class _ScriptDetailPageState extends ConsumerState<ScriptDetailPage> with LazyLo
content: const Text("确认删除该脚本吗"),
actions: [
CupertinoDialogAction(
child: const Text("取消"),
child: const Text(
"取消",
style: TextStyle(
color: Color(0xff999999),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoDialogAction(
child: const Text("确定"),
child: Text(
"确定",
style: TextStyle(
color: primaryColor,
),
),
onPressed: () async {
Navigator.of(context).pop();
HttpResponse<NullResponse> result = await Api.delScript(widget.title, widget.path ?? "");

View File

@@ -367,13 +367,23 @@ class _TaskDetailPageState extends ConsumerState<TaskDetailPage> {
content: Text("确认删除定时任务 ${widget.taskBean.name ?? ""}"),
actions: [
CupertinoDialogAction(
child: const Text("取消"),
child: const Text(
"取消",
style: TextStyle(
color: Color(0xff999999),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoDialogAction(
child: const Text("确定"),
child: Text(
"确定",
style: TextStyle(
color: primaryColor,
),
),
onPressed: () async {
Navigator.of(context).pop();
await ref.read(taskProvider).delCron(widget.taskBean.sId!);

View File

@@ -251,6 +251,7 @@ class TaskItemCell extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: MediaQuery.of(context).size.width,
color: bean.isPinned == 1 ? ref.watch(themeProvider).themeColor.pinColor() : Colors.transparent,
padding: const EdgeInsets.symmetric(
horizontal: 15,
@@ -307,6 +308,7 @@ class TaskItemCell extends StatelessWidget {
height: 8,
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Material(
color: Colors.transparent,
@@ -332,6 +334,22 @@ class TaskItemCell extends StatelessWidget {
: const SizedBox.shrink(),
],
),
const SizedBox(
height: 8,
),
Material(
color: Colors.transparent,
child: Text(
bean.command ?? "",
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
overflow: TextOverflow.ellipsis,
color: ref.watch(themeProvider).themeColor.descColor(),
fontSize: 12,
),
),
),
],
),
),
@@ -401,13 +419,23 @@ class TaskItemCell extends StatelessWidget {
content: Text("确认删除定时任务 ${bean.name ?? ""}"),
actions: [
CupertinoDialogAction(
child: const Text("取消"),
child: const Text(
"取消",
style: TextStyle(
color: Color(0xff999999),
),
),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoDialogAction(
child: const Text("确定"),
child: Text(
"确定",
style: TextStyle(
color: primaryColor,
),
),
onPressed: () {
Navigator.of(context).pop();
ref.read(taskProvider).delCron(bean.sId!);