2026-02-13 19:46:02 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
Widget roundedInput({
|
|
|
|
|
required TextEditingController controller,
|
|
|
|
|
required String hint,
|
|
|
|
|
required IconData icon,
|
|
|
|
|
bool isPassword = false,
|
2026-02-14 10:16:13 +00:00
|
|
|
String? Function(String?)? validator,
|
2026-02-13 19:46:02 +00:00
|
|
|
}) {
|
|
|
|
|
return RoundedInput(
|
|
|
|
|
controller: controller,
|
|
|
|
|
hint: hint,
|
|
|
|
|
icon: icon,
|
|
|
|
|
isPassword: isPassword,
|
2026-02-14 10:16:13 +00:00
|
|
|
validator: validator,
|
2026-02-13 19:46:02 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RoundedInput extends StatefulWidget {
|
|
|
|
|
const RoundedInput({
|
|
|
|
|
super.key,
|
|
|
|
|
required this.controller,
|
|
|
|
|
required this.hint,
|
|
|
|
|
required this.icon,
|
|
|
|
|
this.isPassword = false,
|
2026-02-14 10:16:13 +00:00
|
|
|
this.validator,
|
2026-02-13 19:46:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
final TextEditingController controller;
|
|
|
|
|
final String hint;
|
|
|
|
|
final IconData icon;
|
|
|
|
|
final bool isPassword;
|
2026-02-14 10:16:13 +00:00
|
|
|
final String? Function(String?)? validator;
|
2026-02-13 19:46:02 +00:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<RoundedInput> createState() => _RoundedInputState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _RoundedInputState extends State<RoundedInput> {
|
|
|
|
|
late bool _obscured;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_obscured = widget.isPassword;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2026-02-14 10:16:13 +00:00
|
|
|
return TextFormField(
|
2026-02-13 19:46:02 +00:00
|
|
|
controller: widget.controller,
|
|
|
|
|
obscureText: _obscured,
|
2026-02-14 10:16:13 +00:00
|
|
|
validator: widget.validator,
|
2026-02-13 19:46:02 +00:00
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: widget.hint,
|
|
|
|
|
prefixIcon: Icon(widget.icon, color: Colors.grey),
|
|
|
|
|
suffixIcon: widget.isPassword
|
|
|
|
|
? IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() {
|
|
|
|
|
_obscured = !_obscured;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
icon: Icon(
|
|
|
|
|
_obscured ? Icons.visibility : Icons.visibility_off,
|
|
|
|
|
color: Colors.grey,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
filled: true,
|
|
|
|
|
fillColor: const Color(0xFFE9EEF3),
|
|
|
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 16),
|
|
|
|
|
border: OutlineInputBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(30),
|
|
|
|
|
borderSide: BorderSide.none,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|