Implement password protection
This commit is contained in:
parent
52a0dd006f
commit
565ddb090f
7 changed files with 209 additions and 10 deletions
|
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart' as bg;
|
||||
import 'package:traccar_client/password_service.dart';
|
||||
import 'package:traccar_client/qr_code_screen.dart';
|
||||
import 'package:wakelock_partial_android/wakelock_partial_android.dart';
|
||||
|
||||
|
|
@ -83,6 +84,33 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> _changePassword() async {
|
||||
final controller = TextEditingController();
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(labelText: AppLocalizations.of(context)!.passwordLabel),
|
||||
obscureText: true,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: Text(AppLocalizations.of(context)!.cancelButton),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(AppLocalizations.of(context)!.saveButton),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (result == true) {
|
||||
await PasswordService.setPassword(controller.text);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildListTile(String title, String key, bool isInt) {
|
||||
String? value;
|
||||
if (isInt) {
|
||||
|
|
@ -201,6 +229,11 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||
setState(() {});
|
||||
},
|
||||
),
|
||||
if (advanced)
|
||||
ListTile(
|
||||
title: Text(AppLocalizations.of(context)!.passwordLabel),
|
||||
onTap: _changePassword,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue