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,5 @@
extension FormatDatetimeExtension on DateTime {
String get simpleDateFormat {
return "${day < 10 ? "0" : ""}$day.$month.$year";
}
}

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;
}
}

View file

@ -0,0 +1,24 @@
extension PluralizeIntExtension on int {
String pluralize({
required String name,
required String absent,
required String absentMul,
}) {
final plurality = this % 10 == 1 && this % 100 != 11
? 0
: this % 10 >= 2 &&
this % 10 <= 4 &&
(this % 100 < 10 || this % 100 >= 20)
? 1
: 2;
switch (plurality) {
case 1:
return "$this $absent";
case 2:
return "$this $absentMul";
default:
return "$this $name";
}
}
}