Files
Neo_wallet/neowallet_mobile/lib/TransferMoney/transfer_history.dart
Manasit.K 43c32ef6cf init
2024-10-31 15:57:57 +07:00

167 lines
5.8 KiB
Dart

import 'dart:convert';
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.now());
var end = DateFormat('yyyy-MM-dd').format(DateTime(date.year - 1, date.month, date.day));
var param = jsonEncode(<dynamic, dynamic>{
"id": "",
"payeeUserAccountId": "",
"payerUserAccountId": "",
"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 Expanded(
child: 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(
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,
),
),
],
),
);
}));
}
}