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",
// "password": "3"
};
print(param);
// final service = "${Constant.baseUrlDevone}xauth/login";
final service = "${Constant.baseUrlDevone}auth/login";
print('url login $service');

View File

@@ -1,13 +1,31 @@
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/route.dart';
import '../../provider/current_user_provider.dart';
import '../../widget/custom_drawer.dart';
class ChangeCompanyScreen extends StatelessWidget {
class ChangeCompanyScreen extends HookConsumerWidget {
const ChangeCompanyScreen({super.key});
@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(
padding: EdgeInsets.only(
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(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith(
(states) => Colors.white),
// side: MaterialStateBorderSide.resolveWith(
// (states) => BorderSide(color: Colors.green),
// ),
Expanded(
child: ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith(
(states) => Colors.white),
// side: MaterialStateBorderSide.resolveWith(
// (states) => BorderSide(color: Colors.green),
// ),
// backgroundColor: MaterialStateColor.resolveWith(
// (st) => Constant.pcBtnBackgroundColor),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
color: Colors.green,
// backgroundColor: MaterialStateColor.resolveWith(
// (st) => Constant.pcBtnBackgroundColor),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
color: Colors.green,
),
),
),
shadowColor:
MaterialStateProperty.all(Color(0xffff48423d)),
elevation: MaterialStateProperty.all(4.0),
),
shadowColor:
MaterialStateProperty.all(Color(0xffff48423d)),
elevation: MaterialStateProperty.all(4.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: Constant.getActualXPhone(
context: context, x: 16),
height: Constant.getActualYPhone(
context: context, y: 16),
// decoration: BoxDecoration(color: Colors.grey),
child: Image.asset(
"images/logo_excel.png",
fit: BoxFit.fill,
// scale: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: Constant.getActualXPhone(
context: context, x: 16),
height: Constant.getActualYPhone(
context: context, y: 16),
// decoration: BoxDecoration(color: Colors.grey),
child: Image.asset(
"images/logo_excel.png",
fit: BoxFit.fill,
// scale: 1,
),
),
),
SizedBox(
height: Constant.getActualXPhone(
context: context, x: 8),
),
Text(
'Download Report (xls) ',
style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600,
color: Colors.green,
SizedBox(
width: Constant.getActualXPhone(
context: context, x: 6),
),
),
],
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
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
},
SizedBox(
width: Constant.getActualXPhone(context: context, x: 10),
),
// PDF
ElevatedButton(
style: ButtonStyle(
backgroundColor: MaterialStateColor.resolveWith(
(st) => Constant.pcBtnBackgroundColor),
shape:
MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
color: Constant.pcBtnBackgroundColor,
Expanded(
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),
),
shadowColor:
MaterialStateProperty.all(Color(0xffff48423d)),
elevation: MaterialStateProperty.all(4.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: Constant.getActualXPhone(
context: context, x: 16),
height: Constant.getActualYPhone(
context: context, y: 16),
// decoration: BoxDecoration(color: Colors.grey),
child: Image.asset(
"images/logo_pdf.png",
fit: BoxFit.fill,
// scale: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: Constant.getActualXPhone(
context: context, x: 16),
height: Constant.getActualYPhone(
context: context, y: 16),
// decoration: BoxDecoration(color: Colors.grey),
child: Image.asset(
"images/logo_pdf.png",
fit: BoxFit.fill,
// scale: 1,
),
),
),
SizedBox(
height: Constant.getActualXPhone(
context: context, x: 8),
),
Text(
'Download Report (PDF)',
style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600,
color: Constant.white),
),
],
SizedBox(
width: Constant.getActualXPhone(
context: context, x: 6),
),
Text(
'PDF',
style: Constant.body1(context: context).copyWith(
fontWeight: FontWeight.w600,
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_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import '../../app/constant.dart';
import '../../app/route.dart';
import '../../provider/current_user_provider.dart';
import '../../widget/custom_drawer.dart';
import '../../widget/field_row_history_transaksi.dart';
class HistoryTransaksiScreen extends HookConsumerWidget {
const HistoryTransaksiScreen({super.key});
@override
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(
padding: EdgeInsets.only(
top: Constant.getActualYPhone(context: context, y: 30),
@@ -28,33 +47,74 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
body: SafeArea(
child: SingleChildScrollView(
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(
height: MediaQuery.of(context).size.height - 10,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Card looping transaksi
Card(
margin: EdgeInsets.all(16.0),
child: Padding(
padding: const EdgeInsets.all(16.0),
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Tipe Catatan: DEBIT'),
FieldRowHistoryTransaksi(
label: "Tipe",
value: "DEBIT",
),
SizedBox(height: 8.0),
Text('Tanggal: 15-12-2023'),
FieldRowHistoryTransaksi(
label: "Tanggal",
value: "15-12-2023",
),
SizedBox(height: 8.0),
Text('Nominal: 100.000'),
FieldRowHistoryTransaksi(
label: "Nominal",
value: "100.000",
),
SizedBox(height: 8.0),
Text('Kategori: Jumat Sehat'),
FieldRowHistoryTransaksi(
label: "Kategori",
value: "Jumat Sehat",
),
SizedBox(height: 8.0),
Chip(
label: Text('Verify'),
backgroundColor: Constant.green_600,
labelStyle: TextStyle(color: Colors.white),
label: Text(
'Verify',
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(
mainAxisAlignment: MainAxisAlignment.end,
children: [
@@ -64,9 +124,7 @@ class HistoryTransaksiScreen extends HookConsumerWidget {
},
child: Text(
'Delete',
style: TextStyle(
color: Constant.textWhite
),
style: TextStyle(color: Constant.textWhite),
),
style: ElevatedButton.styleFrom(
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),
),
),
),
],
);
}
}