2025-07-10 18:52:04 -05:00
|
|
|
import 'package:flutter/material.dart';
|
2026-01-08 21:32:12 -06:00
|
|
|
import 'package:flutter/services.dart';
|
2025-07-10 18:52:04 -05:00
|
|
|
|
2026-01-08 21:32:12 -06:00
|
|
|
/// A comprehensive, flexible text input widget that maintains consistent styling
|
|
|
|
|
/// across the entire app while supporting all common text input use cases.
|
|
|
|
|
class BlindMasterInput extends StatefulWidget {
|
|
|
|
|
const BlindMasterInput(
|
|
|
|
|
this.label, {
|
|
|
|
|
super.key,
|
|
|
|
|
this.controller,
|
|
|
|
|
this.validator,
|
|
|
|
|
this.color,
|
|
|
|
|
this.password = false,
|
|
|
|
|
this.enabled = true,
|
|
|
|
|
this.keyboardType,
|
|
|
|
|
this.prefixIcon,
|
|
|
|
|
this.hintText,
|
|
|
|
|
this.textCapitalization = TextCapitalization.none,
|
|
|
|
|
this.inputFormatters,
|
|
|
|
|
this.textAlign = TextAlign.start,
|
|
|
|
|
this.maxLength,
|
|
|
|
|
this.textInputAction,
|
|
|
|
|
this.onFieldSubmitted,
|
|
|
|
|
this.onChanged,
|
|
|
|
|
this.focusedBorderColor,
|
|
|
|
|
this.initialValue,
|
|
|
|
|
this.autofocus = false,
|
|
|
|
|
});
|
2025-07-10 18:52:04 -05:00
|
|
|
|
|
|
|
|
final String label;
|
|
|
|
|
final TextEditingController? controller;
|
|
|
|
|
final Color? color;
|
|
|
|
|
final bool password;
|
2026-01-08 21:32:12 -06:00
|
|
|
final bool enabled;
|
|
|
|
|
final TextInputType? keyboardType;
|
|
|
|
|
final IconData? prefixIcon;
|
|
|
|
|
final String? hintText;
|
|
|
|
|
final TextCapitalization textCapitalization;
|
|
|
|
|
final List<TextInputFormatter>? inputFormatters;
|
|
|
|
|
final TextAlign textAlign;
|
|
|
|
|
final int? maxLength;
|
|
|
|
|
final TextInputAction? textInputAction;
|
|
|
|
|
final Function(String)? onFieldSubmitted;
|
|
|
|
|
final Function(String)? onChanged;
|
|
|
|
|
final Color? focusedBorderColor;
|
|
|
|
|
final String? initialValue;
|
|
|
|
|
final bool autofocus;
|
2025-07-10 18:52:04 -05:00
|
|
|
|
|
|
|
|
final String? Function(String?)? validator;
|
|
|
|
|
|
2026-01-08 13:44:39 -06:00
|
|
|
@override
|
2026-01-08 21:32:12 -06:00
|
|
|
State<BlindMasterInput> createState() => _BlindMasterInputState();
|
2026-01-08 13:44:39 -06:00
|
|
|
}
|
|
|
|
|
|
2026-01-08 21:32:12 -06:00
|
|
|
class _BlindMasterInputState extends State<BlindMasterInput> {
|
2026-01-08 13:44:39 -06:00
|
|
|
bool _obscureText = true;
|
|
|
|
|
|
2025-07-10 18:52:04 -05:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Container(
|
2026-01-08 21:32:12 -06:00
|
|
|
padding: const EdgeInsets.all(10),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
initialValue: widget.initialValue,
|
|
|
|
|
controller: widget.controller,
|
2026-01-08 13:44:39 -06:00
|
|
|
validator: widget.validator,
|
|
|
|
|
obscureText: widget.password && _obscureText,
|
2026-01-08 21:32:12 -06:00
|
|
|
enableSuggestions: !widget.password,
|
|
|
|
|
autocorrect: !widget.password,
|
|
|
|
|
enabled: widget.enabled,
|
|
|
|
|
keyboardType: widget.keyboardType,
|
|
|
|
|
textCapitalization: widget.textCapitalization,
|
|
|
|
|
inputFormatters: widget.inputFormatters,
|
|
|
|
|
textAlign: widget.textAlign,
|
|
|
|
|
maxLength: widget.maxLength,
|
|
|
|
|
textInputAction: widget.textInputAction,
|
|
|
|
|
onFieldSubmitted: widget.onFieldSubmitted,
|
|
|
|
|
onChanged: widget.onChanged,
|
|
|
|
|
autofocus: widget.autofocus,
|
2025-07-10 18:52:04 -05:00
|
|
|
style: TextStyle(
|
2026-01-08 21:32:12 -06:00
|
|
|
color: widget.color,
|
2025-07-10 18:52:04 -05:00
|
|
|
),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
border: OutlineInputBorder(
|
2026-01-08 21:32:12 -06:00
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
2025-07-10 18:52:04 -05:00
|
|
|
),
|
2026-01-08 21:32:12 -06:00
|
|
|
focusedBorder: widget.focusedBorderColor != null
|
|
|
|
|
? OutlineInputBorder(
|
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
|
|
|
|
borderSide: BorderSide(
|
|
|
|
|
color: widget.focusedBorderColor!,
|
|
|
|
|
width: 2,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: null,
|
2026-01-08 13:44:39 -06:00
|
|
|
labelText: widget.label,
|
2026-01-08 21:32:12 -06:00
|
|
|
hintText: widget.hintText,
|
2026-01-08 13:44:39 -06:00
|
|
|
labelStyle: TextStyle(color: widget.color),
|
2026-01-08 21:32:12 -06:00
|
|
|
contentPadding: const EdgeInsets.all(10),
|
|
|
|
|
prefixIcon: widget.prefixIcon != null ? Icon(widget.prefixIcon) : null,
|
2026-01-08 13:44:39 -06:00
|
|
|
suffixIcon: widget.password
|
|
|
|
|
? IconButton(
|
|
|
|
|
icon: Icon(
|
|
|
|
|
_obscureText ? Icons.visibility : Icons.visibility_off,
|
|
|
|
|
),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_obscureText = !_obscureText;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
: null,
|
2026-01-08 21:32:12 -06:00
|
|
|
counterText: widget.maxLength != null ? '' : null, // Hide character counter
|
2025-07-10 18:52:04 -05:00
|
|
|
),
|
2026-01-08 21:32:12 -06:00
|
|
|
),
|
2025-07-10 18:52:04 -05:00
|
|
|
);
|
|
|
|
|
}
|
2026-01-08 21:32:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Legacy alias for backward compatibility
|
|
|
|
|
class BlindMasterMainInput extends BlindMasterInput {
|
|
|
|
|
const BlindMasterMainInput(
|
|
|
|
|
super.label, {
|
|
|
|
|
super.key,
|
|
|
|
|
super.controller,
|
|
|
|
|
super.validator,
|
|
|
|
|
super.color,
|
|
|
|
|
super.password,
|
|
|
|
|
});
|
2025-07-10 18:52:04 -05:00
|
|
|
}
|