step 19 : fix check svg from server
This commit is contained in:
@@ -262,6 +262,18 @@ class Constant {
|
|||||||
// background upload file
|
// background upload file
|
||||||
static Color bgUploadFile = Color.fromRGBO(207, 207, 207, 0.20);
|
static Color bgUploadFile = Color.fromRGBO(207, 207, 207, 0.20);
|
||||||
|
|
||||||
|
// background icon history
|
||||||
|
static Color bgIconHistory = Color.fromRGBO(241, 90, 41, 0.16);
|
||||||
|
|
||||||
|
// background chip confirmed
|
||||||
|
static Color bgChipConfirmed = Color(0xffe8f4f5);
|
||||||
|
|
||||||
|
static Color bgTextChipConfirmed = Color(0xff32827C);
|
||||||
|
|
||||||
|
// delete text
|
||||||
|
static Color bgTextDelete = Color(0xffFF4842);
|
||||||
|
static Color bgTextChipDelete = Color.fromRGBO(255, 72, 66, 0.12);
|
||||||
|
|
||||||
//typoGraphy
|
//typoGraphy
|
||||||
static TextStyle titleH1Login({required BuildContext context}) {
|
static TextStyle titleH1Login({required BuildContext context}) {
|
||||||
return TextStyle(
|
return TextStyle(
|
||||||
|
|||||||
@@ -714,23 +714,188 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
Card(
|
(searchHistoryIsLoading.value)
|
||||||
elevation: 2.0,
|
? Center(
|
||||||
child: Padding(
|
child: CircularProgressIndicator(),
|
||||||
padding: const EdgeInsets.all(10),
|
)
|
||||||
child: Column(
|
: Expanded(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
child: ListView.builder(
|
||||||
// mainAxisAlignment: MainAxisAlignment.start,
|
itemCount: listSearchHistory.value.length,
|
||||||
children: [
|
itemBuilder: (context, idx) {
|
||||||
// atas
|
return Padding(
|
||||||
HistoryRowAtasWidget(),
|
padding: EdgeInsets.only(
|
||||||
|
bottom: Constant.getActualYPhone(
|
||||||
|
context: context,
|
||||||
|
y: 10,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Card(
|
||||||
|
elevation: 2.0,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
child: Column(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// atas
|
||||||
|
HistoryRowAtasWidget(
|
||||||
|
icon_category_id: listSearchHistory
|
||||||
|
.value[idx].kategoriid
|
||||||
|
.toString(),
|
||||||
|
icon_category_name: listSearchHistory
|
||||||
|
.value[idx].kategoriname
|
||||||
|
.toString(),
|
||||||
|
amount: listSearchHistory
|
||||||
|
.value[idx].amount
|
||||||
|
.toString(),
|
||||||
|
tglTransaksi: listSearchHistory
|
||||||
|
.value[idx].tanggaltransaksi
|
||||||
|
.toString(),
|
||||||
|
tipe: listSearchHistory
|
||||||
|
.value[idx].tipe
|
||||||
|
.toString(),
|
||||||
|
),
|
||||||
|
|
||||||
// bawah
|
// bawah
|
||||||
Row(),
|
|
||||||
],
|
if (listSearchHistory
|
||||||
),
|
.value[idx].isconfirm ==
|
||||||
),
|
"Y")
|
||||||
),
|
Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Chip(
|
||||||
|
label: Text(
|
||||||
|
'Confirmed',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Constant.textWhite,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color:
|
||||||
|
Constant.bgChipConfirmed),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
50,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor:
|
||||||
|
Constant.bgChipConfirmed,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: Constant.getActualYPhone(
|
||||||
|
context: context, y: 6),
|
||||||
|
),
|
||||||
|
|
||||||
|
if (listSearchHistory
|
||||||
|
.value[idx].isconfirm ==
|
||||||
|
"N")
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
print('Deleted');
|
||||||
|
},
|
||||||
|
child: Chip(
|
||||||
|
label: Text(
|
||||||
|
'Deleted',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Constant.textWhite,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color:
|
||||||
|
Constant.bgTextChipDelete),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
50,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor:
|
||||||
|
Constant.bgTextDelete,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
// Row(
|
||||||
|
// children: [
|
||||||
|
// Container(
|
||||||
|
// width: Constant.getActualXPhone(
|
||||||
|
// context: context, x: 40),
|
||||||
|
// height: Constant.getActualYPhone(
|
||||||
|
// context: context,
|
||||||
|
// y: 40,
|
||||||
|
// ),
|
||||||
|
// child: Image.asset(
|
||||||
|
// "images/icon_delete.png",
|
||||||
|
// // scale: 1,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// SizedBox(
|
||||||
|
// height: Constant.getActualYPhone(
|
||||||
|
// context: context, y: 12),
|
||||||
|
// ),
|
||||||
|
// Expanded(
|
||||||
|
// child: ElevatedButton(
|
||||||
|
// style: ButtonStyle(
|
||||||
|
// backgroundColor: MaterialStateColor
|
||||||
|
// .resolveWith((st) => Constant
|
||||||
|
// .pcBtnBackgroundColor),
|
||||||
|
// shape:
|
||||||
|
// MaterialStateProperty.all<
|
||||||
|
// RoundedRectangleBorder>(
|
||||||
|
// RoundedRectangleBorder(
|
||||||
|
// borderRadius:
|
||||||
|
// BorderRadius.circular(
|
||||||
|
// 8),
|
||||||
|
// side: BorderSide(
|
||||||
|
// color: Constant
|
||||||
|
// .pcBtnBackgroundColor,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// shadowColor:
|
||||||
|
// MaterialStateProperty.all(
|
||||||
|
// Color(0xffff48423d)),
|
||||||
|
// elevation:
|
||||||
|
// MaterialStateProperty.all(
|
||||||
|
// 4.0),
|
||||||
|
// ),
|
||||||
|
// child: Stack(
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// 'Confirmed',
|
||||||
|
// style: Constant.body1(
|
||||||
|
// context: context)
|
||||||
|
// .copyWith(
|
||||||
|
// fontWeight:
|
||||||
|
// FontWeight
|
||||||
|
// .w600,
|
||||||
|
// color: Constant
|
||||||
|
// .white),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// onPressed: () {},
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'package:app_petty_cash/widget/sankbar_widget.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
@@ -5,10 +7,61 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|||||||
import '../app/constant.dart';
|
import '../app/constant.dart';
|
||||||
|
|
||||||
class HistoryRowAtasWidget extends HookConsumerWidget {
|
class HistoryRowAtasWidget extends HookConsumerWidget {
|
||||||
const HistoryRowAtasWidget({super.key});
|
final String icon_category_id;
|
||||||
|
final String icon_category_name;
|
||||||
|
final String amount;
|
||||||
|
final String tipe;
|
||||||
|
final String tglTransaksi;
|
||||||
|
|
||||||
|
const HistoryRowAtasWidget({
|
||||||
|
Key? key,
|
||||||
|
required this.icon_category_id,
|
||||||
|
required this.icon_category_name,
|
||||||
|
required this.amount,
|
||||||
|
required this.tipe,
|
||||||
|
required this.tglTransaksi,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
|
||||||
|
// check file exist
|
||||||
|
Future<Widget> checkFileExistence(String fileUrl) async {
|
||||||
|
try {
|
||||||
|
final dio = Dio();
|
||||||
|
final response = await dio.head(fileUrl);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return SvgPicture.network(
|
||||||
|
fileUrl,
|
||||||
|
semanticsLabel: 'Icon pizza',
|
||||||
|
placeholderBuilder: (BuildContext context) => Container(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return SvgPicture.network(
|
||||||
|
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
||||||
|
semanticsLabel: 'Icon pizza',
|
||||||
|
placeholderBuilder: (BuildContext context) => Container(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// print('Error checking file existence: $e');
|
||||||
|
return SvgPicture.network(
|
||||||
|
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg',
|
||||||
|
semanticsLabel: 'Icon pizza',
|
||||||
|
placeholderBuilder: (BuildContext context) => Container(
|
||||||
|
padding: const EdgeInsets.all(30.0),
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
// kiri
|
// kiri
|
||||||
@@ -22,28 +75,40 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
// child: Text('s'),
|
// child: Text('s'),
|
||||||
child: SvgPicture.network(
|
child: FutureBuilder<Widget>(
|
||||||
'https://devone.aplikasi.web.id/pettycash-media/icon/icon_12.svg',
|
future: checkFileExistence('https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg'),
|
||||||
semanticsLabel: 'Icon pizza',
|
builder: (context, snapshot) {
|
||||||
placeholderBuilder: (BuildContext context) => Container(
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
padding: const EdgeInsets.all(30.0),
|
return CircularProgressIndicator();
|
||||||
child: const CircularProgressIndicator(),
|
} else if (snapshot.hasError) {
|
||||||
),
|
return Icon(
|
||||||
|
Icons.error,
|
||||||
|
color: Colors.red,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return snapshot.data ??
|
||||||
|
Container();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// tengah
|
// tengah
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(left: 20),
|
padding: EdgeInsets.only(
|
||||||
|
left: Constant.getActualYPhone(context: context, y: 20),
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'Makanan & Minuman',
|
icon_category_name,
|
||||||
style: Constant.body2_600(context: context).copyWith(
|
style: Constant.body2_600(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600, color: Constant.textBlack),
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Constant.textBlack,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Constant.getActualYPhone(
|
height: Constant.getActualYPhone(
|
||||||
@@ -52,7 +117,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'100000',
|
amount,
|
||||||
style: Constant.body1_600(context: context).copyWith(
|
style: Constant.body1_600(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Constant.pcBtnBackgroundColor),
|
color: Constant.pcBtnBackgroundColor),
|
||||||
@@ -65,7 +130,9 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
// kanan
|
// kanan
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(right: 8),
|
padding: EdgeInsets.only(
|
||||||
|
right: Constant.getActualYPhone(context: context, y: 8),
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@@ -74,7 +141,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
// width: Constant.getActualXPhone(context: context, x: 32),
|
// width: Constant.getActualXPhone(context: context, x: 32),
|
||||||
height: Constant.getActualYPhone(context: context, y: 19),
|
height: Constant.getActualYPhone(context: context, y: 19),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Color.fromRGBO(241, 90, 41, 0.16),
|
color: Constant.bgIconHistory,
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
Radius.circular(6.0),
|
Radius.circular(6.0),
|
||||||
),
|
),
|
||||||
@@ -82,7 +149,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(2.0),
|
padding: EdgeInsets.all(2.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Kredit',
|
tipe,
|
||||||
style: Constant.body1_600(context: context).copyWith(
|
style: Constant.body1_600(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Constant.pcBtnBackgroundColor),
|
color: Constant.pcBtnBackgroundColor),
|
||||||
@@ -96,7 +163,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'15 Des 2023',
|
tglTransaksi,
|
||||||
style: Constant.body1_600(context: context).copyWith(
|
style: Constant.body1_600(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600, color: Constant.textGreyv2),
|
fontWeight: FontWeight.w600, color: Constant.textGreyv2),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user