3 Commits

Author SHA1 Message Date
Stephen
b3c9ac534d [Drawer] 2. get company usr & fix css 2024-01-17 12:08:53 +07:00
Stephen
e7685e8576 [Drawer] 1. improve styling drawer 2024-01-17 09:42:15 +07:00
sindhu
f915ed2c10 step 20 : delete transaksi, bug icon svg from server, date convert tgl trans 2024-01-16 22:06:42 +07:00
7 changed files with 710 additions and 321 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

@@ -121,4 +121,34 @@ class TransaksiRepository extends BaseRepository {
}); });
return result; return result;
} }
// delete transaksi
Future<String> deleteTransaksi(
String id,
String userid,
) async {
final service =
"${Constant.baseUrlDevone}transaction/deletetransaction/?id=$id&userid=$userid";
final resp = await get(
// param: {
// "": "",
// },
service: service,
);
print("url delete transaksi : $service");
// final result = List<ListCategory>.empty(growable: true);
// resp['data'].forEach((e) {
// final model = ListCategory.fromJson(e);
// result.add(model);
// });
if(resp['status'] != "OK"){
return resp['message'];
}
return resp['status'];
}
} }

View File

@@ -0,0 +1,84 @@
import 'package:equatable/equatable.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../repository/transaksi_repository.dart';
import '../../provider/dio_provider.dart';
import '../../repository/base_repository.dart';
import 'search_history_transaksi_provider.dart';
abstract class DeleteTransaksiState extends Equatable {
final DateTime date;
const DeleteTransaksiState(this.date);
@override
List<Object?> get props => [date];
}
class DeleteTransaksiStateInit extends DeleteTransaksiState {
DeleteTransaksiStateInit() : super(DateTime.now());
}
class DeleteTransaksiStateLoading extends DeleteTransaksiState {
DeleteTransaksiStateLoading() : super(DateTime.now());
}
class DeleteTransaksiStateError extends DeleteTransaksiState {
final String message;
DeleteTransaksiStateError({
required this.message,
}) : super(DateTime.now());
}
class DeleteTransaksiStateDone extends DeleteTransaksiState {
// final List<ListType> model;
final String resp;
DeleteTransaksiStateDone({
required this.resp,
}) : super(DateTime.now());
}
//notifier
class DeleteTransaksiNotifier extends StateNotifier<DeleteTransaksiState> {
final Ref ref;
DeleteTransaksiNotifier({
required this.ref,
}) : super(DeleteTransaksiStateInit());
void deleteTransaksi(
String id,
String userid,
String companyid,
String tglAwal,
String tglAkhir,
String categoryid,
) async {
try {
state = DeleteTransaksiStateLoading();
final dio = ref.read(dioProvider);
final resp = await TransaksiRepository(dio: dio).deleteTransaksi(
id,
userid,
);
state = DeleteTransaksiStateDone(resp: resp);
// search lagi buat get data
ref.read(searchHistoryTransaksiProvider.notifier).searchHistoryTransaksi(
companyid,
tglAwal,
tglAkhir,
categoryid,
);
} catch (e) {
if (e is BaseRepositoryException) {
state = DeleteTransaksiStateError(message: e.message.toString());
} else {
state = DeleteTransaksiStateError(message: e.toString());
}
}
}
}
//provider
final deleteTransaksiProvider =
StateNotifierProvider<DeleteTransaksiNotifier, DeleteTransaksiState>(
(ref) => DeleteTransaksiNotifier(ref: ref),
);

View File

