Commit 965e5fff authored by Faizol's avatar Faizol

fixing ui

parent af2930c1
...@@ -18,11 +18,16 @@ This project is a starting point for a Flutter application. ...@@ -18,11 +18,16 @@ This project is a starting point for a Flutter application.
** Added Card history endpoint ticket & balance ✅ ** Added Card history endpoint ticket & balance ✅
** Added UI Card history endpoint ticket & balance ✅ ** Added UI Card history endpoint ticket & balance ✅
** Adjust Ui check balance ✅ ** Adjust Ui check balance ✅
** Added function print card history ** Added function print card history
** Added Ui print card history ** Added Ui print card history
** Update mifare mdd lib to version version: 0.1.42 ✅ ** Update mifare mdd lib to version version: 0.1.42 ✅
** Disable print history ✅ ** Disable print history ✅
** Update version ✅ ** Update version ✅
## Version App Change Log SS.23.2.WWW.SB.PC ## Version App Change Log SS.23.2.WWW.SB.PC
## Version Code 17 ## Version Code 17 (actual)
** remove icon printer ✅
** change icon reload ✅
** add datetime in history saldo & ticket ✅
** add scrollable effect to table history ✅
\ No newline at end of file
sdk.dir=C:\\Users\\MDD HP\\AndroidSDK sdk.dir=C:\\Users\\MDD HP\\AndroidSDK
flutter.sdk=C:\\Users\\MDD HP\\flutter flutter.sdk=C:\\Users\\MDD HP\\flutter
flutter.buildMode=debug flutter.buildMode=debug
flutter.versionName=SS.23.2.WWW.SB.PC flutter.versionName=1.0.0
flutter.versionCode=17 flutter.versionCode=1
\ No newline at end of file \ No newline at end of file
...@@ -11,6 +11,12 @@ Color blueColor = const Color(0xff53c1f9); ...@@ -11,6 +11,12 @@ Color blueColor = const Color(0xff53c1f9);
Color purpleColor = const Color(0xff5142E6); Color purpleColor = const Color(0xff5142E6);
Color greenColor = const Color(0xff22B07D); Color greenColor = const Color(0xff22B07D);
//Pallet timer
Color color1 = const Color(0xffFFCD4B);
Color color2 = const Color(0xff3876BF);
Color color3 = const Color(0xffDA0C81);
Color color4 = const Color(0xffE95793);
//Background color //Background color
Color lightBackgroundColor = const Color(0xffF6F8FB); Color lightBackgroundColor = const Color(0xffF6F8FB);
Color darkBackgroundColor = const Color(0xff020518); Color darkBackgroundColor = const Color(0xff020518);
......
...@@ -47,6 +47,8 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -47,6 +47,8 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
int _activeContainerIndex = 1; int _activeContainerIndex = 1;
List<Map<String, dynamic>> balanceHistoryData = []; List<Map<String, dynamic>> balanceHistoryData = [];
List<Map<String, dynamic>> ticketHistoryData = []; List<Map<String, dynamic>> ticketHistoryData = [];
ScrollController _scrollController = ScrollController();
@override @override
void initState() { void initState() {
...@@ -99,101 +101,151 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -99,101 +101,151 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
return DateFormat('dd-MMM-yyyy').format(nowt); return DateFormat('dd-MMM-yyyy').format(nowt);
} }
_getInfoCard(var info, BuildContext context) { void _getInfoCard(var info, BuildContext context) async {
setState((){ try {
if (info.toString().toLowerCase().contains('failed')) { if (info == null) {
print('ini pesan salah'); print('Data tidak ditemukan');
return;
}
if (info.toString().toLowerCase().contains('card not found')) {
message = "Silakan Tempel Wristband Anda Di Reader"; message = "Silakan Tempel Wristband Anda Di Reader";
tapDial(context); tapDial(context);
if (timer != null) timer?.cancel(); if (timer != null) timer?.cancel();
// tapIdle();
} else { } else {
infoCard = info; infoCard = info;
var infoMap = jsonDecode(info); var infoMap = jsonDecode(info);
switch (infoMap["cardType"]) { if (infoMap["cardType"] != null) {
case 1: switch (infoMap["cardType"]) {
// Perubahan cardType 1 baru menjadi case 1:
cardType = "Kartu Belum Aktif"; cardType = "Kartu Belum Aktif";
break; break;
case 2: case 2:
// Perubahan cardType 2 Belum aktif menjadi cardType = "Kartu Aktif";
cardType = "Kartu Aktif"; break;
break; case 3:
case 3: cardType = "Binding Customer";
// Perubahan cardType 3 aktif menjadi break;
cardType = "Binding Customer"; case 4:
break; cardType = "On Customer";
case 4: break;
cardType = "On Customer"; case 5:
break; cardType = "Refund";
case 5: break;
cardType = "Refund"; default:
break; cardType = "Tidak Terdaftar";
default: break;
cardType = "Tidak Terdaftar"; }
break; } else {
cardType = "Tidak Terdaftar";
}
if (infoMap["balance"] != null) {
balance = CurrencyFormat.convertToIdr(
infoMap["balance"],
2,
);
}
if (infoMap["cardExpirity"] != null) {
var cardExpiryMillis = int.parse(infoMap['cardExpirity']) * 1000;
var change = DateTime.fromMillisecondsSinceEpoch(cardExpiryMillis);
final DateFormat formatter = DateFormat('dd-MMM-yyyy');
cardExpirity = formatter.format(change);
}
if (infoMap["deposit"] != null) {
deposit = CurrencyFormat.convertToIdr(infoMap["deposit"], 2);
} }
balance = CurrencyFormat.convertToIdr(
infoMap["balance"], if (infoMap["cardNumber"] != null) {
2, cardNumber = infoMap["cardNumber"];
); String cardNo = cardNumber.toString();
// NOTE merubah tanggal String targetMasked = cardNo.substring(0, 12);
var change = DateTime.fromMillisecondsSinceEpoch( maskedText = cardNo.replaceAll(targetMasked, '************');
int.parse(infoMap['cardExpirity']) * 1000); }
final DateFormat formatter = DateFormat('dd-MMM-yyyy');
cardExpirity = formatter.format(change); if (infoMap["name"] != null) {
deposit = CurrencyFormat.convertToIdr(infoMap["deposit"], 2,); name = infoMap["name"].toString().split("-")[0];
cardNumber = infoMap["cardNumber"]; }
String cardNo = cardNumber.toString();
String targetMasked = cardNo.substring(0, 12); if (infoMap["cardUid"] != null) {
maskedText = cardNo.replaceAll(targetMasked, '************'); cardUid = infoMap["cardUid"];
name = infoMap["name"].toString().split("-")[0]; }
cardUid = infoMap["cardUid"];
regDb= infoMap["regDb"]; if (infoMap["regDb"] != null) {
regDb = infoMap["regDb"];
await _getAuditHistoryBalance(cardUid, regDb);
await _getAuditHistoryTicket(cardUid, regDb);
}
setState(() {
isShowingDialog = false;
isDenomDialogShowing = false;
checkCountZero = false;
});
tapIdle(context);
Navigator.pop(context);
} }
}); } catch (e) {
// Tangani kesalahan saat memproses data
print("Kesalahan saat memproses data: $e");
// Lakukan sesuatu untuk menangani kesalahan ini, seperti menampilkan pesan kesalahan kepada pengguna.
}
} }
Future<void> getAuditHistoryBalance(String cardUid, String regDb) async { Future<void> _getAuditHistoryBalance(String cardUid, String regDb) async {
try { try {
var auditHistoryBalance = await ServiceApi.fetchAuditHistory(cardUid, regDb, "balance"); var auditHistoryBalance = await ServiceApi.fetchAuditHistory(cardUid, regDb, "balance");
print("AUDIT HISTORY BALANCE: $auditHistoryBalance"); print("AUDIT HISTORY BALANCE: $auditHistoryBalance");
balanceHistoryData.clear(); setState(() {
balanceHistoryData.clear();
// Your data is already a Map, so you don't need to decode it if (auditHistoryBalance != null) {
List<dynamic> dataBalance = auditHistoryBalance['data']; List<dynamic> dataBalance = auditHistoryBalance['data'];
// Tambahkan data dari respons ke dalam balanceHistoryData for (var itemBalance in dataBalance) {
for (var itemBalance in dataBalance) { balanceHistoryData.add(itemBalance);
// print("isi dari $item"); }
balanceHistoryData.add(itemBalance);
}
balanceHistoryData = balanceHistoryData.reversed.toList();
balanceHistoryData = balanceHistoryData.reversed.toList();
}
});
} catch (error) { } catch (error) {
print("AUDIT BALANCE ERROR: $error"); setState(() {
print("AUDIT BALANCE ERROR: $error");
});
} }
} }
Future<void> getAuditHistoryTicket(String cardUid, String regDb) async { Future<void> _getAuditHistoryTicket(String cardUid, String regDb) async {
try { try {
var auditHistoryTicket = await ServiceApi.fetchAuditHistory(cardUid, regDb, "ticket"); var auditHistoryTicket = await ServiceApi.fetchAuditHistory(cardUid, regDb, "ticket");
print("AUDIT HISTORY TICKET: $auditHistoryTicket"); print("AUDIT HISTORY TICKET: $auditHistoryTicket");
ticketHistoryData.clear(); setState(() {
List<dynamic> dataTicket = auditHistoryTicket['data']; ticketHistoryData.clear();
for (var itemTicket in dataTicket) { if (auditHistoryTicket != null) {
ticketHistoryData.add(itemTicket); List<dynamic> dataTicket = auditHistoryTicket['data'];
}
ticketHistoryData = ticketHistoryData.reversed.toList(); for (var itemTicket in dataTicket) {
ticketHistoryData.add(itemTicket);
}
ticketHistoryData = ticketHistoryData.reversed.toList();
}
});
} catch (error) { } catch (error) {
print("AUDIT TICKET ERROR: $error"); setState(() {
print("AUDIT TICKET ERROR: $error");
});
} }
} }
void tapIdle(BuildContext context) { Future <void> tapIdle(BuildContext context) async{
var connectivityResult = Connectivity().checkConnectivity(); var connectivityResult = Connectivity().checkConnectivity();
if (connectivityResult == ConnectivityResult.none) { if (connectivityResult == ConnectivityResult.none) {
...@@ -227,13 +279,13 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -227,13 +279,13 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
if (duration == 0 && !isShowingDialog) { if (duration == 0 && !isShowingDialog) {
isShowingDialog = true; isShowingDialog = true;
timer.cancel(); timer.cancel();
_showTap(context); _showTap(context);
tapDial(context); tapDial(context);
} }
}); });
} }
void tapDial(BuildContext context) async { Future<void> tapDial(BuildContext context) async {
var connectivityResult = await Connectivity().checkConnectivity(); var connectivityResult = await Connectivity().checkConnectivity();
if (connectivityResult == ConnectivityResult.none) { if (connectivityResult == ConnectivityResult.none) {
...@@ -258,15 +310,6 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -258,15 +310,6 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
var isTap = await StartService.getCard(); var isTap = await StartService.getCard();
try { try {
_getInfoCard(isTap, context); _getInfoCard(isTap, context);
await Future.wait([
getAuditHistoryTicket(cardUid, regDb),
getAuditHistoryBalance(cardUid, regDb),
]);
isShowingDialog = false;
isDenomDialogShowing = false;
checkCountZero = false;
tapIdle(context);
Navigator.pop(context);
} catch (e) { } catch (e) {
print("Error $isTap"); print("Error $isTap");
tapDial(context); tapDial(context);
...@@ -533,7 +576,7 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -533,7 +576,7 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
Column( Column(
children: [ children: [
Container( Container(
width: screenWidth * 0.01, // Container untuk spasi di kiri width: screenWidth * 0.10, // Container untuk spasi di kiri
), ),
Container( Container(
width: screenWidth * 0.70, width: screenWidth * 0.70,
...@@ -541,14 +584,18 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -541,14 +584,18 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
child: buildWalletSection(), child: buildWalletSection(),
), ),
Container( Container(
margin: EdgeInsets.fromLTRB(0,0,0,0 ), margin: EdgeInsets.fromLTRB(30,0,0,0 ),
width: screenWidth * 0.95, width: screenWidth * 0.95,
height: screenHeight * 0.70, // Container untuk "balance section" height: screenHeight * 0.70, // Container untuk "balance section"
child: buildBalanceSection(), child: buildBalanceSection(),
), ),
SizedBox(height: 20), SizedBox(height: 20),
SizedBox(height: 20), SizedBox(height: 20),
buildTicketSection(), Container(
margin: EdgeInsets.fromLTRB(30,0,0,0 ),
width: screenWidth * 0.95,
height: screenHeight * 0.70,
child: buildTicketSection()),
SizedBox(height: 20), SizedBox(height: 20),
], ],
), ),
...@@ -556,9 +603,10 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -556,9 +603,10 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
), ),
), ),
Positioned( Positioned(
bottom: 20.0, // Adjust the position as needed bottom: 90.0, // Adjust the position as needed
right: 20.0, // Adjust the position as needed right: 5.0, // Adjust the position as needed
child: FloatingActionButton( child: FloatingActionButton(
backgroundColor: purpleColor,
onPressed: () { onPressed: () {
// Add the action for your floating button // Add the action for your floating button
isShowingDialog = true; isShowingDialog = true;
...@@ -566,15 +614,17 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -566,15 +614,17 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
_showTap(context); _showTap(context);
tapDial(context); tapDial(context);
}, },
child: Icon(Icons.search), child: Icon(
Icons.sync,
color: Colors.white,),
), ),
), ),
Positioned( // Positioned(
bottom: 100.0, // Adjust the position as needed // bottom: 100.0, // Adjust the position as needed
right: 20.0, // Adjust the position as needed // right: 20.0, // Adjust the position as needed
child: FloatingActionButton( // child: FloatingActionButton(
onPressed: () { // onPressed: () {
showToastMessage('Maaf , fitur tidak tersedia'); // showToastMessage('Maaf , fitur tidak tersedia');
//Nyalakan kembali jika dibutuhkan //Nyalakan kembali jika dibutuhkan
// Konversi data ke JSON // Konversi data ke JSON
...@@ -595,13 +645,13 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -595,13 +645,13 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
// deposit, // deposit,
// balance // balance
// ); // );
}, // },
child: Icon(Icons.print), // child: Icon(Icons.print),
), // ),
), // ),
Positioned( Positioned(
bottom: 120.0, // Adjust the position as needed bottom: 100.0, // Adjust the position as needed
right: 30.0, // Adjust the position as needed right: 14.5, // Adjust the position as needed
child: buildTimerSection(context), child: buildTimerSection(context),
), ),
], ],
...@@ -955,7 +1005,7 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -955,7 +1005,7 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
const SizedBox( const SizedBox(
height: 25, height: 25,
), ),
], ],
), ),
), ),
], ],
...@@ -970,7 +1020,7 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -970,7 +1020,7 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
return Visibility( return Visibility(
visible: balanceHistoryData.isNotEmpty, visible: balanceHistoryData.isNotEmpty,
child: Container( child: Container(
width: screenWidth , width: screenWidth * 40,
height: 500, height: 500,
padding: EdgeInsets.only(bottom: 20),// padding: EdgeInsets.only(bottom: 20),//
margin: EdgeInsets.all(20), // Add margin to the outer Container margin: EdgeInsets.all(20), // Add margin to the outer Container
...@@ -1018,18 +1068,24 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -1018,18 +1068,24 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
children: [ children: [
TableRow( TableRow(
children: [ children: [
TableCell(child: Text('Terminal',style: TextStyle(fontWeight: FontWeight.bold),)), // Judul untuk sel pertama TableCell(child: Text('Terminal',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center,)),
TableCell(child: Text('Tipe', style: TextStyle(fontWeight: FontWeight.bold))), // Judul untuk sel kedua TableCell(child: Text('Tid',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel pertama// Judul untuk sel pertama
TableCell(child: Text('Jumlah',style: TextStyle(fontWeight: FontWeight.bold))), // Judul untuk sel kedua TableCell(child: Text('Tipe', style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('Saldo Akhir',style: TextStyle(fontWeight: FontWeight.bold))), // Judul untuk sel kedua TableCell(child: Text('Tanggal', style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('Jam', style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('Jumlah',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('Saldo Akhir',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
], ],
), ),
TableRow( TableRow(
children: [ children: [
TableCell(child: Text('-',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel pertama TableCell(child: Text('-',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel pertama
TableCell(child: Text('type',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel kedua TableCell(child: Text('-',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel pertama
TableCell(child: Text('amount',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel kedua TableCell(child: Text('type',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('last balance',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel kedua TableCell(child: Text('date',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('time',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('amount',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('last balance',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
], ],
), ),
], ],
...@@ -1043,49 +1099,78 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -1043,49 +1099,78 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
), ),
Expanded( Expanded(
child: Container( child: Container(
child: child: Scrollbar(
ListView.builder( controller: _scrollController, // Use the same ScrollController
shrinkWrap: true, // Make sure to set shrinkWrap to true thumbVisibility: true,
itemCount: balanceHistoryData.length, radius: Radius.circular(6), // Customize the scrollbar appearance
itemBuilder: (context, index) { thickness: 6,// Ensure scrollbar is always shown
final data = balanceHistoryData[index]; child: ListView.builder(
int amount = data['amount']; shrinkWrap: true, // Make sure to set shrinkWrap to true
int lastBalance = data['last_balance']; itemCount: balanceHistoryData.length,
String fAmount = NumberFormat.decimalPattern().format(amount); itemBuilder: (context, index) {
String fLastBalance = NumberFormat.decimalPattern().format(lastBalance); final data = balanceHistoryData[index];
return SingleChildScrollView( int amount = data['amount'];
physics: BouncingScrollPhysics(), int lastBalance = data['last_balance'];
child: String fAmount = NumberFormat.decimalPattern().format(amount);
Card( String fLastBalance = NumberFormat.decimalPattern().format(lastBalance);
margin: EdgeInsets.fromLTRB(20,0,20,12), String dateTimeString = data['datetime'];
child: Padding( List<String> parts = dateTimeString.split(" ");
padding: const EdgeInsets.fromLTRB(20,10,20,10), String date = parts[0];
child: Column( String time = parts[1];
children: [ String terminalTid = data['terminal'];
Row( String terminalName = data['terminal'];
children: [ String tid = "-";
Expanded( String name = "-";
child: Table(
children: [ if (terminalName.length > 4) {
TableRow( name = terminalName.substring(0, terminalName.length - 5);
children: [ } else {
TableCell(child: Text(data['terminal'])), terminalName = "";
TableCell(child: Text(data['type'])), }
TableCell(child: Text(fAmount.toString())),
TableCell(child: Text(fLastBalance.toString())), if (terminalTid.length >= 4) {
], tid = terminalTid.substring(terminalTid.length - 4); // Mengambil 4 karakter terakhir
), } else {
], while (terminalTid.length < 4) {
terminalTid = "0" + terminalTid;
}
}
return SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Card(
margin: EdgeInsets.fromLTRB(20,0,20,12),
child: Padding(
padding: const EdgeInsets.fromLTRB(20,10,20,10),
child: Column(
children: [
Row(
children: [
Expanded(
child: Table(
children: [
TableRow(
children: [
TableCell(child: Text(name,textAlign: TextAlign.center)),
TableCell(child: Text(tid,textAlign: TextAlign.center)),
TableCell(child: Text(data['type'],textAlign: TextAlign.center)),
TableCell(child: Text(date,textAlign: TextAlign.center)),
TableCell(child: Text(time,textAlign: TextAlign.center)),
TableCell(child: Text(fAmount.toString(),textAlign: TextAlign.center)),
TableCell(child: Text(fLastBalance.toString(),textAlign: TextAlign.center)),
],
),
],
),
), ),
), ],
], ),
), ],
], ),
), ),
), ),
), );
); },
}, ),
), ),
), ),
), ),
...@@ -1098,82 +1183,113 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -1098,82 +1183,113 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
Widget buildTicketSection() { Widget buildTicketSection() {
double screenWidth = MediaQuery.of(context).size.width; double screenWidth = MediaQuery.of(context).size.width;
double textScaleFactor = screenWidth / 1700; double textScaleFactor = screenWidth / 1700;
return Visibility( return Visibility(
visible: ticketHistoryData.isNotEmpty, visible: ticketHistoryData.isNotEmpty,
child: SingleChildScrollView( child: Container(
child: Container( width: screenWidth * 40,
width: screenWidth * 40, height: 500,
height: 500, margin: EdgeInsets.all(20),
margin: EdgeInsets.all(20), padding: EdgeInsets.only(bottom: 20),// Add margin to the outer Container
padding: EdgeInsets.only(bottom: 20),// Add margin to the outer Container child: Column(
child: Column( crossAxisAlignment: CrossAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, children: [
children: [ Text(
Text( "History Card Ticket",
"History Card Ticket", style: blackTextStyle.copyWith(
style: blackTextStyle.copyWith( fontSize: 28,
fontSize: 28, fontWeight: medium,
fontWeight: medium, letterSpacing: 3,
letterSpacing: 3,
),
), ),
Text( ),
'history card ticket', Text(
style: blackTextStyle.copyWith( 'history card ticket',
fontSize: 15, style: blackTextStyle.copyWith(
fontWeight: light, fontSize: 15,
fontStyle: FontStyle.italic, fontWeight: light,
letterSpacing: 3, fontStyle: FontStyle.italic,
), letterSpacing: 3,
), ),
SizedBox(height: 20,), ),
Center( SizedBox(height: 20,),
child: Container( Center(
height: 80, child: Container(
margin: EdgeInsets.fromLTRB(20, 0, 20, 0), height: 80,
child: Card( margin: EdgeInsets.fromLTRB(20, 0, 20, 0),
child: Padding( child: Card(
padding: const EdgeInsets.fromLTRB(20,10,20,10), child: Padding(
child: Row( padding: const EdgeInsets.fromLTRB(10,10,10,10),
children: [ child: Row(
Expanded( children: [
child: Table( Expanded(
children: [ child: Table(
TableRow( children: [
children: [ TableRow(
TableCell(child: Text('Terminal',style: TextStyle(fontWeight: FontWeight.bold),)), // Judul untuk sel pertama children: [
TableCell(child: Text('Tipe', style: TextStyle(fontWeight: FontWeight.bold))), // Judul untuk sel kedua TableCell(child: Text('Terminal',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel pertama
TableCell(child: Text('Kuantitas',style: TextStyle(fontWeight: FontWeight.bold))), // Judul untuk sel kedua TableCell(child: Text('Tid',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel pertama
TableCell(child: Text('Tiket Akhir',style: TextStyle(fontWeight: FontWeight.bold))), // Judul untuk sel kedua TableCell(child: Text('Tipe', style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
], TableCell(child: Text('Tanggal', style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
), TableCell(child: Text('Jam', style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)),
TableRow( TableCell(child: Text('Kuantitas',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
children: [ TableCell(child: Text('Tiket Akhir',style: TextStyle(fontWeight: FontWeight.bold),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('-',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel pertama ],
TableCell(child: Text('type',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel kedua ),
TableCell(child: Text('quantity',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel kedua TableRow(
TableCell(child: Text('last ticket',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic))), // Judul untuk sel kedua children: [
], TableCell(child: Text('-',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel pertama
), TableCell(child: Text('-',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel pertama
], TableCell(child: Text('type',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)),
), TableCell(child: Text('date',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('time',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('quantity',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
TableCell(child: Text('last ticket',style: TextStyle(fontWeight: light , fontStyle: FontStyle.italic),textAlign: TextAlign.center)), // Judul untuk sel kedua
],
),
],
), ),
], ),
), ],
), ),
), ),
), ),
), ),
Expanded( ),
child: Container( Expanded(
child: child: Container(
ListView.builder( child:
Scrollbar(
controller: _scrollController, // Use the same ScrollController
thumbVisibility: true,
radius: Radius.circular(6), // Customize the scrollbar appearance
thickness: 6,
child: ListView.builder(
shrinkWrap: true, // Make sure to set shrinkWrap to true shrinkWrap: true, // Make sure to set shrinkWrap to true
itemCount: ticketHistoryData.length, itemCount: ticketHistoryData.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
final data = ticketHistoryData[index]; final data = ticketHistoryData[index];
String dateTimeString = data['datetime'];
List<String> parts = dateTimeString.split(" ");
String date = parts[0];
String time = parts[1];
String terminalTid = data['terminal'];
String terminalName = data['terminal'];
String tid = "-";
String name = "-";
if (terminalName.length > 4) {
name = terminalName.substring(0, terminalName.length - 5);
} else {
terminalName = "";
}
if (terminalTid.length >= 4) {
tid = terminalTid.substring(terminalTid.length - 4); // Mengambil 4 karakter terakhir
} else {
while (terminalTid.length < 4) {
terminalTid = "0" + terminalTid;
}
}
return SingleChildScrollView( return SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
child: child:
...@@ -1190,10 +1306,12 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -1190,10 +1306,12 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
children: [ children: [
TableRow( TableRow(
children: [ children: [
TableCell(child: Text(data['terminal'])), TableCell(child: Text(name,textAlign: TextAlign.center)),
TableCell(child: Text(data['type'])), TableCell(child: Text(tid,textAlign: TextAlign.center)),
TableCell(child: Text(data['amount'].toString())), TableCell(child: Text(data['type'],textAlign: TextAlign.center)),
TableCell(child: Text(data['last_balance'].toString())), TableCell(child: Text(date,textAlign: TextAlign.center)),
TableCell(child: Text(time,textAlign: TextAlign.center)), TableCell(child: Text(data['amount'].toString(),textAlign: TextAlign.center)),
TableCell(child: Text(data['last_balance'].toString(),textAlign: TextAlign.center)),
], ],
), ),
], ],
...@@ -1210,15 +1328,14 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -1210,15 +1328,14 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
}, },
), ),
), ),
), ], ),
), ), ],
), ),
), ),
); );
} }
buildTimerSection(BuildContext context) { buildTimerSection(BuildContext context) {
return Container( return Container(
height: 80, height: 80,
margin: const EdgeInsets.only( margin: const EdgeInsets.only(
...@@ -1239,23 +1356,38 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements ...@@ -1239,23 +1356,38 @@ class _HomePageCheckBalanceState extends State<HomePageCheckBalance> implements
children: [ children: [
ValueListenableBuilder( ValueListenableBuilder(
valueListenable: idleDuration, valueListenable: idleDuration,
builder: (context, value, child) => builder: (context, value, child) {
CircularProgressIndicator( Color progressBarColor;
strokeWidth: 5, double progressValue = value / _maxDuration;
value: value / _maxDuration,
// Menggunakan nilai langsung dari value if (progressValue < 0.25) {
valueColor: progressBarColor = color4;
AlwaysStoppedAnimation<Color>(Colors.blue), } else if (progressValue < 0.5) {
), progressBarColor = color3;
} else {
progressBarColor = blueColor;
}
return Stack(
alignment: Alignment.center,
children: [
CircularProgressIndicator(
strokeWidth: 5,
value: progressValue,
valueColor: AlwaysStoppedAnimation<Color>(progressBarColor),
),
],
);
},
), ),
RotatedBox( RotatedBox(
quarterTurns: 4, // Menggunakan nilai bulat dari value quarterTurns: 4,
child: ValueListenableBuilder( child: ValueListenableBuilder(
valueListenable: idleDuration, valueListenable: idleDuration,
builder: (context, value, child) => Text( builder: (context, value, child) => Text(
(value.toInt() % _maxDuration).toString(), (value.toInt() % _maxDuration).toString(),
// Menggunakan nilai bulat dari value style: TextStyle(color: darkBackgroundColor,fontSize: 15),
style: TextStyle(fontSize: 19),
), ),
), ),
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment