ente/lib/ui/settings/debug_section_widget.dart

101 lines
3 KiB
Dart
Raw Normal View History

import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_sodium/flutter_sodium.dart';
import 'package:photos/core/configuration.dart';
import 'package:photos/core/network.dart';
import 'package:photos/ui/settings/common_settings.dart';
import 'package:photos/ui/settings/settings_section_title.dart';
import 'package:photos/ui/settings/settings_text_item.dart';
class DebugSectionWidget extends StatelessWidget {
const DebugSectionWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ExpandablePanel(
2022-07-04 06:02:17 +00:00
header: const SettingsSectionTitle("Debug"),
collapsed: Container(),
expanded: _getSectionOptions(context),
theme: getExpandableTheme(context),
);
}
Widget _getSectionOptions(BuildContext context) {
2022-06-11 08:23:52 +00:00
return Column(
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
_showKeyAttributesDialog(context);
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(
2022-07-03 06:56:43 +00:00
text: "Key attributes",
icon: Icons.navigate_next,
),
2022-06-11 08:23:52 +00:00
),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
Network.instance.getAlice().showInspector();
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(
2022-06-11 08:23:52 +00:00
text: "Network requests",
icon: Icons.navigate_next,
),
)
],
);
}
void _showKeyAttributesDialog(BuildContext context) {
final keyAttributes = Configuration.instance.getKeyAttributes();
2022-08-29 14:43:31 +00:00
final AlertDialog alert = AlertDialog(
2022-07-04 06:02:17 +00:00
title: const Text("key attributes"),
content: SingleChildScrollView(
2022-06-11 08:23:52 +00:00
child: Column(
children: [
2022-07-04 06:02:17 +00:00
const Text(
"Key",
style: TextStyle(fontWeight: FontWeight.bold),
),
2022-06-11 08:23:52 +00:00
Text(Sodium.bin2base64(Configuration.instance.getKey())),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(12)),
const Text(
2022-07-03 10:09:01 +00:00
"Encrypted Key",
style: TextStyle(fontWeight: FontWeight.bold),
),
2022-06-11 08:23:52 +00:00
Text(keyAttributes.encryptedKey),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(12)),
const Text(
2022-06-11 08:23:52 +00:00
"Key Decryption Nonce",
style: TextStyle(fontWeight: FontWeight.bold),
),
Text(keyAttributes.keyDecryptionNonce),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(12)),
const Text(
"KEK Salt",
style: TextStyle(fontWeight: FontWeight.bold),
),
2022-06-11 08:23:52 +00:00
Text(keyAttributes.kekSalt),
2022-07-04 06:02:17 +00:00
const Padding(padding: EdgeInsets.all(12)),
2022-06-11 08:23:52 +00:00
],
),
),
actions: [
TextButton(
2022-07-04 06:02:17 +00:00
child: const Text("OK"),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop('dialog');
},
),
],
);
showDialog(
context: context,
builder: (BuildContext context) {
return alert;
},
);
}
}