import 'dart:convert';
import 'dart:io';
import 'dart:ui';

import 'package:pshared/config/common.dart';


class Constants extends CommonConstants {
  static const String _clientIdMobile = 'com.profee.pay.mobile-3f9c3b76-2f89-4e9e-95a2-1a5b705b7a1d';

  static Locale get defaultLocale => CommonConstants.defaultLocale;
  static String get clientId => _clientIdMobile;
  static String get accessTokenStorageKey => CommonConstants.accessTokenStorageKey;
  static String get refreshTokenStorageKey => CommonConstants.refreshTokenStorageKey;
  static String get currentOrgKey => CommonConstants.currentOrgKey;
  static String get apiUrl => CommonConstants.apiUrl;
  static String get serviceUrl => CommonConstants.serviceUrl;
  static int get defaultDimensionLength => CommonConstants.defaultDimensionLength;
  static String get deviceIdStorageKey => CommonConstants.deviceIdStorageKey;
  static String get nilObjectRef => CommonConstants.nilObjectRef;
  static Color get themeColor => CommonConstants.themeColor;

  static Future<void> initialize() async {
    var configFile = File('./config/config.json');
    if (await configFile.exists()) {
      var configJson = jsonDecode(await configFile.readAsString());
      CommonConstants.applyConfiguration({
        ...configJson,
        'clientId': configJson['clientId'] ?? _clientIdMobile, 
      });
    } else {
      CommonConstants.clientId = _clientIdMobile; 
    }
  }
}
