mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 11:18:41 +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';
|
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:flutter/material.dart';
|
||||||
import 'package:twonly/src/services/backup.identitiy.service.dart';
|
|
||||||
import 'package:twonly/src/utils/misc.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';
|
import 'package:twonly/src/views/settings/backup/twonly_identity_backup.view.dart';
|
||||||
|
|
||||||
class BackupView extends StatefulWidget {
|
class BackupView extends StatefulWidget {
|
||||||
|
|
@ -23,11 +23,14 @@ class _BackupViewState extends State<BackupView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future initAsync() async {
|
Future initAsync() async {
|
||||||
_twonlyIdBackupEnabled = await isIdentityBackupEnabled();
|
final user = await getUser();
|
||||||
_twonlyIdLastBackup = await getLastIdentityBackup();
|
if (user != null) {
|
||||||
|
_twonlyIdBackupEnabled = user.identityBackupEnabled;
|
||||||
|
_twonlyIdLastBackup = user.identityBackupLastBackupTime;
|
||||||
_dataBackupEnabled = false;
|
_dataBackupEnabled = false;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
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 {
|
class TwonlyIdentityBackupView extends StatefulWidget {
|
||||||
const TwonlyIdentityBackupView({super.key});
|
const TwonlyIdentityBackupView({super.key});
|
||||||
|
|
@ -9,18 +12,112 @@ class TwonlyIdentityBackupView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TwonlyIdentityBackupViewState extends State<TwonlyIdentityBackupView> {
|
class _TwonlyIdentityBackupViewState extends State<TwonlyIdentityBackupView> {
|
||||||
|
bool obscureText = true;
|
||||||
|
final TextEditingController passwordCtrl = TextEditingController();
|
||||||
|
final TextEditingController repeatedPasswordCtrl = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text("twonly Safe"),
|
title: Text("twonly Safe"),
|
||||||
|
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: ListView(
|
body: Padding(
|
||||||
|
padding: EdgeInsetsGeometry.symmetric(vertical: 40, horizontal: 40),
|
||||||
|
child: ListView(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
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).'),
|
"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