ente/lib/ui/settings/debug_section_widget.dart

95 lines
2.9 KiB
Dart
Raw Normal View History

2022-11-01 06:13:06 +00:00
import 'package:ente_auth/core/configuration.dart';
import 'package:ente_auth/l10n/l10n.dart';
2022-11-01 06:13:06 +00:00
import 'package:ente_auth/ui/settings/common_settings.dart';
import 'package:ente_auth/ui/settings/settings_section_title.dart';
import 'package:ente_auth/ui/settings/settings_text_item.dart';
import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sodium/flutter_sodium.dart';
class DebugSectionWidget extends StatelessWidget {
2023-04-10 04:17:45 +00:00
const DebugSectionWidget({super.key});
2022-11-01 06:13:06 +00:00
@override
Widget build(BuildContext context) {
// This is a debug only section not shown to end users, so these strings are
// not translated.
2022-11-01 06:13:06 +00:00
return ExpandablePanel(
header: const SettingsSectionTitle("Debug"),
collapsed: Container(),
expanded: _getSectionOptions(context),
2023-04-10 04:17:45 +00:00
theme: getExpandableTheme(),
2022-11-01 06:13:06 +00:00
);
}
Widget _getSectionOptions(BuildContext context) {
return Column(
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
_showKeyAttributesDialog(context);
},
child: const SettingsTextItem(
text: "Key attributes",
icon: Icons.navigate_next,
),
),
],
);
}
void _showKeyAttributesDialog(BuildContext context) {
final l10n = context.l10n;
2023-04-10 04:17:45 +00:00
final keyAttributes = Configuration.instance.getKeyAttributes()!;
2022-11-01 06:13:06 +00:00
final AlertDialog alert = AlertDialog(
title: const Text("key attributes"),
content: SingleChildScrollView(
child: Column(
children: [
const Text(
"Key",
style: TextStyle(fontWeight: FontWeight.bold),
),
2023-04-10 04:17:45 +00:00
Text(Sodium.bin2base64(Configuration.instance.getKey()!)),
2022-11-01 06:13:06 +00:00
const Padding(padding: EdgeInsets.all(12)),
const Text(
"Encrypted Key",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(keyAttributes.encryptedKey),
const Padding(padding: EdgeInsets.all(12)),
const Text(
"Key Decryption Nonce",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(keyAttributes.keyDecryptionNonce),
const Padding(padding: EdgeInsets.all(12)),
const Text(
"KEK Salt",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(keyAttributes.kekSalt),
const Padding(padding: EdgeInsets.all(12)),
],
),
),
actions: [
TextButton(
child: Text(l10n.ok),
2022-11-01 06:13:06 +00:00
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
),
],
);
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
}