2025-11-21 15:28:46 +01:00
|
|
|
import 'package:design_system/design_system.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
|
2025-12-03 15:28:10 +01:00
|
|
|
class CustomTextField extends StatefulWidget{
|
2025-11-21 15:28:46 +01:00
|
|
|
bool? showPassword;
|
|
|
|
|
final bool numeric;
|
|
|
|
|
final String hint;
|
|
|
|
|
final String label;
|
|
|
|
|
final int? lines;
|
|
|
|
|
final ValueChanged<String>? onChanged;
|
|
|
|
|
final int? length;
|
|
|
|
|
|
|
|
|
|
CustomTextField({
|
|
|
|
|
super.key,
|
|
|
|
|
this.showPassword,
|
|
|
|
|
this.numeric = false,
|
|
|
|
|
this.hint = '',
|
|
|
|
|
this.label = '',
|
|
|
|
|
this.lines,
|
|
|
|
|
this.length,
|
|
|
|
|
this.onChanged,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@override
|
2025-12-03 15:28:10 +01:00
|
|
|
State<CustomTextField> createState() => CustomTextFieldState();
|
2025-11-21 15:28:46 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-03 15:28:10 +01:00
|
|
|
class CustomTextFieldState extends State<CustomTextField>{
|
2025-11-21 15:28:46 +01:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
2025-12-03 15:28:10 +01:00
|
|
|
return Column(
|
|
|
|
|
spacing: 8,
|
|
|
|
|
children: [
|
|
|
|
|
?widget.label == '' ? null : Align(
|
|
|
|
|
alignment: Alignment.bottomLeft,
|
|
|
|
|
child: Text(
|
|
|
|
|
widget.label,
|
|
|
|
|
style: TextStyle(fontSize: 14, letterSpacing: 0),
|
|
|
|
|
)
|
2025-11-21 15:28:46 +01:00
|
|
|
),
|
2025-12-03 15:28:10 +01:00
|
|
|
TextFormField(
|
|
|
|
|
keyboardType: widget.numeric? TextInputType.number : TextInputType.text,
|
|
|
|
|
obscureText: !(widget.showPassword ?? true),
|
|
|
|
|
enableSuggestions: widget.showPassword ?? true,
|
|
|
|
|
autocorrect: !(widget.showPassword ?? false),
|
|
|
|
|
style: TextStyle(color: Color(0xFF4B4B4B)),
|
|
|
|
|
inputFormatters: widget.numeric? [
|
|
|
|
|
FilteringTextInputFormatter.digitsOnly
|
|
|
|
|
] : [],
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
counterText: "",
|
|
|
|
|
hintText: widget.hint,
|
|
|
|
|
//labelText: widget.label,
|
|
|
|
|
//floatingLabelBehavior: FloatingLabelBehavior.always,
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(12)),
|
|
|
|
|
borderSide: BorderSide(color: Color(0xFF4B4B4B)),
|
|
|
|
|
gapPadding: 16
|
|
|
|
|
),
|
|
|
|
|
suffixIcon: widget.showPassword!=null ? IconButton(
|
|
|
|
|
icon: Icon(widget.showPassword!
|
|
|
|
|
? Icons.visibility_off
|
|
|
|
|
: Icons.visibility),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
widget.showPassword = !widget.showPassword!;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
) : null,
|
|
|
|
|
),
|
|
|
|
|
minLines: widget.lines ?? 1,
|
|
|
|
|
maxLines: widget.lines ?? 1,
|
|
|
|
|
maxLength: widget.length,
|
|
|
|
|
onChanged: widget.onChanged ?? (_)=>{},
|
|
|
|
|
)
|
|
|
|
|
],
|
2025-11-21 15:28:46 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|