step 1 : copy file drawer, history confirm, dialog img, btn excel & pdf
This commit is contained in:
@@ -186,4 +186,33 @@ class TransaksiRepository extends BaseRepository {
|
|||||||
|
|
||||||
return resp['status'];
|
return resp['status'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// confirm transaksi
|
||||||
|
Future<String> confirmTransaksi(
|
||||||
|
String id,
|
||||||
|
String userid,
|
||||||
|
) async {
|
||||||
|
final service =
|
||||||
|
"${Constant.baseUrlDevone}transaction/confirmtransaction/?id=$id&userid=$userid";
|
||||||
|
final resp = await get(
|
||||||
|
// param: {
|
||||||
|
// "": "",
|
||||||
|
// },
|
||||||
|
service: service,
|
||||||
|
);
|
||||||
|
|
||||||
|
print("url confirm 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'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
drawer: CustomDrawer(),
|
drawer: CustomDrawer(),
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -149,8 +148,7 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
// locale: const Locale("en-CA"),
|
// locale: const Locale("en-CA"),
|
||||||
// locale: ,
|
// locale: ,
|
||||||
context: context,
|
context: context,
|
||||||
initialEntryMode:
|
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||||
DatePickerEntryMode.calendarOnly,
|
|
||||||
firstDate: DateTime(2000),
|
firstDate: DateTime(2000),
|
||||||
lastDate: DateTime(2100),
|
lastDate: DateTime(2100),
|
||||||
|
|
||||||
@@ -244,8 +242,7 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
// locale: const Locale("en-CA"),
|
// locale: const Locale("en-CA"),
|
||||||
// locale: ,
|
// locale: ,
|
||||||
context: context,
|
context: context,
|
||||||
initialEntryMode:
|
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||||
DatePickerEntryMode.calendarOnly,
|
|
||||||
firstDate: DateTime(2000),
|
firstDate: DateTime(2000),
|
||||||
lastDate: DateTime(2100),
|
lastDate: DateTime(2100),
|
||||||
|
|
||||||
@@ -273,35 +270,19 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
Spacer(),
|
||||||
),
|
|
||||||
),
|
Row(
|
||||||
),
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
bottomNavigationBar: BottomAppBar(
|
|
||||||
height: 150,
|
|
||||||
child: Container(
|
|
||||||
child: Padding(
|
|
||||||
padding: EdgeInsets.only(
|
|
||||||
// right: Constant.getActualXPhone(context: context, x: 27),
|
|
||||||
// left: Constant.getActualXPhone(context: context, x: 27),
|
|
||||||
// bottom: Constant.getActualYPhone(context: context, y: 32),
|
|
||||||
// top: Constant.getActualYPhone(context: context, y: 24),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
children: [
|
||||||
// Excel
|
ElevatedButton(
|
||||||
Container(
|
|
||||||
width: Constant.getActualXPhone(context: context, x: 336),
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 42),
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
(states) => Colors.white),
|
(states) => Colors.white),
|
||||||
// side: MaterialStateBorderSide.resolveWith(
|
// side: MaterialStateBorderSide.resolveWith(
|
||||||
// (states) => BorderSide(color: Colors.green),
|
// (states) => BorderSide(color: Colors.green),
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
// backgroundColor: MaterialStateColor.resolveWith(
|
// backgroundColor: MaterialStateColor.resolveWith(
|
||||||
// (st) => Constant.pcBtnBackgroundColor),
|
// (st) => Constant.pcBtnBackgroundColor),
|
||||||
shape:
|
shape:
|
||||||
@@ -333,11 +314,11 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Constant.getActualXPhone(
|
width: Constant.getActualXPhone(
|
||||||
context: context, x: 8),
|
context: context, x: 10),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Download Report (xls) ',
|
'Excel',
|
||||||
style: Constant.body1(context: context).copyWith(
|
style: Constant.body1(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
@@ -345,19 +326,41 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () {},
|
onPressed: () async {
|
||||||
),
|
M_CompanyID = await getCompanyID();
|
||||||
),
|
if(M_CompanyID == "0"){
|
||||||
|
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Awal
|
||||||
|
DateTime parsedDateAwal =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAwal =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
|
||||||
|
|
||||||
SizedBox(
|
// Akhir
|
||||||
height: Constant.getActualYPhone(context: context, y: 20),
|
DateTime parsedDateAkhir =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAkhir =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
|
||||||
|
|
||||||
|
String url =
|
||||||
|
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
|
||||||
|
if (!await launchUrl(Uri.parse(url))) {
|
||||||
|
// throw Exception('Could not launch $url');
|
||||||
|
SanckbarWidget(context, 'Could not launch $url',
|
||||||
|
snackbarType.error);
|
||||||
|
}
|
||||||
|
// https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
// PDF
|
// PDF
|
||||||
Container(
|
ElevatedButton(
|
||||||
width: Constant.getActualXPhone(context: context, x: 336),
|
|
||||||
height: Constant.getActualYPhone(context: context, y: 42),
|
|
||||||
child: ElevatedButton(
|
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
(st) => Constant.pcBtnBackgroundColor),
|
(st) => Constant.pcBtnBackgroundColor),
|
||||||
@@ -390,11 +393,11 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Constant.getActualXPhone(
|
width: Constant.getActualXPhone(
|
||||||
context: context, x: 8),
|
context: context, x: 8),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'Download Report (PDF)',
|
'PDF',
|
||||||
style: Constant.body1(context: context).copyWith(
|
style: Constant.body1(context: context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Constant.white),
|
color: Constant.white),
|
||||||
@@ -402,7 +405,29 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
String url = "https://pub.dev/packages?q=url+launcher";
|
M_CompanyID = await getCompanyID();
|
||||||
|
if(M_CompanyID == "0"){
|
||||||
|
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Awal
|
||||||
|
DateTime parsedDateAwal =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAwal =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
|
||||||
|
|
||||||
|
// Akhir
|
||||||
|
DateTime parsedDateAkhir =
|
||||||
|
DateFormat('dd-MM-yyyy').parse(
|
||||||
|
ctrlTglAwal.value.text.toString(),
|
||||||
|
);
|
||||||
|
String formattedDateAkhir =
|
||||||
|
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
|
||||||
|
|
||||||
|
String url =
|
||||||
|
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
|
||||||
if (!await launchUrl(Uri.parse(url))) {
|
if (!await launchUrl(Uri.parse(url))) {
|
||||||
// throw Exception('Could not launch $url');
|
// throw Exception('Could not launch $url');
|
||||||
SanckbarWidget(context, 'Could not launch $url',
|
SanckbarWidget(context, 'Could not launch $url',
|
||||||
@@ -410,9 +435,9 @@ class ReportScreen extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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 ConfirmTransaksiState extends Equatable {
|
||||||
|
final DateTime date;
|
||||||
|
const ConfirmTransaksiState(this.date);
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [date];
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfirmTransaksiStateInit extends ConfirmTransaksiState {
|
||||||
|
ConfirmTransaksiStateInit() : super(DateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfirmTransaksiStateLoading extends ConfirmTransaksiState {
|
||||||
|
ConfirmTransaksiStateLoading() : super(DateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfirmTransaksiStateError extends ConfirmTransaksiState {
|
||||||
|
final String message;
|
||||||
|
ConfirmTransaksiStateError({
|
||||||
|
required this.message,
|
||||||
|
}) : super(DateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
class ConfirmTransaksiStateDone extends ConfirmTransaksiState {
|
||||||
|
// final List<ListType> model;
|
||||||
|
final String resp;
|
||||||
|
ConfirmTransaksiStateDone({
|
||||||
|
required this.resp,
|
||||||
|
}) : super(DateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
|
//notifier
|
||||||
|
class ConfirmTransaksiNotifier extends StateNotifier<ConfirmTransaksiState> {
|
||||||
|
final Ref ref;
|
||||||
|
ConfirmTransaksiNotifier({
|
||||||
|
required this.ref,
|
||||||
|
}) : super(ConfirmTransaksiStateInit());
|
||||||
|
|
||||||
|
void confirmTransaksi(
|
||||||
|
String id,
|
||||||
|
String userid,
|
||||||
|
String companyid,
|
||||||
|
String tglAwal,
|
||||||
|
String tglAkhir,
|
||||||
|
String categoryid,
|
||||||
|
) async {
|
||||||
|
try {
|
||||||
|
state = ConfirmTransaksiStateLoading();
|
||||||
|
final dio = ref.read(dioProvider);
|
||||||
|
final resp = await TransaksiRepository(dio: dio).confirmTransaksi(
|
||||||
|
id,
|
||||||
|
userid,
|
||||||
|
);
|
||||||
|
state = ConfirmTransaksiStateDone(resp: resp);
|
||||||
|
|
||||||
|
// search lagi buat get data
|
||||||
|
ref.read(searchHistoryTransaksiProvider.notifier).searchHistoryTransaksi(
|
||||||
|
companyid,
|
||||||
|
tglAwal,
|
||||||
|
tglAkhir,
|
||||||
|
categoryid,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
if (e is BaseRepositoryException) {
|
||||||
|
state = ConfirmTransaksiStateError(message: e.message.toString());
|
||||||
|
} else {
|
||||||
|
state = ConfirmTransaksiStateError(message: e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//provider
|
||||||
|
final confirmTransaksiProvider =
|
||||||
|
StateNotifierProvider<ConfirmTransaksiNotifier, ConfirmTransaksiState>(
|
||||||
|
(ref) => ConfirmTransaksiNotifier(ref: ref),
|
||||||
|
);
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:app_petty_cash/screen/transaksi/confirm_transaksi_provider.dart';
|
||||||
import 'package:app_petty_cash/screen/transaksi/delete_transaksi_provider.dart';
|
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';
|
||||||
@@ -9,6 +10,7 @@ import 'package:flutter_svg/svg.dart';
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../app/constant.dart';
|
import '../../app/constant.dart';
|
||||||
import '../../app/route.dart';
|
import '../../app/route.dart';
|
||||||
@@ -161,6 +163,27 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// confirm transaksi
|
||||||
|
ref.listen(
|
||||||
|
confirmTransaksiProvider,
|
||||||
|
(previous, next) {
|
||||||
|
if (next is ConfirmTransaksiStateLoading) {
|
||||||
|
searchHistoryIsLoading.value = true;
|
||||||
|
} else if (next is ConfirmTransaksiStateError) {
|
||||||
|
// print(next.message);
|
||||||
|
searchHistoryIsLoading.value = false;
|
||||||
|
SanckbarWidget(context, next.message, snackbarType.error);
|
||||||
|
} else if (next is ConfirmTransaksiStateDone) {
|
||||||
|
// print(jsonEncode(next.model));
|
||||||
|
// print(next.model.length);
|
||||||
|
// listSearchHistory.value = next.model;
|
||||||
|
SanckbarWidget(
|
||||||
|
context, 'Data Berhasil Diconfirm', 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";
|
||||||
@@ -306,6 +329,131 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// confirm dialog
|
||||||
|
Future<void> showConfirmDialog(
|
||||||
|
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 Proses Confirm'),
|
||||||
|
content: Text('Apakah anda yakin mengconfirm data ini?'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop(); // Tutup dialog
|
||||||
|
},
|
||||||
|
child: Text('Batal'),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
print('confirm 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(confirmTransaksiProvider.notifier).confirmTransaksi(
|
||||||
|
id,
|
||||||
|
userid,
|
||||||
|
companyid,
|
||||||
|
formattedDateAwal,
|
||||||
|
formattedDateAkhir,
|
||||||
|
categoryid,
|
||||||
|
);
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Confirm Data',
|
||||||
|
style: Constant.body1_600(context: context).copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Constant.textWhite,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
style: ButtonStyle(
|
||||||
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
|
(st) => Constant.textGreen),
|
||||||
|
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
side: BorderSide(
|
||||||
|
color: Constant.textGreen,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shadowColor: MaterialStateProperty.all(Color(0xffff48423d)),
|
||||||
|
elevation: MaterialStateProperty.all(4.0),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// dialog image
|
||||||
|
Future<void> showImageDialog(
|
||||||
|
BuildContext context,
|
||||||
|
String url,
|
||||||
|
) async {
|
||||||
|
return showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text('Attachment File'),
|
||||||
|
content: Column(
|
||||||
|
children: [
|
||||||
|
Image.network(
|
||||||
|
Constant.baseUrlFile + url,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
// height: MediaQuery.of(context).size.height * 0.5,
|
||||||
|
loadingBuilder: (BuildContext context, Widget child,
|
||||||
|
ImageChunkEvent? loadingProgress) {
|
||||||
|
if (loadingProgress == null) {
|
||||||
|
return child;
|
||||||
|
} else {
|
||||||
|
return Center(
|
||||||
|
child: SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
value: loadingProgress.expectedTotalBytes != null
|
||||||
|
? loadingProgress.cumulativeBytesLoaded /
|
||||||
|
(loadingProgress.expectedTotalBytes ?? 1)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop(); // Tutup dialog
|
||||||
|
},
|
||||||
|
child: Text('Tutup'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _closeKeyboard() {
|
void _closeKeyboard() {
|
||||||
FocusManager.instance.primaryFocus?.unfocus();
|
FocusManager.instance.primaryFocus?.unfocus();
|
||||||
}
|
}
|
||||||
@@ -316,7 +464,9 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
final FocusNode focusNodetglAkhir = useFocusNode();
|
final FocusNode focusNodetglAkhir = useFocusNode();
|
||||||
final tglAkhirHasFocus = useState(false);
|
final tglAkhirHasFocus = useState(false);
|
||||||
|
|
||||||
return Padding(
|
return GestureDetector(
|
||||||
|
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
child: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
top: Constant.getActualYPhone(context: context, y: 30),
|
top: Constant.getActualYPhone(context: context, y: 30),
|
||||||
),
|
),
|
||||||
@@ -357,15 +507,16 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
child: TextField(
|
child: TextField(
|
||||||
enableInteractiveSelection: false,
|
enableInteractiveSelection: false,
|
||||||
showCursor: (tglAwalHasFocus.value) ? true : false,
|
showCursor:
|
||||||
|
(tglAwalHasFocus.value) ? true : false,
|
||||||
controller: ctrlTglAwal,
|
controller: ctrlTglAwal,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintStyle:
|
hintStyle: Constant.body2_400(context: context)
|
||||||
Constant.body2_400(context: context).copyWith(
|
.copyWith(
|
||||||
color: Constant.textGreyv2,
|
color: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
labelStyle:
|
labelStyle: Constant.body2_400(context: context)
|
||||||
Constant.body2_400(context: context).copyWith(
|
.copyWith(
|
||||||
color: Constant.textGreyv2,
|
color: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
@@ -417,13 +568,15 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (selectedDateAwal != null) {
|
if (selectedDateAwal != null) {
|
||||||
String formattedDate = DateFormat('dd-MM-yyyy')
|
String formattedDate =
|
||||||
|
DateFormat('dd-MM-yyyy')
|
||||||
.format(selectedDateAwal);
|
.format(selectedDateAwal);
|
||||||
// ctrlTglAwal.text =
|
// ctrlTglAwal.text =
|
||||||
// selectedDateAwal.toString().split(' ')[0];
|
// selectedDateAwal.toString().split(' ')[0];
|
||||||
ctrlTglAwal.text = formattedDate;
|
ctrlTglAwal.text = formattedDate;
|
||||||
tglAwal.value = selectedDateAwal;
|
tglAwal.value = selectedDateAwal;
|
||||||
tglAwalTmp.value = selectedDateAwal.toString();
|
tglAwalTmp.value =
|
||||||
|
selectedDateAwal.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedDateAwal == null) {
|
if (selectedDateAwal == null) {
|
||||||
@@ -451,15 +604,16 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
child: TextField(
|
child: TextField(
|
||||||
enableInteractiveSelection: false,
|
enableInteractiveSelection: false,
|
||||||
showCursor: (tglAwalHasFocus.value) ? true : false,
|
showCursor:
|
||||||
|
(tglAwalHasFocus.value) ? true : false,
|
||||||
controller: ctrlTglAkhir,
|
controller: ctrlTglAkhir,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintStyle:
|
hintStyle: Constant.body2_400(context: context)
|
||||||
Constant.body2_400(context: context).copyWith(
|
.copyWith(
|
||||||
color: Constant.textGreyv2,
|
color: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
labelStyle:
|
labelStyle: Constant.body2_400(context: context)
|
||||||
Constant.body2_400(context: context).copyWith(
|
.copyWith(
|
||||||
color: Constant.textGreyv2,
|
color: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
border: OutlineInputBorder(
|
border: OutlineInputBorder(
|
||||||
@@ -511,7 +665,8 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (selectedDateAkhir != null) {
|
if (selectedDateAkhir != null) {
|
||||||
String formattedDate = DateFormat('dd-MM-yyyy')
|
String formattedDate =
|
||||||
|
DateFormat('dd-MM-yyyy')
|
||||||
.format(selectedDateAkhir);
|
.format(selectedDateAkhir);
|
||||||
// ctrlTglAkhir.text =
|
// ctrlTglAkhir.text =
|
||||||
// selectedDateAkhir.toString().split(' ')[0];
|
// selectedDateAkhir.toString().split(' ')[0];
|
||||||
@@ -547,10 +702,10 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
// Dropdown kategori
|
// Dropdown kategori
|
||||||
(listCategoryLoading.value)
|
(listCategoryLoading.value)
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
width:
|
width: Constant.getActualXPhone(
|
||||||
Constant.getActualXPhone(context: context, x: 24),
|
context: context, x: 24),
|
||||||
height:
|
height: Constant.getActualYPhone(
|
||||||
Constant.getActualYPhone(context: context, y: 32),
|
context: context, y: 32),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: CircularProgressIndicator(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
@@ -685,8 +840,8 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor: MaterialStateColor.resolveWith(
|
backgroundColor: MaterialStateColor.resolveWith(
|
||||||
(st) => Constant.pcBtnBackgroundColor),
|
(st) => Constant.pcBtnBackgroundColor),
|
||||||
shape:
|
shape: MaterialStateProperty.all<
|
||||||
MaterialStateProperty.all<RoundedRectangleBorder>(
|
RoundedRectangleBorder>(
|
||||||
RoundedRectangleBorder(
|
RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
@@ -854,6 +1009,9 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: listSearchHistory.value.length,
|
itemCount: listSearchHistory.value.length,
|
||||||
itemBuilder: (context, idx) {
|
itemBuilder: (context, idx) {
|
||||||
|
String imgUrl = listSearchHistory
|
||||||
|
.value[idx].imgurl
|
||||||
|
.toString();
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
bottom: Constant.getActualYPhone(
|
bottom: Constant.getActualYPhone(
|
||||||
@@ -874,7 +1032,8 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
icon_category_id: listSearchHistory
|
icon_category_id: listSearchHistory
|
||||||
.value[idx].kategoriid
|
.value[idx].kategoriid
|
||||||
.toString(),
|
.toString(),
|
||||||
icon_category_name: listSearchHistory
|
icon_category_name:
|
||||||
|
listSearchHistory
|
||||||
.value[idx].kategoriname
|
.value[idx].kategoriname
|
||||||
.toString(),
|
.toString(),
|
||||||
amount: listSearchHistory
|
amount: listSearchHistory
|
||||||
@@ -891,34 +1050,34 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
|
|
||||||
// bawah
|
// bawah
|
||||||
|
|
||||||
if (listSearchHistory
|
// if (listSearchHistory
|
||||||
.value[idx].isconfirm ==
|
// .value[idx].isconfirm ==
|
||||||
"Y")
|
// "Y")
|
||||||
Row(
|
// Row(
|
||||||
mainAxisAlignment:
|
// mainAxisAlignment:
|
||||||
MainAxisAlignment.end,
|
// MainAxisAlignment.end,
|
||||||
children: [
|
// children: [
|
||||||
Chip(
|
// Chip(
|
||||||
label: Text(
|
// label: Text(
|
||||||
'Confirmed',
|
// 'Confirmed',
|
||||||
style: TextStyle(
|
// style: TextStyle(
|
||||||
color: Constant.textWhite,
|
// color: Constant.textWhite,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
shape: RoundedRectangleBorder(
|
// shape: RoundedRectangleBorder(
|
||||||
side: BorderSide(
|
// side: BorderSide(
|
||||||
color: Constant
|
// color: Constant
|
||||||
.bgTextChipConfirmed),
|
// .bgTextChipConfirmed),
|
||||||
borderRadius:
|
// borderRadius:
|
||||||
BorderRadius.circular(
|
// BorderRadius.circular(
|
||||||
50,
|
// 50,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
backgroundColor: Constant
|
// backgroundColor: Constant
|
||||||
.bgTextChipConfirmed,
|
// .bgTextChipConfirmed,
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: Constant.getActualYPhone(
|
height: Constant.getActualYPhone(
|
||||||
context: context, y: 6),
|
context: context, y: 6),
|
||||||
@@ -929,7 +1088,8 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
"N")
|
"N")
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.end,
|
MainAxisAlignment
|
||||||
|
.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
@@ -947,7 +1107,8 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
.toString(),
|
.toString(),
|
||||||
userID,
|
userID,
|
||||||
M_CompanyID.value,
|
M_CompanyID.value,
|
||||||
ctrlTglAwal.text.toString(),
|
ctrlTglAwal.text
|
||||||
|
.toString(),
|
||||||
ctrlTglAkhir.text
|
ctrlTglAkhir.text
|
||||||
.toString(),
|
.toString(),
|
||||||
selectedListCategory
|
selectedListCategory
|
||||||
@@ -957,24 +1118,194 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
},
|
},
|
||||||
child: Chip(
|
child: Chip(
|
||||||
label: Text(
|
label: Text(
|
||||||
'Deleted',
|
'Delete',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Constant.textWhite,
|
color:
|
||||||
|
Constant.textWhite,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
shape: RoundedRectangleBorder(
|
shape:
|
||||||
|
RoundedRectangleBorder(
|
||||||
side: BorderSide(
|
side: BorderSide(
|
||||||
color: Constant
|
color: Constant
|
||||||
.bgTextChipDelete),
|
.bgTextChipDelete),
|
||||||
borderRadius:
|
borderRadius:
|
||||||
BorderRadius.circular(
|
BorderRadius.circular(
|
||||||
50,
|
10,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Constant.bgTextDelete,
|
Constant.bgTextDelete,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (imgUrl != "")
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
String fileExtension =
|
||||||
|
imgUrl
|
||||||
|
.split('.')
|
||||||
|
.last
|
||||||
|
.toLowerCase();
|
||||||
|
if (fileExtension == 'png' ||
|
||||||
|
fileExtension ==
|
||||||
|
'jpg' ||
|
||||||
|
fileExtension ==
|
||||||
|
'jpeg') {
|
||||||
|
showImageDialog(
|
||||||
|
context,
|
||||||
|
imgUrl,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (!await launchUrl(
|
||||||
|
Uri.parse(
|
||||||
|
Constant.baseUrlFile +
|
||||||
|
imgUrl,
|
||||||
|
),
|
||||||
|
)) {
|
||||||
|
// throw Exception('Could not launch $url');
|
||||||
|
SanckbarWidget(
|
||||||
|
context,
|
||||||
|
'Could not launch ${Constant.baseUrlFile + imgUrl}',
|
||||||
|
snackbarType
|
||||||
|
.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
Icons.attach_file,
|
||||||
|
color: Constant
|
||||||
|
.pcBtnBackgroundColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
final userID = ref
|
||||||
|
.read(
|
||||||
|
currentUserProvider)
|
||||||
|
?.model
|
||||||
|
.M_UserID ??
|
||||||
|
"0";
|
||||||
|
showConfirmDialog(
|
||||||
|
context,
|
||||||
|
listSearchHistory
|
||||||
|
.value[idx].id
|
||||||
|
.toString(),
|
||||||
|
userID,
|
||||||
|
M_CompanyID.value,
|
||||||
|
ctrlTglAwal.text
|
||||||
|
.toString(),
|
||||||
|
ctrlTglAkhir.text
|
||||||
|
.toString(),
|
||||||
|
selectedListCategory
|
||||||
|
.value.categoryid
|
||||||
|
.toString(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Chip(
|
||||||
|
label: Text(
|
||||||
|
'Confirm',
|
||||||
|
style: TextStyle(
|
||||||
|
color:
|
||||||
|
Constant.textWhite,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shape:
|
||||||
|
RoundedRectangleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color:
|
||||||
|
Constant.green_600,
|
||||||
|
),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
10),
|
||||||
|
),
|
||||||
|
backgroundColor:
|
||||||
|
Constant.green_600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
// Confirmed
|
||||||
|
if (listSearchHistory
|
||||||
|
.value[idx].isconfirm ==
|
||||||
|
"Y")
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment
|
||||||
|
.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Chip(
|
||||||
|
label: Text(
|
||||||
|
'Confirmed',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Constant.green_600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color: Constant.green_600,
|
||||||
|
),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
50),
|
||||||
|
),
|
||||||
|
backgroundColor:
|
||||||
|
Constant.textWhite,
|
||||||
|
),
|
||||||
|
if (imgUrl != "")
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
String fileExtension =
|
||||||
|
imgUrl
|
||||||
|
.split('.')
|
||||||
|
.last
|
||||||
|
.toLowerCase();
|
||||||
|
if (fileExtension == 'png' ||
|
||||||
|
fileExtension ==
|
||||||
|
'jpg' ||
|
||||||
|
fileExtension ==
|
||||||
|
'jpeg') {
|
||||||
|
showImageDialog(
|
||||||
|
context,
|
||||||
|
imgUrl,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (!await launchUrl(
|
||||||
|
Uri.parse(
|
||||||
|
imgUrl))) {
|
||||||
|
// throw Exception('Could not launch $url');
|
||||||
|
SanckbarWidget(
|
||||||
|
context,
|
||||||
|
'Could not launch $imgUrl',
|
||||||
|
snackbarType.error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Icon(
|
||||||
|
Icons.attach_file,
|
||||||
|
color: Constant
|
||||||
|
.pcBtnBackgroundColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Chip(
|
||||||
|
label: Text(
|
||||||
|
'Confirm',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
side: BorderSide(
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
borderRadius:
|
||||||
|
BorderRadius.circular(
|
||||||
|
10),
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// Row(
|
// Row(
|
||||||
@@ -1055,6 +1386,7 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,22 +91,22 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
|
|
||||||
final currentMenu = ref.read(currentPageProvider);
|
final currentMenu = ref.read(currentPageProvider);
|
||||||
|
|
||||||
return Drawer(
|
return Container(
|
||||||
|
width: Constant.getActualXPhone(context: context, x: 300),
|
||||||
|
height: Constant.getActualYPhone(context: context, y: 844),
|
||||||
|
child: Drawer(
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(0))),
|
borderRadius: BorderRadius.all(Radius.circular(0))),
|
||||||
child: Container(
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
child: ListView(
|
child: ListView(
|
||||||
// padding: EdgeInsets.only(
|
|
||||||
// top: Constant.getActualYPhone(context: context, y: 10),
|
|
||||||
// ),
|
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// border: Border(bottom: BorderSide(color: Colors.transparent)) // <--- use the global theme to change the dividerColor property
|
|
||||||
// ),
|
|
||||||
child: Image(
|
child: Image(
|
||||||
image: AssetImage('images/logo_sismedika_landscape.png')),
|
image:
|
||||||
|
AssetImage('images/logo_sismedika_landscape.png')),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -125,7 +125,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// Expanded(
|
|
||||||
// child: Padding(
|
// child: Padding(
|
||||||
// padding: EdgeInsets.only(
|
// padding: EdgeInsets.only(
|
||||||
// left: Constant.getActualXPhone(context: context, x: 24),
|
// left: Constant.getActualXPhone(context: context, x: 24),
|
||||||
@@ -153,7 +152,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
|
|
||||||
Chip(
|
Chip(
|
||||||
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
||||||
label: Text(
|
label: Text(
|
||||||
@@ -180,9 +178,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
: Constant.textGreyv2,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// tileColor: (currentMenu == 0)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Handle navigation to Home screen
|
// Handle navigation to Home screen
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@@ -205,9 +200,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
: Constant.textGreyv2,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// tileColor: (currentMenu == 1)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Handle navigation to Transaksi screen
|
// Handle navigation to Transaksi screen
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@@ -230,9 +222,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
: Constant.textGreyv2,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// tileColor: (currentMenu == 2)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Handle navigation to User screen
|
// Handle navigation to User screen
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@@ -255,9 +244,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
: Constant.textGreyv2,
|
: Constant.textGreyv2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// tileColor: (currentMenu == 3)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Handle navigation to Transaksi screen
|
// Handle navigation to Transaksi screen
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
@@ -265,44 +251,6 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
Navigator.pushNamed(context, reportRoute);
|
Navigator.pushNamed(context, reportRoute);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// ListTile(
|
|
||||||
// title: Text(
|
|
||||||
// 'User',
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: (currentMenu == 4)
|
|
||||||
// ? Constant.textWhite
|
|
||||||
// : Constant.textBlack,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// tileColor: (currentMenu == 4)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
// onTap: () {
|
|
||||||
// // Handle navigation to User screen
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// ref.read(currentPageProvider.state).update((state) => 4);
|
|
||||||
// Navigator.pushNamed(context, userRoute);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ListTile(
|
|
||||||
// title: Text(
|
|
||||||
// 'Change Company',
|
|
||||||
// style: TextStyle(
|
|
||||||
// color: (currentMenu == 5)
|
|
||||||
// ? Constant.textWhite
|
|
||||||
// : Constant.textBlack,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// tileColor: (currentMenu == 5)
|
|
||||||
// ? Constant.pcBtnBackgroundColor
|
|
||||||
// : Colors.transparent,
|
|
||||||
// onTap: () {
|
|
||||||
// // Handle navigation to User screen
|
|
||||||
// Navigator.pop(context);
|
|
||||||
// ref.read(currentPageProvider.state).update((state) => 5);
|
|
||||||
// Navigator.pushNamed(context, changeCompanyRoute);
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(
|
leading: Icon(
|
||||||
Icons.logout,
|
Icons.logout,
|
||||||
@@ -317,21 +265,28 @@ class CustomDrawer extends HookConsumerWidget {
|
|||||||
ref.read(currentPageProvider.state).update((state) => 0);
|
ref.read(currentPageProvider.state).update((state) => 0);
|
||||||
ref.read(logoutProvider.notifier).logout(
|
ref.read(logoutProvider.notifier).logout(
|
||||||
M_UserID: selectedUser?.model.M_UserID ?? "",
|
M_UserID: selectedUser?.model.M_UserID ?? "",
|
||||||
M_UserUsername: selectedUser?.model.M_UserUsername ?? "",
|
M_UserUsername:
|
||||||
|
selectedUser?.model.M_UserUsername ?? "",
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
],
|
||||||
Spacer(),
|
),
|
||||||
|
),
|
||||||
// Versi Aplikasi
|
// Versi Aplikasi
|
||||||
ListTile(
|
Padding(
|
||||||
title: Text(
|
padding: EdgeInsets.only(
|
||||||
|
right: Constant.getActualXPhone(context: context, x: 20),
|
||||||
|
bottom: Constant.getActualYPhone(context: context, y: 10),
|
||||||
|
),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.bottomRight,
|
||||||
|
child: Text(
|
||||||
'Versi ${Constant.version}',
|
'Versi ${Constant.version}',
|
||||||
style: Constant.titleH4Login(context: context)
|
style: Constant.titleH4Login(context: context)
|
||||||
.copyWith(color: Constant.textGrey),
|
.copyWith(color: Constant.textGrey),
|
||||||
),
|
),
|
||||||
onTap: () {},
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
341
app_petty_cash/lib/widget/custom_drawer_v2.dart
Normal file
341
app_petty_cash/lib/widget/custom_drawer_v2.dart
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import '../app/constant.dart';
|
||||||
|
import '../app/route.dart';
|
||||||
|
import '../provider/current_menu_provider.dart';
|
||||||
|
import '../provider/current_user_provider.dart';
|
||||||
|
import '../screen/login/logout_provider.dart';
|
||||||
|
|
||||||
|
class CustomDrawerV2 extends HookConsumerWidget {
|
||||||
|
// final String userCompany;
|
||||||
|
const CustomDrawerV2({
|
||||||
|
Key? key,
|
||||||
|
// required this.userCompany,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final selectedUser = ref.read(currentUserProvider);
|
||||||
|
final isLoading = useState(false);
|
||||||
|
final errorMessage = 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(() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||||
|
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
|
||||||
|
if (userID == "0") {
|
||||||
|
//not login
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
|
||||||
|
|
||||||
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
M_CompanyName.value = await getCompanyName();
|
||||||
|
});
|
||||||
|
return () {};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
ref.listen(logoutProvider, (prev, next) async {
|
||||||
|
if (next is LogoutStateLoading) {
|
||||||
|
isLoading.value = true;
|
||||||
|
} else if (next is LogoutStateError) {
|
||||||
|
isLoading.value = false;
|
||||||
|
errorMessage.value = next.message;
|
||||||
|
Timer(const Duration(seconds: 3), () {
|
||||||
|
errorMessage.value = "";
|
||||||
|
});
|
||||||
|
} else if (next is LogoutStateDone) {
|
||||||
|
isLoading.value = false;
|
||||||
|
final shared = await SharedPreferences.getInstance();
|
||||||
|
final bearerString = shared.get(Constant.bearerName).toString();
|
||||||
|
// print(bearerString);
|
||||||
|
if (bearerString.isNotEmpty) {
|
||||||
|
shared.remove(bearerString);
|
||||||
|
shared.clear();
|
||||||
|
// Navigator.popAndPushNamed(context, loginRoute);
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamedAndRemoveUntil(loginRoute, (route) => false);
|
||||||
|
}
|
||||||
|
Timer(const Duration(seconds: 3), () async {
|
||||||
|
successMessage.value = "";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final currentMenu = ref.read(currentPageProvider);
|
||||||
|
|
||||||
|
return Drawer(
|
||||||
|
elevation: 0,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(0))),
|
||||||
|
child: Container(
|
||||||
|
child: ListView(
|
||||||
|
// 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')),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
height: Constant.getActualYPhone(context: context, y: 8),
|
||||||
|
),
|
||||||
|
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Expanded(
|
||||||
|
// child: Padding(
|
||||||
|
// padding: EdgeInsets.only(
|
||||||
|
// 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),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
|
||||||
|
Chip(
|
||||||
|
backgroundColor: Constant.textGrey.withOpacity(0.16),
|
||||||
|
label: Text(
|
||||||
|
M_CompanyName.value,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.home,
|
||||||
|
color: (currentMenu == 0)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: 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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.money,
|
||||||
|
color: (currentMenu == 1)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: 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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.history,
|
||||||
|
color: (currentMenu == 2)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: 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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.feed,
|
||||||
|
color: (currentMenu == 3)
|
||||||
|
? Constant.pcBtnBackgroundColor
|
||||||
|
: 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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(
|
||||||
|
// 'User',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: (currentMenu == 4)
|
||||||
|
// ? Constant.textWhite
|
||||||
|
// : Constant.textBlack,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// tileColor: (currentMenu == 4)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
// onTap: () {
|
||||||
|
// // Handle navigation to User screen
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// ref.read(currentPageProvider.state).update((state) => 4);
|
||||||
|
// Navigator.pushNamed(context, userRoute);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ListTile(
|
||||||
|
// title: Text(
|
||||||
|
// 'Change Company',
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: (currentMenu == 5)
|
||||||
|
// ? Constant.textWhite
|
||||||
|
// : Constant.textBlack,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// tileColor: (currentMenu == 5)
|
||||||
|
// ? Constant.pcBtnBackgroundColor
|
||||||
|
// : Colors.transparent,
|
||||||
|
// onTap: () {
|
||||||
|
// // Handle navigation to User screen
|
||||||
|
// Navigator.pop(context);
|
||||||
|
// ref.read(currentPageProvider.state).update((state) => 5);
|
||||||
|
// Navigator.pushNamed(context, changeCompanyRoute);
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
Icons.logout,
|
||||||
|
color: Constant.textGreyv2,
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
'Logout',
|
||||||
|
style: TextStyle(color: Constant.textGreyv2),
|
||||||
|
),
|
||||||
|
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 ?? "",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
Spacer(),
|
||||||
|
|
||||||
|
// Versi Aplikasi
|
||||||
|
ListTile(
|
||||||
|
title: Text(
|
||||||
|
'Versi ${Constant.version}',
|
||||||
|
style: Constant.titleH4Login(context: context)
|
||||||
|
.copyWith(color: Constant.textGrey),
|
||||||
|
),
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user