mirror of
https://github.com/foss42/apidash.git
synced 2025-05-22 16:57:07 +08:00
fix: review changes
This commit is contained in:
41
lib/widgets/dialogs.dart
Normal file
41
lib/widgets/dialogs.dart
Normal file
@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
showRenameDialog(
|
||||
BuildContext context,
|
||||
String dialogTitle,
|
||||
String? name,
|
||||
Function(String) onRename,
|
||||
) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
final controller = TextEditingController(text: name ?? "");
|
||||
controller.selection =
|
||||
TextSelection(baseOffset: 0, extentOffset: controller.text.length);
|
||||
return AlertDialog(
|
||||
title: Text(dialogTitle),
|
||||
content: TextField(
|
||||
autofocus: true,
|
||||
controller: controller,
|
||||
decoration: const InputDecoration(hintText: "Enter new name"),
|
||||
),
|
||||
actions: <Widget>[
|
||||
OutlinedButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: const Text('CANCEL')),
|
||||
FilledButton(
|
||||
onPressed: () {
|
||||
final val = controller.text.trim();
|
||||
onRename(val);
|
||||
Navigator.pop(context);
|
||||
Future.delayed(const Duration(milliseconds: 100), () {
|
||||
controller.dispose();
|
||||
});
|
||||
},
|
||||
child: const Text('OK')),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user