fixed MasterDataPage buttons
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/theme/theme.dart';
|
||||
|
||||
class FluxTextField extends StatelessWidget {
|
||||
class FluxTextField extends StatefulWidget {
|
||||
final String label;
|
||||
final IconData icon;
|
||||
final bool isPassword;
|
||||
@@ -30,20 +30,38 @@ class FluxTextField extends StatelessWidget {
|
||||
this.maxLength,
|
||||
});
|
||||
|
||||
@override
|
||||
State<FluxTextField> createState() => _FluxTextFieldState();
|
||||
}
|
||||
|
||||
class _FluxTextFieldState extends State<FluxTextField> {
|
||||
late bool _obscureText;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_obscureText = widget.isPassword;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
controller: controller,
|
||||
obscureText: isPassword,
|
||||
keyboardType: keyboardType,
|
||||
autofocus: autoFocus,
|
||||
minLines: minLines,
|
||||
controller: widget.controller,
|
||||
obscureText: _obscureText,
|
||||
enableSuggestions: !widget.isPassword,
|
||||
autocorrect: !widget.isPassword,
|
||||
keyboardType: widget.keyboardType,
|
||||
autofocus: widget.autoFocus,
|
||||
minLines: widget.minLines,
|
||||
// Se minLines è impostato, maxLines deve essere almeno uguale o null (espandibile)
|
||||
maxLines: minLines != null ? null : maxLines,
|
||||
maxLines: widget.minLines != null ? null : widget.maxLines,
|
||||
style: TextStyle(color: context.primaryText),
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Icon(icon, color: context.accent.withValues(alpha: 0.6)),
|
||||
labelText: label,
|
||||
prefixIcon: Icon(
|
||||
widget.icon,
|
||||
color: context.accent.withValues(alpha: 0.6),
|
||||
),
|
||||
labelText: widget.label,
|
||||
labelStyle: TextStyle(color: context.secondaryText, fontSize: 14),
|
||||
filled: true,
|
||||
fillColor: context.surface.withValues(alpha: 0.5),
|
||||
@@ -61,10 +79,25 @@ class FluxTextField extends StatelessWidget {
|
||||
horizontal: 16,
|
||||
vertical: 16,
|
||||
),
|
||||
suffixIcon: widget.isPassword
|
||||
? IconButton(
|
||||
icon: Icon(
|
||||
// Cambiamo icona in base allo stato
|
||||
_obscureText ? Icons.visibility_off : Icons.visibility,
|
||||
color: Colors.grey,
|
||||
),
|
||||
onPressed: () {
|
||||
// Quando l'utente clicca, invertiamo lo stato e ridisegniamo
|
||||
setState(() {
|
||||
_obscureText = !_obscureText;
|
||||
});
|
||||
},
|
||||
)
|
||||
: null, // Se non è una password, niente icona
|
||||
),
|
||||
onSubmitted: onSubmitted,
|
||||
onChanged: onChanged,
|
||||
maxLength: maxLength,
|
||||
onSubmitted: widget.onSubmitted,
|
||||
onChanged: widget.onChanged,
|
||||
maxLength: widget.maxLength,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user