step 16 : add M_CompanyID for trans, menu drawer, fix bug overflow btn

This commit is contained in:
sindhu
2024-01-16 10:38:44 +07:00
parent a317946fc2
commit 198f7ccd17
9 changed files with 1201 additions and 871 deletions

View File

@@ -1,7 +1,8 @@
import '../screen/change_company/change_company.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../screen/home/home_screen.dart'; import '../screen/home/home_screen.dart';
import '../screen/transaksi/history_transaksi_screen.dart';
import '../screen/transaksi/transaksi_screen.dart'; import '../screen/transaksi/transaksi_screen.dart';
import '../screen/login/login_screen.dart'; import '../screen/login/login_screen.dart';
import '../screen/splash/splash_screen.dart'; import '../screen/splash/splash_screen.dart';
@@ -16,6 +17,8 @@ const homeRoute = "/homeRoute";
const transaksiRoute = "/transaksiRoute"; const transaksiRoute = "/transaksiRoute";
const userRoute = "/userRoute"; const userRoute = "/userRoute";
const reportRoute = "/reportRoute"; const reportRoute = "/reportRoute";
const changeCompanyRoute = "/changeCompanyRoute";
const historyTransaksiRoute = "/historyTransaksiRoute";
// test screen // test screen
const testFilePickerRoute = "/testFilePickerRoute"; const testFilePickerRoute = "/testFilePickerRoute";
@@ -35,6 +38,32 @@ class AppRoute {
}); });
} }
// change Company
if (settings.name == changeCompanyRoute) {
return MaterialPageRoute(builder: (context) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: 1.0,
padding: EdgeInsets.all(0),
),
child: ChangeCompanyScreen(),
);
});
}
// history transaksi
if (settings.name == historyTransaksiRoute) {
return MaterialPageRoute(builder: (context) {
return MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: 1.0,
padding: EdgeInsets.all(0),
),
child: HistoryTransaksiScreen(),
);
});
}
// report screen // report screen
if (settings.name == reportRoute) { if (settings.name == reportRoute) {
return MaterialPageRoute(builder: (context) { return MaterialPageRoute(builder: (context) {

View File

@@ -1,3 +1,7 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import '../app/constant.dart'; import '../app/constant.dart';
import '../model/auth_model.dart'; import '../model/auth_model.dart';
import 'base_repository.dart'; import 'base_repository.dart';

View File

@@ -2,11 +2,33 @@ import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../app/constant.dart';
abstract class BaseRepository { abstract class BaseRepository {
final Dio dio; final Dio dio;
BaseRepository({required this.dio}); BaseRepository({required this.dio});
Future<String> getCompanyID() async {
final shared = await SharedPreferences.getInstance();
String M_CompanyID = "0";
if (shared != null) {
final bearerString = shared.get(Constant.bearerName).toString();
final xmodel = jsonDecode(bearerString);
if (xmodel != null) {
M_CompanyID = xmodel["model"]["M_CompanyID"];
}
}
if (M_CompanyID == "0") {
throw BaseRepositoryException(message: 'Invalid Company ID');
}
return M_CompanyID;
}
Future<Map<String, dynamic>> post({ Future<Map<String, dynamic>> post({
required Map<String, dynamic> param, required Map<String, dynamic> param,
required String service, required String service,

View File

@@ -58,6 +58,7 @@ class TransaksiRepository extends BaseRepository {
String sender, String sender,
String url) async { String url) async {
String paramPostInUrl = ""; String paramPostInUrl = "";
String M_CompanyID = await getCompanyID();
if (tipe == "DEBIT") { if (tipe == "DEBIT") {
sender = ""; sender = "";
paramPostInUrl = paramPostInUrl =
@@ -69,6 +70,8 @@ class TransaksiRepository extends BaseRepository {
"?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender"; "?tanggal=$tanggal&tipe=$tipe&kategoriid=$kategoriid&jumlah=$jumlah&catatan=$catatan&url=$url&userid=$userid&sender=$sender";
} }
} }
paramPostInUrl += "&companyid=$M_CompanyID";
// /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender= // /?tanggal=2023-12-29&tipe=KREDIT&kategoriid=3&jumlah=5000&catatan=Lakban%20Besar&url=&userid=1&sender=
final service = final service =

View File

@@ -25,6 +25,7 @@ class ChangeCompanyScreen extends StatelessWidget {
), ),
), ),
drawer: CustomDrawer(), drawer: CustomDrawer(),
body: Text('Under Construction'),
), ),
); );
} }

View File

@@ -1,3 +1,7 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import '../../widget/sankbar_widget.dart'; import '../../widget/sankbar_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
@@ -25,6 +29,26 @@ class ReportScreen extends HookConsumerWidget {
final tglAkhir = useState<DateTime>(DateTime.now()); final tglAkhir = useState<DateTime>(DateTime.now());
final tglAkhirTmp = useState<String>(""); final tglAkhirTmp = useState<String>("");
String M_CompanyID = "0";
Future<String> getCompanyID() async {
final shared = await SharedPreferences.getInstance();
String M_CompanyID = "0";
if (shared != null) {
final bearerString = shared.get(Constant.bearerName).toString();
final xmodel = jsonDecode(bearerString);
if (xmodel != null) {
M_CompanyID = xmodel["model"]["M_CompanyID"];
}
}
if (M_CompanyID == "0") {
// throw BaseRepositoryException(message: 'Invalid Company ID');
}
return M_CompanyID;
}
useEffect(() { useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
@@ -58,7 +82,6 @@ class ReportScreen extends HookConsumerWidget {
), ),
drawer: CustomDrawer(), drawer: CustomDrawer(),
body: SafeArea( body: SafeArea(
child: SingleChildScrollView(
child: Padding( child: Padding(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Column( child: Column(
@@ -125,8 +148,7 @@ class ReportScreen extends HookConsumerWidget {
// locale: const Locale("en-CA"), // locale: const Locale("en-CA"),
// locale: , // locale: ,
context: context, context: context,
initialEntryMode: initialEntryMode: DatePickerEntryMode.calendarOnly,
DatePickerEntryMode.calendarOnly,
firstDate: DateTime(2000), firstDate: DateTime(2000),
lastDate: DateTime(2100), lastDate: DateTime(2100),
@@ -220,8 +242,7 @@ class ReportScreen extends HookConsumerWidget {
// locale: const Locale("en-CA"), // locale: const Locale("en-CA"),
// locale: , // locale: ,
context: context, context: context,
initialEntryMode: initialEntryMode: DatePickerEntryMode.calendarOnly,
DatePickerEntryMode.calendarOnly,
firstDate: DateTime(2000), firstDate: DateTime(2000),
lastDate: DateTime(2100), lastDate: DateTime(2100),
@@ -249,27 +270,13 @@ class ReportScreen extends HookConsumerWidget {
), ),
], ],
), ),
],
), Spacer(),
),
), Row(
), mainAxisAlignment: MainAxisAlignment.spaceBetween,
bottomNavigationBar: Container(
// height: 150,
child: Padding(
padding: EdgeInsets.only(
// right: Constant.getActualXPhone(context: context, x: 27),
// left: Constant.getActualXPhone(context: context, x: 27),
// bottom: Constant.getActualYPhone(context: context, y: 32),
top: Constant.getActualYPhone(context: context, y: 24),
),
child: Column(
children: [ children: [
// Excel ElevatedButton(
Container(
width: Constant.getActualXPhone(context: context, x: 336),
height: Constant.getActualYPhone(context: context, y: 42),
child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith( backgroundColor: MaterialStateColor.resolveWith(
(states) => Colors.white), (states) => Colors.white),
@@ -279,7 +286,8 @@ class ReportScreen extends HookConsumerWidget {
// backgroundColor: MaterialStateColor.resolveWith( // backgroundColor: MaterialStateColor.resolveWith(
// (st) => Constant.pcBtnBackgroundColor), // (st) => Constant.pcBtnBackgroundColor),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
side: BorderSide( side: BorderSide(
@@ -295,10 +303,10 @@ class ReportScreen extends HookConsumerWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Container(
width: width: Constant.getActualXPhone(
Constant.getActualXPhone(context: context, x: 16), context: context, x: 16),
height: height: Constant.getActualYPhone(
Constant.getActualYPhone(context: context, y: 16), context: context, y: 16),
// decoration: BoxDecoration(color: Colors.grey), // decoration: BoxDecoration(color: Colors.grey),
child: Image.asset( child: Image.asset(
"images/logo_excel.png", "images/logo_excel.png",
@@ -307,8 +315,8 @@ class ReportScreen extends HookConsumerWidget {
), ),
), ),
SizedBox( SizedBox(
height: height: Constant.getActualXPhone(
Constant.getActualXPhone(context: context, x: 8), context: context, x: 8),
), ),
Text( Text(
'Download Report (xls) ', 'Download Report (xls) ',
@@ -320,22 +328,29 @@ class ReportScreen extends HookConsumerWidget {
], ],
), ),
onPressed: () async { onPressed: () async {
M_CompanyID = await getCompanyID();
if(M_CompanyID == "0"){
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
return;
}
// Awal // Awal
DateTime parsedDateAwal = DateFormat('dd-MM-yyyy').parse( DateTime parsedDateAwal =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(), ctrlTglAwal.value.text.toString(),
); );
String formattedDateAwal = String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDateAwal); DateFormat('yyyy-MM-dd').format(parsedDateAwal);
// Akhir // Akhir
DateTime parsedDateAkhir = DateFormat('dd-MM-yyyy').parse( DateTime parsedDateAkhir =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(), ctrlTglAwal.value.text.toString(),
); );
String formattedDateAkhir = String formattedDateAkhir =
DateFormat('yyyy-MM-dd').format(parsedDateAkhir); DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
String url = String url =
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=0&username=adminsas%20"; "https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
if (!await launchUrl(Uri.parse(url))) { if (!await launchUrl(Uri.parse(url))) {
// throw Exception('Could not launch $url'); // throw Exception('Could not launch $url');
SanckbarWidget(context, 'Could not launch $url', SanckbarWidget(context, 'Could not launch $url',
@@ -344,21 +359,14 @@ class ReportScreen extends HookConsumerWidget {
// https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267 // https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267
}, },
), ),
),
SizedBox(
height: Constant.getActualYPhone(context: context, y: 20),
),
// PDF // PDF
Container( ElevatedButton(
width: Constant.getActualXPhone(context: context, x: 336),
height: Constant.getActualYPhone(context: context, y: 42),
child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith( backgroundColor: MaterialStateColor.resolveWith(
(st) => Constant.pcBtnBackgroundColor), (st) => Constant.pcBtnBackgroundColor),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
side: BorderSide( side: BorderSide(
@@ -374,10 +382,10 @@ class ReportScreen extends HookConsumerWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Container( Container(
width: width: Constant.getActualXPhone(
Constant.getActualXPhone(context: context, x: 16), context: context, x: 16),
height: height: Constant.getActualYPhone(
Constant.getActualYPhone(context: context, y: 16), context: context, y: 16),
// decoration: BoxDecoration(color: Colors.grey), // decoration: BoxDecoration(color: Colors.grey),
child: Image.asset( child: Image.asset(
"images/logo_pdf.png", "images/logo_pdf.png",
@@ -386,8 +394,8 @@ class ReportScreen extends HookConsumerWidget {
), ),
), ),
SizedBox( SizedBox(
height: height: Constant.getActualXPhone(
Constant.getActualXPhone(context: context, x: 8), context: context, x: 8),
), ),
Text( Text(
'Download Report (PDF)', 'Download Report (PDF)',
@@ -398,15 +406,37 @@ class ReportScreen extends HookConsumerWidget {
], ],
), ),
onPressed: () async { onPressed: () async {
// String url = M_CompanyID = await getCompanyID();
// "https://pub.dev/packages?q=url+launcher"; if(M_CompanyID == "0"){
// if (!await launchUrl(Uri.parse(url))) { SanckbarWidget(context, 'Invalid Company', snackbarType.error);
// // throw Exception('Could not launch $url'); return;
// SanckbarWidget(context, 'Could not launch $url', }
// snackbarType.error); // Awal
// } DateTime parsedDateAwal =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
// Akhir
DateTime parsedDateAkhir =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAkhir =
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
String url =
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
if (!await launchUrl(Uri.parse(url))) {
// throw Exception('Could not launch $url');
SanckbarWidget(context, 'Could not launch $url',
snackbarType.error);
}
}, },
), ),
],
), ),
], ],
), ),

View File

@@ -0,0 +1,91 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../app/constant.dart';
import '../../widget/custom_drawer.dart';
class HistoryTransaksiScreen extends HookConsumerWidget {
const HistoryTransaksiScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Padding(
padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 30),
),
child: Scaffold(
appBar: AppBar(
title: Text(
'History Transaksi',
style: TextStyle(color: Constant.textWhite),
),
backgroundColor: Constant.pcBtnBackgroundColor,
iconTheme: IconThemeData(
color: Constant.textWhite,
),
),
drawer: CustomDrawer(),
body: SafeArea(
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(20),
child: Container(
height: MediaQuery.of(context).size.height - 10,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Card(
margin: EdgeInsets.all(16.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Tipe Catatan: DEBIT'),
SizedBox(height: 8.0),
Text('Tanggal: 15-12-2023'),
SizedBox(height: 8.0),
Text('Nominal: 100.000'),
SizedBox(height: 8.0),
Text('Kategori: Jumat Sehat'),
SizedBox(height: 8.0),
Chip(
label: Text('Verify'),
backgroundColor: Constant.green_600,
labelStyle: TextStyle(color: Colors.white),
),
SizedBox(height: 16.0),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ElevatedButton(
onPressed: () {
// Handle delete button tap
},
child: Text(
'Delete',
style: TextStyle(
color: Constant.textWhite
),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors
.red, // Ganti dengan warna delete button yang diinginkan
),
),
],
),
],
),
),
),
],
),
),
),
),
),
),
);
}
}

