mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 07:48:40 +00:00
add input fields #121
This commit is contained in:
parent
20030ccd14
commit
9fc62acab6
3 changed files with 110 additions and 29 deletions
|
|
@ -1,20 +1 @@
|
|||
import 'package:twonly/src/utils/storage.dart';
|
||||
|
||||
Future<bool> isIdentityBackupEnabled() async {
|
||||
final user = await getUser();
|
||||
if (user == null) return false;
|
||||
return user.identityBackupEnabled;
|
||||
}
|
||||
|
||||
Future<DateTime?> getLastIdentityBackup() async {
|
||||
final user = await getUser();
|
||||
if (user == null) return null;
|
||||
return user.identityBackupLastBackupTime;
|
||||
}
|
||||
|
||||
Future enableIdentityBackup() async {
|
||||
await updateUserdata((user) {
|
||||
user.identityBackupEnabled = false;
|
||||
return user;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:twonly/src/services/backup.identitiy.service.dart';
|
||||
import 'package:twonly/src/utils/misc.dart';
|
||||
import 'package:twonly/src/utils/storage.dart';
|
||||
import 'package:twonly/src/views/settings/backup/twonly_identity_backup.view.dart';
|
||||
|
||||
class BackupView extends StatefulWidget {
|
||||
|
|
@ -23,10 +23,13 @@ class _BackupViewState extends State<BackupView> {
|
|||
}
|
||||
|
||||
Future initAsync() async {
|
||||
_twonlyIdBackupEnabled = await isIdentityBackupEnabled();
|
||||
_twonlyIdLastBackup = await getLastIdentityBackup();
|
||||
_dataBackupEnabled = false;
|
||||
setState(() {});
|
||||
final user = await getUser();
|
||||
if (user != null) {
|
||||
_twonlyIdBackupEnabled = user.identityBackupEnabled;
|
||||
_twonlyIdLastBackup = user.identityBackupLastBackupTime;
|
||||
_dataBackupEnabled = false;
|
||||
setState(() {});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:twonly/src/utils/misc.dart';
|
||||
import 'package:twonly/src/views/components/alert_dialog.dart';
|
||||
|
||||
class TwonlyIdentityBackupView extends StatefulWidget {
|
||||
const TwonlyIdentityBackupView({super.key});
|
||||
|
|
@ -9,18 +12,112 @@ class TwonlyIdentityBackupView extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _TwonlyIdentityBackupViewState extends State<TwonlyIdentityBackupView> {
|
||||
bool obscureText = true;
|
||||
final TextEditingController passwordCtrl = TextEditingController();
|
||||
final TextEditingController repeatedPasswordCtrl = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("twonly Safe"),
|
||||
),
|
||||
body: ListView(
|
||||
children: [
|
||||
Text(
|
||||
'Backup of your twonly-Identity. As twonly does not have any second factor like your phone number or email, this backup contains your twonly-Identity. If you lose your device, the only option to recover is with the twonly-ID Backup. This backup will be protected by a password chosen by you in the next step and anonymously uploaded to the twonly servers. Read more [here](https://twonly.eu/s/backup).'),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showAlertDialog(context, "twonly Safe",
|
||||
"Backup of your twonly-Identity. As twonly does not have any second factor like your phone number or email, this backup contains your twonly-Identity. If you lose your device, the only option to recover is with the twonly-ID Backup. This backup will be protected by a password chosen by you in the next step and anonymously uploaded to the twonly servers. Read more [here](https://twonly.eu/s/backup)");
|
||||
},
|
||||
icon: FaIcon(FontAwesomeIcons.circleInfo),
|
||||
iconSize: 18,
|
||||
)
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(vertical: 40, horizontal: 40),
|
||||
child: ListView(
|
||||
children: [
|
||||
Text(
|
||||
"Wähle ein sicheres Passwort. Dieses wird benötigt, wenn du dein twonly Safe-Backup wiederherstellen möchtest.",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Stack(
|
||||
children: [
|
||||
TextField(
|
||||
controller: passwordCtrl,
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
// usernameController.text = value.toLowerCase();
|
||||
// usernameController.selection = TextSelection.fromPosition(
|
||||
// TextPosition(offset: usernameController.text.length),
|
||||
// );
|
||||
},
|
||||
style: TextStyle(fontSize: 17),
|
||||
obscureText: obscureText,
|
||||
decoration: getInputDecoration(
|
||||
context,
|
||||
"Password",
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
obscureText = !obscureText;
|
||||
});
|
||||
},
|
||||
icon: FaIcon(
|
||||
obscureText
|
||||
? FontAwesomeIcons.eye
|
||||
: FontAwesomeIcons.eyeSlash,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsGeometry.all(5),
|
||||
child: Text(
|
||||
(passwordCtrl.text.length <= 10 && passwordCtrl.text.isNotEmpty)
|
||||
? "Passwort muss mind. 10 Zeichen lang sein."
|
||||
: "",
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
TextField(
|
||||
controller: repeatedPasswordCtrl,
|
||||
onChanged: (value) {
|
||||
setState(() {});
|
||||
// usernameController.text = value.toLowerCase();
|
||||
// usernameController.selection = TextSelection.fromPosition(
|
||||
// TextPosition(offset: usernameController.text.length),
|
||||
// );
|
||||
},
|
||||
style: TextStyle(fontSize: 17),
|
||||
obscureText: true,
|
||||
decoration: getInputDecoration(
|
||||
context,
|
||||
"Passwordwiederholung",
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsGeometry.all(5),
|
||||
child: Text(
|
||||
(passwordCtrl.text != repeatedPasswordCtrl.text &&
|
||||
repeatedPasswordCtrl.text.isNotEmpty)
|
||||
? "Passwörter stimmen nicht überein."
|
||||
: "",
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue