import 'package:shared_preferences/shared_preferences.dart';

class SharedPrefs {
  static late SharedPreferences _sharedPrefs;

  factory SharedPrefs() => SharedPrefs._internal();

  SharedPrefs._internal();

  Future<void> init() async {
    _sharedPrefs = await SharedPreferences.getInstance();
  }

  /// get/set id_utilisateur
  int get id_utilisateur => _sharedPrefs.getInt('key_id_utilisateur') ?? 0;

  set id_utilisateur(int value) {
    _sharedPrefs.setInt('key_id_utilisateur', value);
  }

  /// get/set expire
  int get expire => _sharedPrefs.getInt('key_expire') ?? 0;

  set expire(int value) {
    _sharedPrefs.setInt('key_expire', value);
  }

  /// get/set email
  String get email => _sharedPrefs.getString('key_email') ?? "";

  set email(String value) {
    _sharedPrefs.setString('key_email', value);
  }

  /// get/set guid
  String get guid => _sharedPrefs.getString('key_guid') ?? "";

  set guid(String value) {
    _sharedPrefs.setString('key_guid', value);
  }

  /// get/set langage
  String get langage => _sharedPrefs.getString('key_langage') ?? "";

  set langage(String value) {
    _sharedPrefs.setString('key_langage', value);
  }

  /// get/set last_traduction
  String get last_traduction =>
      _sharedPrefs.getString('key_last_traduction') ?? "";

  set last_traduction(String value) {
    _sharedPrefs.setString('key_last_traduction', value);
  }

  /// get/set login
  String get login => _sharedPrefs.getString('key_login') ?? "";

  set login(String value) {
    _sharedPrefs.setString('key_login', value);
  }

  /// get/set nom
  String get nom => _sharedPrefs.getString('key_nom') ?? "";

  set nom(String value) {
    _sharedPrefs.setString('key_nom', value);
  }

  /// get/set prenom
  String get prenom => _sharedPrefs.getString('key_prenom') ?? "";

  set prenom(String value) {
    _sharedPrefs.setString('key_prenom', value);
  }

  /// get/set version
  String get version => _sharedPrefs.getString('key_version') ?? "";

  set version(String value) {
    _sharedPrefs.setString('key_version', value);
  }

  /// get/set photo
  String get photo => _sharedPrefs.getString('key_photo') ?? "";

  set photo(String value) {
    _sharedPrefs.setString('key_photo', value);
  }

  /// get/set last id_visite
  int get last_id_visite => _sharedPrefs.getInt('key_last_id_visite') ?? 0;

  set last_id_visite(int value) {
    _sharedPrefs.setInt('key_last_id_visite', value);
  }

  /// get/set isSimulator
  bool get isSimulator => _sharedPrefs.getBool('key_issimulator') ?? false;

  set isSimulator(bool value) {
    _sharedPrefs.setBool('key_issimulator', value);
  }

  /// get/set application's document directory
  String get documentsDir => _sharedPrefs.getString('documentsDir') ?? "";

  set documentsDir(String value) {
    _sharedPrefs.setString('documentsDir', value);
  }

  /// get/set application's photo directory
  String get photosDir => _sharedPrefs.getString('photosDir') ?? "";

  set photosDir(String value) {
    _sharedPrefs.setString('photosDir', value);
  }

  /// get/set url MP4
  String get urlMP4 => _sharedPrefs.getString('urlMP4') ?? "";

  set urlMP4(String value) {
    _sharedPrefs.setString('urlMP4', value);
  }

  /// get/set onboarding visualizaton
  int get onboarding => _sharedPrefs.getInt('key_onboarding') ?? 0;

  set onboarding(int value) {
    _sharedPrefs.setInt('key_onboarding', value);
  }

  /// Get/set last calendar refresh
  String get lastCalendarRefresh =>
      _sharedPrefs.getString('key_lastCalendarRefresh') ?? "";

  set lastCalendarRefresh(String value) {
    _sharedPrefs.setString('key_lastCalendarRefresh', value);
  }
}
