import 'package:get/get.dart';
import 'package:guru_utils/controller/lifecycle_controller.dart';
import 'package:guru_utils/audio/audio_effector.dart';
import 'package:guru_utils/vibration/vibrate_utils.dart';
import 'package:guru_utils/vibration/vibrate_model.dart';

import 'settings_model.dart';

class SettingsController extends LifecycleController {
  final SettingsModel model = SettingsModel();


  void switchSounds(bool value) {
    final effect = value ? SoundEffect.on : SoundEffect.off;
    if (effect == SoundEffect.on) {
      // GuruSettings.instance.soundEffect.set(SoundEffect.off);
      // GuruAnalytics.instance.logEventEx("sound_clk", itemCategory: "off", itemName: "settings");
      AudioEffector.soundEffect = SoundEffect.off;
    } else {
      // GuruSettings.instance.soundEffect.set(SoundEffect.on);
      // GuruAnalytics.instance.logEventEx("sound_clk", itemCategory: "on", itemName: "settings");
      AudioEffector.soundEffect = SoundEffect.on;
    }
  }

  void switchVibration(bool value) {
    final effect = value ? VibrationState.on : VibrationState.off;
    if (effect == SoundEffect.on) {
      VibrateUtils.disableVibrate();
      // GuruSettings.instance.vibration.set(VibrationState.off);
      // GuruAnalytics.instance.logEventEx("vibration_clk", itemCategory: "off", itemName: "settings");
    } else {
      VibrateUtils.enableVibrate();
      // GuruSettings.instance.vibration.set(VibrationState.on);
      // GuruAnalytics.instance.logEventEx("vibration_clk", itemCategory: "on", itemName: "settings");
    }
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }
}
