103 lines
3.0 KiB
Dart
103 lines
3.0 KiB
Dart
|
|
import 'dart:async';
|
||
|
|
|
||
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:flutter_verification_code_input/flutter_verification_code_input.dart';
|
||
|
|
import 'package:provider/provider.dart';
|
||
|
|
import 'package:fcs/model/main_model.dart';
|
||
|
|
import 'package:fcs/pages/util.dart';
|
||
|
|
import 'package:fcs/theme/theme.dart';
|
||
|
|
import 'package:quiver/async.dart';
|
||
|
|
|
||
|
|
class PinLoginDialog extends StatefulWidget {
|
||
|
|
@override
|
||
|
|
_PinLoginDialogState createState() => _PinLoginDialogState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _PinLoginDialogState extends State<PinLoginDialog> {
|
||
|
|
String pin;
|
||
|
|
|
||
|
|
@override
|
||
|
|
void initState() {
|
||
|
|
super.initState();
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
var mainModel = Provider.of<MainModel>(context);
|
||
|
|
|
||
|
|
return AlertDialog(
|
||
|
|
shape: RoundedRectangleBorder(
|
||
|
|
borderRadius: BorderRadius.all(Radius.circular(32.0))),
|
||
|
|
title: Column(
|
||
|
|
children: <Widget>[
|
||
|
|
Image.asset(
|
||
|
|
"assets/pin.png",
|
||
|
|
height: 90,
|
||
|
|
color: primaryColor,
|
||
|
|
),
|
||
|
|
Text(
|
||
|
|
"Enter PIN Code",
|
||
|
|
style: TextStyle(
|
||
|
|
color: primaryColor, fontWeight: FontWeight.bold, fontSize: 20),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
),
|
||
|
|
content: Container(
|
||
|
|
width: double.maxFinite,
|
||
|
|
height: 120.0,
|
||
|
|
child: new ListView(
|
||
|
|
shrinkWrap: true,
|
||
|
|
children: <Widget>[
|
||
|
|
Center(
|
||
|
|
child: VerificationCodeInput(
|
||
|
|
keyboardType: TextInputType.number,
|
||
|
|
length: 6,
|
||
|
|
autofocus: false,
|
||
|
|
itemSize: 40,
|
||
|
|
itemDecoration: BoxDecoration(
|
||
|
|
border: Border.all(
|
||
|
|
color: Colors.grey,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
textStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 23),
|
||
|
|
onCompleted: (String value) {
|
||
|
|
this.pin = value;
|
||
|
|
},
|
||
|
|
),
|
||
|
|
),
|
||
|
|
SizedBox(
|
||
|
|
height: 15,
|
||
|
|
),
|
||
|
|
Row(
|
||
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
|
children: <Widget>[
|
||
|
|
FlatButton(
|
||
|
|
child: Text("Cancel"),
|
||
|
|
onPressed: () {
|
||
|
|
Navigator.of(context).pop();
|
||
|
|
}),
|
||
|
|
FlatButton(
|
||
|
|
color: primaryColor,
|
||
|
|
child: Text("OK",
|
||
|
|
style: TextStyle(
|
||
|
|
color: Colors.white, fontWeight: FontWeight.bold)),
|
||
|
|
onPressed: () async {
|
||
|
|
if (this.pin == null) return;
|
||
|
|
|
||
|
|
if (mainModel.user.pin == this.pin) {
|
||
|
|
mainModel.resetPinTimer();
|
||
|
|
Navigator.of(context).pop();
|
||
|
|
} else {
|
||
|
|
showMsgDialog(context, "Error", "Invalid PIN Code !");
|
||
|
|
}
|
||
|
|
}),
|
||
|
|
],
|
||
|
|
)
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|