Add toggle button to show or hide password in MapSurveyView Settings page

This commit is contained in:
torok.istvan 2025-09-11 08:56:17 +02:00
parent a3b2deec21
commit 057f4a4809
2 changed files with 52 additions and 17 deletions

View File

@ -108,7 +108,8 @@ class MapSurveyController extends GetxController {
Rx<bool> pointMeasuringDirectionForward = true.obs; Rx<bool> pointMeasuringDirectionForward = true.obs;
Rx<bool> isShowPassword = true.obs; Rx<bool> isShowPassword = false.obs;
final passwordFieldFocusNode = FocusNode();
List<PointWithDescription> pointWithDescriptionList = []; List<PointWithDescription> pointWithDescriptionList = [];
late Directory? directory; late Directory? directory;
@ -843,4 +844,10 @@ class MapSurveyController extends GetxController {
} }
void updatePointStatus(int pointId) {} void updatePointStatus(int pointId) {}
void toggleShowPassword() {
isShowPassword.value = !isShowPassword.value;
if (passwordFieldFocusNode.hasPrimaryFocus) return;
passwordFieldFocusNode.canRequestFocus = false;
}
} }

View File

@ -330,26 +330,54 @@ class SettingsDialog extends StatelessWidget {
height: 40, height: 40,
child: TextField( child: TextField(
controller: controller.ntripUsernameController, controller: controller.ntripUsernameController,
decoration: const InputDecoration( enableSuggestions: false,
border: OutlineInputBorder(), autocorrect: false,
decoration: InputDecoration(
floatingLabelBehavior: FloatingLabelBehavior.never,
isDense: true,
filled: true,
fillColor: Colors.grey.shade300,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(12)),
labelText: 'Felhasználónév', labelText: 'Felhasználónév',
icon: Icon(Icons.account_circle_rounded)), prefixIcon: Icon(Icons.account_circle_rounded)),
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
SizedBox( Obx(
height: 40, () => SizedBox(
child: TextField( height: 40,
obscureText: true, child: TextField(
enableSuggestions: false, keyboardType: TextInputType.visiblePassword,
autocorrect: false, obscureText: controller.isShowPassword.value,
controller: controller.ntripPasswordController, focusNode: controller.passwordFieldFocusNode,
decoration: const InputDecoration( enableSuggestions: false,
border: OutlineInputBorder(), autocorrect: false,
labelText: 'Jelszó', controller: controller.ntripPasswordController,
icon: Icon( decoration: InputDecoration(
Icons.lock, floatingLabelBehavior: FloatingLabelBehavior.never,
)), isDense: true,
filled: true,
fillColor: Colors.grey.shade300,
border: OutlineInputBorder(
borderSide: BorderSide.none,
borderRadius: BorderRadius.circular(12)),
labelText: 'Jelszó',
prefixIcon: Icon(
Icons.lock_rounded,
size: 24,
),
suffixIcon: Padding(
padding: const EdgeInsets.fromLTRB(0, 0, 4, 0),
child: GestureDetector(
onTap: controller.toggleShowPassword,
child: Icon(
controller.isShowPassword.value
? Icons.visibility_rounded
: Icons.visibility_off_rounded,
size: 24)))),
),
), ),
), ),
const SizedBox(height: 20) const SizedBox(height: 20)