Initial commit - app-padrao-1.0
This commit is contained in:
78
lib/shared/widgets/custom_text_field.dart
Normal file
78
lib/shared/widgets/custom_text_field.dart
Normal file
@@ -0,0 +1,78 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:barber_app/core/theme/app_theme.dart';
|
||||
|
||||
class CustomTextField extends StatelessWidget {
|
||||
final TextEditingController controller;
|
||||
final String label;
|
||||
final String? hint;
|
||||
final IconData? prefixIcon;
|
||||
final Widget? suffixIcon;
|
||||
final bool obscureText;
|
||||
final TextInputType? keyboardType;
|
||||
final String? Function(String?)? validator;
|
||||
final int maxLines;
|
||||
final void Function(String)? onChanged;
|
||||
final TextCapitalization textCapitalization;
|
||||
final List<TextInputFormatter>? inputFormatters;
|
||||
|
||||
const CustomTextField({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.label,
|
||||
this.hint,
|
||||
this.prefixIcon,
|
||||
this.suffixIcon,
|
||||
this.obscureText = false,
|
||||
this.keyboardType,
|
||||
this.validator,
|
||||
this.maxLines = 1,
|
||||
this.onChanged,
|
||||
this.textCapitalization = TextCapitalization.none,
|
||||
this.inputFormatters,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
final textColor = isDark ? AppColors.textPrimary : Colors.black87;
|
||||
final labelColor = isDark ? AppColors.textSecondary : Colors.black54;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: labelColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
TextFormField(
|
||||
controller: controller,
|
||||
obscureText: obscureText,
|
||||
keyboardType: keyboardType,
|
||||
validator: validator,
|
||||
maxLines: maxLines,
|
||||
onChanged: onChanged,
|
||||
textCapitalization: textCapitalization,
|
||||
inputFormatters: inputFormatters,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 16,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: hint,
|
||||
prefixIcon: prefixIcon != null
|
||||
? Icon(prefixIcon, color: labelColor)
|
||||
: null,
|
||||
suffixIcon: suffixIcon,
|
||||
hintStyle: TextStyle(color: isDark ? Colors.white38 : Colors.black38),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user