186 lines
6.2 KiB
Dart
186 lines
6.2 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:cathaypay_mobile/Home/HomePage.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
import '../api/api.dart';
|
|
import '../model/transaction_model.dart';
|
|
import '../model/transfer_history_model.dart';
|
|
import '../utils/utils.dart';
|
|
|
|
class TransferHistory extends StatefulWidget {
|
|
const TransferHistory({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<TransferHistory> createState() => _TopUpHistoryState();
|
|
}
|
|
|
|
class _TopUpHistoryState extends State<TransferHistory> {
|
|
List<TransferHistoryModel> listTrans = [];
|
|
|
|
getTransaction() {
|
|
listTrans.clear();
|
|
var date = DateTime.now();
|
|
var start = DateFormat('yyyy-MM-dd').format(DateTime(date.year - 1, date.month, date.day));
|
|
var end = DateFormat('yyyy-MM-dd').format(DateTime.now());
|
|
|
|
var param = jsonEncode(<dynamic, dynamic>{
|
|
"id": "",
|
|
"requestUserID": profile!.id,
|
|
"invoiceId": "",
|
|
"referencE1": "",
|
|
"referencE2": "",
|
|
"paymentStatus": "",
|
|
"paymentChannel": "",
|
|
"createDatefrom": start,
|
|
"createDateto": end,
|
|
"requestName": "",
|
|
"fullName": ""
|
|
// "id": "",
|
|
// "payeeUserAccountId": "",
|
|
// "payerUserAccountId": profile!.id,
|
|
// "invoiceId": "",
|
|
// "referencE1": "",
|
|
// "referencE2": "",
|
|
// "referencE3": "",
|
|
// "paymentStatus": "",
|
|
// "paymentChannel": "",
|
|
// "qrId": "",
|
|
// "createDatefrom": null,
|
|
// "createDateto": null,
|
|
// "sattleDate": null,
|
|
// "voidDate": null,
|
|
// "refundDate": null,
|
|
// "cancelDate": null
|
|
});
|
|
|
|
Api.post(context, Api.getTransaction, param).then((value) => {
|
|
if (value != null)
|
|
{
|
|
value.forEach((v) {
|
|
listTrans.add(TransferHistoryModel.fromJson(v));
|
|
}),
|
|
refresh()
|
|
}
|
|
else
|
|
{}
|
|
});
|
|
}
|
|
|
|
refresh() {
|
|
setState(() {});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
getTransaction();
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListView.builder(
|
|
itemCount: listTrans.length,
|
|
shrinkWrap: true,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
TransferHistoryModel transactions = listTrans[index];
|
|
return Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
Utils.convertDateToDay(transactions.updateDate ?? "",context),
|
|
style: GoogleFonts.kanit(
|
|
color: Color(0xff565656),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
Container(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Text(
|
|
transactions.paymentChannel ?? "",
|
|
style: GoogleFonts.kanit(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w300,
|
|
),
|
|
),
|
|
Spacer(),
|
|
Text(
|
|
"${Utils.moneyFormat(transactions.amount ?? "")} ${"Baht".tr()}",
|
|
textAlign: TextAlign.right,
|
|
style: GoogleFonts.kanit(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Text(
|
|
transactions.payeeFullName ?? "",
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
Text(
|
|
"To ${transactions.qrId.toString().split('|').toList().length >= 3 ?transactions.qrId.toString().split('|').toList()[3].startsWith('0') ? transactions.qrId.toString().split('|').toList()[3]:"" : "" }" ?? "",
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
Text(
|
|
transactions.phoneNumber ?? "",
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 16,
|
|
),
|
|
),
|
|
Text(
|
|
Utils.convertDateToTime(transactions.updateDate ?? ""),
|
|
style: TextStyle(
|
|
color: Color(0xff65676b),
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w300,
|
|
),
|
|
),
|
|
// Row(
|
|
// children: [
|
|
// Spacer(),
|
|
// Icon(
|
|
// Icons.keyboard_arrow_down,
|
|
// color: Colors.grey.shade400,
|
|
// size: 30,
|
|
// )
|
|
// ],
|
|
// ),
|
|
],
|
|
),
|
|
),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(10),
|
|
color: Colors.grey.shade100,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
}
|