hide cleartext password

Signed-off-by: ImFatF1sh <imfatf1sh@protonmail.com>
This commit is contained in:
ImFatF1sh 2021-12-15 14:46:22 +08:00
parent f91601661d
commit 0e998ba3b5
3 changed files with 7 additions and 4 deletions

View File

@ -148,7 +148,7 @@ Future<T?> chooseMapDialog<T>(
var _controller = TextEditingController.fromValue(TextEditingValue(text: ''));
Future<String?> displayTextInputDialog(BuildContext context,
{String? title, String src = "", String? hint, String? desc}) {
{String? title, String src = "", String? hint, String? desc, bool isPasswd = false}) {
_controller.text = src;
return showDialog(
context: context,
@ -161,6 +161,8 @@ Future<String?> displayTextInputDialog(BuildContext context,
TextField(
controller: _controller,
decoration: InputDecoration(hintText: hint),
obscureText: isPasswd,
obscuringCharacter: '\u2022',
),
...(desc == null
? []

View File

@ -95,13 +95,14 @@ class _AccountScreenState extends State<AccountScreen> {
),
ListTile(
title: Text("密码"),
subtitle: Text(_password == "" ? "未设置" : "******"),
subtitle: Text(_password == "" ? "未设置" : '\u2022' * 48),
onTap: () async {
String? input = await displayTextInputDialog(
context,
src: _password,
title: '密码',
hint: '请输入密码',
isPasswd: true,
);
if (input != null) {
await method.setPassword(input);

View File

@ -99,7 +99,6 @@ class _RegisterScreenState extends State<RegisterScreen> {
Text('您已经注册成功, 请返回登录'),
Text('账号 : $_email'),
Text('昵称 : $_name'),
Text('密码 : $_password'),
Expanded(child: Container()),
Expanded(child: Container()),
],
@ -140,13 +139,14 @@ class _RegisterScreenState extends State<RegisterScreen> {
),
ListTile(
title: Text("密码 (8位以上)"),
subtitle: Text(_password == "" ? "未设置" : _password),
subtitle: Text(_password == "" ? "未设置" : '\u2022' * 48),
onTap: () async {
String? input = await displayTextInputDialog(
context,
src: _password,
title: '密码',
hint: '请输入密码',
isPasswd: true,
);
if (input != null) {
setState(() {