import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';

class SettingsProvider with ChangeNotifier {
  static const String _keyEnemyAnim = 'settings_enemy_anim';

  bool _enableEnemyAnimations = true; // Default: Enabled

  bool get enableEnemyAnimations => _enableEnemyAnimations;

  SettingsProvider() {
    _loadSettings();
  }

  Future<void> _loadSettings() async {
    final prefs = await SharedPreferences.getInstance();
    _enableEnemyAnimations = prefs.getBool(_keyEnemyAnim) ?? true;
    notifyListeners();
  }

  Future<void> toggleEnemyAnimations(bool value) async {
    _enableEnemyAnimations = value;
    notifyListeners();
    final prefs = await SharedPreferences.getInstance();
    await prefs.setBool(_keyEnemyAnim, value);
  }
}
