mirror of
https://github.com/koloideal/Casha.git
synced 2026-06-10 18:35:28 +03:00
update
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class HapticService {
|
||||
static const _key = 'haptic_enabled';
|
||||
static bool _enabled = true; // runtime cache
|
||||
|
||||
static Future<void> init() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_enabled = prefs.getBool(_key) ?? true;
|
||||
}
|
||||
|
||||
static bool get isEnabled => _enabled;
|
||||
|
||||
static Future<void> setEnabled(bool value) async {
|
||||
_enabled = value;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_key, value);
|
||||
}
|
||||
|
||||
// Light tap — filter chips, toggles, small interactions
|
||||
static void light() {
|
||||
if (!_enabled) return;
|
||||
HapticFeedback.lightImpact();
|
||||
}
|
||||
|
||||
// Medium — confirm button, apply, save
|
||||
static void medium() {
|
||||
if (!_enabled) return;
|
||||
HapticFeedback.mediumImpact();
|
||||
}
|
||||
|
||||
// Heavy — long press on balance card
|
||||
static void heavy() {
|
||||
if (!_enabled) return;
|
||||
HapticFeedback.heavyImpact();
|
||||
}
|
||||
|
||||
// Selection click — switching tabs, filter chips
|
||||
static void selection() {
|
||||
if (!_enabled) return;
|
||||
HapticFeedback.selectionClick();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user