CakeWallet/lib/src/widgets/base_text_form_field.dart
Rafael Saes baabc0a915
Cw 373 theme refactoring in preparation to support additional themes (#933)
* refactor(Theme): migrate accentColor

- based on the specs at https://docs.flutter.dev/release/breaking-changes/theme-data-accent-properties#migration-guide.

* refactor(Theme): all deprecated TextTheme styles

* refactor(Theme): deprecated backgroundColor for colorScheme.background

* refactor(Theme): deprecated buttonColor to use TextTheme backgroundColor instead

* refactor(Theme): deprecated isAlwaysShown to use thumbVisibility instead
2023-05-25 02:19:51 +03:00

119 lines
3.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class BaseTextFormField extends StatelessWidget {
BaseTextFormField(
{this.controller,
this.keyboardType = TextInputType.text,
this.textInputAction = TextInputAction.done,
this.textAlign = TextAlign.start,
this.autovalidateMode,
this.hintText = '',
this.maxLines = 1,
this.inputFormatters,
this.textColor,
this.hintColor,
this.borderColor,
this.prefix,
this.prefixIcon,
this.suffix,
this.suffixIcon,
this.enabled = true,
this.readOnly = false,
this.enableInteractiveSelection = true,
this.validator,
this.textStyle,
this.placeholderTextStyle,
this.maxLength,
this.focusNode,
this.initialValue,
this.onSubmit,
this.borderWidth = 1.0});
final TextEditingController? controller;
final TextInputType? keyboardType;
final TextInputAction? textInputAction;
final TextAlign textAlign;
final AutovalidateMode? autovalidateMode;
final String? hintText;
final int? maxLines;
final List<TextInputFormatter>? inputFormatters;
final Color? textColor;
final Color? hintColor;
final Color? borderColor;
final Widget? prefix;
final Widget? prefixIcon;
final Widget? suffix;
final Widget? suffixIcon;
final bool? enabled;
final FormFieldValidator<String>? validator;
final TextStyle? placeholderTextStyle;
final TextStyle? textStyle;
final int? maxLength;
final FocusNode? focusNode;
final bool readOnly;
final bool? enableInteractiveSelection;
final String? initialValue;
final double borderWidth;
final void Function(String)? onSubmit;
@override
Widget build(BuildContext context) {
return TextFormField(
enableInteractiveSelection: enableInteractiveSelection,
readOnly: readOnly,
initialValue: initialValue,
focusNode: focusNode,
controller: controller,
keyboardType: keyboardType,
textInputAction: textInputAction,
textAlign: textAlign,
autovalidateMode: autovalidateMode,
maxLines: maxLines,
inputFormatters: inputFormatters,
enabled: enabled,
maxLength: maxLength,
onFieldSubmitted: onSubmit,
style: textStyle ??
TextStyle(
fontSize: 16.0,
color: textColor ??
Theme.of(context).primaryTextTheme!.titleLarge!.color!),
decoration: InputDecoration(
prefix: prefix,
prefixIcon: prefixIcon,
suffix: suffix,
suffixIcon: suffixIcon,
hintStyle: placeholderTextStyle ??
TextStyle(
color: hintColor ?? Theme.of(context).hintColor,
fontSize: 16),
hintText: hintText,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: borderColor ??
Theme.of(context)
.primaryTextTheme!
.titleLarge!
.backgroundColor!,
width: borderWidth)),
disabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: borderColor ??
Theme.of(context)
.primaryTextTheme!
.titleLarge!
.backgroundColor!,
width: borderWidth)),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: borderColor ??
Theme.of(context)
.primaryTextTheme!
.titleLarge!
.backgroundColor!,
width: borderWidth))),
validator: validator,
);
}
}