step 21 : fix bug history transaksi, logo apk.png
This commit is contained in:
BIN
app_petty_cash/images/logo_apk.png
Normal file
BIN
app_petty_cash/images/logo_apk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
@@ -2,10 +2,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'app/route.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
initializeDateFormatting();
|
||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||
statusBarIconBrightness:
|
||||
Brightness.dark, // this will change the brightness of the icons
|
||||
|
||||
@@ -28,7 +28,44 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// check file exist
|
||||
Future<Widget> checkFileExistence(String fileUrl) async {
|
||||
// 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(),
|
||||
// // ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
final iconProvider =
|
||||
FutureProvider.family<Widget, String>((ref, fileUrl) async {
|
||||
try {
|
||||
final dio = Dio();
|
||||
final response = await dio.head(fileUrl);
|
||||
@@ -36,39 +73,26 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
||||
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(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// fungsi tanggal
|
||||
String formatDateString(String inputDate) {
|
||||
try {
|
||||
// Parsing tanggal dari string input
|
||||
DateTime date = DateFormat('dd-MM-yyyy').parse(inputDate);
|
||||
DateTime date = DateFormat('dd-MM-yyyy','id').parse(inputDate);
|
||||
|
||||
// Format tanggal ke '30 Des 2023'
|
||||
String formattedDate = DateFormat('dd MMM yyyy', 'id').format(date);
|
||||
@@ -82,6 +106,46 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Widget getIconUrl(String categoryid) {
|
||||
List<Map<String, String>> iconDataList = [
|
||||
{'categoryid': '1', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '2', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '3', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_3.svg'},
|
||||
{'categoryid': '4', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '5', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_5.svg'},
|
||||
{'categoryid': '6', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_6.svg'},
|
||||
{'categoryid': '7', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '8', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '9', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '10', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '11', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
{'categoryid': '12', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_12.svg'},
|
||||
{'categoryid': '13', 'url': 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg'},
|
||||
];
|
||||
|
||||
String urlFix = "";
|
||||
|
||||
for (var i = 0; i < iconDataList.length; i++) {
|
||||
if (iconDataList[i]['categoryid'] == categoryid) {
|
||||
// urlFix =
|
||||
// "https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg";
|
||||
|
||||
urlFix = iconDataList[i]['url'] ?? "https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg";
|
||||
}
|
||||
}
|
||||
|
||||
if (urlFix == "") {
|
||||
urlFix =
|
||||
"https://devone.aplikasi.web.id/pettycash-media/icon/icon_13.svg";
|
||||
}
|
||||
|
||||
// return urlFix;
|
||||
return SvgPicture.network(
|
||||
urlFix,
|
||||
semanticsLabel: 'Icon category',
|
||||
);
|
||||
}
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
// kiri
|
||||
@@ -95,22 +159,71 @@ 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'),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator();
|
||||
} else if (snapshot.hasError) {
|
||||
return Icon(
|
||||
Icons.error,
|
||||
color: Colors.red,
|
||||
);
|
||||
} else {
|
||||
return snapshot.data ?? Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
// child: FutureBuilder<Widget>(
|
||||
// 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();
|
||||
// // return Text('');
|
||||
// // } else if (snapshot.hasError) {
|
||||
// // return Icon(
|
||||
// // Icons.error,
|
||||
// // color: Colors.red,
|
||||
// // );
|
||||
// // } else {
|
||||
// // return snapshot.data ?? Container();
|
||||
// // }
|
||||
|
||||
// if (snapshot.connectionState == ConnectionState.done) {
|
||||
// return snapshot.data ?? Container();
|
||||
// } else if (snapshot.hasError) {
|
||||
// return Icon(
|
||||
// Icons.error,
|
||||
// color: Colors.red,
|
||||
// );
|
||||
// } else {
|
||||
// return Text('');
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// child: Consumer(
|
||||
// builder: (context, watch, child) {
|
||||
// String iconUrl =
|
||||
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg';
|
||||
// final iconAsyncValue = ref.read(
|
||||
// iconProvider(
|
||||
// iconUrl,
|
||||
// ),
|
||||
// );
|
||||
|
||||
// return iconAsyncValue.when(
|
||||
// loading: () {
|
||||
// print('loading iconurl : $iconUrl');
|
||||
// return CircularProgressIndicator();
|
||||
// },
|
||||
// error: (error, stackTrace) {
|
||||
// print('error iconurl : $iconUrl');
|
||||
// return Icon(
|
||||
// Icons.error,
|
||||
// color: Colors.red,
|
||||
// );
|
||||
// },
|
||||
// data: (iconWidget) {
|
||||
// print('data iconurl : $iconUrl');
|
||||
// return iconWidget ?? Container();
|
||||
// }
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
|
||||
// child: SvgPicture.network(
|
||||
// 'https://devone.aplikasi.web.id/pettycash-media/icon/icon_$icon_category_id.svg',
|
||||
// semanticsLabel: 'Icon pizza',
|
||||
// ),
|
||||
|
||||
child: getIconUrl(icon_category_id),
|
||||
),
|
||||
|
||||
// tengah
|
||||
|
||||
Reference in New Issue
Block a user