feat: add sentry

This commit is contained in:
problematicconsumer
2023-09-17 00:23:31 +03:30
parent 2668684f15
commit f4177da9f9
23 changed files with 205 additions and 332 deletions

View File

@@ -1,5 +1,6 @@
export 'app_update_notifier.dart';
export 'confirmation_dialogs.dart';
export 'custom_app_bar.dart';
export 'general_pref_tiles.dart';
export 'profile_tile.dart';
export 'qr_code_scanner_screen.dart';

View File

@@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:flutter_localized_locales/flutter_localized_locales.dart';
import 'package:go_router/go_router.dart';
import 'package:hiddify/core/core_providers.dart';
import 'package:hiddify/core/prefs/prefs.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
class LocalePrefTile extends HookConsumerWidget {
const LocalePrefTile({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final locale = ref.watch(localeNotifierProvider);
return ListTile(
title: Text(t.settings.general.locale),
subtitle: Text(
LocaleNamesLocalizationsDelegate.nativeLocaleNames[locale.name] ??
locale.name,
),
leading: const Icon(Icons.language),
onTap: () async {
final selectedLocale = await showDialog<AppLocale>(
context: context,
builder: (context) {
return SimpleDialog(
title: Text(t.settings.general.locale),
children: AppLocale.values
.map(
(e) => RadioListTile(
title: Text(
LocaleNamesLocalizationsDelegate
.nativeLocaleNames[e.name] ??
e.name,
),
value: e,
groupValue: locale,
onChanged: (e) => context.pop(e),
),
)
.toList(),
);
},
);
if (selectedLocale != null) {
await ref
.read(localeNotifierProvider.notifier)
.update(selectedLocale);
}
},
);
}
}
class EnableAnalyticsPrefTile extends HookConsumerWidget {
const EnableAnalyticsPrefTile({
super.key,
this.onChanged,
});
final ValueChanged<bool>? onChanged;
@override
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
final autoReport = ref.watch(enableAnalyticsProvider);
return SwitchListTile(
title: Text(t.settings.general.enableAnalytics),
subtitle: Text(
t.settings.general.enableAnalyticsMsg,
style: Theme.of(context).textTheme.bodySmall,
),
secondary: const Icon(Icons.bug_report),
value: autoReport,
onChanged: (value) async {
if (onChanged != null) {
return onChanged!(value);
}
return ref.read(enableAnalyticsProvider.notifier).update(value);
},
);
}
}