add pin login and add pin code

This commit is contained in:
tzw
2024-10-04 13:55:59 +06:30
parent b5023a4171
commit 81dfeb037d
18 changed files with 340 additions and 68 deletions

View File

@@ -203,9 +203,27 @@ class _HomePageState extends State<HomePage> {
super.dispose();
}
_logoutPinAccount() async {
setState(() {
_isLoading = true;
});
try {
await context.read<MainModel>().logoutPinAccount();
Navigator.pushNamedAndRemoveUntil(context, "/pin_login", (r) => false);
} catch (e) {
showMsgDialog(context, "Error", e.toString());
} finally {
setState(() {
_isLoading = false;
});
}
}
@override
Widget build(BuildContext context) {
User? user = Provider.of<MainModel>(context).user;
var mainModel = context.watch<MainModel>();
User? user = mainModel.user;
if (user == null) {
Future.microtask(
@@ -213,7 +231,7 @@ class _HomePageState extends State<HomePage> {
return Container();
}
login = Provider.of<MainModel>(context).isLogin();
login = mainModel.isLogin();
LanguageModel languageModel = Provider.of<LanguageModel>(context);
final faqBtn = TaskButton("faq.btn",
@@ -357,7 +375,7 @@ class _HomePageState extends State<HomePage> {
selectedColor: Colors.white,
color: Colors.blue,
children: <Widget>[
Icon(MaterialCommunityIcons.account_tie,size: 25),
Icon(MaterialCommunityIcons.account_tie, size: 25),
],
onPressed: (i) => this.setState(() {
isFcs[0] = !isFcs[0];
@@ -387,11 +405,14 @@ class _HomePageState extends State<HomePage> {
color: buttonColor,
),
);
final pinLoginBtn = IconButton(
onPressed: () {
Navigator.of(context)
.push(CupertinoPageRoute(builder: (context) => PinLoginPage()));
Navigator.pushAndRemoveUntil(
context,
CupertinoPageRoute(
builder: (BuildContext context) => PinLoginPage()),
(r) => false);
},
iconSize: 25,
icon: Icon(
@@ -400,6 +421,19 @@ class _HomePageState extends State<HomePage> {
),
);
final pinLogoutBtn = IconButton(
onPressed: () {
showConfirmDialog(context, "home.pin.logout.confirm", () async {
await _logoutPinAccount();
});
},
iconSize: 25,
icon: Icon(
MaterialCommunityIcons.lock_open_variant_outline,
color: buttonColor,
),
);
var searchInput = Row(children: [
Expanded(
child: Padding(
@@ -478,7 +512,7 @@ class _HomePageState extends State<HomePage> {
profileBtn,
]
: <Widget>[
pinLoginBtn,
mainModel.isPinLogin ? pinLogoutBtn : pinLoginBtn,
fcsToggle,
profileBtn,
]