Initial commit
This commit is contained in:
82
lib/widgets/widget_text_fields.dart
Normal file
82
lib/widgets/widget_text_fields.dart
Normal file
@@ -0,0 +1,82 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hum/core/constants/app_theme.dart';
|
||||
|
||||
class TXTFieldInput
|
||||
extends
|
||||
StatefulWidget {
|
||||
const TXTFieldInput({
|
||||
super.key,
|
||||
this.placeholder = '',
|
||||
this.inputType = TextInputType.text,
|
||||
this.password = false,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
final String placeholder;
|
||||
final TextInputType inputType;
|
||||
final bool password;
|
||||
final TextEditingController controller;
|
||||
// final ValueKey fieldId;
|
||||
|
||||
@override
|
||||
State<
|
||||
TXTFieldInput
|
||||
>
|
||||
createState() => _TXTFieldInputState();
|
||||
}
|
||||
|
||||
class _TXTFieldInputState
|
||||
extends
|
||||
State<
|
||||
TXTFieldInput
|
||||
> {
|
||||
bool _obscure = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_obscure = widget.password
|
||||
? true
|
||||
: false;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(
|
||||
BuildContext context,
|
||||
) {
|
||||
return CupertinoTextField(
|
||||
controller: widget.controller,
|
||||
key: widget.key,
|
||||
placeholder: widget.placeholder,
|
||||
keyboardType: widget.inputType,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: 12,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoDynamicColor.resolve(
|
||||
colorBackground,
|
||||
context,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
roundLarge,
|
||||
),
|
||||
),
|
||||
|
||||
obscureText: _obscure,
|
||||
suffix: widget.password
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => setState(
|
||||
() => _obscure = !_obscure,
|
||||
),
|
||||
child: Icon(
|
||||
_obscure
|
||||
? CupertinoIcons.eye
|
||||
: CupertinoIcons.eye_slash,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user