2025-04-12 14:35:08 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class UIDialogs {
|
2025-04-18 00:11:01 +02:00
|
|
|
|
2025-04-12 14:35:08 +02:00
|
|
|
static Future<String?> showTextInput(BuildContext context, String title, String hintText) {
|
|
|
|
var _textFieldController = TextEditingController();
|
|
|
|
|
|
|
|
return showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => AlertDialog(
|
|
|
|
title: Text(title),
|
|
|
|
content: TextField(
|
|
|
|
autofocus: true,
|
|
|
|
controller: _textFieldController,
|
|
|
|
decoration: InputDecoration(hintText: hintText),
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
child: Text('Cancel'),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => Navigator.of(context).pop(_textFieldController.text),
|
|
|
|
child: Text('OK'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2025-04-18 00:11:01 +02:00
|
|
|
|
|
|
|
static Future<bool> showConfirmDialog(BuildContext context, String title, {String? text, String? okText, String? cancelText}) {
|
|
|
|
return showDialog<bool>(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => AlertDialog(
|
|
|
|
title: Text(title),
|
|
|
|
content: (text != null) ? Text(text) : null,
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => Navigator.of(context).pop(false),
|
|
|
|
child: Text(cancelText ?? 'Cancel'),
|
|
|
|
),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () => Navigator.of(context).pop(true),
|
|
|
|
child: Text(okText ?? 'OK'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
).then((value) => value ?? false);
|
|
|
|
}
|
|
|
|
|
2025-04-12 14:35:08 +02:00
|
|
|
}
|