add submit
This commit is contained in:
@@ -18,6 +18,7 @@ void showBrandDialog(BuildContext context, {BrandModel? brand}) {
|
||||
labelText: "Nome Brand",
|
||||
hintText: "es. Apple, Samsung...",
|
||||
),
|
||||
onSubmitted: (_) => _submitBrand(controller, context, brand),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -25,15 +26,7 @@ void showBrandDialog(BuildContext context, {BrandModel? brand}) {
|
||||
child: const Text("Annulla"),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (controller.text.isNotEmpty) {
|
||||
context.read<ProductCubit>().saveBrand(
|
||||
controller.text,
|
||||
id: brand?.id,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
onPressed: () => _submitBrand(controller, context, brand),
|
||||
child: const Text("Salva"),
|
||||
),
|
||||
],
|
||||
@@ -41,6 +34,17 @@ void showBrandDialog(BuildContext context, {BrandModel? brand}) {
|
||||
);
|
||||
}
|
||||
|
||||
void _submitBrand(
|
||||
TextEditingController controller,
|
||||
BuildContext context,
|
||||
BrandModel? brand,
|
||||
) {
|
||||
if (controller.text.trim().isNotEmpty) {
|
||||
context.read<ProductCubit>().saveBrand(controller.text, id: brand?.id);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
void showModelDialog(BuildContext context, {ModelModel? model}) {
|
||||
final controller = TextEditingController(text: model?.name);
|
||||
|
||||
@@ -55,6 +59,7 @@ void showModelDialog(BuildContext context, {ModelModel? model}) {
|
||||
labelText: "Nome Modello",
|
||||
hintText: "es. iPhone 15, Galaxy S24...",
|
||||
),
|
||||
onSubmitted: (_) => _submitModel(controller, context, model),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -62,15 +67,7 @@ void showModelDialog(BuildContext context, {ModelModel? model}) {
|
||||
child: const Text("Annulla"),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (controller.text.isNotEmpty) {
|
||||
context.read<ProductCubit>().saveModel(
|
||||
controller.text,
|
||||
id: model?.id,
|
||||
);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
onPressed: () => _submitModel(controller, context, model),
|
||||
child: const Text("Salva"),
|
||||
),
|
||||
],
|
||||
@@ -78,6 +75,17 @@ void showModelDialog(BuildContext context, {ModelModel? model}) {
|
||||
);
|
||||
}
|
||||
|
||||
void _submitModel(
|
||||
TextEditingController controller,
|
||||
BuildContext context,
|
||||
ModelModel? model,
|
||||
) {
|
||||
if (controller.text.isNotEmpty) {
|
||||
context.read<ProductCubit>().saveModel(controller.text, id: model?.id);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
}
|
||||
|
||||
void confirmToggle(BuildContext context, String title, VoidCallback onConfirm) {
|
||||
showDialog(
|
||||
context: context,
|
||||
|
||||
Reference in New Issue
Block a user