import 'package:get/get.dart';

class Params {
  static dynamic params;
  static late String privacyEn, privacyAr;
  static late String termsEn, termsAr;
  static late String aboutUsEn, aboutUsAr;
  static late String currentAndroidVersion, currentIosVersion;
  static late bool forceUpdateAndroid, forceUpdateIos;
  static fromJson(jsonMap) {
    params = jsonMap;
    aboutUsAr = jsonMap['about_us_ar'];

    aboutUsEn = jsonMap['about_us_en'];
    privacyAr = jsonMap['privacy_ar'];

    privacyEn = jsonMap['privacy_en'];
    termsAr = jsonMap['terms_ar'];
    termsEn = jsonMap['terms_en'];

    currentAndroidVersion = jsonMap['current_android_version'];
    currentIosVersion = jsonMap['current_ios_version'];
    forceUpdateAndroid = parseBool(jsonMap['force_update_android']);
    forceUpdateIos = parseBool(jsonMap['force_update_ios']);
  }

  static bool parseBool(String source) {
    switch (source) {
      case 'true':
        return true;
      case 'false':
        return false;
      default:
        return false;
    }
  }

  static String get privacy {
    String locale = Get.locale!.languageCode;
    switch (locale) {
      case 'ar':
        return privacyAr;
      case 'en':
        return privacyEn;
    }
    return privacyEn;
  }

  static String get terms {
    String locale = Get.locale!.languageCode;
    switch (locale) {
      case 'ar':
        return termsAr;
      case 'en':
        return termsEn;
    }
    return termsEn;
  }

  static String get aboutUs {
    String locale = Get.locale!.languageCode;
    switch (locale) {
      case 'ar':
        return aboutUsAr;
      case 'en':
        return aboutUsEn;
    }
    return aboutUsEn;
  }
}
