98 lines
2.9 KiB
Dart
98 lines
2.9 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
|
||
|
|
|
||
|
|
import '../../../core/components/buttons.dart';
|
||
|
|
import '../../../core/components/custom_text_field.dart';
|
||
|
|
import '../../../core/components/spaces.dart';
|
||
|
|
|
||
|
|
class FormTaxDialog extends StatefulWidget {
|
||
|
|
final int taxValue;
|
||
|
|
final int serviceChargeValue;
|
||
|
|
final Function(int taxValue, int serviceChargeValue)? onSave;
|
||
|
|
|
||
|
|
const FormTaxDialog({
|
||
|
|
super.key,
|
||
|
|
required this.taxValue,
|
||
|
|
required this.serviceChargeValue,
|
||
|
|
this.onSave,
|
||
|
|
});
|
||
|
|
|
||
|
|
@override
|
||
|
|
State<FormTaxDialog> createState() => _FormTaxDialogState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _FormTaxDialogState extends State<FormTaxDialog> {
|
||
|
|
late final TextEditingController serviceFeeController;
|
||
|
|
late final TextEditingController taxFeeController;
|
||
|
|
|
||
|
|
@override
|
||
|
|
void initState() {
|
||
|
|
super.initState();
|
||
|
|
serviceFeeController = TextEditingController(text: widget.serviceChargeValue.toString());
|
||
|
|
taxFeeController = TextEditingController(text: widget.taxValue.toString());
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
void dispose() {
|
||
|
|
serviceFeeController.dispose();
|
||
|
|
taxFeeController.dispose();
|
||
|
|
super.dispose();
|
||
|
|
}
|
||
|
|
|
||
|
|
@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(
|
||
|
|
child: SizedBox(
|
||
|
|
width: context.deviceWidth / 3,
|
||
|
|
child: Column(
|
||
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
|
children: [
|
||
|
|
CustomTextField(
|
||
|
|
controller: serviceFeeController,
|
||
|
|
label: 'Biaya Layanan (%)',
|
||
|
|
onChanged: (value) {},
|
||
|
|
keyboardType: TextInputType.number,
|
||
|
|
suffixIcon: const Icon(Icons.percent),
|
||
|
|
),
|
||
|
|
const SpaceHeight(24.0),
|
||
|
|
CustomTextField(
|
||
|
|
controller: taxFeeController,
|
||
|
|
label: 'Pajak PB1 (%)',
|
||
|
|
onChanged: (value) {},
|
||
|
|
keyboardType: TextInputType.number,
|
||
|
|
suffixIcon: const Icon(Icons.percent),
|
||
|
|
),
|
||
|
|
const SpaceHeight(24.0),
|
||
|
|
Button.filled(
|
||
|
|
onPressed: () {
|
||
|
|
final taxValue = int.tryParse(taxFeeController.text) ?? 0;
|
||
|
|
final serviceChargeValue = int.tryParse(serviceFeeController.text) ?? 0;
|
||
|
|
|
||
|
|
if (widget.onSave != null) {
|
||
|
|
widget.onSave!(taxValue, serviceChargeValue);
|
||
|
|
}
|
||
|
|
|
||
|
|
context.pop();
|
||
|
|
},
|
||
|
|
label: 'Simpan',
|
||
|
|
)
|
||
|
|
],
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|