apply method

Future<void> apply()

Apply all configurations to the Face SDK

Implementation

Future<void> apply() async {
  final customization = _faceSDK.customization;

  // Apply colors configuration
  if (_colors != null) {
    // Onboarding screen colors
    if (_colors!.onboardingScreenBackground != null) {
      customization.colors.onboardingScreenBackground =
          _colors!.onboardingScreenBackground!;
    }
    if (_colors!.onboardingScreenMessageLabelsText != null) {
      customization.colors.onboardingScreenMessageLabelsText =
          _colors!.onboardingScreenMessageLabelsText!;
    }
    if (_colors!.onboardingScreenStartButtonTitle != null) {
      customization.colors.onboardingScreenStartButtonTitle =
          _colors!.onboardingScreenStartButtonTitle!;
    }
    if (_colors!.onboardingScreenStartButtonBackground != null) {
      debugPrint(
        "onboardingScreenStartButtonBackground: ${_colors!.onboardingScreenStartButtonBackground}",
      );
      customization.colors.onboardingScreenStartButtonBackground =
          _colors!.onboardingScreenStartButtonBackground!;
    }
    if (_colors!.onboardingScreenTitleLabelText != null) {
      customization.colors.onboardingScreenTitleLabelText =
          _colors!.onboardingScreenTitleLabelText!;
    }
    if (_colors!.onboardingScreenSubtitleLabelText != null) {
      customization.colors.onboardingScreenSubtitleLabelText =
          _colors!.onboardingScreenSubtitleLabelText!;
    }

    // Camera screen colors
    if (_colors!.cameraScreenStrokeActive != null) {
      customization.colors.cameraScreenStrokeActive =
          _colors!.cameraScreenStrokeActive!;
    }
    if (_colors!.cameraScreenStrokeNormal != null) {
      customization.colors.cameraScreenStrokeNormal =
          _colors!.cameraScreenStrokeNormal!;
    }
    if (_colors!.cameraScreenSectorTarget != null) {
      customization.colors.cameraScreenSectorTarget =
          _colors!.cameraScreenSectorTarget!;
    }
    if (_colors!.cameraScreenSectorActive != null) {
      customization.colors.cameraScreenSectorActive =
          _colors!.cameraScreenSectorActive!;
    }
    if (_colors!.cameraScreenFrontHintLabelText != null) {
      customization.colors.cameraScreenFrontHintLabelText =
          _colors!.cameraScreenFrontHintLabelText!;
    }
    if (_colors!.cameraScreenFrontHintLabelBackground != null) {
      customization.colors.cameraScreenFrontHintLabelBackground =
          _colors!.cameraScreenFrontHintLabelBackground!;
    }

    // Processing screen colors
    if (_colors!.processingScreenBackground != null) {
      customization.colors.processingScreenBackground =
          _colors!.processingScreenBackground!;
    }
    if (_colors!.processingScreenProgress != null) {
      customization.colors.processingScreenProgress =
          _colors!.processingScreenProgress!;
    }
    if (_colors!.processingScreenTitleLabel != null) {
      customization.colors.processingScreenTitleLabel =
          _colors!.processingScreenTitleLabel!;
    }

    // Success screen colors
    if (_colors!.successScreenBackground != null) {
      customization.colors.successScreenBackground =
          _colors!.successScreenBackground!;
    }

    // Retry screen colors
    if (_colors!.retryScreenBackground != null) {
      customization.colors.retryScreenBackground =
          _colors!.retryScreenBackground!;
    }
    if (_colors!.retryScreenTitleLabelText != null) {
      customization.colors.retryScreenTitleLabelText =
          _colors!.retryScreenTitleLabelText!;
    }
    if (_colors!.retryScreenSubtitleLabelText != null) {
      customization.colors.retryScreenSubtitleLabelText =
          _colors!.retryScreenSubtitleLabelText!;
    }
    if (_colors!.retryScreenHintLabelsText != null) {
      customization.colors.retryScreenHintLabelsText =
          _colors!.retryScreenHintLabelsText!;
    }
    if (_colors!.retryScreenRetryButtonTitle != null) {
      customization.colors.retryScreenRetryButtonTitle =
          _colors!.retryScreenRetryButtonTitle!;
    }
    if (_colors!.retryScreenRetryButtonBackground != null) {
      customization.colors.retryScreenRetryButtonBackground =
          _colors!.retryScreenRetryButtonBackground!;
    }
  }

  // Apply fonts configuration
  if (_fonts != null) {
    final fontFamily = _fonts!.fontFamily ?? "sans-serif";

    // Onboarding screen fonts
    if (_fonts!.onboardingScreenMessageLabelsSize != null) {
      customization.fonts.onboardingScreenMessageLabels = Font(
        fontFamily,
        size: _fonts!.onboardingScreenMessageLabelsSize!,
      );
    }
    if (_fonts!.onboardingScreenStartButtonSize != null) {
      customization.fonts.onboardingScreenStartButton = Font(
        fontFamily,
        size: _fonts!.onboardingScreenStartButtonSize!,
      );
    }
    if (_fonts!.onboardingScreenTitleLabelSize != null) {
      customization.fonts.onboardingScreenTitleLabel = Font(
        fontFamily,
        size: _fonts!.onboardingScreenTitleLabelSize!,
      );
    }
    if (_fonts!.onboardingScreenSubtitleLabelSize != null) {
      customization.fonts.onboardingScreenSubtitleLabel = Font(
        fontFamily,
        size: _fonts!.onboardingScreenSubtitleLabelSize!,
      );
    }

    // Camera screen fonts
    if (_fonts!.cameraScreenHintLabelSize != null) {
      customization.fonts.cameraScreenHintLabel = Font(
        fontFamily,
        size: _fonts!.cameraScreenHintLabelSize!,
      );
    }

    // Processing screen fonts
    if (_fonts!.processingScreenLabelSize != null) {
      customization.fonts.processingScreenLabel = Font(
        fontFamily,
        size: _fonts!.processingScreenLabelSize!,
      );
    }

    // Retry screen fonts
    if (_fonts!.retryScreenTitleLabelSize != null) {
      customization.fonts.retryScreenTitleLabel = Font(
        fontFamily,
        size: _fonts!.retryScreenTitleLabelSize!,
      );
    }
    if (_fonts!.retryScreenSubtitleLabelSize != null) {
      customization.fonts.retryScreenSubtitleLabel = Font(
        fontFamily,
        size: _fonts!.retryScreenSubtitleLabelSize!,
      );
    }
    if (_fonts!.retryScreenHintLabelsSize != null) {
      customization.fonts.retryScreenHintLabels = Font(
        fontFamily,
        size: _fonts!.retryScreenHintLabelsSize!,
      );
    }
    if (_fonts!.retryScreenRetryButtonSize != null) {
      customization.fonts.retryScreenRetryButton = Font(
        fontFamily,
        size: _fonts!.retryScreenRetryButtonSize!,
      );
    }
  }

  // Apply images configuration
  if (_images != null) {
    // Onboarding screen images
    if (_images!.onboardingScreenIllumination != null) {
      customization.images.onboardingScreenIllumination =
          _images!.onboardingScreenIllumination!;
    }
    if (_images!.onboardingScreenAccessories != null) {
      customization.images.onboardingScreenAccessories =
          _images!.onboardingScreenAccessories!;
    }
    if (_images!.onboardingScreenCameraLevel != null) {
      customization.images.onboardingScreenCameraLevel =
          _images!.onboardingScreenCameraLevel!;
    }

    // Success screen images
    if (_images!.successScreenImage != null) {
      customization.images.successScreenImage = _images!.successScreenImage!;
    }

    // Retry screen images
    if (_images!.retryScreenHintSubject != null) {
      customization.images.retryScreenHintSubject =
          _images!.retryScreenHintSubject!;
    }
    if (_images!.retryScreenHintEnvironment != null) {
      customization.images.retryScreenHintEnvironment =
          _images!.retryScreenHintEnvironment!;
    }
  }

  _faceSDK.customization = customization;
}