QRInput/Display for Batch Backups
This commit is contained in:
parent
c6ba763a83
commit
da0285f6c5
|
@ -63,3 +63,52 @@ Future<String?> pickDecodeQRImage() async {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
class QRDisplay extends StatelessWidget {
|
||||
final String label;
|
||||
final String value;
|
||||
QRDisplay(this.label, this.value);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = TextEditingController(text: value);
|
||||
return Row(children: [
|
||||
Expanded(child: TextFormField(decoration: InputDecoration(labelText: label), controller: c, readOnly: true)),
|
||||
IconButton(onPressed: () => _showQR(context), icon: Icon(Icons.qr_code))
|
||||
]);
|
||||
}
|
||||
|
||||
_showQR(BuildContext context) {
|
||||
showQR(context, value, label);
|
||||
}
|
||||
}
|
||||
|
||||
class QRInput extends StatefulWidget {
|
||||
final String label;
|
||||
final String? hint;
|
||||
final TextEditingController controller;
|
||||
QRInput(this.label, this.controller, { this.hint });
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => QRInputState();
|
||||
}
|
||||
|
||||
class QRInputState extends State<QRInput> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(children: [
|
||||
Expanded(child: TextFormField(decoration: InputDecoration(labelText: widget.label, hintText: widget.hint),
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
controller: widget.controller)),
|
||||
IconButton(onPressed: _scanQR, icon: Icon(Icons.qr_code))
|
||||
]);
|
||||
}
|
||||
|
||||
_scanQR() async {
|
||||
final code = await scanCode(context);
|
||||
if (code != null) {
|
||||
widget.controller.text = code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ import 'generated/l10n.dart';
|
|||
import 'main.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import 'qrscanner.dart';
|
||||
|
||||
class ResetPage extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ResetState();
|
||||
|
@ -85,12 +87,7 @@ class FullBackupState extends State<FullBackupPage> {
|
|||
appBar: AppBar(title: Text(s.fullBackup)),
|
||||
body: Card(
|
||||
child: Column(children: [
|
||||
TextField(
|
||||
decoration: InputDecoration(labelText: s.backupEncryptionKey),
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
controller: key,
|
||||
),
|
||||
QRInput(s.backupEncryptionKey, key, hint: 'age'),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 8)),
|
||||
ButtonBar(children: [
|
||||
ElevatedButton.icon(onPressed: _onGenerate, icon: Icon(Icons.key), label: Text('Generate')),
|
||||
|
@ -161,9 +158,10 @@ class AGEKeysState extends State<AGEKeysForm> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
return Form(child: SingleChildScrollView(child: Column(children: [
|
||||
TextFormField(decoration: InputDecoration(labelText: S.current.encryptionKey), controller: pk, readOnly: true),
|
||||
TextFormField(decoration: InputDecoration(labelText: S.current.secretKey), controller: sk, readOnly: true),
|
||||
QRDisplay(s.encryptionKey, widget.keys.pk),
|
||||
QRDisplay(s.secretKey, widget.keys.sk)
|
||||
])));
|
||||
}
|
||||
}
|
||||
|
@ -182,12 +180,7 @@ class _FullRestoreState extends State<FullRestorePage> {
|
|||
return Scaffold(
|
||||
appBar: AppBar(title: Text(s.fullRestore)),
|
||||
body: Card(child: Column(children: [
|
||||
TextField(
|
||||
decoration: InputDecoration(labelText: s.privateKey, hintText: 'AGE-SECRET-KEY-'),
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
controller: controller,
|
||||
),
|
||||
QRInput(s.secretKey, controller, hint: 'AGE-SECRET-KEY-'),
|
||||
Padding(padding: EdgeInsets.symmetric(vertical: 8)),
|
||||
ElevatedButton.icon(
|
||||
onPressed: _onLoad,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 880fd98729718c9fc64965f1f726b37c343f3bcf
|
||||
Subproject commit c1b4c88fe1f1816fc6373c37243912cd79f1a50c
|
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.3.1+373
|
||||
version: 1.3.2+374
|
||||
|
||||
environment:
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
|
Loading…
Reference in New Issue