Initial and done prolly

This commit is contained in:
Andrew 2025-01-05 16:01:21 +07:00
commit 6f88b9966f
175 changed files with 15445 additions and 0 deletions

View file

@ -0,0 +1,84 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
extension GetInterfaceExtension on GetInterface {
Future<bool> confirm({
required String title,
required String content,
String yes = "Да",
String no = "Нет",
}) async {
final result = await Get.defaultDialog(
title: title,
content: Text(content),
textConfirm: yes,
textCancel: no,
onConfirm: () => Get.backLegacy(result: true),
onCancel: () => Get.backLegacy(result: false),
);
return result == true;
}
Future<String?> prompt({
required String title,
String message = "",
String hintText = "",
String label = "",
String defaultValue = "",
String positiveLabel = "ОК",
String negativeLabel = "Отмена",
int? maxLength,
int maxLines = 1,
Widget? prefix,
required String? Function(String? x) stringValidator,
}) async {
final controller = TextEditingController(text: defaultValue);
final value = Get.dialog<String>(
AlertDialog(
title: Text(title),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (message.isNotEmpty)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(message),
),
TextFormField(
controller: controller,
decoration: InputDecoration(
hintText: hintText,
filled: true,
prefix: prefix,
label: Text(label),
),
maxLength: maxLength,
maxLines: maxLines,
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: stringValidator,
)
],
),
actions: [
ElevatedButton(
onPressed: () {
if (stringValidator(controller.value.text) == null) {
Get.backLegacy(result: controller.value.text);
}
},
child: Text(positiveLabel),
),
ElevatedButton(
onPressed: () => Get.backLegacy(result: null),
child: Text(negativeLabel),
),
],
),
barrierDismissible: false,
useSafeArea: true,
);
return value;
}
}