import 'package:shared_preferences/shared_preferences.dart';

class SharedPreferencesHelper {
  static late SharedPreferences preferences;

  static Future<void> initial() async {
    preferences = await SharedPreferences.getInstance();
  }

  static const String themeMode = 'theme-mode';
  static const String token = 'auth_token';
}

class ThemeModeStorage {
  static String getMode() {
    final prefs = SharedPreferencesHelper.preferences;
    return prefs.getString(SharedPreferencesHelper.themeMode) ?? "system";
  }

  static void setMode(String mode) {
    final prefs = SharedPreferencesHelper.preferences;
    prefs.setString(SharedPreferencesHelper.themeMode, mode);
  }

  static void clearMode() {
    final prefs = SharedPreferencesHelper.preferences;
    prefs.remove(SharedPreferencesHelper.themeMode);
  }
}

class AuthTokenStorage {
  static String getToken() {
    final prefs = SharedPreferencesHelper.preferences;
    return prefs.getString(SharedPreferencesHelper.token) ?? "";
  }

  static void setToken(String token) {
    final prefs = SharedPreferencesHelper.preferences;
    prefs.setString(SharedPreferencesHelper.token, token);
  }

  static void clearToken() {
    final prefs = SharedPreferencesHelper.preferences;
    prefs.remove(SharedPreferencesHelper.token);
  }
}