@@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:app_petty_cash/screen/transaksi/delete_transaksi_provider.dart';
import 'package:app_petty_cash/screen/transaksi/search_history_transaksi_provider.dart'; import 'package:app_petty_cash/screen/transaksi/search_history_transaksi_provider.dart';
import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -41,7 +42,8 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
), ),
); );
String M_CompanyID = "0"; // String M_CompanyID = "0";
final M_CompanyID = useState<String>("0");
String formattedDate = DateFormat('dd-MM-yyyy').format(DateTime.now()); String formattedDate = DateFormat('dd-MM-yyyy').format(DateTime.now());
final ctrlTglAwal = useTextEditingController(text: formattedDate); final ctrlTglAwal = useTextEditingController(text: formattedDate);
@@ -138,6 +140,27 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
}, },
); );
// delete transaksi
ref.listen(
deleteTransaksiProvider,
(previous, next) {
if (next is DeleteTransaksiStateLoading) {
searchHistoryIsLoading.value = true;
} else if (next is DeleteTransaksiStateError) {
// print(next.message);
searchHistoryIsLoading.value = false;
SanckbarWidget(context, next.message, snackbarType.error);
} else if (next is DeleteTransaksiStateDone) {
// print(jsonEncode(next.model));
// print(next.model.length);
// listSearchHistory.value = next.model;
SanckbarWidget(
context, 'Data Berhasil Dihapus', snackbarType.success);
searchHistoryIsLoading.value = false;
}
},
);
Future<String> getCompanyID() async { Future<String> getCompanyID() async {
final shared = await SharedPreferences.getInstance(); final shared = await SharedPreferences.getInstance();
String M_CompanyID = "0"; String M_CompanyID = "0";
@@ -180,7 +203,7 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
// list category provider // list category provider
ref.read(listCategoryProvider.notifier).getListCategory(); ref.read(listCategoryProvider.notifier).getListCategory();
M_CompanyID = await getCompanyID(); M_CompanyID.value = await getCompanyID();
DateTime parsedDate = DateFormat('dd-MM-yyyy').parse( DateTime parsedDate = DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(), ctrlTglAwal.value.text.toString(),
@@ -199,11 +222,100 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
ref ref
.read(searchHistoryTransaksiProvider.notifier) .read(searchHistoryTransaksiProvider.notifier)
.searchHistoryTransaksi( .searchHistoryTransaksi(
M_CompanyID, formattedDateAwal, formattedDateAkhir, categoryid); M_CompanyID.value,
formattedDateAwal,
formattedDateAkhir,
categoryid,
);
}); });
return () {}; return () {};
}, []); }, []);
// delete alert
Future<void> showDeleteConfirmationDialog(
BuildContext context,
String id,
String userid,
String companyid,
String tglAwal,
String tglAkhir,
String categoryid,
) async {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Konfirmasi Hapus'),
content: Text('Apakah anda yakin menghapus data ini?'),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop(); // Tutup dialog
},
child: Text('Batal'),
),
ElevatedButton(
onPressed: () {
print('Deleted id $id , userid $userid');
DateTime parsedDate = DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDate);
DateTime parsedDateAkhir = DateFormat('dd-MM-yyyy').parse(
ctrlTglAkhir.value.text.toString(),
);
String formattedDateAkhir =
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
ref.read(deleteTransaksiProvider.notifier).deleteTransaksi(
id,
userid,
companyid,
formattedDateAwal,
formattedDateAkhir,
categoryid,
);
Navigator.of(context).pop();
},
child: Text(
'Hapus Data',
style: Constant.body1_600(context: context).copyWith(
fontWeight: FontWeight.w600,
color: Constant.textWhite,
),
),
style: ButtonStyle(
backgroundColor:
MaterialStateColor.resolveWith((st) => Constant.textRed),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
color: Constant.textRed,
),
),
),
shadowColor: MaterialStateProperty.all(Color(0xffff48423d)),
elevation: MaterialStateProperty.all(4.0),
),
),
],
);
},
);
}
void _closeKeyboard() {
FocusManager.instance.primaryFocus?.unfocus();
}
final FocusNode focusNodetglAwal = useFocusNode();
final tglAwalHasFocus = useState(false);
final FocusNode focusNodetglAkhir = useFocusNode();
final tglAkhirHasFocus = useState(false);
return Padding( return Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 30), top: Constant.getActualYPhone(context: context, y: 30),
@@ -238,80 +350,91 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
children: [ children: [
// Tanggal Awal // Tanggal Awal
Expanded( Expanded(
child: TextField( child: GestureDetector(
controller: ctrlTglAwal, onTap: () {
decoration: InputDecoration( focusNodetglAwal.unfocus();
hintStyle: // _closeKeyboard();
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
labelStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.orange,
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Constant.textGreyv2,
width: 1,
),
),
labelText: "Tanggal Awal",
hintText: 'Tanggal Awal',
// suffixIcon: isLoadingFilterScope.value
// ? SizedBox(
// width: Constant.getActualXPhone(
// context: context,
// x: 4,
// ),
// height: Constant.getActualYPhone(
// context: context,
// y: 4,
// ),
// child: CircularProgressIndicator(
// color: Constant.textRed,
// ),
// )
// : Icon(
// Icons.calendar_month_sharp,
// color: Constant.colorIconDate,
// ),
),
onTap: () async {
final selectedDateAwal = await showDatePicker(
// locale: const Locale("en-CA"),
// locale: ,
context: context,
initialEntryMode:
DatePickerEntryMode.calendarOnly,
firstDate: DateTime(2000),
lastDate: DateTime(2100),
initialDate: (ctrlTglAwal.text.isEmpty)
? DateTime.now()
: tglAwal.value,
);
if (selectedDateAwal != null) {
String formattedDate = DateFormat('dd-MM-yyyy')
.format(selectedDateAwal);
// ctrlTglAwal.text =
// selectedDateAwal.toString().split(' ')[0];
ctrlTglAwal.text = formattedDate;
tglAwal.value = selectedDateAwal;
tglAwalTmp.value = selectedDateAwal.toString();
}
if (selectedDateAwal == null) {
print('cancel button');
return;
}
}, },
child: TextField(
enableInteractiveSelection: false,
showCursor: (tglAwalHasFocus.value) ? true : false,
controller: ctrlTglAwal,
decoration: InputDecoration(
hintStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
labelStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.orange,
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Constant.textGreyv2,
width: 1,
),
),
labelText: "Tanggal Awal",
hintText: 'Tanggal Awal',
// suffixIcon: isLoadingFilterScope.value
// ? SizedBox(
// width: Constant.getActualXPhone(
// context: context,
// x: 4,
// ),
// height: Constant.getActualYPhone(
// context: context,
// y: 4,
// ),
// child: CircularProgressIndicator(
// color: Constant.textRed,
// ),
// )
// : Icon(
// Icons.calendar_month_sharp,
// color: Constant.colorIconDate,
// ),
),
onTap: () async {
final selectedDateAwal = await showDatePicker(
// locale: const Locale("en-CA"),
// locale: ,
context: context,
initialEntryMode:
DatePickerEntryMode.calendarOnly,
firstDate: DateTime(2000),
lastDate: DateTime(2100),
initialDate: (ctrlTglAwal.text.isEmpty)
? DateTime.now()
: tglAwal.value,
);
if (selectedDateAwal != null) {
String formattedDate = DateFormat('dd-MM-yyyy')
.format(selectedDateAwal);
// ctrlTglAwal.text =
// selectedDateAwal.toString().split(' ')[0];
ctrlTglAwal.text = formattedDate;
tglAwal.value = selectedDateAwal;
tglAwalTmp.value = selectedDateAwal.toString();
}
if (selectedDateAwal == null) {
print('cancel button');
return;
}
// focusNodetglAwal.unfocus();
// _closeKeyboard();
},
),
), ),
), ),
@@ -321,80 +444,89 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
), ),
// Tanggal Akhir // Tanggal Akhir
Expanded( Expanded(
child: TextField( child: GestureDetector(
controller: ctrlTglAkhir, onTap: () {
decoration: InputDecoration( focusNodetglAkhir.unfocus();
hintStyle: // _closeKeyboard();
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
labelStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.orange,
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Constant.textGreyv2,
width: 1,
),
),
labelText: "Tanggal Akhir",
hintText: 'Tanggal Akhir',
// suffixIcon: isLoadingFilterScope.value
// ? SizedBox(
// width: Constant.getActualXPhone(
// context: context,
// x: 4,
// ),
// height: Constant.getActualYPhone(
// context: context,
// y: 4,
// ),
// child: CircularProgressIndicator(
// color: Constant.textRed,
// ),
// )
// : Icon(
// Icons.calendar_month_sharp,
// color: Constant.colorIconDate,
// ),
),
onTap: () async {
final selectedDateAkhir = await showDatePicker(
// locale: const Locale("en-CA"),
// locale: ,
context: context,
initialEntryMode:
DatePickerEntryMode.calendarOnly,
firstDate: DateTime(2000),
lastDate: DateTime(2100),
initialDate: (ctrlTglAkhir.text.isEmpty)
? DateTime.now()
: tglAkhir.value,
);
if (selectedDateAkhir != null) {
String formattedDate = DateFormat('dd-MM-yyyy')
.format(selectedDateAkhir);
// ctrlTglAkhir.text =
// selectedDateAkhir.toString().split(' ')[0];
ctrlTglAkhir.text = formattedDate;
tglAkhir.value = selectedDateAkhir;
tglAkhirTmp.value = selectedDateAkhir.toString();
}
if (selectedDateAkhir == null) {
print('cancel button');
return;
}
}, },
child: TextField(
enableInteractiveSelection: false,
showCursor: (tglAwalHasFocus.value) ? true : false,
controller: ctrlTglAkhir,
decoration: InputDecoration(
hintStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
labelStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2,
),
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.orange,
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Constant.textGreyv2,
width: 1,
),
),
labelText: "Tanggal Akhir",
hintText: 'Tanggal Akhir',
// suffixIcon: isLoadingFilterScope.value
// ? SizedBox(
// width: Constant.getActualXPhone(
// context: context,
// x: 4,
// ),
// height: Constant.getActualYPhone(
// context: context,
// y: 4,
// ),
// child: CircularProgressIndicator(
// color: Constant.textRed,
// ),
// )
// : Icon(
// Icons.calendar_month_sharp,
// color: Constant.colorIconDate,
// ),
),
onTap: () async {
final selectedDateAkhir = await showDatePicker(
// locale: const Locale("en-CA"),
// locale: ,
context: context,
initialEntryMode:
DatePickerEntryMode.calendarOnly,
firstDate: DateTime(2000),
lastDate: DateTime(2100),
initialDate: (ctrlTglAkhir.text.isEmpty)
? DateTime.now()
: tglAkhir.value,
);
if (selectedDateAkhir != null) {
String formattedDate = DateFormat('dd-MM-yyyy')
.format(selectedDateAkhir);
// ctrlTglAkhir.text =
// selectedDateAkhir.toString().split(' ')[0];
ctrlTglAkhir.text = formattedDate;
tglAkhir.value = selectedDateAkhir;
tglAkhirTmp.value =
selectedDateAkhir.toString();
}
if (selectedDateAkhir == null) {
print('cancel button');
return;
}
},
),
), ),
), ),
], ],
@@ -588,11 +720,11 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
], ],
), ),
onPressed: () async { onPressed: () async {
M_CompanyID = await getCompanyID(); M_CompanyID.value = await getCompanyID();
ref ref
.read(searchHistoryTransaksiProvider.notifier) .read(searchHistoryTransaksiProvider.notifier)
.searchHistoryTransaksi( .searchHistoryTransaksi(
M_CompanyID, M_CompanyID.value,
ctrlTglAwal.text, ctrlTglAwal.text,
ctrlTglAkhir.text, ctrlTglAkhir.text,
selectedListCategory.value.categoryid ?? "0", selectedListCategory.value.categoryid ?? "0",
@@ -754,6 +886,7 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
tipe: listSearchHistory tipe: listSearchHistory
.value[idx].tipe .value[idx].tipe
.toString(), .toString(),
// searchHistoryIsLoading.value
), ),
// bawah // bawah
@@ -774,15 +907,15 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
), ),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
side: BorderSide( side: BorderSide(
color: color: Constant
Constant.bgChipConfirmed), .bgTextChipConfirmed),
borderRadius: borderRadius:
BorderRadius.circular( BorderRadius.circular(
50, 50,
), ),
), ),
backgroundColor: backgroundColor: Constant
Constant.bgChipConfirmed, .bgTextChipConfirmed,
), ),
], ],
), ),
@@ -799,8 +932,28 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
MainAxisAlignment.end, MainAxisAlignment.end,
children: [ children: [
InkWell( InkWell(
onTap: () { onTap: () async {
print('Deleted'); final userID = ref
.read(
currentUserProvider)
?.model
.M_UserID ??
"0";
// print('Deleted');
showDeleteConfirmationDialog(
context,
listSearchHistory
.value[idx].id
.toString(),
userID,
M_CompanyID.value,
ctrlTglAwal.text.toString(),
ctrlTglAkhir.text
.toString(),
selectedListCategory
.value.categoryid
.toString(),
);
}, },
child: Chip( child: Chip(
label: Text( label: Text(
@@ -811,8 +964,8 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
), ),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
side: BorderSide( side: BorderSide(
color: color: Constant
Constant.bgTextChipDelete), .bgTextChipDelete),
borderRadius: borderRadius:
BorderRadius.circular( BorderRadius.circular(
50, 50,

View File

@@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
@@ -12,9 +13,12 @@ import '../provider/current_user_provider.dart';
import '../screen/login/logout_provider.dart'; import '../screen/login/logout_provider.dart';
class CustomDrawer extends HookConsumerWidget { class CustomDrawer extends HookConsumerWidget {
// final String userCompany;
const CustomDrawer({ const CustomDrawer({
super.key, Key? key,
}); // required this.userCompany,
}) : super(key: key);
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@@ -22,6 +26,26 @@ class CustomDrawer extends HookConsumerWidget {
final isLoading = useState(false); final isLoading = useState(false);
final errorMessage = useState(""); final errorMessage = useState("");
final successMessage = useState(""); final successMessage = useState("");
final M_CompanyName = useState("-");
Future<String> getCompanyName() async {
final shared = await SharedPreferences.getInstance();
String M_CompanyName = "-";
if (shared != null) {
final bearerString = shared.get(Constant.bearerName).toString();
final xmodel = jsonDecode(bearerString);
if (xmodel != null) {
M_CompanyName = xmodel["model"]["M_CompanyName"];
}
}
if (M_CompanyName == "0") {
// throw BaseRepositoryException(message: 'Invalid Company ID');
}
return M_CompanyName;
}
useEffect(() { useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
@@ -34,6 +58,7 @@ class CustomDrawer extends HookConsumerWidget {
// Navigator.popAndPushNamed(context, loginRoute); // Navigator.popAndPushNamed(context, loginRoute);
return; return;
} }
M_CompanyName.value = await getCompanyName();
}); });
return () {}; return () {};
}, []); }, []);
@@ -69,152 +94,229 @@ class CustomDrawer extends HookConsumerWidget {
final currentMenu = ref.read(currentPageProvider); final currentMenu = ref.read(currentPageProvider);
return Drawer( return Drawer(
child: ListView( elevation: 0,
// padding: EdgeInsets.only( shape: RoundedRectangleBorder(
// top: Constant.getActualYPhone(context: context, y: 10), borderRadius: BorderRadius.all(Radius.circular(0))
// ), ),
children: [
DrawerHeader( child: Container(
decoration: BoxDecoration( child: ListView(
color: Colors.blue, // padding: EdgeInsets.only(
// top: Constant.getActualYPhone(context: context, y: 10),
// ),
children: [
Container(
// decoration: BoxDecoration(
// border: Border(bottom: BorderSide(color: Colors.transparent)) // <--- use the global theme to change the dividerColor property
// ),
child:
Image(image: AssetImage('images/logo_sismedika_landscape.png')),
), ),
child: Text(
'Drawer Header', SizedBox(
style: TextStyle( height: Constant.getActualYPhone(context: context, y: 8),
color: Colors.white, ),
fontSize: 24,
Padding(
padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 10),
bottom: Constant.getActualYPhone(context: context, y: 10),
right: Constant.getActualXPhone(context: context, x: 24),
left: Constant.getActualXPhone(context: context, x: 24),
),
child: Container(
width: Constant.getActualXPhone(context: context, x: 300),
), ),
), ),
),
ListTile( Expanded(
title: Text( child: Padding(
'Home', padding: EdgeInsets.only(
style: TextStyle( left: Constant.getActualXPhone(context: context, x: 24),
right: Constant.getActualXPhone(context: context, x: 71),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Constant.textGrey.withOpacity(0.16),
),
child: Padding(
padding: EdgeInsets.only(
left: Constant.getActualXPhone(context: context, x: 8),
right: Constant.getActualXPhone(context: context, x: 8),
),
child: Text(
M_CompanyName.value,
style: Constant.body3(context: context).copyWith(
fontWeight: FontWeight.w700,
color: Constant.textGreyv2,
backgroundColor: Constant.textGrey.withOpacity(0.16),
),
),
),
),
),
),
ListTile(
leading: Icon(
Icons.home,
color: (currentMenu == 0) color: (currentMenu == 0)
? Constant.textWhite ? Constant.pcBtnBackgroundColor
: Constant.textBlack, : Constant.textGreyv2,
), ),
title: Text(
'Home',
style: TextStyle(
color: (currentMenu == 0)
? Constant.pcBtnBackgroundColor
: Constant.textGreyv2,
),
),
// tileColor: (currentMenu == 0)
// ? Constant.pcBtnBackgroundColor
// : Colors.transparent,
onTap: () {
// Handle navigation to Home screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 0);
Navigator.pushNamed(context, homeRoute);
},
), ),
tileColor: (currentMenu == 0) ListTile(
? Constant.pcBtnBackgroundColor leading: Icon(
: Colors.transparent, Icons.money,
onTap: () {
// Handle navigation to Home screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 0);
Navigator.pushNamed(context, homeRoute);
},
),
ListTile(
title: Text(
'Transaksi',
style: TextStyle(
color: (currentMenu == 1) color: (currentMenu == 1)
? Constant.textWhite ? Constant.pcBtnBackgroundColor
: Constant.textBlack, : Constant.textGreyv2,
), ),
title: Text(
'Transaksi',
style: TextStyle(
color: (currentMenu == 1)
? Constant.pcBtnBackgroundColor
: Constant.textGreyv2,
),
),
// tileColor: (currentMenu == 1)
// ? Constant.pcBtnBackgroundColor
// : Colors.transparent,
onTap: () {
// Handle navigation to Transaksi screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 1);
Navigator.pushNamed(context, transaksiRoute);
},
), ),
tileColor: (currentMenu == 1) ListTile(
? Constant.pcBtnBackgroundColor leading: Icon(
: Colors.transparent, Icons.history,
onTap: () {
// Handle navigation to Transaksi screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 1);
Navigator.pushNamed(context, transaksiRoute);
},
),
ListTile(
title: Text(
'History Transaksi',
style: TextStyle(
color: (currentMenu == 2) color: (currentMenu == 2)
? Constant.textWhite ? Constant.pcBtnBackgroundColor
: Constant.textBlack, : Constant.textGreyv2,
), ),
title: Text(
'History Transaksi',
style: TextStyle(
color: (currentMenu == 2)
? Constant.pcBtnBackgroundColor
: Constant.textGreyv2,
),
),
// tileColor: (currentMenu == 2)
// ? Constant.pcBtnBackgroundColor
// : Colors.transparent,
onTap: () {
// Handle navigation to User screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 2);
Navigator.pushNamed(context, historyTransaksiRoute);
},
), ),
tileColor: (currentMenu == 2) ListTile(
? Constant.pcBtnBackgroundColor leading: Icon(
: Colors.transparent, Icons.feed,
onTap: () {
// Handle navigation to User screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 2);
Navigator.pushNamed(context, historyTransaksiRoute);
},
),
ListTile(
title: Text(
'Report',
style: TextStyle(
color: (currentMenu == 3) color: (currentMenu == 3)
? Constant.textWhite ? Constant.pcBtnBackgroundColor
: Constant.textBlack, : Constant.textGreyv2,
), ),
title: Text(
'Report',
style: TextStyle(
color: (currentMenu == 3)
? Constant.pcBtnBackgroundColor
: Constant.textGreyv2,
),
),
// tileColor: (currentMenu == 3)
// ? Constant.pcBtnBackgroundColor
// : Colors.transparent,
onTap: () {
// Handle navigation to Transaksi screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 3);
Navigator.pushNamed(context, reportRoute);
},
), ),
tileColor: (currentMenu == 3) // ListTile(
? Constant.pcBtnBackgroundColor // title: Text(
: Colors.transparent, // 'User',
onTap: () { // style: TextStyle(
// Handle navigation to Transaksi screen // color: (currentMenu == 4)
Navigator.pop(context); // ? Constant.textWhite
ref.read(currentPageProvider.state).update((state) => 3); // : Constant.textBlack,
Navigator.pushNamed(context, reportRoute); // ),
}, // ),
), // tileColor: (currentMenu == 4)
// ListTile( // ? Constant.pcBtnBackgroundColor
// title: Text( // : Colors.transparent,
// 'User', // onTap: () {
// style: TextStyle( // // Handle navigation to User screen
// color: (currentMenu == 4) // Navigator.pop(context);
// ? Constant.textWhite // ref.read(currentPageProvider.state).update((state) => 4);
// : Constant.textBlack, // Navigator.pushNamed(context, userRoute);
// ), // },
// ), // ),
// tileColor: (currentMenu == 4) // ListTile(
// ? Constant.pcBtnBackgroundColor // title: Text(
// : Colors.transparent, // 'Change Company',
// onTap: () { // style: TextStyle(
// // Handle navigation to User screen // color: (currentMenu == 5)
// Navigator.pop(context); // ? Constant.textWhite
// ref.read(currentPageProvider.state).update((state) => 4); // : Constant.textBlack,
// Navigator.pushNamed(context, userRoute); // ),
// }, // ),
// ), // tileColor: (currentMenu == 5)
// ListTile( // ? Constant.pcBtnBackgroundColor
// title: Text( // : Colors.transparent,
// 'Change Company', // onTap: () {
// style: TextStyle( // // Handle navigation to User screen
// color: (currentMenu == 5) // Navigator.pop(context);
// ? Constant.textWhite // ref.read(currentPageProvider.state).update((state) => 5);
// : Constant.textBlack, // Navigator.pushNamed(context, changeCompanyRoute);
// ), // },
// ), // ),
// tileColor: (currentMenu == 5) ListTile(
// ? Constant.pcBtnBackgroundColor leading: Icon(
// : Colors.transparent, Icons.logout,
// onTap: () { color: Constant.textGreyv2,
// // Handle navigation to User screen ),
// Navigator.pop(context); title: Text(
// ref.read(currentPageProvider.state).update((state) => 5); 'Logout',
// Navigator.pushNamed(context, changeCompanyRoute); style: TextStyle(color: Constant.textGreyv2),
// }, ),
// ), onTap: () {
ListTile( // di set ke 0 lagi
title: Text( ref.read(currentPageProvider.state).update((state) => 0);
'Logout', ref.read(logoutProvider.notifier).logout(
// style: TextStyle(color: Constant.textWhite), M_UserID: selectedUser?.model.M_UserID ?? "",
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
);
},
), ),
onTap: () { ],
// di set ke 0 lagi ),
ref.read(currentPageProvider.state).update((state) => 0);
ref.read(logoutProvider.notifier).logout(
M_UserID: selectedUser?.model.M_UserID ?? "",
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
);
},
),
],
), ),
); );
} }

