import 'package:vibration/vibration.dart';

class HapticService {
  Future<bool> get _hasVibrator async => Vibration.hasVibrator();

  Future<void> obstacleVeryClose() async {
    if (!await _hasVibrator) return;
    Vibration.vibrate(pattern: [0, 500, 100, 500, 100, 500]);
  }

  Future<void> obstacleClose() async {
    if (!await _hasVibrator) return;
    Vibration.vibrate(pattern: [0, 300, 100, 300]);
  }

  Future<void> obstacleMedium() async {
    if (!await _hasVibrator) return;
    Vibration.vibrate(duration: 150);
  }

  Future<void> sosTriggered() async {
    if (!await _hasVibrator) return;
    Vibration.vibrate(pattern: [0, 1000, 200, 1000, 200, 1000]);
  }

  Future<void> callIncoming() async {
    if (!await _hasVibrator) return;
    Vibration.vibrate(pattern: [0, 500, 500, 500, 500, 500, 500, 500]);
  }

  Future<void> success() async {
    if (!await _hasVibrator) return;
    Vibration.vibrate(duration: 80);
  }

  Future<void> stop() async => Vibration.cancel();
}
