import 'package:flutter_riverpod/flutter_riverpod.dart';

import 'providers.dart';

/// SFX + gameplay haptics on/off, seeded from the save repository.
class SoundEnabledNotifier extends Notifier<bool> {
  @override
  bool build() => ref.read(saveRepositoryProvider).soundEnabled;

  Future<void> toggle() => set(!state);

  Future<void> set(bool value) async {
    if (state == value) return;
    await ref.read(saveRepositoryProvider).setSoundEnabled(value);
    state = value;
  }
}
