added country_code_picker package to link phone feature
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class CustomTextField extends StatefulWidget{
|
||||
bool? showPassword;
|
||||
class CustomTextField extends StatefulWidget {
|
||||
final bool? showPassword;
|
||||
final bool numeric;
|
||||
final String hint;
|
||||
final String label;
|
||||
final int? lines;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final int? length;
|
||||
final TextEditingController? controller;
|
||||
|
||||
CustomTextField({
|
||||
const CustomTextField({
|
||||
super.key,
|
||||
this.showPassword,
|
||||
this.numeric = false,
|
||||
@@ -21,63 +20,74 @@ class CustomTextField extends StatefulWidget{
|
||||
this.lines,
|
||||
this.length,
|
||||
this.onChanged,
|
||||
this.controller,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CustomTextField> createState() => CustomTextFieldState();
|
||||
}
|
||||
|
||||
class CustomTextFieldState extends State<CustomTextField>{
|
||||
class CustomTextFieldState extends State<CustomTextField> {
|
||||
late bool _showPassword;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_showPassword = widget.showPassword ?? true;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Column(
|
||||
spacing: 8,
|
||||
children: [
|
||||
?widget.label == '' ? null : Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
widget.label,
|
||||
style: TextStyle(fontSize: 14, letterSpacing: 0),
|
||||
)
|
||||
),
|
||||
if (widget.label.isNotEmpty)
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
widget.label,
|
||||
style: const TextStyle(fontSize: 14, letterSpacing: 0),
|
||||
),
|
||||
),
|
||||
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
|
||||
] : [],
|
||||
controller: widget.controller,
|
||||
keyboardType: widget.numeric
|
||||
? TextInputType.number
|
||||
: TextInputType.text,
|
||||
obscureText: !_showPassword,
|
||||
enableSuggestions: _showPassword,
|
||||
autocorrect: !_showPassword,
|
||||
style: const TextStyle(color: Color(0xFF4B4B4B)),
|
||||
inputFormatters: widget.numeric
|
||||
? <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly]
|
||||
: const <TextInputFormatter>[],
|
||||
decoration: InputDecoration(
|
||||
counterText: "",
|
||||
hintText: widget.hint,
|
||||
//labelText: widget.label,
|
||||
//floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||
border: OutlineInputBorder(
|
||||
border: const OutlineInputBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
borderSide: BorderSide(color: Color(0xFF4B4B4B)),
|
||||
gapPadding: 16
|
||||
gapPadding: 16,
|
||||
),
|
||||
suffixIcon: widget.showPassword!=null ? IconButton(
|
||||
icon: Icon(widget.showPassword!
|
||||
? Icons.visibility_off
|
||||
: Icons.visibility),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
widget.showPassword = !widget.showPassword!;
|
||||
});
|
||||
},
|
||||
) : null,
|
||||
suffixIcon: widget.showPassword != null
|
||||
? IconButton(
|
||||
icon: Icon(
|
||||
_showPassword ? Icons.visibility_off : Icons.visibility,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_showPassword = !_showPassword;
|
||||
});
|
||||
},
|
||||
)
|
||||
: null,
|
||||
),
|
||||
minLines: widget.lines ?? 1,
|
||||
maxLines: widget.lines ?? 1,
|
||||
maxLength: widget.length,
|
||||
onChanged: widget.onChanged ?? (_)=>{},
|
||||
)
|
||||
onChanged: widget.onChanged,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user