View File

@@ -156,6 +156,9 @@ class TransaksiScreen extends HookConsumerWidget {
// Navigator.popAndPushNamed(context, loginRoute); // Navigator.popAndPushNamed(context, loginRoute);
return; return;
} }
ctrlCompanyName.text =
ref.read(currentUserProvider)?.model.M_CompanyName ?? "";
}); });
return () {}; return () {};
}, []); }, []);
@@ -200,6 +203,8 @@ class TransaksiScreen extends HookConsumerWidget {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Container(
height: MediaQuery.of(context).size.height - 10,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@@ -207,7 +212,8 @@ class TransaksiScreen extends HookConsumerWidget {
Text( Text(
'Company Name', 'Company Name',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600, color: Constant.textBlack), fontWeight: FontWeight.w600,
color: Constant.textBlack),
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 10), height: Constant.getActualYPhone(context: context, y: 10),
@@ -246,7 +252,8 @@ class TransaksiScreen extends HookConsumerWidget {
Text( Text(
'Tanggal Transaksi', 'Tanggal Transaksi',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600, color: Constant.textBlack), fontWeight: FontWeight.w600,
color: Constant.textBlack),
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 10), height: Constant.getActualYPhone(context: context, y: 10),
@@ -342,7 +349,8 @@ class TransaksiScreen extends HookConsumerWidget {
Text( Text(
'Tipe Transaksi', 'Tipe Transaksi',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600, color: Constant.textBlack), fontWeight: FontWeight.w600,
color: Constant.textBlack),
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 10), height: Constant.getActualYPhone(context: context, y: 10),
@@ -389,7 +397,8 @@ class TransaksiScreen extends HookConsumerWidget {
}, },
), ),
Text( Text(
listTypeData.value[i].typename ?? "", listTypeData.value[i].typename ??
"",
style: style:
Constant.body1(context: context) Constant.body1(context: context)
.copyWith( .copyWith(
@@ -409,7 +418,7 @@ class TransaksiScreen extends HookConsumerWidget {
), ),
// Kategori // Kategori
if (selectedListTypeData.value.typeid == "KREDIT") ...[ if (selectedListTypeData.value.typeid == "DEBIT") ...[
Text( Text(
'Kategori', 'Kategori',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context).copyWith(
@@ -418,7 +427,8 @@ class TransaksiScreen extends HookConsumerWidget {
), ),
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 10), height:
Constant.getActualYPhone(context: context, y: 10),
), ),
// Dropdown kategori // Dropdown kategori
(listCategoryLoading.value) (listCategoryLoading.value)
@@ -442,7 +452,8 @@ class TransaksiScreen extends HookConsumerWidget {
Expanded( Expanded(
child: Text( child: Text(
'Select Item', 'Select Item',
style: Constant.body1(context: context) style: Constant.body1(
context: context)
.copyWith( .copyWith(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Constant.textBlack), color: Constant.textBlack),
@@ -468,7 +479,8 @@ class TransaksiScreen extends HookConsumerWidget {
onChanged: (ListCategory? newValue) { onChanged: (ListCategory? newValue) {
// if (newValue) { // if (newValue) {
selectedListCategory.value = newValue!; selectedListCategory.value = newValue!;
print(selectedListCategory.value.categoryid); print(
selectedListCategory.value.categoryid);
// } // }
}, },
buttonStyleData: ButtonStyleData( buttonStyleData: ButtonStyleData(
@@ -551,12 +563,13 @@ class TransaksiScreen extends HookConsumerWidget {
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 20), height:
Constant.getActualYPhone(context: context, y: 20),
), ),
], ],
// Nama Pengirim // Nama Pengirim
if (selectedListTypeData.value.typeid == "DEBIT") ...[ if (selectedListTypeData.value.typeid == "KREDIT") ...[
Text( Text(
'Nama Pengirim', 'Nama Pengirim',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context).copyWith(
@@ -564,7 +577,8 @@ class TransaksiScreen extends HookConsumerWidget {
color: Constant.textBlack), color: Constant.textBlack),
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 10), height:
Constant.getActualYPhone(context: context, y: 10),
), ),
TextField( TextField(
controller: ctrlNamaPengirim, controller: ctrlNamaPengirim,
@@ -602,7 +616,8 @@ class TransaksiScreen extends HookConsumerWidget {
Text( Text(
'Jumlah', 'Jumlah',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600, color: Constant.textBlack), fontWeight: FontWeight.w600,
color: Constant.textBlack),
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 20), height: Constant.getActualYPhone(context: context, y: 20),
@@ -611,10 +626,12 @@ class TransaksiScreen extends HookConsumerWidget {
controller: ctrlJumlah, controller: ctrlJumlah,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
hintStyle: Constant.body2_400(context: context).copyWith( hintStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2, color: Constant.textGreyv2,
), ),
labelStyle: Constant.body2_400(context: context).copyWith( labelStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2, color: Constant.textGreyv2,
), ),
border: OutlineInputBorder( border: OutlineInputBorder(
@@ -642,7 +659,8 @@ class TransaksiScreen extends HookConsumerWidget {
Text( Text(
'Catatan', 'Catatan',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600, color: Constant.textBlack), fontWeight: FontWeight.w600,
color: Constant.textBlack),
), ),
SizedBox( SizedBox(
height: Constant.getActualYPhone(context: context, y: 20), height: Constant.getActualYPhone(context: context, y: 20),
@@ -652,10 +670,12 @@ class TransaksiScreen extends HookConsumerWidget {
controller: ctrlCatatan, controller: ctrlCatatan,
maxLines: 4, maxLines: 4,
decoration: InputDecoration( decoration: InputDecoration(
hintStyle: Constant.body2_400(context: context).copyWith( hintStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2, color: Constant.textGreyv2,
), ),
labelStyle: Constant.body2_400(context: context).copyWith( labelStyle:
Constant.body2_400(context: context).copyWith(
color: Constant.textGreyv2, color: Constant.textGreyv2,
), ),
border: OutlineInputBorder( border: OutlineInputBorder(
@@ -701,28 +721,17 @@ class TransaksiScreen extends HookConsumerWidget {
], ],
), ),
), ),
],
), Spacer(),
),
), Container(
), width: Constant.getActualXPhone(context: context, x: 390),
bottomNavigationBar: Padding(
padding: EdgeInsets.only(
right: Constant.getActualXPhone(context: context, x: 27),
left: Constant.getActualXPhone(context: context, x: 27),
bottom: Constant.getActualYPhone(context: context, y: 32),
top: Constant.getActualYPhone(context: context, y: 10),
),
child: BottomAppBar(
elevation: 2.0,
child: Container(
width: Constant.getActualXPhone(context: context, x: 336),
height: Constant.getActualYPhone(context: context, y: 42),
child: ElevatedButton( child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith( backgroundColor: MaterialStateColor.resolveWith(
(st) => Constant.pcBtnBackgroundColor), (st) => Constant.pcBtnBackgroundColor),
shape: MaterialStateProperty.all<RoundedRectangleBorder>( shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
side: BorderSide( side: BorderSide(
@@ -730,7 +739,8 @@ class TransaksiScreen extends HookConsumerWidget {
), ),
), ),
), ),
shadowColor: MaterialStateProperty.all(Color(0xffff48423d)), shadowColor:
MaterialStateProperty.all(Color(0xffff48423d)),
elevation: MaterialStateProperty.all(4.0), elevation: MaterialStateProperty.all(4.0),
), ),
child: Stack( child: Stack(
@@ -747,7 +757,8 @@ class TransaksiScreen extends HookConsumerWidget {
) )
: Text( : Text(
'Simpan', 'Simpan',
style: Constant.body1(context: context).copyWith( style: Constant.body1(context: context)
.copyWith(
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Constant.white), color: Constant.white),
), ),
@@ -773,18 +784,22 @@ class TransaksiScreen extends HookConsumerWidget {
DateFormat('yyyy-MM-dd').format(parsedDate); DateFormat('yyyy-MM-dd').format(parsedDate);
var param = { var param = {
"tgltransaksi": formattedDateTransaksi, "tgltransaksi": formattedDateTransaksi,
"typeid": selectedListTypeData.value.typeid.toString(), "typeid":
selectedListTypeData.value.typeid.toString(),
"categoryid": "categoryid":
selectedListCategory.value.categoryid.toString(), selectedListCategory.value.categoryid.toString(),
"jumlah": ctrlJumlah.value.text.toString(), "jumlah": ctrlJumlah.value.text.toString(),
"catatan": ctrlCatatan.value.text.toString(), "catatan": ctrlCatatan.value.text.toString(),
// "userid": "1", // "userid": "1",
"userid": userIDLogin, "userid": userIDLogin,
"namapengirim": ctrlNamaPengirim.value.text.toString(), "namapengirim":
ctrlNamaPengirim.value.text.toString(),
"url": "", "url": "",
}; };
print(param); print(param);
ref.read(insertTransaksiProvider.notifier).insertTransaksi( ref
.read(insertTransaksiProvider.notifier)
.insertTransaksi(
formattedDateTransaksi, formattedDateTransaksi,
selectedListTypeData.value.typeid.toString(), selectedListTypeData.value.typeid.toString(),
selectedListCategory.value.categoryid.toString(), selectedListCategory.value.categoryid.toString(),
@@ -798,9 +813,106 @@ class TransaksiScreen extends HookConsumerWidget {
}, },
), ),
), ),
],
), ),
), ),
), ),
),
),
// bottomNavigationBar: Padding(
// padding: EdgeInsets.only(
// right: Constant.getActualXPhone(context: context, x: 27),
// left: Constant.getActualXPhone(context: context, x: 27),
// bottom: Constant.getActualYPhone(context: context, y: 32),
// top: Constant.getActualYPhone(context: context, y: 10),
// ),
// child: BottomAppBar(
// elevation: 2.0,
// child: Container(
// width: Constant.getActualXPhone(context: context, x: 336),
// height: Constant.getActualYPhone(context: context, y: 42),
// child: ElevatedButton(
// style: ButtonStyle(
// backgroundColor: MaterialStateColor.resolveWith(
// (st) => Constant.pcBtnBackgroundColor),
// shape: MaterialStateProperty.all<RoundedRectangleBorder>(
// RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(8),
// side: BorderSide(
// color: Constant.pcBtnBackgroundColor,
// ),
// ),
// ),
// shadowColor: MaterialStateProperty.all(Color(0xffff48423d)),
// elevation: MaterialStateProperty.all(4.0),
// ),
// child: Stack(
// children: [
// (transaksiIsLoading.value)
// ? SizedBox(
// width: Constant.getActualXPhone(
// context: context, x: 24),
// height: Constant.getActualYPhone(
// context: context, y: 32),
// child: CircularProgressIndicator(
// color: Colors.white,
// ),
// )
// : Text(
// 'Simpan',
// style: Constant.body1(context: context).copyWith(
// fontWeight: FontWeight.w600,
// color: Constant.white),
// ),
// ],
// ),
// onPressed: () {
// if (selectedListTypeData.value.typeid.toString() == "DEBIT") {
// ctrlNamaPengirim.text = "";
// // validasi form
// } else {
// if (selectedListTypeData.value.typeid.toString() ==
// "KREDIT") {
// selectedListCategory.value.categoryid = "0";
// // validasi form
// }
// }
// DateTime parsedDate = DateFormat('dd-MM-yyyy').parse(
// ctrlTglAwal.value.text.toString(),
// );
// String formattedDateTransaksi =
// DateFormat('yyyy-MM-dd').format(parsedDate);
// var param = {
// "tgltransaksi": formattedDateTransaksi,
// "typeid": selectedListTypeData.value.typeid.toString(),
// "categoryid":
// selectedListCategory.value.categoryid.toString(),
// "jumlah": ctrlJumlah.value.text.toString(),
// "catatan": ctrlCatatan.value.text.toString(),
// // "userid": "1",
// "userid": userIDLogin,
// "namapengirim": ctrlNamaPengirim.value.text.toString(),
// "url": "",
// };
// print(param);
// ref.read(insertTransaksiProvider.notifier).insertTransaksi(
// formattedDateTransaksi,
// selectedListTypeData.value.typeid.toString(),
// selectedListCategory.value.categoryid.toString(),
// ctrlJumlah.value.text.toString(),
// ctrlCatatan.value.text.toString(),
// // "1",
// userIDLogin,
// ctrlNamaPengirim.value.text.toString(),
// "",
// );
// },
// ),
// ),
// ),
// ),
),
); );
} }
} }

