466 lines
16 KiB
Dart
466 lines
16 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
import '../Pay/PayPromptPay.dart';
|
|
import '../PinCodeVadidate.dart';
|
|
import '../api/api.dart';
|
|
import '../utils/color_custom.dart';
|
|
import 'TransferCathayPayDialog.dart';
|
|
TextEditingController _phone = TextEditingController();
|
|
class TransferCathayPay extends StatefulWidget {
|
|
const TransferCathayPay({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<TransferCathayPay> createState() => _TransferCathayPayState();
|
|
}
|
|
|
|
class _TransferCathayPayState extends State<TransferCathayPay> {
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(body: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
IconButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
icon: Icon(
|
|
Icons.arrow_back_ios,
|
|
color: Colors.black,
|
|
)),
|
|
Text(
|
|
"โอนเงินให้สมาชิก NEO PAY".tr(),
|
|
style: TextStyle(
|
|
color: Color(0xff050505),
|
|
fontSize: 20,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SizedBox(height: 20,),
|
|
Container(
|
|
child: TextField(
|
|
keyboardType: TextInputType.number,
|
|
inputFormatters: [
|
|
FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
|
|
],
|
|
controller: _phone,
|
|
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: 20,),
|
|
InkWell(
|
|
onTap: () async {
|
|
showModalBottomSheet<void>(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
useSafeArea: true,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(
|
|
top: Radius.circular(16),
|
|
),
|
|
),
|
|
builder: (BuildContext context) {
|
|
return TransferCathayPayDetail();
|
|
});
|
|
},
|
|
child: Container(
|
|
width: double.infinity,
|
|
margin: const EdgeInsets.symmetric(horizontal: 15),
|
|
child: Card(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(40),
|
|
),
|
|
child: Container(
|
|
padding: EdgeInsets.all(10),
|
|
child: Text(
|
|
"Next".tr(),
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.kanit(
|
|
color: ColorCustom.greyBorder,
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
)
|
|
],
|
|
),
|
|
),);
|
|
}
|
|
}
|
|
|
|
class TransferCathayPayDetail extends StatefulWidget {
|
|
const TransferCathayPayDetail({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<TransferCathayPayDetail> createState() => _TransferCathayPayDetailState();
|
|
}
|
|
|
|
class _TransferCathayPayDetailState extends State<TransferCathayPayDetail> {
|
|
@override
|
|
void initState() {
|
|
initPromptPay(context);
|
|
super.initState();
|
|
}
|
|
TextEditingController _price = TextEditingController();
|
|
String name ="";
|
|
initPromptPay(BuildContext context) {
|
|
_phone.text = '${_phone.text .substring(0, 3)}-${_phone.text .substring(3, 6)}-${_phone.text .substring(6)}';
|
|
var param = jsonEncode(<dynamic, dynamic>{"idCardOrMobileDeviceNo": _phone.text, "amount": 0});
|
|
Api.post(context, Api.transferedPromptPayInitial, param).then((value) => {
|
|
if (value != null)
|
|
{
|
|
name = value["prompPayname"].toString()
|
|
// refresh()
|
|
}
|
|
else
|
|
{}
|
|
|
|
});
|
|
refresh();
|
|
}
|
|
refresh() {
|
|
setState(() {});
|
|
}
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.white,
|
|
actions: [
|
|
CupertinoButton(
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: IconButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
icon: const Icon(
|
|
Icons.clear,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
elevation: 0,
|
|
title: Text(
|
|
"Transfer Money".tr(),
|
|
textAlign: TextAlign.center,
|
|
style: GoogleFonts.kanit(
|
|
color: Colors.black,
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"ชื่อ".tr(),
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w300,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Container(
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xfff2f2f2),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Spacer(),
|
|
Text(
|
|
name,
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 20,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
"เบอร์โทรศัพท์".tr(),
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w300,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Text(
|
|
"",
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Text(
|
|
"จำนวนเงินที่โอน / จ่าย".tr(),
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w300,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xfff2f2f2),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Spacer(),
|
|
Text(
|
|
"",
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 20,
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 20,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Text(
|
|
"ใช้แต้ม NEO PAY แทนเงินสด".tr(),
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w300,
|
|
),
|
|
),
|
|
Text(
|
|
"${"คะแนนของคุณ".tr()} : 12,000 ${"แต้ม".tr()}",
|
|
style: TextStyle(
|
|
color: Color(0xff9d001b),
|
|
fontSize: 14,
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xfff2f2f2),
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 20,
|
|
vertical: 6,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
"10 ${"แต้ม".tr()}",
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Text(
|
|
"=",
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 24,
|
|
),
|
|
),
|
|
Container(
|
|
width: 161,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(100),
|
|
color: Color(0xff9d001b),
|
|
),
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 20,
|
|
vertical: 6,
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
"100 ${"Baht".tr()}",
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
Center(
|
|
child: Text(
|
|
"1 แต้ม = 10 สตางค์".tr(),
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w300,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
height: 136,
|
|
color: Colors.transparent,
|
|
child: Column(
|
|
children: [
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
"ยอดเงินทั้งหมด".tr(),
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Text(
|
|
"",
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Color(0xff9d001b),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
Text(
|
|
" ${"Baht".tr()}",
|
|
textAlign: TextAlign.right,
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
InkWell(
|
|
onTap: () async {
|
|
final result = await Navigator.push(
|
|
context,
|
|
MaterialPageRoute(builder: (context) => PinCodeValidatePage()),
|
|
);
|
|
if (result == true) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return TransferCathayPayDialog();
|
|
});
|
|
}
|
|
},
|
|
child: SizedBox(
|
|
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,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
}
|