step 17 : extract widget field row history transaksi

This commit is contained in:
sindhu
2024-01-16 11:46:17 +07:00
parent 198f7ccd17
commit de84b76170
5 changed files with 289 additions and 159 deletions

View File

@@ -23,6 +23,8 @@ class AuthRepository extends BaseRepository {
// "doctor_id": "2891", // "doctor_id": "2891",
// "password": "3" // "password": "3"
}; };
print(param);
// final service = "${Constant.baseUrlDevone}xauth/login"; // final service = "${Constant.baseUrlDevone}xauth/login";
final service = "${Constant.baseUrlDevone}auth/login"; final service = "${Constant.baseUrlDevone}auth/login";
print('url login $service'); print('url login $service');

View File

@@ -1,13 +1,31 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../app/constant.dart'; import '../../app/constant.dart';
import '../../app/route.dart';
import '../../provider/current_user_provider.dart';
import '../../widget/custom_drawer.dart'; import '../../widget/custom_drawer.dart';
class ChangeCompanyScreen extends StatelessWidget { class ChangeCompanyScreen extends HookConsumerWidget {
const ChangeCompanyScreen({super.key}); const ChangeCompanyScreen({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context, WidgetRef ref) {
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
if (userID == "0") {
//not login
Navigator.of(context)
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
// Navigator.popAndPushNamed(context, loginRoute);
return;
}
});
return () {};
}, []);
return Padding( return Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 30), top: Constant.getActualYPhone(context: context, y: 30),
@@ -29,4 +47,4 @@ class ChangeCompanyScreen extends StatelessWidget {
), ),
); );
} }
} }

View File

