74 lines
2.6 KiB
Dart
74 lines
2.6 KiB
Dart
import 'package:birzha/components/TextInputCustom.dart';
|
|
import 'package:birzha/components/dialog.dart';
|
|
import 'package:birzha/core/adaptix/adaptix.dart';
|
|
import 'package:birzha/models/settings/settingsModel.dart';
|
|
import 'package:birzha/services/textMetaData.dart';
|
|
import 'package:birzha/services/validator.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
class AskQuantityDialog extends StatefulWidget {
|
|
AskQuantityDialog({Key? key, required this.initialQuantity}) : super(key: key);
|
|
|
|
final double initialQuantity;
|
|
|
|
@override
|
|
__AskQuantityDialogState createState() => __AskQuantityDialogState();
|
|
}
|
|
|
|
class __AskQuantityDialogState extends State<AskQuantityDialog> {
|
|
late final TextEditingController _controller;
|
|
final GlobalKey<FormState> _form = GlobalKey<FormState>();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = TextEditingController(text: widget.initialQuantity.toString());
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppDialog(
|
|
title: 'quantitySumm'.translation,
|
|
child: Form(
|
|
key: _form,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: TextInputCustom(
|
|
fieldStandard: TextInputMetaData(
|
|
name: 'enterQuantity'.translation,
|
|
label: 'enterQuantity'.translation,
|
|
validation: Validation(conditions: [
|
|
(inp) {
|
|
return inp.isEmpty || (double.tryParse(inp.trim())) == null ? 'formatError'.translation : null;
|
|
}
|
|
]),
|
|
formatters: [
|
|
FilteringTextInputFormatter.allow(RegExp('[0-9.]')),
|
|
],
|
|
key: 'quantity'),
|
|
controller: _controller),
|
|
),
|
|
],
|
|
)),
|
|
actions: [
|
|
Expanded(
|
|
child: Center(
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
if (_form.currentState?.validate() ?? false) Navigator.of(context).pop(double.tryParse(_controller.text));
|
|
},
|
|
child: Text(
|
|
MaterialLocalizations.of(context).continueButtonLabel.characters.first +
|
|
MaterialLocalizations.of(context).continueButtonLabel.substring(1).toLowerCase(),
|
|
style: TextStyle(color: Theme.of(context).accentColor, fontWeight: FontWeight.bold, fontSize: 12.99.adaptedPx()),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|