Add AppInputDecoration to AppTextFormField.

This commit is contained in:
Elias Bonnici 2023-12-14 17:21:46 +01:00
parent a7f6284dd7
commit 7ea025f9f0
No known key found for this signature in database
GPG Key ID: 5EAC28EA3F980CCF
7 changed files with 73 additions and 106 deletions

View File

@ -28,6 +28,7 @@ import '../../app/message.dart';
import '../../app/models.dart';
import '../../desktop/models.dart';
import '../../fido/models.dart';
import '../../widgets/app_text_field.dart';
import '../../widgets/app_text_form_field.dart';
import '../../widgets/responsive_dialog.dart';
import '../../widgets/utf8_utils.dart';
@ -206,7 +207,7 @@ class _AddFingerprintDialogState extends ConsumerState<AddFingerprintDialog>
inputFormatters: [limitBytesLength(15)],
buildCounter: buildByteCounterFor(_label),
autofocus: true,
decoration: InputDecoration(
decoration: AppInputDecoration(
enabled: _fingerprint != null,
border: const OutlineInputBorder(),
labelText: l10n.s_name,

View File

@ -24,6 +24,7 @@ import '../../app/message.dart';
import '../../app/models.dart';
import '../../app/state.dart';
import '../../desktop/models.dart';
import '../../widgets/app_text_field.dart';
import '../../widgets/app_text_form_field.dart';
import '../../widgets/responsive_dialog.dart';
import '../models.dart';
@ -81,16 +82,13 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
autofocus: true,
obscureText: _isObscureCurrent,
autofillHints: const [AutofillHints.password],
decoration: InputDecoration(
decoration: AppInputDecoration(
border: const OutlineInputBorder(),
labelText: l10n.s_current_pin,
errorText: _currentIsWrong ? _currentPinError : null,
errorMaxLines: 3,
prefixIcon: const Icon(Icons.pin_outlined),
suffixIcon: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
IconButton(
suffixIcon: IconButton(
icon: Icon(_isObscureCurrent
? Icons.visibility
: Icons.visibility_off),
@ -99,18 +97,10 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
_isObscureCurrent = !_isObscureCurrent;
});
},
tooltip: _isObscureCurrent
? l10n.s_show_pin
: l10n.s_hide_pin,
tooltip:
_isObscureCurrent ? l10n.s_show_pin : l10n.s_hide_pin,
),
),
if (_currentIsWrong) ...[
const Icon(Icons.error_outlined),
const SizedBox(
width: 8.0,
)
]
],
)),
onChanged: (value) {
setState(() {
_currentIsWrong = false;
@ -126,35 +116,23 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
autofocus: !hasPin,
obscureText: _isObscureNew,
autofillHints: const [AutofillHints.password],
decoration: InputDecoration(
decoration: AppInputDecoration(
border: const OutlineInputBorder(),
labelText: l10n.s_new_pin,
enabled: !hasPin || _currentPin.isNotEmpty,
errorText: _newIsWrong ? _newPinError : null,
errorMaxLines: 3,
prefixIcon: const Icon(Icons.pin_outlined),
suffixIcon: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
IconButton(
icon: Icon(_isObscureNew
? Icons.visibility
: Icons.visibility_off),
suffixIcon: IconButton(
icon: Icon(
_isObscureNew ? Icons.visibility : Icons.visibility_off),
onPressed: () {
setState(() {
_isObscureNew = !_isObscureNew;
});
},
tooltip:
_isObscureNew ? l10n.s_show_pin : l10n.s_hide_pin,
tooltip: _isObscureNew ? l10n.s_show_pin : l10n.s_hide_pin,
),
if (_newIsWrong) ...[
const Icon(Icons.error_outlined),
const SizedBox(
width: 8.0,
)
]
]),
),
onChanged: (value) {
setState(() {
@ -167,14 +145,11 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
initialValue: _confirmPin,
obscureText: _isObscureConfirm,
autofillHints: const [AutofillHints.password],
decoration: InputDecoration(
decoration: AppInputDecoration(
border: const OutlineInputBorder(),
labelText: l10n.s_confirm_pin,
prefixIcon: const Icon(Icons.pin_outlined),
suffixIcon: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
IconButton(
suffixIcon: IconButton(
icon: Icon(_isObscureConfirm
? Icons.visibility
: Icons.visibility_off),
@ -185,8 +160,6 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
},
tooltip:
_isObscureConfirm ? l10n.s_show_pin : l10n.s_hide_pin,
)
],
),
enabled:
(!hasPin || _currentPin.isNotEmpty) && _newPin.isNotEmpty,

View File

@ -21,6 +21,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../app/message.dart';
import '../../app/models.dart';
import '../../desktop/models.dart';
import '../../widgets/app_text_field.dart';
import '../../widgets/app_text_form_field.dart';
import '../../widgets/responsive_dialog.dart';
import '../../widgets/utf8_utils.dart';
@ -95,7 +96,7 @@ class _RenameAccountDialogState extends ConsumerState<RenameFingerprintDialog> {
maxLength: 15,
inputFormatters: [limitBytesLength(15)],
buildCounter: buildByteCounterFor(_label),
decoration: InputDecoration(
decoration: AppInputDecoration(
border: const OutlineInputBorder(),
labelText: l10n.s_label,
prefixIcon: const Icon(Icons.fingerprint_outlined),

View File

@ -26,6 +26,7 @@ import '../../app/views/app_page.dart';
import '../../app/views/graphics.dart';
import '../../app/views/message_page.dart';
import '../../core/state.dart';
import '../../widgets/app_text_field.dart';
import '../../widgets/app_text_form_field.dart';
import '../features.dart' as features;
import '../keys.dart' as keys;
@ -161,7 +162,7 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
// Use the default style, but with a smaller font size:
style: textTheme.titleMedium
?.copyWith(fontSize: textTheme.titleSmall?.fontSize),
decoration: InputDecoration(
decoration: AppInputDecoration(
hintText: l10n.s_search_accounts,
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(32)),

View File

@ -25,6 +25,7 @@ import '../../app/models.dart';
import '../../app/state.dart';
import '../../desktop/models.dart';
import '../../exception/cancellation_exception.dart';
import '../../widgets/app_text_field.dart';
import '../../widgets/app_text_form_field.dart';
import '../../widgets/focus_utils.dart';
import '../../widgets/responsive_dialog.dart';
@ -179,7 +180,7 @@ class _RenameAccountDialogState extends ConsumerState<RenameAccountDialog> {
buildCounter: buildByteCounterFor(_issuer),
inputFormatters: [limitBytesLength(issuerRemaining)],
key: keys.issuerField,
decoration: InputDecoration(
decoration: AppInputDecoration(
border: const OutlineInputBorder(),
labelText: l10n.s_issuer_optional,
helperText: '', // Prevents dialog resizing when disabled
@ -198,7 +199,7 @@ class _RenameAccountDialogState extends ConsumerState<RenameAccountDialog> {
inputFormatters: [limitBytesLength(nameRemaining)],
buildCounter: buildByteCounterFor(_name),
key: keys.nameField,
decoration: InputDecoration(
decoration: AppInputDecoration(
border: const OutlineInputBorder(),
labelText: l10n.s_account_name,
helperText: '', // Prevents dialog resizing when disabled

View File

@ -210,7 +210,7 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
controller: _currentController,
readOnly: _defaultKeyUsed,
maxLength: !_defaultKeyUsed ? currentType.keyLength * 2 : null,
decoration: InputDecoration(
decoration: AppInputDecoration(
border: const OutlineInputBorder(),
labelText: l10n.s_current_management_key,
helperText: _defaultKeyUsed ? l10n.l_default_key_used : null,
@ -229,10 +229,7 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
: (_hasMetadata && _currentIsWrong ||
_currentInvalidFormat)
? const Icon(Icons.error)
: Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
IconButton(
: IconButton(
icon: Icon(_defaultKeyUsed
? Icons.auto_awesome
: Icons.auto_awesome_outlined),
@ -249,15 +246,6 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
});
},
),
if (_currentIsWrong ||
_currentInvalidFormat) ...[
const Icon(Icons.error_outlined),
const SizedBox(
width: 8.0,
)
]
],
),
),
textInputAction: TextInputAction.next,
onChanged: (value) {

View File

@ -16,6 +16,8 @@
import 'package:flutter/material.dart';
import 'app_text_field.dart';
/// TextFormField without autocorrect and suggestions
class AppTextFormField extends TextFormField {
AppTextFormField({
@ -28,7 +30,7 @@ class AppTextFormField extends TextFormField {
super.controller,
super.initialValue,
super.focusNode,
super.decoration,
AppInputDecoration? decoration,
super.textCapitalization,
super.textInputAction,
super.style,
@ -87,5 +89,5 @@ class AppTextFormField extends TextFormField {
super.clipBehavior,
super.scribbleEnabled,
super.canRequestFocus,
});
}) : super(decoration: decoration);
}