import 'package:flutter/material.dart';
import 'package:prosapp_web_app/services/local_storage.dart';

class ThemeProvider extends ChangeNotifier {
  static const _key = 'dark_mode';

  ThemeMode _mode = ThemeMode.light;
  ThemeMode get mode => _mode;
  bool get isDark => _mode == ThemeMode.dark;

  ThemeProvider() {
    final saved = LocalStorage.prefs.getBool(_key) ?? false;
    _mode = saved ? ThemeMode.dark : ThemeMode.light;
  }

  void toggle() {
    _mode = isDark ? ThemeMode.light : ThemeMode.dark;
    LocalStorage.prefs.setBool(_key, isDark);
    notifyListeners();
  }
}