View File

@@ -70,22 +70,22 @@ class CustomDrawer extends HookConsumerWidget {
return Drawer( return Drawer(
child: ListView( child: ListView(
padding: EdgeInsets.only( // padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 10), // top: Constant.getActualYPhone(context: context, y: 10),
), // ),
children: [ children: [
// DrawerHeader( DrawerHeader(
// decoration: BoxDecoration( decoration: BoxDecoration(
// color: Colors.blue, color: Colors.blue,
// ), ),
// child: Text( child: Text(
// 'Drawer Header', 'Drawer Header',
// style: TextStyle( style: TextStyle(
// color: Colors.white, color: Colors.white,
// fontSize: 24, fontSize: 24,
// ), ),
// ), ),
// ), ),
ListTile( ListTile(
title: Text( title: Text(
'Home', 'Home',
@@ -126,7 +126,7 @@ class CustomDrawer extends HookConsumerWidget {
), ),
ListTile( ListTile(
title: Text( title: Text(
'Report', 'History Transaksi',
style: TextStyle( style: TextStyle(
color: (currentMenu == 2) color: (currentMenu == 2)
? Constant.textWhite ? Constant.textWhite
@@ -137,15 +137,15 @@ class CustomDrawer extends HookConsumerWidget {
? Constant.pcBtnBackgroundColor ? Constant.pcBtnBackgroundColor
: Colors.transparent, : Colors.transparent,
onTap: () { onTap: () {
// Handle navigation to Transaksi screen // Handle navigation to User screen
Navigator.pop(context); Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 2); ref.read(currentPageProvider.state).update((state) => 2);
Navigator.pushNamed(context, reportRoute); Navigator.pushNamed(context, historyTransaksiRoute);
}, },
), ),
ListTile( ListTile(
title: Text( title: Text(
'User', 'Report',
style: TextStyle( style: TextStyle(
color: (currentMenu == 3) color: (currentMenu == 3)
? Constant.textWhite ? Constant.textWhite
@@ -156,12 +156,50 @@ class CustomDrawer extends HookConsumerWidget {
? Constant.pcBtnBackgroundColor ? Constant.pcBtnBackgroundColor
: Colors.transparent, : Colors.transparent,
onTap: () { onTap: () {
// Handle navigation to User screen // Handle navigation to Transaksi screen
Navigator.pop(context); Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 3); ref.read(currentPageProvider.state).update((state) => 3);
Navigator.pushNamed(context, reportRoute);
},
),
ListTile(
title: Text(
'User',
style: TextStyle(
color: (currentMenu == 4)
? Constant.textWhite
: Constant.textBlack,
),
),
tileColor: (currentMenu == 4)
? Constant.pcBtnBackgroundColor
: Colors.transparent,
onTap: () {
// Handle navigation to User screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 4);
Navigator.pushNamed(context, userRoute); Navigator.pushNamed(context, userRoute);
}, },
), ),
ListTile(
title: Text(
'Change Company',
style: TextStyle(
color: (currentMenu == 5)
? Constant.textWhite
: Constant.textBlack,
),
),
tileColor: (currentMenu == 5)
? Constant.pcBtnBackgroundColor
: Colors.transparent,
onTap: () {
// Handle navigation to User screen
Navigator.pop(context);
ref.read(currentPageProvider.state).update((state) => 5);
Navigator.pushNamed(context, changeCompanyRoute);
},
),
ListTile( ListTile(
title: Text( title: Text(
'Logout', 'Logout',