Add more haptic feedback
This commit is contained in:
@@ -32,4 +32,10 @@ class HapticService extends _$HapticService {
|
||||
await HapticFeedback.mediumImpact();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> heavyImpact() async {
|
||||
if (state) {
|
||||
await HapticFeedback.heavyImpact();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,17 @@ class ConnectionNotifier extends _$ConnectionNotifier with AppLogger {
|
||||
}).run();
|
||||
}
|
||||
|
||||
ref.listenSelf(
|
||||
(previous, next) async {
|
||||
if (previous == next) return;
|
||||
if (previous case AsyncData(:final value) when !value.isConnected) {
|
||||
if (next case AsyncData(value: final Connected _)) {
|
||||
await ref.read(hapticServiceProvider.notifier).heavyImpact();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
activeProfileProvider.select((value) => value.asData?.value),
|
||||
(previous, next) async {
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:hiddify/core/haptic/haptic_service.dart';
|
||||
import 'package:hiddify/features/profile/data/profile_data_providers.dart';
|
||||
import 'package:hiddify/features/profile/data/profile_repository.dart';
|
||||
import 'package:hiddify/features/profile/model/profile_entity.dart';
|
||||
@@ -46,6 +47,7 @@ class ProfilesOverviewNotifier extends _$ProfilesOverviewNotifier
|
||||
|
||||
Future<Unit> selectActiveProfile(String id) async {
|
||||
loggy.debug('changing active profile to: [$id]');
|
||||
await ref.read(hapticServiceProvider.notifier).lightImpact();
|
||||
return _profilesRepo.setAsActive(id).getOrElse((err) {
|
||||
loggy.warning('failed to set [$id] as active profile', err);
|
||||
throw err;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:circle_flags/circle_flags.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hiddify/core/haptic/haptic_service.dart';
|
||||
import 'package:hiddify/core/localization/translations.dart';
|
||||
import 'package:hiddify/core/utils/ip_utils.dart';
|
||||
import 'package:hiddify/utils/riverpod_utils.dart';
|
||||
@@ -7,6 +8,11 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
final _showIp = StateProvider.autoDispose((ref) {
|
||||
ref.disposeDelay(const Duration(seconds: 20));
|
||||
ref.listenSelf((previous, next) {
|
||||
if (previous == false && next == true) {
|
||||
ref.read(hapticServiceProvider.notifier).mediumImpact();
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user