View File

@@ -3,6 +3,7 @@ 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';
import 'package:intl/intl.dart';
import '../app/constant.dart'; import '../app/constant.dart';
@@ -12,6 +13,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
final String amount; final String amount;
final String tipe; final String tipe;
final String tglTransaksi; final String tglTransaksi;
// final ValueNotifier<bool> searchHistoryIsLoading;
const HistoryRowAtasWidget({ const HistoryRowAtasWidget({
Key? key, Key? key,
@@ -20,11 +22,11 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
required this.amount, required this.amount,
required this.tipe, required this.tipe,
required this.tglTransaksi, required this.tglTransaksi,
// required this.searchHistoryIsLoading,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
// check file exist // check file exist
Future<Widget> checkFileExistence(String fileUrl) async { Future<Widget> checkFileExistence(String fileUrl) async {
try { 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( return Row(
children: [ children: [
// kiri // kiri
@@ -76,7 +96,8 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
), ),
// child: Text('s'), // child: Text('s'),
child: FutureBuilder<Widget>( 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) { builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) { if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); return CircularProgressIndicator();
@@ -86,8 +107,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
color: Colors.red, color: Colors.red,
); );
} else { } else {
return snapshot.data ?? return snapshot.data ?? Container();
Container();
} }
}, },
), ),
@@ -163,7 +183,7 @@ class HistoryRowAtasWidget extends HookConsumerWidget {
), ),
), ),
Text( Text(
tglTransaksi, formatDateString(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),
), ),

View File

@@ -61,10 +61,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.1" version: "1.18.0"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@@ -240,14 +240,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.17.0" version: "0.17.0"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@@ -260,26 +252,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.15" version: "0.12.16"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0" version: "0.5.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.10.0"
open_file: open_file:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -465,18 +457,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.10.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.11.0" version: "1.11.1"
state_notifier: state_notifier:
dependency: transitive dependency: transitive
description: description:
@@ -489,10 +481,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
@@ -513,10 +505,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "0.6.1"
top_snackbar_flutter: top_snackbar_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -629,6 +621,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.dev"
source: hosted
version: "0.3.0"
win32: win32:
dependency: transitive dependency: transitive
description: description:
@@ -654,5 +654,5 @@ packages:
source: hosted source: hosted
version: "6.3.0" version: "6.3.0"
sdks: sdks:
dart: ">=3.0.6 <4.0.0" dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.10.0" flutter: ">=3.10.0"