|
|
|
@ -1,20 +1,29 @@
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
|
|
|
|
import 'package:test_sa/models/gas_refill/gas_refill_details.dart';
|
|
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
|
|
|
import 'package:test_sa/views/app_style/colors.dart';
|
|
|
|
|
|
|
|
import 'package:test_sa/views/widgets/app_text_form_field.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '../../../controllers/localization/localization.dart';
|
|
|
|
|
|
|
|
import '../buttons/app_button.dart';
|
|
|
|
|
|
|
|
import '../titles/app_sub_title.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class GasRefillCreateDetailsItem extends StatelessWidget {
|
|
|
|
class GasRefillCreateDetailsItem extends StatelessWidget {
|
|
|
|
final GasRefillDetails model;
|
|
|
|
final GasRefillDetails model;
|
|
|
|
final VoidCallback onDelete;
|
|
|
|
final VoidCallback onPressed;
|
|
|
|
|
|
|
|
final bool isUpdate;
|
|
|
|
|
|
|
|
|
|
|
|
const GasRefillCreateDetailsItem({Key key, this.model, this.onDelete}) : super(key: key);
|
|
|
|
const GasRefillCreateDetailsItem({Key key, this.isUpdate, this.model, this.onPressed}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
|
|
final subtitle = AppLocalization.of(context).subtitle;
|
|
|
|
|
|
|
|
final startEditing = isUpdate && (model.selectedForEditing ?? false);
|
|
|
|
|
|
|
|
String deliveredQuantity = "0";
|
|
|
|
return Column(
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
Row(
|
|
|
|
children: [Expanded(child: Text(model.type.name)), IconButton(onPressed: onDelete, color: AColors.red, icon: const Icon(Icons.delete))],
|
|
|
|
children: [Expanded(child: Text(model.type.name)), IconButton(onPressed: onPressed, color: isUpdate ? AColors.cyan : AColors.red, icon: Icon(isUpdate ? Icons.edit : Icons.delete))],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Wrap(
|
|
|
|
Wrap(
|
|
|
|
spacing: 10,
|
|
|
|
spacing: 10,
|
|
|
|
@ -31,6 +40,34 @@ class GasRefillCreateDetailsItem extends StatelessWidget {
|
|
|
|
Text(model.deliveredQuantity.toStringAsFixed(0)),
|
|
|
|
Text(model.deliveredQuantity.toStringAsFixed(0)),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
if (startEditing) const SizedBox(height: 16),
|
|
|
|
|
|
|
|
if (startEditing) ASubTitle(subtitle.deliveredQuantity),
|
|
|
|
|
|
|
|
if (startEditing) const SizedBox(height: 4),
|
|
|
|
|
|
|
|
if (startEditing)
|
|
|
|
|
|
|
|
ATextFormField(
|
|
|
|
|
|
|
|
initialValue: model.deliveredQuantity?.toString(),
|
|
|
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
|
|
|
// controller: deliveredQuantityController,
|
|
|
|
|
|
|
|
style: Theme.of(context).textTheme.subtitle1,
|
|
|
|
|
|
|
|
// validator: (value) => Validator.isNumeric(value) ? null : "allow numbers only",
|
|
|
|
|
|
|
|
textInputType: TextInputType.number,
|
|
|
|
|
|
|
|
onChange: (value) {
|
|
|
|
|
|
|
|
deliveredQuantity = value;
|
|
|
|
|
|
|
|
// _currentDetails?.deliveredQuantity = double.tryParse(value);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
if (startEditing) const SizedBox(height: 8),
|
|
|
|
|
|
|
|
if (startEditing)
|
|
|
|
|
|
|
|
AButton(
|
|
|
|
|
|
|
|
text: subtitle.edit,
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
final value = double.tryParse(deliveredQuantity ?? "");
|
|
|
|
|
|
|
|
if (value != null) {
|
|
|
|
|
|
|
|
model.deliveredQuantity = value;
|
|
|
|
|
|
|
|
onPressed();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
const Divider(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|