12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import 'package:cs_resources/constants/color_constants.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
- import '../my_text_field.dart';
- /**
- * 基于 MyTextField 实现圆角背景的文本框表单。
- *
- * 主要用于注册,忘记密码等页面。
- */
- class CustomTextField extends StatelessWidget {
- final String formKey;
- final double marginTop;
- final double marginLeft;
- final double marginRight;
- final double paddingRight;
- final double paddingLeft;
- final TextInputType textInputType;
- final String? errorText;
- final TextInputAction textInputAction;
- final Function onSubmit;
- final Map<String, dynamic> formData;
- CustomTextField({
- required this.formKey,
- required this.formData,
- required this.onSubmit,
- this.marginTop = 0,
- this.marginLeft = 15,
- this.marginRight = 15,
- this.paddingRight = 15,
- this.paddingLeft = 15,
- this.textInputType = TextInputType.text,
- this.errorText,
- this.textInputAction = TextInputAction.next,
- });
- @override
- Widget build(BuildContext context) {
- return IgnoreKeyboardDismiss(
- child: MyTextField(
- formKey,
- formData[formKey]!['value'],
- hintText: formData[formKey]!['hintText'],
- hintStyle: const TextStyle(
- color: ColorConstants.textGrayAECAE5,
- fontSize: 15.0,
- fontWeight: FontWeight.w400,
- ),
- controller: formData[formKey]['controller'],
- focusNode: formData[formKey]['focusNode'],
- margin: EdgeInsets.only(left: marginLeft, right: marginRight, top: marginTop),
- showDivider: false,
- fillBackgroundColor: ColorConstants.dividerBar,
- fillCornerRadius: 5,
- padding: EdgeInsets.only(left: paddingLeft, right: paddingRight, top: 2.5, bottom: 2.5),
- height: 50,
- style: TextStyle(
- color: ColorConstants.white,
- fontSize: 15.0,
- fontWeight: FontWeight.w400,
- ),
- inputType: textInputType,
- textInputAction: textInputAction,
- onSubmit: onSubmit,
- cursorColor: ColorConstants.white,
- obscureText: formData[formKey] != null ? formData[formKey]['obsecure'] : false,
- errorText: errorText,
- showLeftIcon: false,
- showRightIcon: false,
- ),
- );
- }
- }
|