- Changed window size to mobile phone format (400x800) - Removed width condition for ActiveProxyFooter - now always visible - Added run-umbrix.sh launch script with icon copying - Stats cards now display on all screen sizes
41 lines
1.0 KiB
Dart
41 lines
1.0 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:umbrix/core/preferences/preferences_provider.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
part 'haptic_service.g.dart';
|
|
|
|
@Riverpod(keepAlive: true)
|
|
class HapticService extends _$HapticService {
|
|
@override
|
|
bool build() {
|
|
return _preferences.getBool(hapticFeedbackPrefKey) ?? true;
|
|
}
|
|
|
|
static const String hapticFeedbackPrefKey = "haptic_feedback";
|
|
SharedPreferences get _preferences => ref.read(sharedPreferencesProvider).requireValue;
|
|
|
|
Future<void> updatePreference(bool value) async {
|
|
state = value;
|
|
await _preferences.setBool(hapticFeedbackPrefKey, value);
|
|
}
|
|
|
|
Future<void> lightImpact() async {
|
|
if (state) {
|
|
await HapticFeedback.lightImpact();
|
|
}
|
|
}
|
|
|
|
Future<void> mediumImpact() async {
|
|
if (state) {
|
|
await HapticFeedback.mediumImpact();
|
|
}
|
|
}
|
|
|
|
Future<void> heavyImpact() async {
|
|
if (state) {
|
|
await HapticFeedback.heavyImpact();
|
|
}
|
|
}
|
|
}
|