|
|
|
@ -1,13 +1,10 @@
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:healthcare_delivery/common/dashboard.dart';
|
|
|
|
|
import 'package:healthcare_delivery/common/login.dart';
|
|
|
|
|
import 'package:healthcare_delivery/common/settings.dart';
|
|
|
|
|
|
|
|
|
|
class OtpScreen extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
var phoneNumber;
|
|
|
|
|
OtpScreen({
|
|
|
|
|
this.phoneNumber
|
|
|
|
|
});
|
|
|
|
|
var myObject;
|
|
|
|
|
OtpScreen({this.myObject});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<OtpScreen> createState() => _OtpScreenState();
|
|
|
|
@ -21,7 +18,12 @@ class _OtpScreenState extends State<OtpScreen> {
|
|
|
|
|
final TextEditingController _fieldFour = TextEditingController();
|
|
|
|
|
final TextEditingController _fieldFive = TextEditingController();
|
|
|
|
|
final TextEditingController _fieldSix = TextEditingController();
|
|
|
|
|
TextEditingController phoneverificationCodeController = TextEditingController();
|
|
|
|
|
TextEditingController mobileNumberController = TextEditingController();
|
|
|
|
|
TextEditingController passwordController = TextEditingController();
|
|
|
|
|
|
|
|
|
|
bool isTextfieldVisible=true;
|
|
|
|
|
bool isOtpVisible=false;
|
|
|
|
|
bool isObscureText=true;
|
|
|
|
|
|
|
|
|
|
// This is the entered code
|
|
|
|
|
// It will be displayed in a Text widget
|
|
|
|
@ -29,16 +31,62 @@ class _OtpScreenState extends State<OtpScreen> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: screenBackgroundColor,
|
|
|
|
|
body: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
const Text('Phone Number Verification'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Visibility(
|
|
|
|
|
visible: false,
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: const EdgeInsets.all(10),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
cursorColor: greyColor,
|
|
|
|
|
controller: mobileNumberController,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
prefixIcon: Icon(
|
|
|
|
|
Icons.phone,
|
|
|
|
|
color: greyColor,
|
|
|
|
|
),
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: greyColor)),
|
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color:greyColor),
|
|
|
|
|
),
|
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: greyColor),
|
|
|
|
|
),
|
|
|
|
|
labelText: 'Enter MobileNumber',
|
|
|
|
|
labelStyle: TextStyle(
|
|
|
|
|
color: greyColor, //<-- SEE HERE
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 30,
|
|
|
|
|
),
|
|
|
|
|
Visibility(
|
|
|
|
|
visible: false,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * .99,
|
|
|
|
|
height: 50,
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
primary: primaryColor, // background
|
|
|
|
|
onPrimary: Colors.white, // foreground
|
|
|
|
|
),
|
|
|
|
|
onPressed: ()async {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
child: const Text('Submit')),
|
|
|
|
|
),),
|
|
|
|
|
// Implement 4 input fields
|
|
|
|
|
Row(
|
|
|
|
|
Visibility(
|
|
|
|
|
visible:true,
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
|
children: [
|
|
|
|
|
OtpInput(_fieldOne, true), // auto focus
|
|
|
|
@ -48,11 +96,59 @@ class _OtpScreenState extends State<OtpScreen> {
|
|
|
|
|
OtpInput(_fieldFive, false),
|
|
|
|
|
OtpInput(_fieldSix, false),
|
|
|
|
|
],
|
|
|
|
|
),),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 30,
|
|
|
|
|
),
|
|
|
|
|
Visibility(
|
|
|
|
|
visible: false,
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(10, 10, 10, 0),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
cursorColor: greyColor,
|
|
|
|
|
obscureText: isObscureText,
|
|
|
|
|
controller: passwordController,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
labelText: 'Password',
|
|
|
|
|
prefixIcon: const Icon(Icons.password, color: greyColor,),
|
|
|
|
|
labelStyle: const TextStyle(
|
|
|
|
|
color: greyColor, //<-- SEE HERE
|
|
|
|
|
),
|
|
|
|
|
border: const OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: greyColor)),
|
|
|
|
|
focusedBorder: const OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: greyColor),
|
|
|
|
|
),
|
|
|
|
|
enabledBorder: const OutlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: textFieldStartColor),
|
|
|
|
|
),
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
Icons.visibility_off_outlined,
|
|
|
|
|
color: isObscureText==true?greyColor:primaryColor,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
|
|
print("show password");
|
|
|
|
|
setState(() {
|
|
|
|
|
isObscureText = !isObscureText;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
),
|
|
|
|
|
),),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 30,
|
|
|
|
|
),
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
Visibility(
|
|
|
|
|
visible: true,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width * .99,
|
|
|
|
|
height: 50,
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
primary: primaryColor, // background
|
|
|
|
|
onPrimary: Colors.white, // foreground
|
|
|
|
@ -67,7 +163,6 @@ class _OtpScreenState extends State<OtpScreen> {
|
|
|
|
|
_fieldSix.text;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_otp!.length == 6) {
|
|
|
|
|
AppSettings.preLoaderDialog(context);
|
|
|
|
|
|
|
|
|
@ -76,48 +171,40 @@ class _OtpScreenState extends State<OtpScreen> {
|
|
|
|
|
if(isOnline){
|
|
|
|
|
var payload = new Map<String, dynamic>();
|
|
|
|
|
payload["phoneVerificationCode"] = _otp.toString();
|
|
|
|
|
payload["phone"] = widget.phoneNumber.toString();
|
|
|
|
|
bool signinStatus = await AppSettings.login(payload);
|
|
|
|
|
try{
|
|
|
|
|
if (signinStatus) {
|
|
|
|
|
payload["phone"] = widget.myObject.toString();
|
|
|
|
|
bool phoneVerified = await AppSettings.login(payload);
|
|
|
|
|
if(phoneVerified){
|
|
|
|
|
Navigator.of(context,rootNavigator: true).pop();
|
|
|
|
|
await Navigator.push(
|
|
|
|
|
AppSettings.longSuccessToast(
|
|
|
|
|
"Phone verified successfully");
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(builder: (context) => Dashboard()),
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => Dashboard()),
|
|
|
|
|
);
|
|
|
|
|
AppSettings.longSuccessToast("Logged in Successfully");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context,rootNavigator: true).pop();
|
|
|
|
|
AppSettings.longFailedToast("Please enter valid details");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(exception){
|
|
|
|
|
else{
|
|
|
|
|
Navigator.of(context,rootNavigator: true).pop();
|
|
|
|
|
print(exception);
|
|
|
|
|
AppSettings.longFailedToast(
|
|
|
|
|
"please enter valid pin");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
Navigator.of(context,rootNavigator: true).pop();
|
|
|
|
|
AppSettings.longFailedToast("Please Check internet");
|
|
|
|
|
AppSettings.longFailedToast(
|
|
|
|
|
"Please check your internet");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
|
|
AppSettings.longFailedToast("Please enter valid details");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
child: const Text('Submit')),
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 30,
|
|
|
|
|
),
|
|
|
|
|
// Display the entered OTP code
|
|
|
|
|
Text(
|
|
|
|
|
_otp ?? 'Please enter OTP',
|
|
|
|
|
style: const TextStyle(fontSize: 30),
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
@ -142,7 +229,7 @@ class OtpInput extends StatelessWidget {
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
controller: controller,
|
|
|
|
|
maxLength: 1,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
cursorColor: Theme.of(context).primaryColor,
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
filled: true,
|
|
|
|
|
fillColor: Colors.white,
|
|
|
|
|