dev #1
@ -12,6 +12,7 @@ class CustomModalDialog extends StatelessWidget {
|
||||
final double? maxWidth;
|
||||
final double? minHeight;
|
||||
final double? maxHeight;
|
||||
final EdgeInsets? contentPadding;
|
||||
|
||||
const CustomModalDialog({
|
||||
super.key,
|
||||
@ -23,6 +24,7 @@ class CustomModalDialog extends StatelessWidget {
|
||||
this.maxWidth,
|
||||
this.minHeight,
|
||||
this.maxHeight,
|
||||
this.contentPadding,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -100,7 +102,10 @@ class CustomModalDialog extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
child,
|
||||
Padding(
|
||||
padding: contentPadding ?? EdgeInsets.zero,
|
||||
child: child,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import 'package:enaklo_pos/core/components/custom_modal_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||||
|
||||
@ -28,7 +29,8 @@ class _FormTaxDialogState extends State<FormTaxDialog> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
serviceFeeController = TextEditingController(text: widget.serviceChargeValue.toString());
|
||||
serviceFeeController =
|
||||
TextEditingController(text: widget.serviceChargeValue.toString());
|
||||
taxFeeController = TextEditingController(text: widget.taxValue.toString());
|
||||
}
|
||||
|
||||
@ -41,19 +43,10 @@ class _FormTaxDialogState extends State<FormTaxDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () => context.pop(),
|
||||
icon: const Icon(Icons.close),
|
||||
),
|
||||
const Text('Edit Perhitungan Biaya'),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
return CustomModalDialog(
|
||||
title: 'Edit Perhitungan Biaya',
|
||||
contentPadding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: context.deviceWidth / 3,
|
||||
child: Column(
|
||||
@ -78,7 +71,8 @@ class _FormTaxDialogState extends State<FormTaxDialog> {
|
||||
Button.filled(
|
||||
onPressed: () {
|
||||
final taxValue = int.tryParse(taxFeeController.text) ?? 0;
|
||||
final serviceChargeValue = int.tryParse(serviceFeeController.text) ?? 0;
|
||||
final serviceChargeValue =
|
||||
int.tryParse(serviceFeeController.text) ?? 0;
|
||||
|
||||
if (widget.onSave != null) {
|
||||
widget.onSave!(taxValue, serviceChargeValue);
|
||||
|
||||
@ -31,11 +31,11 @@ class _TaxPageState extends State<TaxPage> {
|
||||
serviceChargeValue: serviceChargeValue,
|
||||
onSave: (newTaxValue, newServiceChargeValue) {
|
||||
context.read<TaxSettingsBloc>().add(
|
||||
TaxSettingsEvent.updateSettings(
|
||||
taxValue: newTaxValue,
|
||||
serviceChargeValue: newServiceChargeValue,
|
||||
),
|
||||
);
|
||||
TaxSettingsEvent.updateSettings(
|
||||
taxValue: newTaxValue,
|
||||
serviceChargeValue: newServiceChargeValue,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
@ -49,11 +49,11 @@ class _TaxPageState extends State<TaxPage> {
|
||||
serviceChargeValue: serviceChargeValue,
|
||||
onSave: (newTaxValue, newServiceChargeValue) {
|
||||
context.read<TaxSettingsBloc>().add(
|
||||
TaxSettingsEvent.updateSettings(
|
||||
taxValue: newTaxValue,
|
||||
serviceChargeValue: newServiceChargeValue,
|
||||
),
|
||||
);
|
||||
TaxSettingsEvent.updateSettings(
|
||||
taxValue: newTaxValue,
|
||||
serviceChargeValue: newServiceChargeValue,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
@ -61,91 +61,110 @@ class _TaxPageState extends State<TaxPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SettingsTitle('Perhitungan Biaya'),
|
||||
const SizedBox(height: 24),
|
||||
BlocBuilder<TaxSettingsBloc, TaxSettingsState>(
|
||||
builder: (context, state) {
|
||||
return state.when(
|
||||
initial: () => const Center(child: CircularProgressIndicator()),
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (message) => Center(child: Text('Error: $message')),
|
||||
loaded: (taxModel, serviceChargeValue) {
|
||||
final items = [
|
||||
TaxModel(name: 'Biaya Layanan', type: TaxType.layanan, value: serviceChargeValue),
|
||||
taxModel,
|
||||
];
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SettingsTitle(
|
||||
'Perhitungan Biaya',
|
||||
subtitle: 'Biaya Layanan dan Pajak',
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: BlocBuilder<TaxSettingsBloc, TaxSettingsState>(
|
||||
builder: (context, state) {
|
||||
return state.when(
|
||||
initial: () =>
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
loading: () =>
|
||||
const Center(child: CircularProgressIndicator()),
|
||||
error: (message) => Center(child: Text('Error: $message')),
|
||||
loaded: (taxModel, serviceChargeValue) {
|
||||
final items = [
|
||||
TaxModel(
|
||||
name: 'Biaya Layanan',
|
||||
type: TaxType.layanan,
|
||||
value: serviceChargeValue),
|
||||
taxModel,
|
||||
];
|
||||
|
||||
return CustomTabBar(
|
||||
tabTitles: const ['Layanan', 'Pajak'],
|
||||
initialTabIndex: 0,
|
||||
tabViews: [
|
||||
// LAYANAN TAB
|
||||
SizedBox(
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: 2, // Add button + 1 service charge item
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
childAspectRatio: 0.85,
|
||||
crossAxisCount: 3,
|
||||
crossAxisSpacing: 30.0,
|
||||
mainAxisSpacing: 30.0,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return AddData(
|
||||
title: 'Edit Perhitungan',
|
||||
onPressed: () => onAddDataTap(serviceChargeValue, taxModel.value),
|
||||
return CustomTabBar(
|
||||
tabTitles: const ['Layanan', 'Pajak'],
|
||||
initialTabIndex: 0,
|
||||
tabViews: [
|
||||
// LAYANAN TAB
|
||||
SizedBox(
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: 2, // Add button + 1 service charge item
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
childAspectRatio: 0.85,
|
||||
crossAxisCount: 3,
|
||||
crossAxisSpacing: 30.0,
|
||||
mainAxisSpacing: 30.0,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return AddData(
|
||||
title: 'Edit Perhitungan',
|
||||
onPressed: () => onAddDataTap(
|
||||
serviceChargeValue, taxModel.value),
|
||||
);
|
||||
}
|
||||
final item = items.firstWhere(
|
||||
(element) => element.type.isLayanan);
|
||||
return ManageTaxCard(
|
||||
data: item,
|
||||
onEditTap: () => onEditTap(
|
||||
item, serviceChargeValue, taxModel.value),
|
||||
);
|
||||
}
|
||||
final item = items.firstWhere((element) => element.type.isLayanan);
|
||||
return ManageTaxCard(
|
||||
data: item,
|
||||
onEditTap: () => onEditTap(item, serviceChargeValue, taxModel.value),
|
||||
);
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// PAJAK TAB
|
||||
SizedBox(
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: 2, // Add button + 1 tax item
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
childAspectRatio: 0.85,
|
||||
crossAxisCount: 3,
|
||||
crossAxisSpacing: 30.0,
|
||||
mainAxisSpacing: 30.0,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return AddData(
|
||||
title: 'Edit Perhitungan',
|
||||
onPressed: () => onAddDataTap(serviceChargeValue, taxModel.value),
|
||||
// PAJAK TAB
|
||||
SizedBox(
|
||||
child: GridView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: 2, // Add button + 1 tax item
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
childAspectRatio: 0.85,
|
||||
crossAxisCount: 3,
|
||||
crossAxisSpacing: 30.0,
|
||||
mainAxisSpacing: 30.0,
|
||||
),
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return AddData(
|
||||
title: 'Edit Perhitungan',
|
||||
onPressed: () => onAddDataTap(
|
||||
serviceChargeValue, taxModel.value),
|
||||
);
|
||||
}
|
||||
final item = items.firstWhere(
|
||||
(element) => element.type.isPajak);
|
||||
return ManageTaxCard(
|
||||
data: item,
|
||||
onEditTap: () => onEditTap(
|
||||
item, serviceChargeValue, taxModel.value),
|
||||
);
|
||||
}
|
||||
final item = items.firstWhere((element) => element.type.isPajak);
|
||||
return ManageTaxCard(
|
||||
data: item,
|
||||
onEditTap: () => onEditTap(item, serviceChargeValue, taxModel.value),
|
||||
);
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import '../../../core/components/spaces.dart';
|
||||
import '../../../core/constants/colors.dart';
|
||||
|
||||
|
||||
|
||||
class AddData extends StatelessWidget {
|
||||
final String title;
|
||||
final VoidCallback onPressed;
|
||||
@ -21,18 +19,25 @@ class AddData extends StatelessWidget {
|
||||
onTap: onPressed,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(
|
||||
side: const BorderSide(width: 1, color: AppColors.card),
|
||||
borderRadius: BorderRadius.circular(19),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.add,
|
||||
color: AppColors.primary,
|
||||
Container(
|
||||
width: 56.0,
|
||||
height: 56.0,
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.primary.withOpacity(0.1),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
color: AppColors.primary,
|
||||
),
|
||||
),
|
||||
const SpaceHeight(8.0),
|
||||
Text(
|
||||
|
||||
@ -18,11 +18,9 @@ class ManageTaxCard extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
decoration: ShapeDecoration(
|
||||
shape: RoundedRectangleBorder(
|
||||
side: const BorderSide(width: 1, color: AppColors.card),
|
||||
borderRadius: BorderRadius.circular(19),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
@ -36,7 +34,7 @@ class ManageTaxCard extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(top: 30.0),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: AppColors.disabled.withOpacity(0.4),
|
||||
color: AppColors.primary.withOpacity(0.1),
|
||||
),
|
||||
child: Text(
|
||||
'${data.value}%',
|
||||
@ -48,23 +46,12 @@ class ManageTaxCard extends StatelessWidget {
|
||||
),
|
||||
const Spacer(),
|
||||
Center(
|
||||
child: RichText(
|
||||
text: TextSpan(
|
||||
text: 'Nama Promo : ',
|
||||
children: [
|
||||
TextSpan(
|
||||
text: data.type.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.black,
|
||||
),
|
||||
child: Text(
|
||||
data.type.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user