187 lines
6.8 KiB
Dart
187 lines
6.8 KiB
Dart
import 'package:cathaypay_mobile/Home/HomePage.dart';
|
|
import 'package:cathaypay_mobile/Home/all_menu.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:cathaypay_mobile/PinCode.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import '../api/api.dart';
|
|
import '../utils/color_custom.dart';
|
|
import '../utils/utils.dart';
|
|
|
|
TextEditingController _current_email = TextEditingController();
|
|
TextEditingController _new_email = TextEditingController();
|
|
|
|
class ChangeEmailPage extends StatefulWidget {
|
|
const ChangeEmailPage({super.key});
|
|
|
|
@override
|
|
State<ChangeEmailPage> createState() => _ChangeEmailPageState();
|
|
}
|
|
|
|
class _ChangeEmailPageState extends State<ChangeEmailPage> {
|
|
|
|
ChangeEmail() {
|
|
print(_current_email.text);
|
|
print(_new_email.text);
|
|
if (_current_email.text.isNotEmpty &&_new_email.text.isNotEmpty) {
|
|
var param = jsonEncode(<dynamic, dynamic>{
|
|
"userID": profile?.id,
|
|
"oldEmail": _current_email.text,
|
|
"newEmail": _new_email.text,
|
|
"confirmEmail": _new_email.text
|
|
});
|
|
Api.post(context, Api.changeEmail, param).then((value) => {
|
|
if (value != null) {
|
|
// initQrCode(value)
|
|
Utils.showAlertDialogCallback(
|
|
context,
|
|
"บันทึกสำเร็จ",
|
|
(value) {
|
|
Navigator.pushNamed(context, '/HomePage');
|
|
},
|
|
)
|
|
} else {}
|
|
});
|
|
}
|
|
}
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// extendBodyBehindAppBar: true,
|
|
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.white,
|
|
leading: CupertinoButton(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: const Icon(
|
|
Icons.arrow_back,
|
|
color: Colors.black54,
|
|
),
|
|
),
|
|
elevation: 0,
|
|
centerTitle: true,
|
|
title: Text(
|
|
"เปลี่ยนอีเมล".tr(),
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.kanit(
|
|
color: Colors.black,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
body: SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Container(height: MediaQuery.of(context).size.height,
|
|
child: Column(mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Text(
|
|
"อีเมลปัจจุบัน".tr(),
|
|
style: GoogleFonts.kanit(
|
|
color: Color(0xff565656),
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
child: TextField(
|
|
keyboardType: TextInputType.emailAddress,
|
|
// inputFormatters: [
|
|
// FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
|
|
// ],
|
|
controller: _current_email,
|
|
decoration: InputDecoration(
|
|
// hintText: 'อีเมลปัจจุบัน'.tr(),
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 16),
|
|
),
|
|
),
|
|
// margin: EdgeInsets.symmetric(horizontal: 20),
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xfff2f2f2),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Text(
|
|
"อีเมลใหม่".tr(),
|
|
style: GoogleFonts.kanit(
|
|
color: Color(0xff565656),
|
|
fontSize: 15,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
child: TextField(
|
|
keyboardType: TextInputType.emailAddress,
|
|
// inputFormatters: [
|
|
// FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
|
|
// ],
|
|
controller: _new_email,
|
|
decoration: InputDecoration(
|
|
// hintText: 'อีเมลปัจจุบัน'.tr(),
|
|
border: InputBorder.none,
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 16),
|
|
),
|
|
),
|
|
// margin: EdgeInsets.symmetric(horizontal: 20),
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xfff2f2f2),
|
|
),
|
|
),
|
|
Spacer(),
|
|
// Expanded(child: Container()),
|
|
InkWell(
|
|
onTap: () async {
|
|
// initPromptPay(context);
|
|
ChangeEmail();
|
|
},
|
|
child: Container(
|
|
width: double.infinity,
|
|
child: Card(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(40),
|
|
),
|
|
child: Container(
|
|
padding: EdgeInsets.all(10),
|
|
child: Text(
|
|
"Confirm".tr(),
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.kanit(
|
|
color: ColorCustom.greyBorder,
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
]),
|
|
))));
|
|
}
|
|
}
|