Add debug mode
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dartx/dartx.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
import 'package:hiddify/core/prefs/misc_prefs.dart';
|
||||
import 'package:hiddify/domain/clash/clash.dart';
|
||||
import 'package:hiddify/domain/failures.dart';
|
||||
import 'package:hiddify/features/common/common.dart';
|
||||
import 'package:hiddify/features/logs/notifier/notifier.dart';
|
||||
import 'package:hiddify/services/service_providers.dart';
|
||||
import 'package:hiddify/utils/utils.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:recase/recase.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
import 'package:tint/tint.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class LogsPage extends HookConsumerWidget {
|
||||
const LogsPage({super.key});
|
||||
@@ -21,6 +27,45 @@ class LogsPage extends HookConsumerWidget {
|
||||
final asyncState = ref.watch(logsNotifierProvider);
|
||||
final notifier = ref.watch(logsNotifierProvider.notifier);
|
||||
|
||||
final debug = ref.watch(debugModeProvider);
|
||||
|
||||
final List<PopupMenuEntry> popupButtons = debug || PlatformUtils.isDesktop
|
||||
? [
|
||||
PopupMenuItem(
|
||||
child: Text(t.logs.shareCoreLogs.sentenceCase),
|
||||
onTap: () async {
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await launchUrl(
|
||||
ref.read(filesEditorServiceProvider).logsDir.uri,
|
||||
);
|
||||
} else {
|
||||
final file = XFile(
|
||||
ref.read(filesEditorServiceProvider).coreLogsPath,
|
||||
mimeType: "text/plain",
|
||||
);
|
||||
await Share.shareXFiles([file]);
|
||||
}
|
||||
},
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Text(t.logs.shareAppLogs.sentenceCase),
|
||||
onTap: () async {
|
||||
if (Platform.isWindows || Platform.isLinux) {
|
||||
await launchUrl(
|
||||
ref.read(filesEditorServiceProvider).logsDir.uri,
|
||||
);
|
||||
} else {
|
||||
final file = XFile(
|
||||
ref.read(filesEditorServiceProvider).appLogsPath,
|
||||
mimeType: "text/plain",
|
||||
);
|
||||
await Share.shareXFiles([file]);
|
||||
}
|
||||
},
|
||||
),
|
||||
]
|
||||
: [];
|
||||
|
||||
switch (asyncState) {
|
||||
case AsyncData(value: final state):
|
||||
return Scaffold(
|
||||
@@ -28,6 +73,14 @@ class LogsPage extends HookConsumerWidget {
|
||||
// TODO: fix height
|
||||
toolbarHeight: 90,
|
||||
title: Text(t.logs.pageTitle.titleCase),
|
||||
actions: [
|
||||
if (popupButtons.isNotEmpty)
|
||||
PopupMenuButton(
|
||||
itemBuilder: (context) {
|
||||
return popupButtons;
|
||||
},
|
||||
),
|
||||
],
|
||||
bottom: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(36),
|
||||
child: Padding(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
import 'package:hiddify/core/prefs/misc_prefs.dart';
|
||||
import 'package:hiddify/domain/constants.dart';
|
||||
@@ -16,6 +17,7 @@ class MiscellaneousSettingTiles extends HookConsumerWidget {
|
||||
|
||||
final connectionTestUrl = ref.watch(connectionTestUrlProvider);
|
||||
final concurrentTestCount = ref.watch(concurrentTestCountProvider);
|
||||
final debug = ref.watch(debugModeProvider);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
@@ -37,7 +39,7 @@ class MiscellaneousSettingTiles extends HookConsumerWidget {
|
||||
subtitle: Text(concurrentTestCount.toString()),
|
||||
onTap: () async {
|
||||
final val = await SettingsInputDialog<int>(
|
||||
title: t.settings.miscellaneous.connectionTestUrl.titleCase,
|
||||
title: t.settings.miscellaneous.concurrentTestCount.titleCase,
|
||||
initialValue: concurrentTestCount,
|
||||
resetValue: Defaults.concurrentTestCount,
|
||||
mapTo: (value) => int.tryParse(value),
|
||||
@@ -47,6 +49,34 @@ class MiscellaneousSettingTiles extends HookConsumerWidget {
|
||||
await ref.read(concurrentTestCountProvider.notifier).update(val);
|
||||
},
|
||||
),
|
||||
SwitchListTile(
|
||||
title: Text(t.settings.miscellaneous.debugMode.titleCase),
|
||||
value: debug,
|
||||
onChanged: (value) async {
|
||||
if (value) {
|
||||
await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(t.settings.miscellaneous.debugMode.titleCase),
|
||||
content: Text(
|
||||
t.settings.miscellaneous.debugModeMsg.sentenceCase,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(true),
|
||||
child: Text(
|
||||
MaterialLocalizations.of(context).okButtonLabel,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
await ref.read(debugModeProvider.notifier).update(value);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user