Made alignment of message and initial value of TextInputWidget configurable

This commit is contained in:
ashilkn 2023-02-07 14:01:49 +05:30
parent 64b479dbf4
commit 335c464180
3 changed files with 21 additions and 3 deletions

View file

@ -166,6 +166,8 @@ class TextInputDialog extends StatefulWidget {
final FutureVoidCallbackParamStr onConfirm;
final String? hintText;
final IconData? prefixIcon;
final String? initialValue;
final Alignment? alignMessage;
const TextInputDialog({
required this.title,
this.body,
@ -176,6 +178,8 @@ class TextInputDialog extends StatefulWidget {
this.message,
this.hintText,
this.prefixIcon,
this.initialValue,
this.alignMessage,
super.key,
});
@ -218,6 +222,8 @@ class _TextInputDialogState extends State<TextInputDialog> {
message: widget.message,
hintText: widget.hintText,
prefixIcon: widget.prefixIcon,
initialValue: widget.initialValue,
alignMessage: widget.alignMessage,
),
),
const SizedBox(height: 36),

View file

@ -8,17 +8,22 @@ class TextInputWidget extends StatelessWidget {
final String? message;
final String? hintText;
final IconData? prefixIcon;
final String? initialValue;
final Alignment? alignMessage;
const TextInputWidget({
required this.textController,
this.label,
this.message,
this.hintText,
this.prefixIcon,
this.initialValue,
this.alignMessage,
super.key,
});
@override
Widget build(BuildContext context) {
initialValue != null ? textController.text = initialValue! : null;
final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
var textInputChildren = <Widget>[];
@ -71,9 +76,12 @@ class TextInputWidget extends StatelessWidget {
textInputChildren.add(
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Text(
message!,
style: textTheme.small.copyWith(color: colorScheme.textMuted),
child: Align(
alignment: alignMessage ?? Alignment.centerLeft,
child: Text(
message!,
style: textTheme.small.copyWith(color: colorScheme.textMuted),
),
),
),
);

View file

@ -262,6 +262,8 @@ Future<ButtonAction?> showTextInputDialog(
String? hintText,
required FutureVoidCallbackParamStr onConfirm,
IconData? prefixIcon,
String? initialValue,
Alignment? alignMessage,
}) {
return showDialog(
context: context,
@ -277,6 +279,8 @@ Future<ButtonAction?> showTextInputDialog(
onConfirm: onConfirm,
hintText: hintText,
prefixIcon: prefixIcon,
initialValue: initialValue,
alignMessage: alignMessage,
),
);
},