mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-14 02:12:21 -06:00
Initial commit
This commit is contained in:
53
lib/features/login/view/widgets/password_text_field.dart
Normal file
53
lib/features/login/view/widgets/password_text_field.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ObscuredInputTextFormField extends StatefulWidget {
|
||||
final String? initialValue;
|
||||
final String label;
|
||||
final void Function(String?) onChanged;
|
||||
final FormFieldValidator<String>? validator;
|
||||
|
||||
const ObscuredInputTextFormField({
|
||||
super.key,
|
||||
required this.onChanged,
|
||||
required this.label,
|
||||
this.validator,
|
||||
this.initialValue,
|
||||
});
|
||||
|
||||
@override
|
||||
State<ObscuredInputTextFormField> createState() => _ObscuredInputTextFormFieldState();
|
||||
}
|
||||
|
||||
class _ObscuredInputTextFormFieldState extends State<ObscuredInputTextFormField> {
|
||||
bool _showPassword = false;
|
||||
final FocusNode _passwordFocusNode = FocusNode();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_passwordFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: widget.validator,
|
||||
initialValue: widget.initialValue,
|
||||
focusNode: _passwordFocusNode,
|
||||
obscureText: !_showPassword,
|
||||
autocorrect: false,
|
||||
onChanged: widget.onChanged,
|
||||
autofillHints: const [AutofillHints.password],
|
||||
decoration: InputDecoration(
|
||||
label: Text(widget.label),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_showPassword ? Icons.visibility_off : Icons.visibility),
|
||||
onPressed: () => setState(() {
|
||||
_showPassword = !_showPassword;
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user