mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Add AppInputDecoration
to AppTextFormField
.
This commit is contained in:
parent
a7f6284dd7
commit
7ea025f9f0
@ -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,
|
||||
|
@ -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,36 +82,25 @@ class _FidoPinDialogState extends ConsumerState<FidoPinDialog> {
|
||||
autofocus: true,
|
||||
obscureText: _isObscureCurrent,
|
||||
autofillHints: const [AutofillHints.password],
|
||||
decoration: InputDecoration(
|
||||
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(
|
||||
icon: Icon(_isObscureCurrent
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isObscureCurrent = !_isObscureCurrent;
|
||||
});
|
||||
},
|
||||
tooltip: _isObscureCurrent
|
||||
? l10n.s_show_pin
|
||||
: l10n.s_hide_pin,
|
||||
),
|
||||
if (_currentIsWrong) ...[
|
||||
const Icon(Icons.error_outlined),
|
||||
const SizedBox(
|
||||
width: 8.0,
|
||||
)
|
||||
]
|
||||
],
|
||||
)),
|
||||
decoration: AppInputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: l10n.s_current_pin,
|
||||
errorText: _currentIsWrong ? _currentPinError : null,
|
||||
errorMaxLines: 3,
|
||||
prefixIcon: const Icon(Icons.pin_outlined),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_isObscureCurrent
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isObscureCurrent = !_isObscureCurrent;
|
||||
});
|
||||
},
|
||||
tooltip:
|
||||
_isObscureCurrent ? l10n.s_show_pin : l10n.s_hide_pin,
|
||||
),
|
||||
),
|
||||
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),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isObscureNew = !_isObscureNew;
|
||||
});
|
||||
},
|
||||
tooltip:
|
||||
_isObscureNew ? l10n.s_show_pin : l10n.s_hide_pin,
|
||||
),
|
||||
if (_newIsWrong) ...[
|
||||
const Icon(Icons.error_outlined),
|
||||
const SizedBox(
|
||||
width: 8.0,
|
||||
)
|
||||
]
|
||||
]),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_isObscureNew ? Icons.visibility : Icons.visibility_off),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isObscureNew = !_isObscureNew;
|
||||
});
|
||||
},
|
||||
tooltip: _isObscureNew ? l10n.s_show_pin : l10n.s_hide_pin,
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
@ -167,26 +145,21 @@ 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(
|
||||
icon: Icon(_isObscureConfirm
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isObscureConfirm = !_isObscureConfirm;
|
||||
});
|
||||
},
|
||||
tooltip:
|
||||
_isObscureConfirm ? l10n.s_show_pin : l10n.s_hide_pin,
|
||||
)
|
||||
],
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_isObscureConfirm
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isObscureConfirm = !_isObscureConfirm;
|
||||
});
|
||||
},
|
||||
tooltip:
|
||||
_isObscureConfirm ? l10n.s_show_pin : l10n.s_hide_pin,
|
||||
),
|
||||
enabled:
|
||||
(!hasPin || _currentPin.isNotEmpty) && _newPin.isNotEmpty,
|
||||
|
@ -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),
|
||||
|
@ -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)),
|
||||
|
@ -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
|
||||
|
@ -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,34 +229,22 @@ class _ManageKeyDialogState extends ConsumerState<ManageKeyDialog> {
|
||||
: (_hasMetadata && _currentIsWrong ||
|
||||
_currentInvalidFormat)
|
||||
? const Icon(Icons.error)
|
||||
: Wrap(
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(_defaultKeyUsed
|
||||
? Icons.auto_awesome
|
||||
: Icons.auto_awesome_outlined),
|
||||
tooltip: l10n.s_use_default,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_defaultKeyUsed = !_defaultKeyUsed;
|
||||
if (_defaultKeyUsed) {
|
||||
_currentController.text =
|
||||
defaultManagementKey;
|
||||
} else {
|
||||
_currentController.clear();
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
if (_currentIsWrong ||
|
||||
_currentInvalidFormat) ...[
|
||||
const Icon(Icons.error_outlined),
|
||||
const SizedBox(
|
||||
width: 8.0,
|
||||
)
|
||||
]
|
||||
],
|
||||
: IconButton(
|
||||
icon: Icon(_defaultKeyUsed
|
||||
? Icons.auto_awesome
|
||||
: Icons.auto_awesome_outlined),
|
||||
tooltip: l10n.s_use_default,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_defaultKeyUsed = !_defaultKeyUsed;
|
||||
if (_defaultKeyUsed) {
|
||||
_currentController.text =
|
||||
defaultManagementKey;
|
||||
} else {
|
||||
_currentController.clear();
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user