-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
363 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
v1.6.7 | ||
|
||
- [x] ✨ 对分类进行排序(设置项) | ||
- [x] ✨ 生物验证 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
import '../basic/commons.dart'; | ||
import '../basic/methods.dart'; | ||
import 'DesktopAuthenticationScreen.dart'; | ||
import 'android_version.dart'; | ||
const _propertyName = "authentication"; | ||
late bool _authentication; | ||
|
||
Future<void> initAuthentication() async { | ||
if (Platform.isIOS || androidVersion >= 29) { | ||
_authentication = | ||
(await methods.loadProperty(_propertyName)) == "true"; | ||
} | ||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) { | ||
_authentication = await needDesktopAuthentication(); | ||
} | ||
} | ||
|
||
bool currentAuthentication() { | ||
return _authentication; | ||
} | ||
|
||
Future<bool> verifyAuthentication(BuildContext context) async { | ||
if (Platform.isIOS || androidVersion >= 29) { | ||
return await methods.verifyAuthentication(); | ||
} | ||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) { | ||
return await Navigator.of(context).push( | ||
MaterialPageRoute(builder: (context) => const VerifyPassword())) == | ||
true; | ||
} | ||
return false; | ||
} | ||
|
||
Widget authenticationSetting() { | ||
if (Platform.isIOS || androidVersion >= 29) { | ||
return StatefulBuilder( | ||
builder: (BuildContext context, void Function(void Function()) setState) { | ||
return ListTile( | ||
title: const Text("进入APP时验证身份(如果系统已经录入密码或指纹)"), | ||
subtitle: Text(_authentication ? "是" : "否"), | ||
onTap: () async { | ||
await _chooseAuthentication(context); | ||
setState(() {}); | ||
}, | ||
); | ||
}, | ||
); | ||
} | ||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) { | ||
return StatefulBuilder(builder: ( | ||
BuildContext context, | ||
void Function(void Function()) setState, | ||
) { | ||
return ListTile( | ||
title: const Text("设置应用程序密码"), | ||
onTap: () async { | ||
Navigator.of(context).push( | ||
MaterialPageRoute(builder: (context) => const SetPassword())); | ||
}, | ||
); | ||
}); | ||
} | ||
return Container(); | ||
} | ||
|
||
Future<void> _chooseAuthentication(BuildContext context) async { | ||
if (await methods.verifyAuthentication()) { | ||
String? result = | ||
await chooseListDialog<String>(context, title: "进入APP时验证身份", values: ["是", "否"]); | ||
if (result != null) { | ||
var target = result == "是"; | ||
await methods.saveProperty(_propertyName, "$target"); | ||
_authentication = target; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:jasmine/basic/methods.dart'; | ||
|
||
const _key = "desktopAuthPassword"; | ||
|
||
Future<bool> needDesktopAuthentication() async { | ||
return await methods.loadProperty(_key) != ""; | ||
} | ||
|
||
class VerifyPassword extends StatefulWidget { | ||
const VerifyPassword({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _VerifyPasswordState(); | ||
} | ||
|
||
class _VerifyPasswordState extends State<VerifyPassword> { | ||
String _password = ""; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: Center( | ||
child: Padding( | ||
padding: const EdgeInsets.all(30), | ||
child: Column( | ||
children: [ | ||
Expanded(child: Container()), | ||
TextField( | ||
decoration: const InputDecoration(labelText: "当前密码"), | ||
onChanged: (value) { | ||
_password = value; | ||
}, | ||
), | ||
Container(height: 10), | ||
ElevatedButton( | ||
onPressed: () async { | ||
String savedPassword = await methods.loadProperty(_key); | ||
if (_password == savedPassword) { | ||
Navigator.of(context).pop(true); | ||
} else { | ||
ScaffoldMessenger.of(context) | ||
.showSnackBar(const SnackBar(content: Text("密码错误"))); | ||
} | ||
}, | ||
child: const Text("确定"), | ||
), | ||
Expanded(child: Container()), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class SetPassword extends StatefulWidget { | ||
const SetPassword({Key? key}) : super(key: key); | ||
|
||
@override | ||
State<StatefulWidget> createState() => _SetPasswordState(); | ||
} | ||
|
||
class _SetPasswordState extends State<SetPassword> { | ||
String _password = ""; | ||
String _password2 = ""; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: Center( | ||
child: Padding( | ||
padding: const EdgeInsets.all(30), | ||
child: Column( | ||
children: [ | ||
const Text( | ||
"密码初始化", | ||
style: TextStyle( | ||
height: 18, | ||
), | ||
), | ||
Container( | ||
height: 10, | ||
), | ||
TextField( | ||
decoration: const InputDecoration(labelText: "密码"), | ||
onChanged: (value) { | ||
_password = value; | ||
}, | ||
), | ||
Container( | ||
height: 10, | ||
), | ||
TextField( | ||
decoration: const InputDecoration(labelText: "再次输入密码"), | ||
onChanged: (value) { | ||
_password2 = value; | ||
}, | ||
), | ||
Container( | ||
height: 10, | ||
), | ||
Row( | ||
children: [ | ||
ElevatedButton( | ||
onPressed: () async { | ||
Navigator.of(context).pop(false); | ||
}, | ||
child: const Text("取消"), | ||
), | ||
Container(width: 10), | ||
Expanded( | ||
child: ElevatedButton( | ||
onPressed: () async { | ||
if (_password != _password2) { | ||
ScaffoldMessenger.of(context).showSnackBar( | ||
const SnackBar(content: Text("两次输入的密码不一致"))); | ||
return; | ||
} | ||
await methods.saveProperty(_key, _password); | ||
Navigator.of(context).pop(true); | ||
}, | ||
child: const Text("设置密码"), | ||
), | ||
), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.