213 lines
6.5 KiB
Dart
213 lines
6.5 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:cathaypay_mobile/utils/utils.dart';
|
|
import 'package:device_info_plus/device_info_plus.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
import '../api/api.dart';
|
|
|
|
class ForgotPassword extends StatefulWidget {
|
|
const ForgotPassword({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<ForgotPassword> createState() => _LoginValidateState();
|
|
}
|
|
|
|
class _LoginValidateState extends State<ForgotPassword> {
|
|
@override
|
|
void initState() {
|
|
deviceId();
|
|
super.initState();
|
|
}
|
|
|
|
AndroidDeviceInfo? androidDeviceInfo;
|
|
IosDeviceInfo? iosDeviceInfo;
|
|
|
|
deviceId() async {
|
|
DeviceInfoPlugin device = DeviceInfoPlugin();
|
|
if (Platform.isAndroid) {
|
|
androidDeviceInfo = await device.androidInfo;
|
|
} else if (Platform.isIOS) {
|
|
iosDeviceInfo = await device.iosInfo;
|
|
}
|
|
}
|
|
|
|
authen(BuildContext context) {
|
|
var device = "";
|
|
if (Platform.isAndroid) {
|
|
device = androidDeviceInfo?.id ?? "";
|
|
} else if (Platform.isIOS) {
|
|
device = iosDeviceInfo?.name ?? "";
|
|
}
|
|
var param = jsonEncode(<dynamic, dynamic>{"email": email.text, "mobileDeviceID": device});
|
|
Api.postLogin(context, Api.forgot_password, param).then((value) => {
|
|
if (value != null)
|
|
{
|
|
Utils.showAlertDialogCallback(
|
|
context,
|
|
"ตรวจสอบรหัสผ่านที่อีเมลของท่าน",
|
|
(value) {
|
|
Navigator.pop(context);
|
|
},
|
|
)
|
|
}
|
|
else
|
|
{}
|
|
});
|
|
}
|
|
|
|
refresh() {
|
|
setState(() {});
|
|
}
|
|
|
|
TextEditingController email = TextEditingController();
|
|
TextEditingController phone = TextEditingController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Column(
|
|
children: [
|
|
Row(children: [
|
|
IconButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
icon: Icon(
|
|
Icons.arrow_back_ios,
|
|
color: Colors.black,
|
|
)),
|
|
Text(
|
|
"Forgot Password".tr(),
|
|
style: TextStyle(
|
|
color: Color(0xff050505),
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
]),
|
|
SizedBox(
|
|
height: 50,
|
|
),
|
|
Container(
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xfff2f2f2),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
width: 10,
|
|
),
|
|
Center(
|
|
child: FaIcon(
|
|
FontAwesomeIcons.addressCard,
|
|
color: Color(0xff65676b),
|
|
)),
|
|
Expanded(
|
|
child: TextField(
|
|
keyboardType: TextInputType.emailAddress,
|
|
// inputFormatters: [
|
|
// FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
|
|
// ],
|
|
controller: email,
|
|
decoration: InputDecoration(
|
|
hintText: 'Email',
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 16),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
/* SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xfff2f2f2),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
SizedBox(
|
|
width: 10,
|
|
),
|
|
Center(
|
|
child: FaIcon(
|
|
FontAwesomeIcons.phone,
|
|
color: Color(0xff65676b),
|
|
)),
|
|
Expanded(
|
|
child: TextField(
|
|
keyboardType: TextInputType.phone,
|
|
// inputFormatters: [
|
|
// FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
|
|
// ],
|
|
controller: phone,
|
|
decoration: InputDecoration(
|
|
hintText: 'เบอร์มือถือ',
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 16),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),*/
|
|
SizedBox(
|
|
height: 60,
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
authen(context);
|
|
},
|
|
child: Container(
|
|
width: 374,
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xff9d001b),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
"ยืนยัน",
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.kanit(
|
|
color: Colors.white,
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|