Add reconnect alert for config options

This commit is contained in:
problematicconsumer
2024-03-03 14:03:36 +03:30
parent 45fbe76c6e
commit 60db9a2239
6 changed files with 202 additions and 1 deletions

View File

@@ -1,5 +1,9 @@
import 'package:flutter/material.dart';
import 'package:hiddify/core/localization/translations.dart';
import 'package:hiddify/core/notification/in_app_notification_controller.dart';
import 'package:hiddify/features/config_option/notifier/config_option_notifier.dart';
import 'package:hiddify/features/connection/notifier/connection_notifier.dart';
import 'package:hiddify/features/profile/notifier/active_profile_notifier.dart';
import 'package:hiddify/utils/custom_loggers.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
@@ -19,6 +23,21 @@ class _ConnectionWrapperState extends ConsumerState<ConnectionWrapper>
Widget build(BuildContext context) {
ref.listen(connectionNotifierProvider, (_, __) {});
ref.listen(configOptionNotifierProvider, (previous, next) {
if (next case AsyncData(value: true)) {
final t = ref.read(translationsProvider);
ref.watch(inAppNotificationControllerProvider).showActionToast(
t.settings.config.reconnectMsg,
actionText: t.settings.config.reconnectBtn,
callback: () async {
await ref
.read(connectionNotifierProvider.notifier)
.reconnect(await ref.read(activeProfileProvider.future));
},
);
}
});
return widget.child;
}