146 lines
4.5 KiB
Dart
146 lines
4.5 KiB
Dart
// @dart=2.9
|
|
|
|
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/ente_theme_data.dart';
|
|
import 'package:photos/services/ignored_files_service.dart';
|
|
import 'package:photos/services/local_sync_service.dart';
|
|
import 'package:photos/services/sync_service.dart';
|
|
import 'package:photos/ui/components/captioned_text_widget.dart';
|
|
import 'package:photos/ui/components/menu_item_widget.dart';
|
|
import 'package:photos/ui/settings/common_settings.dart';
|
|
import 'package:photos/ui/settings/settings_text_item.dart';
|
|
import 'package:photos/utils/toast_util.dart';
|
|
|
|
class DebugSectionWidget extends StatefulWidget {
|
|
const DebugSectionWidget({Key key}) : super(key: key);
|
|
|
|
@override
|
|
State<DebugSectionWidget> createState() => _DebugSectionWidgetState();
|
|
}
|
|
|
|
class _DebugSectionWidgetState extends State<DebugSectionWidget> {
|
|
final expandableController = ExpandableController(initialExpanded: false);
|
|
|
|
@override
|
|
void dispose() {
|
|
expandableController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ExpandablePanel(
|
|
header: MenuItemWidget(
|
|
captionedTextWidget: const CaptionedTextWidget(
|
|
text: "Debug",
|
|
),
|
|
isHeaderOfExpansion: true,
|
|
leadingIcon: Icons.bug_report_outlined,
|
|
trailingIcon: Icons.expand_more,
|
|
menuItemColor:
|
|
Theme.of(context).colorScheme.enteTheme.colorScheme.fillFaint,
|
|
expandableController: expandableController,
|
|
),
|
|
collapsed: const SizedBox.shrink(),
|
|
expanded: _getSectionOptions(context),
|
|
theme: getExpandableTheme(context),
|
|
controller: expandableController,
|
|
);
|
|
}
|
|
|
|
Widget _getSectionOptions(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
sectionOptionDivider,
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.translucent,
|
|
onTap: () async {
|
|
_showKeyAttributesDialog(context);
|
|
},
|
|
child: const SettingsTextItem(
|
|
text: "Key attributes",
|
|
icon: Icons.navigate_next,
|
|
),
|
|
),
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.translucent,
|
|
onTap: () async {
|
|
await LocalSyncService.instance.resetLocalSync();
|
|
showToast(context, "Done");
|
|
},
|
|
child: const SettingsTextItem(
|
|
text: "Delete Local Import DB",
|
|
icon: Icons.navigate_next,
|
|
),
|
|
),
|
|
GestureDetector(
|
|
behavior: HitTestBehavior.translucent,
|
|
onTap: () async {
|
|
await IgnoredFilesService.instance.reset();
|
|
SyncService.instance.sync();
|
|
showToast(context, "Done");
|
|
},
|
|
child: const SettingsTextItem(
|
|
text: "Allow auto-upload for ignored files",
|
|
icon: Icons.navigate_next,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
void _showKeyAttributesDialog(BuildContext context) {
|
|
final keyAttributes = Configuration.instance.getKeyAttributes();
|
|
final AlertDialog alert = AlertDialog(
|
|
title: const Text("key attributes"),
|
|
content: SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
const Text(
|
|
"Key",
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
Text(Sodium.bin2base64(Configuration.instance.getKey())),
|
|
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: const Text("OK"),
|
|
onPressed: () {
|
|
Navigator.of(context, rootNavigator: true).pop('dialog');
|
|
},
|
|
),
|
|
],
|
|
);
|
|
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return alert;
|
|
},
|
|
);
|
|
}
|
|
}
|