Files
umbrix/lib/features/connection/widget/experimental_feature_notice.dart

85 lines
2.9 KiB
Dart
Raw Normal View History

2024-03-08 17:15:17 +03:30
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/foundation.dart';
2023-12-31 10:28:52 +03:30
import 'package:flutter/material.dart';
2024-03-08 17:15:17 +03:30
import 'package:gap/gap.dart';
2023-12-31 10:28:52 +03:30
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/core/router/routes.dart';
2024-03-08 17:15:17 +03:30
import 'package:hiddify/core/utils/preferences_utils.dart';
2023-12-31 10:28:52 +03:30
import 'package:hooks_riverpod/hooks_riverpod.dart';
2024-03-08 17:15:17 +03:30
bool _testExperimentalNotice = false;
2023-12-31 10:28:52 +03:30
2024-03-08 17:15:17 +03:30
final disableExperimentalFeatureNoticeProvider =
PreferencesNotifier.createAutoDispose(
"disable_experimental_feature_notice",
false,
overrideValue: _testExperimentalNotice && kDebugMode ? false : null,
);
2023-12-31 10:28:52 +03:30
class ExperimentalFeatureNoticeDialog extends HookConsumerWidget {
const ExperimentalFeatureNoticeDialog({super.key});
Future<bool?> show(BuildContext context) async {
return showDialog<bool>(
context: context,
builder: (context) => this,
);
}
@override
Widget build(BuildContext context, WidgetRef ref) {
final t = ref.watch(translationsProvider);
2024-03-08 17:15:17 +03:30
final disableNotice = ref.watch(disableExperimentalFeatureNoticeProvider);
2023-12-31 10:28:52 +03:30
2024-03-08 17:15:17 +03:30
return AlertDialog(
title: Text(t.home.connection.experimentalNotice),
content: SingleChildScrollView(
child: SizedBox(
width: 468,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(t.home.connection.experimentalNoticeMsg),
const Gap(8),
CheckboxListTile(
value: disableNotice,
title: Text(t.home.connection.disableExperimentalNotice),
secondary: const Icon(FluentIcons.eye_off_24_regular),
onChanged: (value) async => ref
.read(disableExperimentalFeatureNoticeProvider.notifier)
.update(value ?? false),
dense: true,
),
ListTile(
title: Text(t.settings.config.pageTitle),
leading: const Icon(FluentIcons.box_edit_24_regular),
trailing: const Icon(FluentIcons.chevron_right_20_regular),
onTap: () async {
await Navigator.of(context).maybePop(false);
if (context.mounted) {
const ConfigOptionsRoute().push(context);
}
},
dense: true,
),
],
2023-12-31 10:28:52 +03:30
),
),
),
2024-03-08 17:15:17 +03:30
actions: [
TextButton(
onPressed: () => Navigator.of(context).maybePop(false),
child: Text(
MaterialLocalizations.of(context).cancelButtonLabel.toUpperCase(),
),
),
TextButton(
onPressed: () => Navigator.of(context).maybePop(true),
child: Text(t.home.connection.connectAnyWay.toUpperCase()),
),
],
2023-12-31 10:28:52 +03:30
);
}
}