mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Customize input dialog button label
This commit is contained in:
parent
3d2003de26
commit
dc83f49d81
2 changed files with 9 additions and 6 deletions
|
@ -444,7 +444,9 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
void _onEditAppBarAddTextPressed() {
|
||||
showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => const SimpleInputDialog(),
|
||||
builder: (context) => SimpleInputDialog(
|
||||
buttonText: MaterialLocalizations.of(context).saveButtonLabel,
|
||||
),
|
||||
).then((value) {
|
||||
if (value == null) {
|
||||
return;
|
||||
|
@ -467,6 +469,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
showDialog<String>(
|
||||
context: context,
|
||||
builder: (context) => SimpleInputDialog(
|
||||
buttonText: MaterialLocalizations.of(context).saveButtonLabel,
|
||||
initialText: item.text,
|
||||
),
|
||||
).then((value) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart';
|
|||
class SimpleInputDialog extends StatefulWidget {
|
||||
const SimpleInputDialog({
|
||||
Key? key,
|
||||
required this.buttonText,
|
||||
this.initialText,
|
||||
this.hintText,
|
||||
this.validator,
|
||||
|
@ -12,6 +13,7 @@ class SimpleInputDialog extends StatefulWidget {
|
|||
@override
|
||||
createState() => _SimpleInputDialogState();
|
||||
|
||||
final String buttonText;
|
||||
final String? initialText;
|
||||
final String? hintText;
|
||||
final FormFieldValidator<String>? validator;
|
||||
|
@ -36,16 +38,14 @@ class _SimpleInputDialogState extends State<SimpleInputDialog> {
|
|||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: _onSavePressed,
|
||||
child: Text(
|
||||
MaterialLocalizations.of(context).saveButtonLabel,
|
||||
),
|
||||
onPressed: _onButtonPressed,
|
||||
child: Text(widget.buttonText),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _onSavePressed() {
|
||||
void _onButtonPressed() {
|
||||
if (_formKey.currentState?.validate() == true) {
|
||||
_formValue = _FormValue();
|
||||
_formKey.currentState!.save();
|
||||
|
|
Loading…
Reference in a new issue