@@ -276,165 +276,175 @@ class ReportScreen extends HookConsumerWidget {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
ElevatedButton( Expanded(
style: ButtonStyle( child: ElevatedButton(
backgroundColor: MaterialStateColor.resolveWith( style: ButtonStyle(
(states) => Colors.white), backgroundColor: MaterialStateColor.resolveWith(
// side: MaterialStateBorderSide.resolveWith( (states) => Colors.white),
// (states) => BorderSide(color: Colors.green), // side: MaterialStateBorderSide.resolveWith(
// ), // (states) => BorderSide(color: Colors.green),
// ),
// backgroundColor: MaterialStateColor.resolveWith( // backgroundColor: MaterialStateColor.resolveWith(
// (st) => Constant.pcBtnBackgroundColor), // (st) => Constant.pcBtnBackgroundColor),
shape: shape:
MaterialStateProperty.all<RoundedRectangleBorder>( MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder( RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
side: BorderSide( side: BorderSide(
color: Colors.green, color: Colors.green,
),
), ),
), ),
shadowColor:
MaterialStateProperty.all(Color(0xffff48423d)),
elevation: MaterialStateProperty.all(4.0),
), ),
shadowColor: child: Row(
MaterialStateProperty.all(Color(0xffff48423d)), mainAxisAlignment: MainAxisAlignment.center,
elevation: MaterialStateProperty.all(4.0), children: [
), Container(
child: Row( width: Constant.getActualXPhone(
mainAxisAlignment: MainAxisAlignment.center, context: context, x: 16),
children: [ height: Constant.getActualYPhone(
Container( context: context, y: 16),
width: Constant.getActualXPhone( // decoration: BoxDecoration(color: Colors.grey),
context: context, x: 16), child: Image.asset(
height: Constant.getActualYPhone( "images/logo_excel.png",
context: context, y: 16), fit: BoxFit.fill,
// decoration: BoxDecoration(color: Colors.grey), // scale: 1,
child: Image.asset( ),
"images/logo_excel.png",
fit: BoxFit.fill,
// scale: 1,
), ),
), SizedBox(
SizedBox( width: Constant.getActualXPhone(
height: Constant.getActualXPhone( context: context, x: 6),
context: context, x: 8),
),
Text(
'Download Report (xls) ',
style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600,
color: Colors.green,
), ),
), Text(
], 'Excel',
style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600,
color: Colors.green,
),
),
],
),
onPressed: () async {
M_CompanyID = await getCompanyID();
if (M_CompanyID == "0") {
SanckbarWidget(
context, 'Invalid Company', snackbarType.error);
return;
}
// Awal
DateTime parsedDateAwal =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
// 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=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
if (!await launchUrl(Uri.parse(url))) {
// throw Exception('Could not launch $url');
SanckbarWidget(context, 'Could not launch $url',
snackbarType.error);
}
// https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267
},
), ),
onPressed: () async { ),
M_CompanyID = await getCompanyID();
if(M_CompanyID == "0"){
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
return;
}
// Awal
DateTime parsedDateAwal =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
// Akhir SizedBox(
DateTime parsedDateAkhir = width: Constant.getActualXPhone(context: context, x: 10),
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAkhir =
DateFormat('yyyy-MM-dd').format(parsedDateAkhir);
String url =
"https://${Constant.baseUrlDevoneReport}/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=xls&PStartDate=$formattedDateAwal&PEndDate=$formattedDateAkhir&PCompanyID=$M_CompanyID&username=adminsas%20";
if (!await launchUrl(Uri.parse(url))) {
// throw Exception('Could not launch $url');
SanckbarWidget(context, 'Could not launch $url',
snackbarType.error);
}
// https://devone.aplikasi.web.id/birt/run?__report=report/one/pettycash/rpt_r_pt_001.rptdesign&__format=pdf&PStartDate=2023-11-01&PEndDate=2023-12-30&PCompanyID=0&username=adminsas%20&tm=1701327096267
},
), ),
// PDF // PDF
ElevatedButton( Expanded(
style: ButtonStyle( child: ElevatedButton(
backgroundColor: MaterialStateColor.resolveWith( style: ButtonStyle(
(st) => Constant.pcBtnBackgroundColor), backgroundColor: MaterialStateColor.resolveWith(
shape: (st) => Constant.pcBtnBackgroundColor),
MaterialStateProperty.all<RoundedRectangleBorder>( shape:
RoundedRectangleBorder( MaterialStateProperty.all<RoundedRectangleBorder>(
borderRadius: BorderRadius.circular(8), RoundedRectangleBorder(
side: BorderSide( borderRadius: BorderRadius.circular(8),
color: Constant.pcBtnBackgroundColor, side: BorderSide(
color: Constant.pcBtnBackgroundColor,
),
), ),
), ),
shadowColor:
MaterialStateProperty.all(Color(0xffff48423d)),
elevation: MaterialStateProperty.all(4.0),
), ),
shadowColor: child: Row(
MaterialStateProperty.all(Color(0xffff48423d)), mainAxisAlignment: MainAxisAlignment.center,
elevation: MaterialStateProperty.all(4.0), children: [
), Container(
child: Row( width: Constant.getActualXPhone(
mainAxisAlignment: MainAxisAlignment.center, context: context, x: 16),
children: [ height: Constant.getActualYPhone(
Container( context: context, y: 16),
width: Constant.getActualXPhone( // decoration: BoxDecoration(color: Colors.grey),
context: context, x: 16), child: Image.asset(
height: Constant.getActualYPhone( "images/logo_pdf.png",
context: context, y: 16), fit: BoxFit.fill,
// decoration: BoxDecoration(color: Colors.grey), // scale: 1,
child: Image.asset( ),
"images/logo_pdf.png",
fit: BoxFit.fill,
// scale: 1,
), ),
), SizedBox(
SizedBox( width: Constant.getActualXPhone(
height: Constant.getActualXPhone( context: context, x: 6),
context: context, x: 8), ),
), Text(
Text( 'PDF',
'Download Report (PDF)', style: Constant.body1(context: context).copyWith(
style: Constant.body1(context: context).copyWith( fontWeight: FontWeight.w600,
fontWeight: FontWeight.w600, color: Constant.white),
color: Constant.white), ),
), ],
], ),
onPressed: () async {
M_CompanyID = await getCompanyID();
if (M_CompanyID == "0") {
SanckbarWidget(
context, 'Invalid Company', snackbarType.error);
return;
}
// Awal
DateTime parsedDateAwal =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
// 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);
}
},
), ),
onPressed: () async {
M_CompanyID = await getCompanyID();
if(M_CompanyID == "0"){
SanckbarWidget(context, 'Invalid Company', snackbarType.error);
return;
}
// Awal
DateTime parsedDateAwal =
DateFormat('dd-MM-yyyy').parse(
ctrlTglAwal.value.text.toString(),
);
String formattedDateAwal =
DateFormat('yyyy-MM-dd').format(parsedDateAwal);
// 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

@@ -1,14 +1,33 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../app/constant.dart'; import '../../app/constant.dart';
import '../../app/route.dart';
import '../../provider/current_user_provider.dart';
import '../../widget/custom_drawer.dart'; import '../../widget/custom_drawer.dart';
import '../../widget/field_row_history_transaksi.dart';
class HistoryTransaksiScreen extends HookConsumerWidget { class HistoryTransaksiScreen extends HookConsumerWidget {
const HistoryTransaksiScreen({super.key}); const HistoryTransaksiScreen({super.key});
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
useEffect(() {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
final userID = ref.read(currentUserProvider)?.model.M_UserID ?? "0";
if (userID == "0") {
//not login
Navigator.of(context)
.pushNamedAndRemoveUntil(loginRoute, (route) => true);
// Navigator.popAndPushNamed(context, loginRoute);
return;
}
});
return () {};
}, []);
return Padding( return Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 30), top: Constant.getActualYPhone(context: context, y: 30),
@@ -28,33 +47,74 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
body: SafeArea( body: SafeArea(
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: EdgeInsets.all(20), padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 10),
left: Constant.getActualXPhone(context: context, x: 8),
right: Constant.getActualXPhone(context: context, x: 8),
),
child: Container( child: Container(
height: MediaQuery.of(context).size.height - 10, height: MediaQuery.of(context).size.height - 10,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Card looping transaksi
Card( Card(
margin: EdgeInsets.all(16.0), margin: EdgeInsets.all(16.0),
child: Padding( child: Padding(
padding: const EdgeInsets.all(16.0), padding: EdgeInsets.all(16.0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text('Tipe Catatan: DEBIT'), FieldRowHistoryTransaksi(
label: "Tipe",
value: "DEBIT",
),
SizedBox(height: 8.0), SizedBox(height: 8.0),
Text('Tanggal: 15-12-2023'), FieldRowHistoryTransaksi(
label: "Tanggal",
value: "15-12-2023",
),
SizedBox(height: 8.0), SizedBox(height: 8.0),
Text('Nominal: 100.000'), FieldRowHistoryTransaksi(
label: "Nominal",
value: "100.000",
),
SizedBox(height: 8.0), SizedBox(height: 8.0),
Text('Kategori: Jumat Sehat'), FieldRowHistoryTransaksi(
label: "Kategori",
value: "Jumat Sehat",
),
SizedBox(height: 8.0), SizedBox(height: 8.0),
Chip( Chip(
label: Text('Verify'), label: Text(
backgroundColor: Constant.green_600, 'Verify',
labelStyle: TextStyle(color: Colors.white), style: TextStyle(color: Constant.green_600),
),
shape: RoundedRectangleBorder(
side: BorderSide(
color: Constant.green_600,
),
borderRadius: BorderRadius.circular(4.0),
),
backgroundColor: Colors.white,
),
SizedBox(
height: Constant.getActualYPhone(
context: context, y: 6),
),
Chip(
label: Text(
'Not Verify',
style: TextStyle(color: Constant.textGreyv2),
),
shape: RoundedRectangleBorder(
side: BorderSide(
color: Constant.textGreyv2,
),
borderRadius: BorderRadius.circular(4.0),
),
backgroundColor: Colors.white,
), ),
SizedBox(height: 16.0),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@@ -64,9 +124,7 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
}, },
child: Text( child: Text(
'Delete', 'Delete',
style: TextStyle( style: TextStyle(color: Constant.textWhite),
color: Constant.textWhite
),
), ),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors backgroundColor: Colors

View File

@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../app/constant.dart';
class FieldRowHistoryTransaksi extends HookConsumerWidget {
final String label;
final String value;
const FieldRowHistoryTransaksi({
Key? key,
required this.label,
required this.value,
}) : super(key: key);
@override
Widget build(BuildContext context, WidgetRef ref) {
return Row(
children: [
Padding(
padding: EdgeInsets.only(left: 10),
child: SizedBox(
width: Constant.getActualXPhone(context: context, x: 100),
child: Text(label),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 10),
child: Text(':'),
),
Expanded(
child: Padding(
padding: EdgeInsets.only(right: 10),
child: Text(
value,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
),
],
);
}
}