Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
3.8 kB
2
Indexable
import ‘package:base_architecture/presentation/resources/color_manager.dart’;
import ‘package:flutter/material.dart’;
import ‘package:flutter/services.dart’;
import ‘package:google_fonts/google_fonts.dart’;

class TamTextField extends StatelessWidget {
  const TamTextField({
    Key? key,
    required this.hintText,
    required this.labelText,
    this.onSaved,
    this.textInputAction,
    this.validator,
    this.keyboardType,
    this.initialValue,
    this.obscureText,
    this.textAlign,
    this.onChanged,
    this.borderRadius,
    this.controller,
    this.maxLengthEnforced,
    this.maxLength,
    this.maxLines,
    this.onFieldSubmitted,
    this.formatter,
    this.borderColor,
  }) : super(key: key);
  final int? maxLines;
  final TextInputAction? textInputAction;
  final ValueChanged<String>? onFieldSubmitted;
  final ValueChanged<String?>? onSaved;
  final FormFieldValidator<String?>? validator;
  final TextInputType? keyboardType;
  final String? initialValue;
  final String hintText;
  final TextAlign? textAlign;
  final String labelText;
  final bool? obscureText;
  final Color? borderColor;
  final FormFieldSetter? onChanged;
  final BorderRadius? borderRadius;
  final bool? maxLengthEnforced;
  final int? maxLength;
  final List<TextInputFormatter>? formatter;
  final TextEditingController? controller;
  @override
  Widget build(BuildContext context) => Container(
        height: 86,
        padding: const EdgeInsets.only(left: 12, bottom: 6, right: 12),
        width: MediaQuery.of(context).size.width,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius:
              borderRadius ?? const BorderRadius.all(Radius.circular(12)),
          border: Border.all(
            color: borderColor ?? Colors.pink,
            width: 2,
          ),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Expanded(
              child: TextFormField(
                decoration: InputDecoration(
                  floatingLabelStyle: GoogleFonts.poppins(
                    fontSize: 14,
                    fontWeight: FontWeight.w400,
                    color: HexColor.fromHex(‘#828282’),
                  ),
                  border: InputBorder.none,
                  hintText: hintText,
                  labelStyle: GoogleFonts.poppins(
                    fontSize: 14,
                    fontWeight: FontWeight.w400,
                    color: HexColor.fromHex(‘#828282’),
                  ),
                  alignLabelWithHint: true,
                  hintStyle: GoogleFonts.poppins(
                    fontSize: 19,
                    fontWeight: FontWeight.w500,
                    color: HexColor.fromHex(‘#192126’),
                  ),
                  labelText: labelText,
                ),
                inputFormatters: formatter ?? <TextInputFormatter>[],
                textInputAction: textInputAction,
                initialValue: initialValue,
                controller: controller,
                onSaved: onSaved,
                onFieldSubmitted: onFieldSubmitted,
                onChanged: onChanged,
                validator: validator,
                cursorHeight: 22,
                cursorColor: Colors.black,
                style: GoogleFonts.poppins(
                  fontWeight: FontWeight.w500,
                  color: HexColor.fromHex(‘#192126’),
                  fontSize: 20,
                ),
                obscureText: obscureText ?? false,
                maxLength: maxLength,
              ),
            ),
          ],
        ),
      );
}