step 20 : delete transaksi, bug icon svg from server, date convert tgl trans

This commit is contained in:
sindhu
2024-01-16 22:06:42 +07:00
parent 178dd3b509
commit f915ed2c10
4 changed files with 451 additions and 164 deletions

View File

@@ -3,6 +3,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:intl/intl.dart';
import '../app/constant.dart';
@@ -12,6 +13,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
final String amount;
final String tipe;
final String tglTransaksi;
// final ValueNotifier<bool> searchHistoryIsLoading;
const HistoryRowAtasWidget({
Key? key,
@@ -20,11 +22,11 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
required this.amount,
required this.tipe,
required this.tglTransaksi,
// required this.searchHistoryIsLoading,
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
// check file exist
Future<Widget> checkFileExistence(String fileUrl) async {
try {
@@ -62,6 +64,24 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
}
}
// fungsi tanggal
String formatDateString(String inputDate) {
try {
// Parsing tanggal dari string input
DateTime date = DateFormat('dd-MM-yyyy').parse(inputDate);
// Format tanggal ke '30 Des 2023'
String formattedDate = DateFormat('dd MMM yyyy', 'id').format(date);
return formattedDate;
} catch (e) {
// Tangkap kesalahan jika format tanggal tidak sesuai
print('Error parsing date: $e');
// return 'Format Tanggal Salah';
return inputDate;
}
}
return Row(
children: [
// kiri
@@ -76,7 +96,8 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
),
// child: Text('s'),
child: FutureBuilder<Widget>(
future: checkFileExistence('https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg'),
future: checkFileExistence(
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg'),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator();
@@ -86,8 +107,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
color: Colors.red,
);
} else {
return snapshot.data ??
Container();
return snapshot.data ?? Container();
}
},
),
@@ -163,7 +183,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
),
),
Text(
tglTransaksi,
formatDateString(tglTransaksi),
style: Constant.body1_600(context: context).copyWith(
fontWeight: FontWeight.w600, color: Constant.textGreyv2),
),