From f91601661d11dfe11924c5dcda86731ae67f6bc7 Mon Sep 17 00:00:00 2001 From: niuhuan Date: Wed, 15 Dec 2021 12:22:40 +0800 Subject: [PATCH] hidden login screen password --- lib/basic/Common.dart | 43 ++++++++++----------- lib/basic/config/ChooserRoot.dart | 8 ++-- lib/basic/config/Proxy.dart | 8 ++-- lib/basic/config/Themes.dart | 7 ++-- lib/screens/AccountScreen.dart | 16 ++++---- lib/screens/RegisterScreen.dart | 63 +++++++++++++------------------ 6 files changed, 66 insertions(+), 79 deletions(-) diff --git a/lib/basic/Common.dart b/lib/basic/Common.dart index 733df6e..093cc9d 100644 --- a/lib/basic/Common.dart +++ b/lib/basic/Common.dart @@ -147,19 +147,14 @@ Future chooseMapDialog( var _controller = TextEditingController.fromValue(TextEditingValue(text: '')); -Future displayTextInputDialog( - BuildContext context, - String title, - String hint, - String src, - String desc, -) { +Future displayTextInputDialog(BuildContext context, + {String? title, String src = "", String? hint, String? desc}) { _controller.text = src; return showDialog( context: context, builder: (context) { return AlertDialog( - title: Text(title), + title: title == null ? null : Text(title), content: SingleChildScrollView( child: ListBody( children: [ @@ -167,21 +162,23 @@ Future displayTextInputDialog( controller: _controller, decoration: InputDecoration(hintText: hint), ), - desc.isEmpty - ? Container() - : Container( - padding: EdgeInsets.only(top: 20, bottom: 10), - child: Text( - desc, - style: TextStyle( - fontSize: 12, - color: Theme.of(context) - .textTheme - .bodyText1 - ?.color - ?.withOpacity(.5)), - ), - ), + ...(desc == null + ? [] + : [ + Container( + padding: EdgeInsets.only(top: 20, bottom: 10), + child: Text( + desc, + style: TextStyle( + fontSize: 12, + color: Theme.of(context) + .textTheme + .bodyText1 + ?.color + ?.withOpacity(.5)), + ), + ) + ]), ], ), ), diff --git a/lib/basic/config/ChooserRoot.dart b/lib/basic/config/ChooserRoot.dart index c8c2d10..28cd908 100644 --- a/lib/basic/config/ChooserRoot.dart +++ b/lib/basic/config/ChooserRoot.dart @@ -51,10 +51,10 @@ Future currentChooserRoot() async { Future _inputChooserRoot(BuildContext context) async { String? input = await displayTextInputDialog( context, - '文件夹选择器根路径', - '请输入文件夹选择器根路径', - _chooserRoot, - "导出时选择目录的默认路径, 同时也是根路径, 不能正常导出时也可以尝试设置此选项。", + src: _chooserRoot, + title: '文件夹选择器根路径', + hint: '请输入文件夹选择器根路径', + desc: "导出时选择目录的默认路径, 同时也是根路径, 不能正常导出时也可以尝试设置此选项。", ); if (input != null) { await method.saveProperty(_propertyName, input); diff --git a/lib/basic/config/Proxy.dart b/lib/basic/config/Proxy.dart index 4620867..89c7549 100644 --- a/lib/basic/config/Proxy.dart +++ b/lib/basic/config/Proxy.dart @@ -18,10 +18,10 @@ String currentProxyName() { Future inputProxy(BuildContext context) async { String? input = await displayTextInputDialog( context, - '代理服务器', - '请输入代理服务器', - _currentProxy, - " ( 例如 socks5://127.0.0.1:1080/ ) ", + src: _currentProxy, + title: '代理服务器', + hint: '请输入代理服务器', + desc: " ( 例如 socks5://127.0.0.1:1080/ ) ", ); if (input != null) { await method.setProxy(input); diff --git a/lib/basic/config/Themes.dart b/lib/basic/config/Themes.dart index 0313537..6d464e2 100644 --- a/lib/basic/config/Themes.dart +++ b/lib/basic/config/Themes.dart @@ -28,8 +28,8 @@ ThemeData _fontThemeData(bool dark) { Future inputFont(BuildContext context) async { var font = await displayTextInputDialog( - context, "字体", "请输入字体", "$_fontFamily", - "请输入字体的名称, 例如宋体/黑体, 如果您保存后没有发生变化, 说明字体无法使用或名称错误, 可以去参考C:\\Windows\\Fonts寻找您的字体。", + context, src: "$_fontFamily", title: "字体", hint: "请输入字体", + desc: "请输入字体的名称, 例如宋体/黑体, 如果您保存后没有发生变化, 说明字体无法使用或名称错误, 可以去参考C:\\Windows\\Fonts寻找您的字体。", ); if (font != null) { await method.saveProperty(_fontFamilyProperty, font); @@ -174,7 +174,8 @@ class _DustyBlueTheme extends _ThemePackage { @override ThemeData themeData(ThemeData rawData) => rawData.copyWith( - scaffoldBackgroundColor: Color.alphaBlend(Color(0x11999999), Color(0xff20253b)), + scaffoldBackgroundColor: Color.alphaBlend( + Color(0x11999999), Color(0xff20253b)), cardColor: Color.alphaBlend(Color(0x11AAAAAA), Color(0xff20253b)), brightness: Brightness.light, colorScheme: ColorScheme.light( diff --git a/lib/screens/AccountScreen.dart b/lib/screens/AccountScreen.dart index 2cc1fe2..1f9712f 100644 --- a/lib/screens/AccountScreen.dart +++ b/lib/screens/AccountScreen.dart @@ -81,10 +81,9 @@ class _AccountScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '账号', - '请输入账号', - _username, - "", + src: _username, + title: '账号', + hint: '请输入账号', ); if (input != null) { await method.setUsername(input); @@ -96,14 +95,13 @@ class _AccountScreenState extends State { ), ListTile( title: Text("密码"), - subtitle: Text(_password == "" ? "未设置" : _password), + subtitle: Text(_password == "" ? "未设置" : "******"), onTap: () async { String? input = await displayTextInputDialog( context, - '密码', - '请输入密码', - _password, - "", + src: _password, + title: '密码', + hint: '请输入密码', ); if (input != null) { await method.setPassword(input); diff --git a/lib/screens/RegisterScreen.dart b/lib/screens/RegisterScreen.dart index 6573375..c4e184d 100644 --- a/lib/screens/RegisterScreen.dart +++ b/lib/screens/RegisterScreen.dart @@ -127,10 +127,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '账号', - '请输入账号', - _email, - "", + src: _email, + title: '账号', + hint: '请输入账号', ); if (input != null) { setState(() { @@ -145,10 +144,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '密码', - '请输入密码', - _password, - "", + src: _password, + title: '密码', + hint: '请输入密码', ); if (input != null) { setState(() { @@ -163,10 +161,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '昵称', - '请输入昵称', - _name, - "", + src: _name, + title: '昵称', + hint: '请输入昵称', ); if (input != null) { setState(() { @@ -237,10 +234,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '问题1', - '请输入问题1', - _question1, - "", + src: _question1, + title: '问题1', + hint: '请输入问题1', ); if (input != null) { setState(() { @@ -255,10 +251,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '回答1', - '请输入回答1', - _answer1, - "", + src: _answer1, + title: '回答1', + hint: '请输入回答1', ); if (input != null) { setState(() { @@ -273,10 +268,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '问题2', - '请输入问题2', - _question2, - "", + src: _question2, + title: '问题2', + hint: '请输入问题2', ); if (input != null) { setState(() { @@ -291,10 +285,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '回答2', - '请输入回答2', - _answer2, - "", + src: _answer2, + title: '回答2', + hint: '请输入回答2', ); if (input != null) { setState(() { @@ -309,10 +302,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '问题3', - '请输入问题3', - _question3, - "", + src: _question3, + title: '问题3', + hint: '请输入问题3', ); if (input != null) { setState(() { @@ -327,10 +319,9 @@ class _RegisterScreenState extends State { onTap: () async { String? input = await displayTextInputDialog( context, - '回答3', - '请输入回答3', - _answer3, - "", + src: _answer3, + title: '回答3', + hint: '请输入回答3', ); if (input != null) { setState(() {