first commit
This commit is contained in:
111
lib/widgets/bahan_table_widget.dart
Normal file
111
lib/widgets/bahan_table_widget.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../model/registration_model.dart';
|
||||
|
||||
class BahanTableWidget extends HookConsumerWidget {
|
||||
const BahanTableWidget({
|
||||
super.key,
|
||||
required this.specimenLoading,
|
||||
required this.tempRegistrationData,
|
||||
required this.addOrderLoading,
|
||||
});
|
||||
|
||||
final ValueNotifier<bool> specimenLoading;
|
||||
final RegistrationModel tempRegistrationData;
|
||||
final bool addOrderLoading;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.13,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Bahan',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.11,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Jumlah',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 300),
|
||||
child: specimenLoading.value
|
||||
? Center(
|
||||
child: LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 30),
|
||||
)
|
||||
: ListView(children: [
|
||||
...?tempRegistrationData.bahan?.map((e) => SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.13,
|
||||
color: Colors.white,
|
||||
child: Chip(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6)),
|
||||
),
|
||||
backgroundColor: Constant.blue_016,
|
||||
label: Text(
|
||||
'${e.name}'.replaceAll(' ', '\u00A0'),
|
||||
style: Constant.caption1_600(
|
||||
context: context)
|
||||
.copyWith(color: Constant.textBlue)),
|
||||
)),
|
||||
Container(
|
||||
height: Constant.getActualY(
|
||||
context: context, y: 52),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.11,
|
||||
child: TextField(
|
||||
enabled: !addOrderLoading,
|
||||
controller: e.ctr,
|
||||
onChanged: (value) {
|
||||
print(value);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8)))),
|
||||
))
|
||||
],
|
||||
),
|
||||
)),
|
||||
]),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
0
lib/widgets/button_registrasi.dart
Normal file
0
lib/widgets/button_registrasi.dart
Normal file
409
lib/widgets/custom_dialog_builder.dart
Normal file
409
lib/widgets/custom_dialog_builder.dart
Normal file
@@ -0,0 +1,409 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import 'iframe_view.dart';
|
||||
|
||||
class CustomDialogBuilder {
|
||||
// // pdf mobile
|
||||
// static reportPdf(
|
||||
// BuildContext context,
|
||||
// String typeReportParam,
|
||||
// String startDateParam,
|
||||
// String endDateParam,
|
||||
// String usernameParam,
|
||||
// String filterRegionalID,
|
||||
// String tatReportCategoryCode,
|
||||
// ) {
|
||||
// String urlParam = "";
|
||||
// String tatReportCategoryCodeLowerCase = tatReportCategoryCode.toLowerCase();
|
||||
// if (typeReportParam == "type_report_pendapatan") {
|
||||
// // pendapatan
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/run?__report=report/one/rekap/rpt_sales_001.rptdesign&__format=xlsx&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&tm=${DateTime.now()}";
|
||||
|
||||
// // urlParam =
|
||||
// // "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=xls&username=ADMIN&PID=131878&tm=1697596972372";
|
||||
|
||||
// if (filterRegionalID == "0") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_sales_nasional_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// } else {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_sales_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// }
|
||||
// } else {
|
||||
// // piutang
|
||||
// if (typeReportParam == "type_report_piutang") {
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/run?__report=report/one/rekap/rpt_sales_001.rptdesign&__format=xlsx&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&tm=${DateTime.now()}";
|
||||
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=xls&username=ADMIN&PID=131878&tm=1697596972372";
|
||||
|
||||
// if (filterRegionalID == "0") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_piutang_nasional_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// } else {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_piutang_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// }
|
||||
// } else {
|
||||
// // tat
|
||||
// if (filterRegionalID == "0") {
|
||||
// // global
|
||||
// if (tatReportCategoryCodeLowerCase == "global") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// print("global nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // fo
|
||||
// if (tatReportCategoryCodeLowerCase == "fo") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// print("fo nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // proses
|
||||
// if (tatReportCategoryCodeLowerCase == "proses") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// print("proses nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // sampling
|
||||
// if (tatReportCategoryCodeLowerCase == "sampling") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// print("sampling nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // pengolahan
|
||||
// if (tatReportCategoryCodeLowerCase == "pengolahan") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// print("sampling nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // validasi
|
||||
// if (tatReportCategoryCodeLowerCase == "validasi") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=pdf ";
|
||||
// print("sampling nasional tat : $urlParam");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // global
|
||||
// if (tatReportCategoryCodeLowerCase == "global") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// print("global regional tat : $urlParam");
|
||||
// } else {
|
||||
// // fo
|
||||
// if (tatReportCategoryCodeLowerCase == "fo") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// print("fo regional tat : $urlParam");
|
||||
// } else {
|
||||
// // proses
|
||||
// if (tatReportCategoryCodeLowerCase == "proses") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// print("proses regional tat : $urlParam");
|
||||
// } else {
|
||||
// // sampling
|
||||
// if (tatReportCategoryCodeLowerCase == "sampling") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// print("sampling regional tat : $urlParam");
|
||||
// } else {
|
||||
// // pengolahan
|
||||
// if (tatReportCategoryCodeLowerCase == "pengolahan") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// print("sampling regional tat : $urlParam");
|
||||
// } else {
|
||||
// // validasi
|
||||
// if (tatReportCategoryCodeLowerCase == "validasi") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=pdf";
|
||||
// print("sampling regional tat : $urlParam");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // launchUrlString(urlParam, mode: LaunchMode.externalNonBrowserApplication);
|
||||
// launchUrlString(urlParam);
|
||||
// }
|
||||
|
||||
// // excel web or mobile
|
||||
// static reportExcel(
|
||||
// String typeReportParam,
|
||||
// String startDateParam,
|
||||
// String endDateParam,
|
||||
// String usernameParam,
|
||||
// String filterRegionalID,
|
||||
// String tatReportCategoryCode,
|
||||
// ) {
|
||||
// String urlParam = "";
|
||||
// String tatReportCategoryCodeLowerCase = tatReportCategoryCode.toLowerCase();
|
||||
// if (typeReportParam == "type_report_pendapatan") {
|
||||
// // pendapatan
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/run?__report=report/one/rekap/rpt_sales_001.rptdesign&__format=xlsx&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&tm=${DateTime.now()}";
|
||||
|
||||
// // urlParam =
|
||||
// // "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=xls&username=ADMIN&PID=131878&tm=1697596972372";
|
||||
|
||||
// if (filterRegionalID == "0") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_sales_nasional_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// } else {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_sales_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// }
|
||||
// } else {
|
||||
// if (typeReportParam == "type_report_piutang") {
|
||||
// // piutang
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/run?__report=report/one/rekap/rpt_sales_001.rptdesign&__format=xlsx&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&tm=${DateTime.now()}";
|
||||
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=xls&username=ADMIN&PID=131878&tm=1697596972372";
|
||||
|
||||
// if (filterRegionalID == "0") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_piutang_nasional_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// } else {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_piutang_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// }
|
||||
// } else {
|
||||
// // tat
|
||||
// // if (filterRegionalID == "0") {
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// // } else {
|
||||
// // urlParam =
|
||||
// // "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// // }
|
||||
|
||||
// // tat
|
||||
// if (filterRegionalID == "0") {
|
||||
// // global
|
||||
// if (tatReportCategoryCodeLowerCase == "global") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// print("global nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // fo
|
||||
// if (tatReportCategoryCodeLowerCase == "fo") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// print("fo nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // proses
|
||||
// if (tatReportCategoryCodeLowerCase == "proses") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// print("proses nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // sampling
|
||||
// if (tatReportCategoryCodeLowerCase == "sampling") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// print("sampling nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // pengolahan
|
||||
// if (tatReportCategoryCodeLowerCase == "pengolahan") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// print("sampling nasional tat : $urlParam");
|
||||
// } else {
|
||||
// // validasi
|
||||
// if (tatReportCategoryCodeLowerCase == "validasi") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&__format=xls ";
|
||||
// print("sampling nasional tat : $urlParam");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // global
|
||||
// if (tatReportCategoryCodeLowerCase == "global") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// print("global regional tat : $urlParam");
|
||||
// } else {
|
||||
// // fo
|
||||
// if (tatReportCategoryCodeLowerCase == "fo") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// print("fo regional tat : $urlParam");
|
||||
// } else {
|
||||
// // proses
|
||||
// if (tatReportCategoryCodeLowerCase == "proses") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// print("proses regional tat : $urlParam");
|
||||
// } else {
|
||||
// // sampling
|
||||
// if (tatReportCategoryCodeLowerCase == "sampling") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// print("sampling regional tat : $urlParam");
|
||||
// } else {
|
||||
// // pengolahan
|
||||
// if (tatReportCategoryCodeLowerCase == "pengolahan") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// print("sampling regional tat : $urlParam");
|
||||
// } else {
|
||||
// // validasi
|
||||
// if (tatReportCategoryCodeLowerCase == "validasi") {
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_tat_nasional_001i_$tatReportCategoryCodeLowerCase.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&PregionalID=${filterRegionalID}&username=${usernameParam}&__format=xls";
|
||||
// print("sampling regional tat : $urlParam");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// launchUrlString(urlParam);
|
||||
// }
|
||||
|
||||
// pdf web
|
||||
static dialogBuilderWebPDF(
|
||||
BuildContext context,
|
||||
String startDateParam,
|
||||
String endDateParam,
|
||||
String noRegNamaParam,
|
||||
String username,
|
||||
String companyID) {
|
||||
String urlParam = "";
|
||||
String titleParam = "";
|
||||
|
||||
// pendapatan
|
||||
var param = {
|
||||
"CompanyID": companyID,
|
||||
"startDateParam": startDateParam,
|
||||
"endDateParam": endDateParam,
|
||||
"noRegNamaParam": noRegNamaParam
|
||||
};
|
||||
|
||||
print(param);
|
||||
|
||||
// Parsing tanggal dan waktu
|
||||
DateTime dateTime = DateTime.now();
|
||||
|
||||
// Mengonversi ke timestamp
|
||||
int timestamp = dateTime.millisecondsSinceEpoch;
|
||||
|
||||
titleParam = "Report Order";
|
||||
urlParam =
|
||||
"${Constant.protocol}//${Constant.ipAddress}/birt/run?__report=report/one/regional/mitra/rpt_list_order.rptdesign&__format=pdf&PStartDate=$startDateParam&PEndDate=$endDateParam&PSearch=$noRegNamaParam&username=$username&CompanyID=$companyID&tm=$timestamp";
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/rekap/rpt_sales_001.rptdesign&__format=pdf&PStartDate=$startDateParam&PEndDate=$endDateParam&username=${usernameParam}&tm=${DateTime.now()}";
|
||||
|
||||
// urlParam =
|
||||
// "https://${Constant.ipAddress}/birt/run?__report=report/one/one_dash/rpt_sales_nasional_001.rptdesign&PStartDate=$startDateParam&PEndDate=$endDateParam&noreg=${noRegNamaParam}&__format=pdf ";
|
||||
|
||||
// urlParam =
|
||||
// "https://devone.aplikasi.web.id/birt/frameset?__report=report/one/lab/rpt_test.rptdesign&__format=pdf&username=ADMIN&PID=131878&tm=1697596972372";
|
||||
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return HookConsumer(builder: (context, ref, widget) {
|
||||
final isLoading = useState(true);
|
||||
useEffect(() {
|
||||
Timer(Duration(seconds: 3), () {
|
||||
isLoading.value = false;
|
||||
});
|
||||
return null;
|
||||
}, []);
|
||||
|
||||
return AlertDialog(
|
||||
shape:
|
||||
RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
title: Text(titleParam),
|
||||
content: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 1440),
|
||||
child: Column(
|
||||
children: [
|
||||
// Text('${startDateParam}'),
|
||||
// Text('${endDateParam}'),
|
||||
// Text('${noRegNamaParam}'),
|
||||
Expanded(
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
IframeView(
|
||||
key: UniqueKey(),
|
||||
source: urlParam,
|
||||
onCreated: (idx) {
|
||||
// print('Oncreated print ${idx}');
|
||||
isLoading.value = false;
|
||||
},
|
||||
),
|
||||
// loading
|
||||
if (isLoading.value == true)
|
||||
const Center(
|
||||
child: SizedBox(
|
||||
width: 32,
|
||||
height: 32,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
actions: <Widget>[
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
textStyle: Constant.body3_600(context: context),
|
||||
),
|
||||
onPressed: (isLoading.value)
|
||||
? null
|
||||
: () {
|
||||
isLoading.value = false;
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Text(
|
||||
'Tutup',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
65
lib/widgets/custom_snackbar_widget.dart
Normal file
65
lib/widgets/custom_snackbar_widget.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:top_snackbar_flutter/custom_snack_bar.dart';
|
||||
import 'package:top_snackbar_flutter/top_snack_bar.dart';
|
||||
|
||||
enum snackbarType { error, info, success, warning }
|
||||
|
||||
SanckbarWidget(BuildContext context, String msg, snackbarType tipe) {
|
||||
switch (tipe) {
|
||||
case snackbarType.error:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: Duration(seconds: 1),
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.error(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case snackbarType.success:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: Duration(seconds: 1),
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.success(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case snackbarType.info:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: Duration(seconds: 1),
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.info(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case snackbarType.warning:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: Duration(seconds: 1),
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.info(
|
||||
backgroundColor: Colors.orangeAccent,
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
return showTopSnackBar(
|
||||
animationDuration: Duration(milliseconds: 900),
|
||||
displayDuration: Duration(seconds: 1),
|
||||
dismissType: DismissType.onTap,
|
||||
Overlay.of(context),
|
||||
CustomSnackBar.info(
|
||||
message: msg,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
254
lib/widgets/custom_text_field.dart
Normal file
254
lib/widgets/custom_text_field.dart
Normal file
@@ -0,0 +1,254 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
|
||||
class CustomTextField extends StatelessWidget {
|
||||
final String hintText;
|
||||
final String labelText;
|
||||
final bool isPassword;
|
||||
final int? minLines;
|
||||
final int? maxLines;
|
||||
final Widget? suffixIcon;
|
||||
final TextInputType? inputType;
|
||||
final TextEditingController? controller;
|
||||
final TextStyle? hintStyle;
|
||||
final TextStyle? labelStyle;
|
||||
final TextStyle? style;
|
||||
final bool? isDense;
|
||||
final bool? disable;
|
||||
final Function? onChange;
|
||||
final List<TextInputFormatter>? inputFormater;
|
||||
final String? initialValue;
|
||||
final String? Function(String?)? validator;
|
||||
// final String Function(String?)? validator;
|
||||
|
||||
const CustomTextField(
|
||||
{super.key,
|
||||
required this.hintText,
|
||||
required this.labelText,
|
||||
this.isPassword = false,
|
||||
this.maxLines = 1,
|
||||
this.minLines = 1,
|
||||
this.suffixIcon,
|
||||
this.inputType,
|
||||
this.style,
|
||||
this.hintStyle,
|
||||
this.labelStyle,
|
||||
this.isDense,
|
||||
this.disable,
|
||||
this.onChange,
|
||||
this.inputFormater,
|
||||
this.initialValue,
|
||||
this.validator,
|
||||
this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
onChanged: (value) {
|
||||
if (onChange != null) {
|
||||
onChange!(value);
|
||||
}
|
||||
},
|
||||
enabled: disable,
|
||||
controller: controller,
|
||||
style: style ?? Constant.body2_400(context: context),
|
||||
obscureText: isPassword,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
keyboardType: inputType,
|
||||
initialValue: initialValue,
|
||||
validator: validator,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
if (inputType == TextInputType.number)
|
||||
FilteringTextInputFormatter.digitsOnly,
|
||||
...?inputFormater
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
hintStyle: hintStyle ?? Constant.body2_400(context: context),
|
||||
labelStyle: labelStyle ?? Constant.body2_400(context: context),
|
||||
fillColor: Constant.primaryBlue,
|
||||
labelText: labelText,
|
||||
isDense: isDense ?? false,
|
||||
contentPadding: isDense == true
|
||||
? EdgeInsets.symmetric(
|
||||
vertical: Constant.getActualY(context: context, y: 8),
|
||||
horizontal: Constant.getActualX(context: context, x: 10))
|
||||
: null,
|
||||
|
||||
// isCollapsed: true,
|
||||
hintText: hintText,
|
||||
suffixIcon: suffixIcon,
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CustomPasswordField extends HookConsumerWidget {
|
||||
final String hintText;
|
||||
final String labelText;
|
||||
final ValueNotifier<bool> isPassword;
|
||||
final int? minLines;
|
||||
final int? maxLines;
|
||||
final Widget? suffixIcon;
|
||||
final TextEditingController? controller;
|
||||
final String? Function(String?)? validator;
|
||||
|
||||
const CustomPasswordField(
|
||||
{super.key,
|
||||
required this.hintText,
|
||||
required this.labelText,
|
||||
required this.isPassword,
|
||||
this.maxLines = 1,
|
||||
this.minLines = 1,
|
||||
this.suffixIcon,
|
||||
this.validator,
|
||||
this.controller});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
style: Constant.body2_400(context: context),
|
||||
obscureText: isPassword.value,
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
validator: validator,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
decoration: InputDecoration(
|
||||
hintStyle: Constant.body2_400(context: context),
|
||||
labelStyle: Constant.body2_400(context: context),
|
||||
fillColor: Constant.primaryBlue,
|
||||
labelText: labelText,
|
||||
hintText: hintText,
|
||||
suffixIcon: IconButton(
|
||||
icon:
|
||||
Icon(!isPassword.value ? EvaIcons.eye : EvaIcons.eyeOffOutline),
|
||||
onPressed: () {
|
||||
isPassword.value = !isPassword.value;
|
||||
},
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CustomDropDownModel {
|
||||
String? id;
|
||||
String? name;
|
||||
String? type;
|
||||
|
||||
CustomDropDownModel({this.id, this.name, this.type});
|
||||
|
||||
CustomDropDownModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
type = json['type'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['name'] = name;
|
||||
data['type'] = type;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class CustomDropDown extends HookConsumerWidget {
|
||||
const CustomDropDown(
|
||||
{super.key,
|
||||
required this.data,
|
||||
this.selectedData,
|
||||
required this.onSelect,
|
||||
required this.hintText,
|
||||
required this.width,
|
||||
required this.loading,
|
||||
required this.label});
|
||||
final List<CustomDropDownModel> data;
|
||||
final ValueNotifier<CustomDropDownModel>? selectedData;
|
||||
final Function onSelect;
|
||||
final String hintText;
|
||||
final bool loading;
|
||||
final Widget label;
|
||||
final double width;
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final selectedLokal = useState(CustomDropDownModel());
|
||||
final key = useState(10000);
|
||||
// final selectedLokal = useState(CustomDropDownModel());
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
if (selectedData?.value.id != null) {
|
||||
var tempIdx = CustomDropDownModel(id: "-1");
|
||||
if (data.isNotEmpty) {
|
||||
tempIdx = data
|
||||
.firstWhere((element) => element.id == selectedData?.value.id);
|
||||
}
|
||||
var selectedDataIndex = data.indexOf(tempIdx);
|
||||
if (selectedDataIndex != -1) {
|
||||
if (data.isNotEmpty) {
|
||||
selectedLokal.value = data[selectedDataIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
key.value = key.value + 1;
|
||||
});
|
||||
return () {};
|
||||
}, [selectedData]);
|
||||
selectedLokal.addListener(
|
||||
() {
|
||||
selectedData?.value = selectedLokal.value;
|
||||
},
|
||||
);
|
||||
return DropdownMenu<CustomDropDownModel>(
|
||||
key: ValueKey(key.value),
|
||||
initialSelection: selectedLokal.value,
|
||||
trailingIcon: loading
|
||||
? LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 20)
|
||||
: null,
|
||||
width: width,
|
||||
hintText: hintText,
|
||||
textStyle: Constant.body2_400(context: context),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: Constant.primaryBlue),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
)),
|
||||
label: label,
|
||||
onSelected: (value) {
|
||||
onSelect(value);
|
||||
selectedLokal.value = value!;
|
||||
},
|
||||
dropdownMenuEntries: data
|
||||
.map<DropdownMenuEntry<CustomDropDownModel>>(
|
||||
(e) => DropdownMenuEntry(value: e, label: e.name ?? ""))
|
||||
.toList());
|
||||
|
||||
// return DropdownButton<CustomDropDownModel>(
|
||||
// // value: selectedData?.value,
|
||||
// items: data.length > 0
|
||||
// ? data
|
||||
// .map<DropdownMenuItem<CustomDropDownModel>>(
|
||||
// (e) => DropdownMenuItem(
|
||||
// child: Text(e.name!),
|
||||
// ))
|
||||
// .toList()
|
||||
// : [],
|
||||
// onChanged: (value) => onSelect(value),
|
||||
// );
|
||||
}
|
||||
}
|
||||
70
lib/widgets/dialog_print.dart
Normal file
70
lib/widgets/dialog_print.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/app/constant.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class DialogPrint extends HookConsumerWidget {
|
||||
const DialogPrint({super.key, required this.url});
|
||||
final String url;
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
late WebViewController controller;
|
||||
|
||||
controller = WebViewController()
|
||||
..loadRequest(
|
||||
Uri.parse(url),
|
||||
);
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(40),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 32)),
|
||||
height: Constant.getActualY(context: context, y: 96),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(8),
|
||||
topLeft: Radius.circular(8)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Cetak Surat Jalan",
|
||||
style: Constant.h2_600(context: context),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
size: 30,
|
||||
Icons.close_rounded,
|
||||
color: Colors.red,
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
// color: Colors.red,
|
||||
height: Constant.getActualY(context: context, y: 800),
|
||||
// width: Constant.getActualX(context: context, x: 1500),
|
||||
child: WebViewWidget(
|
||||
controller: controller,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
376
lib/widgets/header.dart
Normal file
376
lib/widgets/header.dart
Normal file
@@ -0,0 +1,376 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/date_symbol_data_local.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:mitra_corporate/provider/menu_provider.dart';
|
||||
import 'package:mitra_corporate/widgets/custom_text_field.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../app/route.dart';
|
||||
import '../provider/auth_provider.dart';
|
||||
import '../screen/login/change_password_provider.dart';
|
||||
import '../screen/login/logout_provider.dart';
|
||||
import 'custom_snackbar_widget.dart';
|
||||
|
||||
class Header extends HookConsumerWidget {
|
||||
const Header({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final currentUser = ref.watch(authProvider);
|
||||
final isExpand = ref.watch(sideBarExpandProvider);
|
||||
final auth = ref.watch(authProvider);
|
||||
final date = useState("");
|
||||
ref.listen(logoutProvider, (prev, next) async {
|
||||
if (next is LogoutStateLoading) {
|
||||
} else if (next is LogoutStateError) {
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
} else if (next is LogoutStateDone) {
|
||||
if (next.message == "OK") {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove(Constant.tokenName);
|
||||
Navigator.pushNamed(context, loginRoute);
|
||||
} else {
|
||||
SanckbarWidget(context, "Logout Gagal", snackbarType.error);
|
||||
}
|
||||
}
|
||||
});
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
DateTime now = DateTime.now();
|
||||
initializeDateFormatting('id', '').then((_) {
|
||||
date.value = DateFormat('EEEE, d MMMM yyyy', "id").format(now);
|
||||
print(DateFormat('EEEE, d MMMM yyyy', "id").format(now));
|
||||
});
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
alignment: Alignment.center,
|
||||
width: Constant.getActualX(context: context, x: isExpand ? 1159 : 1344),
|
||||
height: Constant.getActualY(context: context, y: 90),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(top: 16, bottom: 16, left: 34, right: 34),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// Center(
|
||||
// child: Icon(
|
||||
// EvaIcons.calendarOutline,
|
||||
// // size: 24,
|
||||
// size: Constant.getActualX(context: context, x: 24),
|
||||
// color: Constant.primaryRed,
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Icon(EvaIcons.calendarOutline,
|
||||
color: Constant.textBlack, size: 24),
|
||||
),
|
||||
SizedBox(width: Constant.getActualX(context: context, x: 8)),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 8.0),
|
||||
child: Text(
|
||||
date.value,
|
||||
style: Constant.body1_600(context: context)
|
||||
.copyWith(color: Constant.textBlack),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
// Icon(EvaIcons.bell, size: 28, color: Constant.primaryRed),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 24),
|
||||
),
|
||||
// CircleAvatar(
|
||||
// child: Icon(EvaIcons.person),
|
||||
// ),
|
||||
MenuAnchor(
|
||||
style: MenuStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(Colors.white),
|
||||
elevation: WidgetStatePropertyAll(5),
|
||||
padding: WidgetStatePropertyAll(EdgeInsets.all(10)),
|
||||
shape: WidgetStatePropertyAll(RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
side: WidgetStatePropertyAll(BorderSide.none)),
|
||||
builder: (BuildContext context, MenuController controller,
|
||||
Widget? child) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (controller.isOpen) {
|
||||
controller.close();
|
||||
} else {
|
||||
controller.open();
|
||||
}
|
||||
},
|
||||
child: CircleAvatar(
|
||||
backgroundColor: Constant.primaryRed,
|
||||
child: Icon(
|
||||
EvaIcons.person,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
alignmentOffset: Offset(-190, 20),
|
||||
menuChildren: [
|
||||
Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 20),
|
||||
width: Constant.getActualX(context: context, x: 200),
|
||||
child: Column(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
backgroundColor: Constant.primaryRed,
|
||||
child: Icon(
|
||||
EvaIcons.person,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(bottom: 10),
|
||||
child: Center(
|
||||
child: Text(
|
||||
auth?.mUserUsername ?? "",
|
||||
style: Constant.body1_600(context: context),
|
||||
))),
|
||||
MenuItemButton(
|
||||
leadingIcon: Icon(
|
||||
EvaIcons.logOut,
|
||||
color: Constant.primaryRed,
|
||||
),
|
||||
onPressed: () {
|
||||
ref.read(logoutProvider.notifier).logout(
|
||||
M_UserID: currentUser!.mUserID ?? "0",
|
||||
M_UserUsername: currentUser.companyName ?? "0");
|
||||
},
|
||||
child: Text(
|
||||
'Logout',
|
||||
style: Constant.body3_400(context: context),
|
||||
),
|
||||
),
|
||||
MenuItemButton(
|
||||
leadingIcon: Icon(
|
||||
EvaIcons.shield,
|
||||
color: Constant.primaryRed,
|
||||
),
|
||||
onPressed: () {
|
||||
showDialog<String>(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20)),
|
||||
title: Text(
|
||||
'Ubah Password',
|
||||
style: Constant.body1_600(context: context),
|
||||
),
|
||||
content: ChangePassword(),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
'Ubah Password',
|
||||
style: Constant.body3_400(context: context),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 10, bottom: 10),
|
||||
child: Center(
|
||||
child: Text(Constant.version,
|
||||
style:
|
||||
Constant.caption1_600(context: context).copyWith(
|
||||
color: Constant.textGrey,
|
||||
)),
|
||||
),
|
||||
)
|
||||
])
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ChangePassword extends HookConsumerWidget {
|
||||
const ChangePassword({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final auth = ref.watch(authProvider);
|
||||
final currPassState = useState(true);
|
||||
final newPassState = useState(true);
|
||||
final newPassVerState = useState(true);
|
||||
final loading = useState(false);
|
||||
final updatekey = useState(0);
|
||||
final currPassCtr = useTextEditingController(text: "");
|
||||
final newPassCtr = useTextEditingController(text: "");
|
||||
final newPassVerCtr = useTextEditingController(text: "");
|
||||
newPassVerCtr.addListener(() {
|
||||
updatekey.value = updatekey.value + 1;
|
||||
});
|
||||
changePassword() {
|
||||
ref.read(ChangePasswordProvider.notifier).ChangePassword(
|
||||
token: auth?.token ?? "",
|
||||
current_password: currPassCtr.text,
|
||||
new_password: newPassCtr.text,
|
||||
password_confirmation: newPassVerCtr.text);
|
||||
}
|
||||
|
||||
ref.listen(ChangePasswordProvider, (prev, next) async {
|
||||
if (next is ChangePasswordStateInit) {
|
||||
loading.value = true;
|
||||
} else if (next is ChangePasswordStateLoading) {
|
||||
loading.value = true;
|
||||
} else if (next is ChangePasswordStateError) {
|
||||
SanckbarWidget(context, next.message, snackbarType.error);
|
||||
loading.value = false;
|
||||
Constant.autoLogout(context: context, msg: next.message);
|
||||
} else if (next is ChangePasswordStateDone) {
|
||||
// if (next.message == "OK") {
|
||||
// final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.remove(Constant.tokenName);
|
||||
// Navigator.pushNamed(context, loginRoute);
|
||||
// } else {
|
||||
// SanckbarWidget(context, "ChangePassword Gagal", snackbarType.error);
|
||||
// }
|
||||
ref.read(logoutProvider.notifier).logout(
|
||||
M_UserID: auth!.mUserID ?? "0",
|
||||
M_UserUsername: auth.companyName ?? "0");
|
||||
SanckbarWidget(context, next.message, snackbarType.success);
|
||||
}
|
||||
loading.value = false;
|
||||
});
|
||||
|
||||
return SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 370),
|
||||
width: Constant.getActualX(context: context, x: 300),
|
||||
child: Column(
|
||||
children: [
|
||||
CustomPasswordField(
|
||||
controller: currPassCtr,
|
||||
isPassword: currPassState,
|
||||
hintText: "Current Password",
|
||||
labelText: "Current password"),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 24),
|
||||
),
|
||||
CustomPasswordField(
|
||||
controller: newPassCtr,
|
||||
isPassword: newPassState,
|
||||
validator: (String? value) {
|
||||
if (value != null) {
|
||||
if (value.isNotEmpty) {
|
||||
// if (value != newPassVerCtr.text) {
|
||||
// return "verifikasi password salah";
|
||||
// }
|
||||
if (!value.contains(RegExp(r'[A-Z]'))) {
|
||||
return " password harus mengandung 1 huruf besar";
|
||||
}
|
||||
if (!value.contains(RegExp(r'[a-z]'))) {
|
||||
return " password harus mengandung 1 huruf kecil";
|
||||
}
|
||||
if (!value.contains(RegExp(r'[0-9]'))) {
|
||||
return " password harus mengandung 1 angka";
|
||||
}
|
||||
if (value.length < 8) {
|
||||
return " password minimal 8 digit";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
hintText: "New Password",
|
||||
labelText: "New password"),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 24),
|
||||
),
|
||||
CustomPasswordField(
|
||||
controller: newPassVerCtr,
|
||||
isPassword: newPassVerState,
|
||||
validator: (String? value) {
|
||||
if (value != null) {
|
||||
if (value.isNotEmpty) {
|
||||
if (value != newPassCtr.text) {
|
||||
return "verifikasi password salah";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
hintText: "New Password verification",
|
||||
labelText: "New Password verification"),
|
||||
Spacer(),
|
||||
Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
side:
|
||||
BorderSide(color: Constant.primaryRed, width: 2),
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
onPressed: !loading.value
|
||||
? () {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
: null,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 8),
|
||||
child: Text(
|
||||
"Batal",
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.primaryRed),
|
||||
),
|
||||
)),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
ElevatedButton(
|
||||
key: ValueKey(updatekey.value),
|
||||
onPressed: currPassCtr.text.isNotEmpty &&
|
||||
newPassCtr.text.isNotEmpty &&
|
||||
newPassVerCtr.text.isNotEmpty &&
|
||||
newPassCtr.text == newPassVerCtr.text &&
|
||||
loading.value == false
|
||||
? () {
|
||||
changePassword();
|
||||
}
|
||||
: null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Constant.primaryRed,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8))),
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 8),
|
||||
child: loading.value
|
||||
? Center(
|
||||
child: LoadingAnimationWidget.staggeredDotsWave(
|
||||
color: Constant.primaryRed, size: 24),
|
||||
)
|
||||
: Text("Simpan",
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textWhite)),
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
52
lib/widgets/iframe_view.dart
Normal file
52
lib/widgets/iframe_view.dart
Normal file
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:html';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
class IframeView extends StatefulWidget {
|
||||
final String source;
|
||||
final void Function(int)? onCreated;
|
||||
const IframeView({
|
||||
super.key,
|
||||
required this.source,
|
||||
this.onCreated,
|
||||
});
|
||||
|
||||
@override
|
||||
_IframeViewState createState() => _IframeViewState();
|
||||
}
|
||||
|
||||
class _IframeViewState extends State<IframeView> {
|
||||
// Widget _iframeWidget;
|
||||
final IFrameElement _iframeElement = IFrameElement();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_iframeElement.style.border = 'none';
|
||||
_iframeElement.onLoad.listen((event) {
|
||||
if (widget.onCreated != null && event.type == "load") {
|
||||
widget.onCreated!(0);
|
||||
}
|
||||
});
|
||||
_iframeElement.src = widget.source;
|
||||
//ignore: undefined_prefixed_name
|
||||
ui.platformViewRegistry.registerViewFactory(
|
||||
widget.source, //use source as registered key to ensure uniqueness
|
||||
(int viewId) => _iframeElement,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return HtmlElementView(
|
||||
key: UniqueKey(),
|
||||
viewType: widget.source,
|
||||
);
|
||||
}
|
||||
}
|
||||
38
lib/widgets/order_status_icon.dart
Normal file
38
lib/widgets/order_status_icon.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class OrderStatusIcon extends StatelessWidget {
|
||||
const OrderStatusIcon({super.key, required this.status});
|
||||
final String status;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (status) {
|
||||
case "N":
|
||||
return Tooltip(
|
||||
message: "Belum dikirim",
|
||||
child: Icon(
|
||||
EvaIcons.stopCircle,
|
||||
color: Colors.blue,
|
||||
),
|
||||
);
|
||||
case "P":
|
||||
return Tooltip(
|
||||
message: "Pending",
|
||||
child: Icon(
|
||||
EvaIcons.clock,
|
||||
color: Colors.yellow,
|
||||
),
|
||||
);
|
||||
case "S":
|
||||
return Tooltip(
|
||||
message: "Terkirim",
|
||||
child: Icon(
|
||||
EvaIcons.checkmarkCircle2,
|
||||
color: Colors.green,
|
||||
),
|
||||
);
|
||||
default:
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
}
|
||||
0
lib/widgets/progress_stepper.dart
Normal file
0
lib/widgets/progress_stepper.dart
Normal file
38
lib/widgets/qr_status_chip.dart
Normal file
38
lib/widgets/qr_status_chip.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class QRStatusChip extends StatelessWidget {
|
||||
const QRStatusChip({super.key, required this.status});
|
||||
final String status;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
switch (status) {
|
||||
case "N":
|
||||
return Tooltip(
|
||||
message: "Belum dikirim",
|
||||
child: Icon(
|
||||
EvaIcons.stopCircle,
|
||||
color: Colors.blue,
|
||||
),
|
||||
);
|
||||
case "P":
|
||||
return Tooltip(
|
||||
message: "Pending",
|
||||
child: Icon(
|
||||
EvaIcons.clock,
|
||||
color: Colors.yellow,
|
||||
),
|
||||
);
|
||||
case "S":
|
||||
return Tooltip(
|
||||
message: "Terkirim",
|
||||
child: Icon(
|
||||
EvaIcons.checkmarkCircle2,
|
||||
color: Colors.green,
|
||||
),
|
||||
);
|
||||
default:
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
}
|
||||
151
lib/widgets/side_menu.dart
Normal file
151
lib/widgets/side_menu.dart
Normal file
@@ -0,0 +1,151 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/app/route.dart';
|
||||
import 'package:mitra_corporate/model/menu_model.dart';
|
||||
import 'package:mitra_corporate/provider/auth_provider.dart';
|
||||
import 'package:mitra_corporate/provider/menu_provider.dart';
|
||||
import 'package:mitra_corporate/screen/login/logout_provider.dart';
|
||||
import 'package:mitra_corporate/widgets/side_menu_btn_widget.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import 'custom_snackbar_widget.dart';
|
||||
|
||||
class SideMenu extends HookConsumerWidget {
|
||||
const SideMenu({
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final currentMenu = ref.watch(currentMenuProvider);
|
||||
final isExpand = ref.watch(sideBarExpandProvider);
|
||||
final List<MenuModel> menuList = Constant.getMenuModel();
|
||||
|
||||
return Container(
|
||||
color: Colors.white,
|
||||
child: isExpand
|
||||
? Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 280),
|
||||
height: Constant.getActualY(context: context, y: 90),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 24, right: 24, top: 12, bottom: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Image.asset('images/logo_pramita.png',
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 147),
|
||||
height: Constant.getActualY(
|
||||
context: context, y: 46)),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
ref.read(sideBarExpandProvider.notifier).state =
|
||||
!isExpand;
|
||||
// ref.read(logoutProvider.notifier).logout(
|
||||
// M_UserID: currentUser!.mUserID ?? "0",
|
||||
// M_UserUsername: currentUser.companyName ?? "0");
|
||||
},
|
||||
icon: Icon(EvaIcons.menu2,
|
||||
color: Constant.primaryRed,
|
||||
size: Constant.getActualX(
|
||||
context: context, x: 24)),
|
||||
)
|
||||
],
|
||||
),
|
||||
)),
|
||||
),
|
||||
SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 280),
|
||||
height: Constant.getActualY(context: context, y: 930),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: ListView(
|
||||
children: menuList
|
||||
.map(
|
||||
(e) => Container(
|
||||
margin: EdgeInsets.only(
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 24)),
|
||||
decoration: BoxDecoration(
|
||||
color: e.subValue.contains(currentMenu)
|
||||
? Constant.selectedMenuBg
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(8)),
|
||||
child: sideBarMenuBtnWidget(
|
||||
currentMenu: currentMenu,
|
||||
title: e.title,
|
||||
value: e.subValue,
|
||||
iconMenu: e.icon,
|
||||
selectedColor: Constant.selectedMenuBg,
|
||||
selectedColorText: Constant.primaryRed,
|
||||
onTap: () {
|
||||
ref.read(currentMenuProvider.notifier).state =
|
||||
e.mainValue;
|
||||
// Navigator.pushNamed(context, dashboardRoute);
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: Constant.getActualX(context: context, x: 95),
|
||||
height: Constant.getActualY(context: context, y: 90),
|
||||
child: Center(
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
ref.read(sideBarExpandProvider.notifier).state =
|
||||
!isExpand;
|
||||
},
|
||||
icon: Icon(EvaIcons.menu2,
|
||||
color: Constant.primaryRed,
|
||||
size:
|
||||
Constant.getActualX(context: context, x: 24)),
|
||||
),
|
||||
)),
|
||||
),
|
||||
SizedBox(
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(context: context, x: 95),
|
||||
height: Constant.getActualY(context: context, y: 930),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: ListView(
|
||||
children: menuList
|
||||
.map(
|
||||
(e) => SideBarBtnSmallWidget(
|
||||
title: e.title,
|
||||
currentMenu: currentMenu,
|
||||
value: e.subValue,
|
||||
iconMenu: e.icon,
|
||||
selectedColor: Constant.selectedMenuBg,
|
||||
selectedColorText: Constant.primaryRed,
|
||||
onTap: () {
|
||||
ref.read(currentMenuProvider.notifier).state =
|
||||
e.mainValue;
|
||||
// Navigator.pushNamed(context, dashboardRoute);
|
||||
},
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
105
lib/widgets/side_menu_btn_widget.dart
Normal file
105
lib/widgets/side_menu_btn_widget.dart
Normal file
@@ -0,0 +1,105 @@
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/provider/menu_provider.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
|
||||
class sideBarMenuBtnWidget extends HookConsumerWidget {
|
||||
const sideBarMenuBtnWidget({
|
||||
super.key,
|
||||
required this.currentMenu,
|
||||
required this.value,
|
||||
required this.selectedColor,
|
||||
required this.onTap,
|
||||
required this.title,
|
||||
required this.selectedColorText,
|
||||
this.iconMenu,
|
||||
});
|
||||
|
||||
final int currentMenu;
|
||||
final String title;
|
||||
final List<int> value;
|
||||
final Color selectedColor;
|
||||
final Color selectedColorText;
|
||||
final Function onTap;
|
||||
final IconData? iconMenu;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isExpand = ref.watch(sideBarExpandProvider);
|
||||
final isSelected = useState(false);
|
||||
useEffect(() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
|
||||
isSelected.value = value.any((element) => element == currentMenu);
|
||||
});
|
||||
return () {};
|
||||
}, [currentMenu, value]);
|
||||
return Container(
|
||||
child: ListTile(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||||
selected: isSelected.value ? true : false,
|
||||
selectedTileColor: selectedColor,
|
||||
title: Text(title,
|
||||
style: Constant.body3_400(context: context).copyWith(
|
||||
color: isSelected.value ? selectedColorText : Colors.grey)),
|
||||
leading: Icon(iconMenu ?? EvaIcons.grid,
|
||||
color: isSelected.value ? selectedColorText : Colors.grey,
|
||||
size: 24.0),
|
||||
onTap: () {
|
||||
onTap();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SideBarBtnSmallWidget extends StatelessWidget {
|
||||
const SideBarBtnSmallWidget({
|
||||
super.key,
|
||||
required this.currentMenu,
|
||||
required this.value,
|
||||
required this.selectedColor,
|
||||
required this.onTap,
|
||||
required this.title,
|
||||
required this.selectedColorText,
|
||||
this.iconMenu,
|
||||
});
|
||||
|
||||
final int currentMenu;
|
||||
final List<int> value;
|
||||
final Color selectedColor;
|
||||
final Color selectedColorText;
|
||||
final String title;
|
||||
final Function onTap;
|
||||
final IconData? iconMenu;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
margin:
|
||||
EdgeInsets.only(bottom: Constant.getActualY(context: context, y: 24)),
|
||||
decoration: BoxDecoration(
|
||||
color: value.any((element) => element == currentMenu)
|
||||
? selectedColor
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(8)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
onTap();
|
||||
},
|
||||
icon: Tooltip(
|
||||
message: title,
|
||||
child: Icon(iconMenu ?? EvaIcons.grid,
|
||||
color: value.any((element) => element == currentMenu)
|
||||
? selectedColorText
|
||||
: Colors.grey,
|
||||
size: 24),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
113
lib/widgets/specimen_table_widget.dart
Normal file
113
lib/widgets/specimen_table_widget.dart
Normal file
@@ -0,0 +1,113 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../model/registration_model.dart';
|
||||
|
||||
class SpecimenTableWidget extends HookConsumerWidget {
|
||||
const SpecimenTableWidget({
|
||||
super.key,
|
||||
required this.specimenLoading,
|
||||
required this.tempRegistrationData,
|
||||
required this.addOrderLoading,
|
||||
});
|
||||
|
||||
final ValueNotifier<bool> specimenLoading;
|
||||
final RegistrationModel tempRegistrationData;
|
||||
final bool addOrderLoading;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.13,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Specimen',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.11,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Jumlah',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 300),
|
||||
child: specimenLoading.value
|
||||
? Center(
|
||||
child: LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 30),
|
||||
)
|
||||
: ListView(children: [
|
||||
...?tempRegistrationData.specimens?.map((e) => SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.13,
|
||||
color: Colors.white,
|
||||
child: Chip(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6)),
|
||||
),
|
||||
backgroundColor: Constant.yellow_016,
|
||||
label: Text(
|
||||
'${e.name}'.replaceAll(' ', '\u00A0'),
|
||||
style: Constant.caption1_600(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textYellow)),
|
||||
)),
|
||||
Container(
|
||||
height: Constant.getActualY(
|
||||
context: context, y: 52),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.11,
|
||||
child: TextField(
|
||||
enabled: !addOrderLoading,
|
||||
controller: e.ctr,
|
||||
onChanged: (value) {
|
||||
print(value);
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8))),
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
)),
|
||||
]),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
64
lib/widgets/stepper_edit.dart
Normal file
64
lib/widgets/stepper_edit.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/provider/order_provider.dart';
|
||||
import 'package:mitra_corporate/provider/registrasi_provider.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
|
||||
class StepperEdit extends HookConsumerWidget {
|
||||
final int _currentStep = 0;
|
||||
StepperType stepperType = StepperType.horizontal;
|
||||
|
||||
StepperEdit({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final step = ref.watch(EditStepProvider);
|
||||
final tempRegistrationData = ref.watch(registrationDataProvider);
|
||||
final selectedTest = ref.watch(selectedTestProvider);
|
||||
final orderLoading = ref.watch(addOrderLoadingProvider);
|
||||
|
||||
return Scaffold(
|
||||
body: Stepper(
|
||||
elevation: 0,
|
||||
type: stepperType,
|
||||
physics: const ScrollPhysics(),
|
||||
currentStep: step,
|
||||
onStepTapped: !orderLoading
|
||||
? (value) {
|
||||
if ((value) != 3) {
|
||||
ref.read(registrasiProvider.notifier).state = value;
|
||||
}
|
||||
}
|
||||
: null,
|
||||
steps: <Step>[
|
||||
Step(
|
||||
title: Text('Data Pasien',
|
||||
style: Constant.caption1_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
content: Container(),
|
||||
isActive: step == 0,
|
||||
state: tempRegistrationData.patientData?.name != null
|
||||
? StepState.complete
|
||||
: StepState.disabled,
|
||||
),
|
||||
Step(
|
||||
title: Text('Pemeriksaan',
|
||||
style: Constant.caption1_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
content: Container(),
|
||||
isActive: step == 1,
|
||||
state: tempRegistrationData.tests != null
|
||||
? StepState.complete
|
||||
: StepState.disabled,
|
||||
),
|
||||
Step(
|
||||
title: Text('Detail Order',
|
||||
style: Constant.caption1_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
content: Container(),
|
||||
isActive: step == 2,
|
||||
state: step - 1 >= 2 ? StepState.complete : StepState.disabled,
|
||||
),
|
||||
]));
|
||||
}
|
||||
}
|
||||
63
lib/widgets/stepper_registrasi.dart
Normal file
63
lib/widgets/stepper_registrasi.dart
Normal file
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mitra_corporate/provider/registrasi_provider.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
|
||||
class StepperRegistrasi extends HookConsumerWidget {
|
||||
final int _currentStep = 0;
|
||||
StepperType stepperType = StepperType.horizontal;
|
||||
|
||||
StepperRegistrasi({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final step = ref.watch(registrasiProvider);
|
||||
final tempRegistrationData = ref.watch(registrationDataProvider);
|
||||
final selectedTest = ref.watch(selectedTestProvider);
|
||||
final orderLoading = ref.watch(addOrderLoadingProvider);
|
||||
|
||||
return Scaffold(
|
||||
body: Stepper(
|
||||
elevation: 0,
|
||||
type: stepperType,
|
||||
physics: const ScrollPhysics(),
|
||||
currentStep: step,
|
||||
onStepTapped: !orderLoading
|
||||
? (value) {
|
||||
if ((value) != 3) {
|
||||
ref.read(registrasiProvider.notifier).state = value;
|
||||
}
|
||||
}
|
||||
: null,
|
||||
steps: <Step>[
|
||||
Step(
|
||||
title: Text('Data Pasien',
|
||||
style: Constant.caption1_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
content: Container(),
|
||||
isActive: step == 0,
|
||||
state: tempRegistrationData.patientData?.name != null
|
||||
? StepState.complete
|
||||
: StepState.disabled,
|
||||
),
|
||||
Step(
|
||||
title: Text('Pemeriksaan',
|
||||
style: Constant.caption1_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
content: Container(),
|
||||
isActive: step == 1,
|
||||
state: tempRegistrationData.tests != null
|
||||
? StepState.complete
|
||||
: StepState.disabled,
|
||||
),
|
||||
Step(
|
||||
title: Text('Detail Order',
|
||||
style: Constant.caption1_400(context: context)
|
||||
.copyWith(color: Constant.textBlack)),
|
||||
content: Container(),
|
||||
isActive: step == 2,
|
||||
state: step - 1 >= 2 ? StepState.complete : StepState.disabled,
|
||||
),
|
||||
]));
|
||||
}
|
||||
}
|
||||
574
lib/widgets/tests_tabel_edit_widget.dart
Normal file
574
lib/widgets/tests_tabel_edit_widget.dart
Normal file
@@ -0,0 +1,574 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../model/registration_model.dart';
|
||||
|
||||
class TestsTableEditWidget extends HookConsumerWidget {
|
||||
const TestsTableEditWidget({
|
||||
super.key,
|
||||
required this.paketDelete,
|
||||
required this.specimenLoading,
|
||||
required this.testScrollCtr,
|
||||
required this.tempRegistrationData,
|
||||
required this.addOrderLoading,
|
||||
required this.delete,
|
||||
required this.pickDateTime,
|
||||
});
|
||||
|
||||
final ValueNotifier<bool> specimenLoading;
|
||||
final ScrollController testScrollCtr;
|
||||
final RegistrationModel tempRegistrationData;
|
||||
final bool addOrderLoading;
|
||||
final Function(String id, String idtab) delete;
|
||||
final Function(String idtab, String idtest, String dt) pickDateTime;
|
||||
final Function(String id) paketDelete;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
var maskFormatter = MaskTextInputFormatter(
|
||||
initialText:
|
||||
DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now()).toString(),
|
||||
mask: '##-##-#### ##:##',
|
||||
filter: {"#": RegExp(r'[0-9]')},
|
||||
type: MaskAutoCompletionType.eager);
|
||||
bool isDate(String str) {
|
||||
if (DateTime.tryParse(str) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// try {
|
||||
// DateTime.tryParse(str);
|
||||
// return true;
|
||||
// } catch (e) {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
formatDate(String date) {
|
||||
String formated = "";
|
||||
if (isDate(date)) {
|
||||
formated = DateFormat('dd-MM-yyyy HH:mm')
|
||||
.format(DateTime.parse(date))
|
||||
.toString();
|
||||
} else {
|
||||
formated = date;
|
||||
}
|
||||
return formated;
|
||||
}
|
||||
|
||||
String? validateDate(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return "tidak boleh ksosng";
|
||||
}
|
||||
final splitted = value.split(" ");
|
||||
if (splitted.length == 2) {
|
||||
final date = splitted[0];
|
||||
final time = splitted[1];
|
||||
final splittedDate = date.split("-");
|
||||
final splittedTime = time.split(":");
|
||||
if (splittedDate.length == 3) {
|
||||
final day = int.tryParse(splittedDate[0]);
|
||||
final month = int.tryParse(splittedDate[1]);
|
||||
final year = int.tryParse(splittedDate[2]);
|
||||
if (day != null) {
|
||||
if (day > 31) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
if (month != null) {
|
||||
if (month > 12) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
// if (year == null) {
|
||||
// return "Format salah";
|
||||
// }
|
||||
} else {
|
||||
return "Format salah";
|
||||
}
|
||||
if (splittedTime.length == 2) {
|
||||
var hour = int.tryParse(splittedTime[0]);
|
||||
var sec = int.tryParse(splittedTime[1]);
|
||||
if (hour != null) {
|
||||
if (hour > 24) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
if (sec != null) {
|
||||
if (sec > 60) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return "Format salah";
|
||||
}
|
||||
} else {
|
||||
return "Format salah";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.9,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Pemeriksaan',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
// Container(
|
||||
// alignment: Alignment.centerLeft,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
// width: Constant.getActualX(context: context, x: 1160) * 0.20,
|
||||
// height: Constant.getActualY(context: context, y: 64),
|
||||
// color: Constant.grey_200,
|
||||
// child: Text('Jenis Specimen',
|
||||
// style: Constant.body3_600(context: context)
|
||||
// .copyWith(color: Constant.textGrey)),
|
||||
// ),
|
||||
// Container(
|
||||
// alignment: Alignment.centerLeft,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
// width: Constant.getActualX(context: context, x: 1160) * 0.13,
|
||||
// height: Constant.getActualY(context: context, y: 64),
|
||||
// color: Constant.grey_200,
|
||||
// child: Text('Harga',
|
||||
// style: Constant.body3_600(context: context)
|
||||
// .copyWith(color: Constant.textGrey)),
|
||||
// ),
|
||||
// Container(
|
||||
// alignment: Alignment.centerLeft,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
// width: Constant.getActualX(context: context, x: 1160) * 0.4,
|
||||
// height: Constant.getActualY(context: context, y: 64),
|
||||
// color: Constant.grey_200,
|
||||
// child: Text('Waktu Pengambilan Sample',
|
||||
// style: Constant.body3_600(context: context)
|
||||
// .copyWith(color: Constant.textGrey)),
|
||||
// ),
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.1,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Aksi',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 390),
|
||||
// color: Colors.red,
|
||||
child: specimenLoading.value
|
||||
? Center(
|
||||
child: LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 40),
|
||||
)
|
||||
: Scrollbar(
|
||||
thumbVisibility: true,
|
||||
trackVisibility: true,
|
||||
scrollbarOrientation: ScrollbarOrientation.right,
|
||||
controller: testScrollCtr,
|
||||
child: ScrollConfiguration(
|
||||
behavior: ScrollBehavior().copyWith(dragDevices: {
|
||||
PointerDeviceKind.mouse,
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.trackpad,
|
||||
PointerDeviceKind.stylus,
|
||||
PointerDeviceKind.unknown
|
||||
}),
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
addAutomaticKeepAlives: true,
|
||||
controller: testScrollCtr,
|
||||
// semanticChildCount:
|
||||
// tempRegistrationData.tests?.length,
|
||||
children: [
|
||||
Column(
|
||||
children: tempRegistrationData.paket!.map((e) {
|
||||
var index = tempRegistrationData.paket?.indexOf(e);
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 16),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 16)),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.9,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: Constant.getActualY(
|
||||
context: context, y: 64)),
|
||||
// height: Constant.getActualY(
|
||||
// context: context, y: 64),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(e.name ?? '',
|
||||
style: Constant.body3_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color:
|
||||
Constant.textBlack)),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(e.detail ?? '',
|
||||
style: Constant.caption2_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color:
|
||||
Constant.textGrey)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 16),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 16)),
|
||||
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.1,
|
||||
child: IconButton(
|
||||
onPressed: !addOrderLoading
|
||||
? () {
|
||||
// delete(e.id!, e.tab!);
|
||||
paketDelete(e.id!);
|
||||
}
|
||||
: null,
|
||||
icon: Icon(EvaIcons.trash2,
|
||||
size: 24,
|
||||
color: Constant.textGrey)),
|
||||
)
|
||||
],
|
||||
),
|
||||
Divider()
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
Column(
|
||||
children: tempRegistrationData.tests!.map((e) {
|
||||
var index = tempRegistrationData.tests?.indexOf(e);
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 16),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 16)),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.9,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: Constant.getActualY(
|
||||
context: context, y: 64)),
|
||||
// height: Constant.getActualY(
|
||||
// context: context, y: 64),
|
||||
color: Colors.white,
|
||||
child: Text(e.name ?? '',
|
||||
style: Constant.body3_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack)),
|
||||
),
|
||||
// Container(
|
||||
// // alignment: Alignment.centerLeft,
|
||||
// margin: EdgeInsets.only(
|
||||
// bottom: Constant.getActualY(
|
||||
// context: context, y: 20)),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// vertical: Constant.getActualY(
|
||||
// context: context, y: 10),
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20)),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.20,
|
||||
// // height: Constant.getActualY(
|
||||
// // context: context, y: 64),
|
||||
// color: Colors.white,
|
||||
// child: Column(
|
||||
// // spacing: 10,
|
||||
// // runSpacing: 10,
|
||||
|
||||
// crossAxisAlignment:
|
||||
// CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// ...?e.specimen
|
||||
// ?.map(
|
||||
// (e) => Container(
|
||||
// margin: EdgeInsets.only(
|
||||
// bottom: 10),
|
||||
// child: Chip(
|
||||
// shape:
|
||||
// RoundedRectangleBorder(
|
||||
// borderRadius:
|
||||
// BorderRadius.all(
|
||||
// Radius.circular(
|
||||
// 6)),
|
||||
// ),
|
||||
// backgroundColor:
|
||||
// Constant.yellow_016,
|
||||
// label: Text(
|
||||
// '${e.name} '.replaceAll(
|
||||
// ' ', '\u00A0'),
|
||||
// overflow: TextOverflow
|
||||
// .ellipsis,
|
||||
// style: Constant
|
||||
// .caption1_600(
|
||||
// context:
|
||||
// context)
|
||||
// .copyWith(
|
||||
// color: Constant
|
||||
// .textYellow)),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// ...?e.bahan
|
||||
// ?.map(
|
||||
// (e) => Container(
|
||||
// margin: EdgeInsets.only(
|
||||
// bottom: 10),
|
||||
// child: Chip(
|
||||
// shape:
|
||||
// RoundedRectangleBorder(
|
||||
// borderRadius:
|
||||
// BorderRadius.all(
|
||||
// Radius.circular(
|
||||
// 6)),
|
||||
// ),
|
||||
// backgroundColor:
|
||||
// Constant.blue_016,
|
||||
// label: Text(
|
||||
// '${e.name} '.replaceAll(
|
||||
// ' ', '\u00A0'),
|
||||
// overflow: TextOverflow
|
||||
// .ellipsis,
|
||||
// style: Constant
|
||||
// .caption1_600(
|
||||
// context:
|
||||
// context)
|
||||
// .copyWith(
|
||||
// color: Constant
|
||||
// .textBlue)),
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// ])),
|
||||
// Container(
|
||||
// margin: EdgeInsets.only(
|
||||
// bottom: Constant.getActualY(
|
||||
// context: context, y: 20)),
|
||||
|
||||
// // alignment: Alignment.centerLeft,
|
||||
// alignment: Alignment.centerRight,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20)),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.13,
|
||||
// // height: Constant.getActualY(
|
||||
// // context: context, y: 64),
|
||||
// color: Colors.white,
|
||||
// child: Text(Constant.convertToIdr(
|
||||
// int.parse(e.price ?? "0"), 0))),
|
||||
// Container(
|
||||
// margin: EdgeInsets.only(
|
||||
// bottom: Constant.getActualY(
|
||||
// context: context, y: 20)),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20)),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.4,
|
||||
// color: Colors.white,
|
||||
// child: SizedBox(
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 250),
|
||||
// child: CustomTextField(
|
||||
// suffixIcon: Icon(EvaIcons.calendar),
|
||||
// initialValue: formatDate(e.date!),
|
||||
// onChange: (value) {
|
||||
// pickDateTime(
|
||||
// e.tab!,
|
||||
// e.id!,
|
||||
// value,
|
||||
// );
|
||||
// },
|
||||
// validator: validateDate,
|
||||
// inputFormater: [
|
||||
// MaskTextInputFormatter(
|
||||
// initialText: e.date,
|
||||
// mask: '##-##-#### ##:##',
|
||||
// filter: {"#": RegExp(r'[0-9]')},
|
||||
// type: MaskAutoCompletionType
|
||||
// .eager)
|
||||
// ],
|
||||
|
||||
// // controller:
|
||||
// // TextEditingController(text: e.date),
|
||||
// // controller: searchCtr,
|
||||
// isPassword: false,
|
||||
// hintText: "dd-mm-yyyy hh:mm",
|
||||
// labelText: "dd-mm-yyyy hh:mm",
|
||||
// ),
|
||||
// )
|
||||
// // InkWell(
|
||||
// // onTap: !addOrderLoading
|
||||
// // ? () {
|
||||
// // pickDateTime(
|
||||
// // e.tab!,
|
||||
// // e.id!,
|
||||
// // e.date!,
|
||||
// // );
|
||||
// // }
|
||||
// // : null,
|
||||
// // child: Chip(
|
||||
// // shape: RoundedRectangleBorder(
|
||||
// // borderRadius: BorderRadius.all(
|
||||
// // Radius.circular(6)),
|
||||
// // ),
|
||||
// // backgroundColor: Constant.grey_200,
|
||||
// // label: Text(
|
||||
// // DateFormat('dd MMM yyyy HH:mm')
|
||||
// // .format(DateTime.parse(e.date!)),
|
||||
// // style: Constant.caption1_600(
|
||||
// // context: context)
|
||||
// // .copyWith(
|
||||
// // color: Constant.textGrey)),
|
||||
// // ),
|
||||
// // ),
|
||||
// ),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 20)),
|
||||
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.1,
|
||||
child: IconButton(
|
||||
onPressed: !addOrderLoading
|
||||
? () {
|
||||
delete(e.id!, e.tab!);
|
||||
}
|
||||
: null,
|
||||
icon: Icon(EvaIcons.trash2,
|
||||
size: 24,
|
||||
color: Constant.textGrey)),
|
||||
)
|
||||
],
|
||||
),
|
||||
Divider()
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
// Container(
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20)),
|
||||
// child: Divider()),
|
||||
// Row(
|
||||
// children: [
|
||||
// Container(
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20),
|
||||
// vertical: Constant.getActualY(
|
||||
// context: context, y: 16)),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.34,
|
||||
// child: Text(
|
||||
// "TOTAL",
|
||||
// style: Constant.body3_500(context: context),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// alignment: Alignment.centerRight,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20),
|
||||
// vertical: Constant.getActualY(
|
||||
// context: context, y: 16)),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.13,
|
||||
// child: Text(
|
||||
// Constant.convertToIdr(
|
||||
// double.parse(
|
||||
// tempRegistrationData.total ?? "0"),
|
||||
// 0),
|
||||
// style: Constant.body3_500(context: context),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
422
lib/widgets/tests_tabel_widget.dart
Normal file
422
lib/widgets/tests_tabel_widget.dart
Normal file
@@ -0,0 +1,422 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
|
||||
|
||||
import '../app/constant.dart';
|
||||
import '../model/registration_model.dart';
|
||||
|
||||
class TestsTableWidget extends HookConsumerWidget {
|
||||
const TestsTableWidget({
|
||||
super.key,
|
||||
required this.specimenLoading,
|
||||
required this.testScrollCtr,
|
||||
required this.tempRegistrationData,
|
||||
required this.addOrderLoading,
|
||||
required this.deletePaket,
|
||||
required this.delete,
|
||||
required this.pickDateTime,
|
||||
});
|
||||
|
||||
final ValueNotifier<bool> specimenLoading;
|
||||
final ScrollController testScrollCtr;
|
||||
final RegistrationModel tempRegistrationData;
|
||||
final bool addOrderLoading;
|
||||
final Function(String id, String idtab) delete;
|
||||
final Function(String id) deletePaket;
|
||||
final Function(String idtab, String idtest, String dt) pickDateTime;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
var maskFormatter = MaskTextInputFormatter(
|
||||
initialText:
|
||||
DateFormat('dd-MM-yyyy HH:mm').format(DateTime.now()).toString(),
|
||||
mask: '##-##-#### ##:##',
|
||||
filter: {"#": RegExp(r'[0-9]')},
|
||||
type: MaskAutoCompletionType.eager);
|
||||
bool isDate(String str) {
|
||||
if (DateTime.tryParse(str) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// try {
|
||||
// DateTime.tryParse(str);
|
||||
// return true;
|
||||
// } catch (e) {
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
formatDate(String date) {
|
||||
String formated = "";
|
||||
if (isDate(date)) {
|
||||
formated = DateFormat('dd-MM-yyyy HH:mm')
|
||||
.format(DateTime.parse(date))
|
||||
.toString();
|
||||
} else {
|
||||
formated = date;
|
||||
}
|
||||
return formated;
|
||||
}
|
||||
|
||||
String? validateDate(String? value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return "tidak boleh ksosng";
|
||||
}
|
||||
final splitted = value.split(" ");
|
||||
if (splitted.length == 2) {
|
||||
final date = splitted[0];
|
||||
final time = splitted[1];
|
||||
final splittedDate = date.split("-");
|
||||
final splittedTime = time.split(":");
|
||||
if (splittedDate.length == 3) {
|
||||
final day = int.tryParse(splittedDate[0]);
|
||||
final month = int.tryParse(splittedDate[1]);
|
||||
final year = int.tryParse(splittedDate[2]);
|
||||
if (day != null) {
|
||||
if (day > 31) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
if (month != null) {
|
||||
if (month > 12) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
// if (year == null) {
|
||||
// return "Format salah";
|
||||
// }
|
||||
} else {
|
||||
return "Format salah";
|
||||
}
|
||||
if (splittedTime.length == 2) {
|
||||
var hour = int.tryParse(splittedTime[0]);
|
||||
var sec = int.tryParse(splittedTime[1]);
|
||||
if (hour != null) {
|
||||
if (hour > 24) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
if (sec != null) {
|
||||
if (sec > 60) {
|
||||
return "Format salah";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return "Format salah";
|
||||
}
|
||||
} else {
|
||||
return "Format salah";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.9,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Pemeriksaan',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
// Container(
|
||||
// alignment: Alignment.centerLeft,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
// width: Constant.getActualX(context: context, x: 1160) * 0.4,
|
||||
// height: Constant.getActualY(context: context, y: 64),
|
||||
// color: Constant.grey_200,
|
||||
// child: Text('Waktu Pengambilan Sample',
|
||||
// style: Constant.body3_600(context: context)
|
||||
// .copyWith(color: Constant.textGrey)),
|
||||
// ),
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(context: context, x: 20)),
|
||||
width: Constant.getActualX(context: context, x: 1160) * 0.1,
|
||||
height: Constant.getActualY(context: context, y: 64),
|
||||
color: Constant.grey_200,
|
||||
child: Text('Aksi',
|
||||
style: Constant.body3_600(context: context)
|
||||
.copyWith(color: Constant.textGrey)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: Constant.getActualY(context: context, y: 390),
|
||||
// color: Colors.red,
|
||||
child: specimenLoading.value
|
||||
? Center(
|
||||
child: LoadingAnimationWidget.discreteCircle(
|
||||
color: Constant.primaryBlue, size: 40),
|
||||
)
|
||||
: Scrollbar(
|
||||
thumbVisibility: true,
|
||||
trackVisibility: true,
|
||||
scrollbarOrientation: ScrollbarOrientation.right,
|
||||
controller: testScrollCtr,
|
||||
child: ScrollConfiguration(
|
||||
behavior: ScrollBehavior().copyWith(dragDevices: {
|
||||
PointerDeviceKind.mouse,
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.trackpad,
|
||||
PointerDeviceKind.stylus,
|
||||
PointerDeviceKind.unknown
|
||||
}),
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
addAutomaticKeepAlives: true,
|
||||
controller: testScrollCtr,
|
||||
// semanticChildCount:
|
||||
// tempRegistrationData.tests?.length,
|
||||
children: [
|
||||
Column(
|
||||
children: tempRegistrationData.paket!.map((e) {
|
||||
var index = tempRegistrationData.paket?.indexOf(e);
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 16),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 16)),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.9,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: Constant.getActualY(
|
||||
context: context, y: 64)),
|
||||
// height: Constant.getActualY(
|
||||
// context: context, y: 64),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(e.name ?? '',
|
||||
style: Constant.body3_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color:
|
||||
Constant.textBlack)),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(e.detail ?? '',
|
||||
style: Constant.caption2_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color:
|
||||
Constant.textGrey)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 16),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 16)),
|
||||
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.1,
|
||||
child: IconButton(
|
||||
onPressed: !addOrderLoading
|
||||
? () {
|
||||
// delete(e.id!, e.tab!);
|
||||
deletePaket(e.id!);
|
||||
}
|
||||
: null,
|
||||
icon: Icon(EvaIcons.trash2,
|
||||
size: 24,
|
||||
color: Constant.textGrey)),
|
||||
)
|
||||
],
|
||||
),
|
||||
Divider()
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
Column(
|
||||
children: tempRegistrationData.tests!.map((e) {
|
||||
var index = tempRegistrationData.tests?.indexOf(e);
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
top: Constant.getActualY(
|
||||
context: context, y: 16),
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 16)),
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.9,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: Constant.getActualY(
|
||||
context: context, y: 64)),
|
||||
// height: Constant.getActualY(
|
||||
// context: context, y: 64),
|
||||
color: Colors.white,
|
||||
child: Text(e.name ?? '',
|
||||
style: Constant.body3_400(
|
||||
context: context)
|
||||
.copyWith(
|
||||
color: Constant.textBlack)),
|
||||
),
|
||||
// Container(
|
||||
// margin: EdgeInsets.only(
|
||||
// bottom: Constant.getActualY(
|
||||
// context: context, y: 20)),
|
||||
// alignment: Alignment.centerLeft,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20),
|
||||
// vertical: 10),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.4,
|
||||
// color: Colors.white,
|
||||
// child: SizedBox(
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 250),
|
||||
// child: CustomTextField(
|
||||
// suffixIcon: Icon(EvaIcons.calendar),
|
||||
// initialValue: formatDate(e.date!),
|
||||
// onChange: (value) {
|
||||
// pickDateTime(
|
||||
// e.tab!,
|
||||
// e.id!,
|
||||
// value,
|
||||
// );
|
||||
// },
|
||||
// validator: validateDate,
|
||||
// inputFormater: [
|
||||
// MaskTextInputFormatter(
|
||||
// initialText: e.date,
|
||||
// mask: '##-##-#### ##:##',
|
||||
// filter: {"#": RegExp(r'[0-9]')},
|
||||
// type: MaskAutoCompletionType.eager)
|
||||
// ],
|
||||
|
||||
// // controller:
|
||||
// // TextEditingController(text: e.date),
|
||||
// // controller: searchCtr,
|
||||
// isPassword: false,
|
||||
// hintText: "dd-mm-yyyy hh:mm",
|
||||
// labelText: "dd-mm-yyyy hh:mm",
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Container(
|
||||
margin: EdgeInsets.only(
|
||||
bottom: Constant.getActualY(
|
||||
context: context, y: 20)),
|
||||
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: Constant.getActualX(
|
||||
context: context, x: 20)),
|
||||
// color: Colors.red,
|
||||
width: Constant.getActualX(
|
||||
context: context, x: 1160) *
|
||||
0.1,
|
||||
child: IconButton(
|
||||
onPressed: !addOrderLoading
|
||||
? () {
|
||||
delete(e.id!, e.tab!);
|
||||
}
|
||||
: null,
|
||||
icon: Icon(EvaIcons.trash2,
|
||||
size: 24,
|
||||
color: Constant.textGrey)),
|
||||
)
|
||||
],
|
||||
),
|
||||
Divider()
|
||||
],
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
// Container(
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20)),
|
||||
// child: Divider()),
|
||||
// Row(
|
||||
// children: [
|
||||
// Container(
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20),
|
||||
// vertical: Constant.getActualY(
|
||||
// context: context, y: 16)),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.34,
|
||||
// child: Text(
|
||||
// "TOTAL",
|
||||
// style: Constant.body3_500(context: context),
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// alignment: Alignment.centerRight,
|
||||
// padding: EdgeInsets.symmetric(
|
||||
// horizontal: Constant.getActualX(
|
||||
// context: context, x: 20),
|
||||
// vertical: Constant.getActualY(
|
||||
// context: context, y: 16)),
|
||||
// width: Constant.getActualX(
|
||||
// context: context, x: 1160) *
|
||||
// 0.13,
|
||||
// child: Text(
|
||||
// Constant.convertToIdr(
|
||||
// double.parse(
|
||||
// tempRegistrationData.total ?? "0"),
|
||||
// 0),
|
||||
// style: Constant.body3_500(context: context),
|
||||
// ),
|
||||
// )
|
||||
// ],
|
||||
// )
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user