package br.com.expo.modules.oitiexpoliveness3d.theme import br.com.oiti.liveness3d.theme.Liveness3DTheme class Liveness3DTheme( private var themeBuilder: Map, ) { private fun parseIntThemeValue(key: String): Int? { val raw = themeBuilder[key]?.trim()?.takeIf { it.isNotEmpty() } ?: return null return raw.toIntOrNull() ?: raw.toDoubleOrNull()?.toInt() } private val guidanceCustomizationBackgroundColors: String? = themeBuilder["guidanceCustomizationBackgroundColors"] private val guidanceCustomizationForegroundColor: String? = themeBuilder["guidanceCustomizationForegroundColor"] private val guidanceCustomizationButtonTextNormalColor: String? = themeBuilder["guidanceCustomizationButtonTextNormalColor"] private val guidanceCustomizationButtonBackgroundNormalColor: String? = themeBuilder["guidanceCustomizationButtonBackgroundNormalColor"] private val guidanceCustomizationButtonTextHighlightColor: String? = themeBuilder["guidanceCustomizationButtonTextHighlightColor"] private val guidanceCustomizationButtonBackgroundHighlightColor: String? = themeBuilder["guidanceCustomizationButtonBackgroundHighlightColor"] private val guidanceCustomizationButtonTextDisabledColor: String? = themeBuilder["guidanceCustomizationButtonTextDisabledColor"] private val guidanceCustomizationButtonBackgroundDisabledColor: String? = themeBuilder["guidanceCustomizationButtonBackgroundDisabledColor"] private val guidanceCustomizationButtonBorderColor: String? = themeBuilder["guidanceCustomizationButtonBorderColor"] private val guidanceCustomizationButtonBorderWidth: Int? = parseIntThemeValue("guidanceCustomizationButtonBorderWidth") private val guidanceCustomizationButtonCornerRadius: Int? = parseIntThemeValue("guidanceCustomizationButtonCornerRadius") private val guidanceCustomizationReadyScreenHeaderTextColor: String? = themeBuilder["guidanceCustomizationReadyScreenHeaderTextColor"] private val guidanceCustomizationReadyScreenSubtextTextColor: String? = themeBuilder["guidanceCustomizationReadyScreenSubtextTextColor"] private val guidanceCustomizationRetryScreenHeaderTextColor: String? = themeBuilder["guidanceCustomizationRetryScreenHeaderTextColor"] private val guidanceCustomizationRetryScreenSubtextTextColor: String? = themeBuilder["guidanceCustomizationRetryScreenSubtextTextColor"] private val guidanceCustomizationReadyScreenOvalFillColor: String? = themeBuilder["guidanceCustomizationReadyScreenOvalFillColor"] private val guidanceCustomizationReadyScreenTextBackgroundColor: String? = themeBuilder["guidanceCustomizationReadyScreenTextBackgroundColor"] private val guidanceCustomizationReadyScreenTextBackgroundCornerRadius: Int? = parseIntThemeValue("guidanceCustomizationReadyScreenTextBackgroundCornerRadius") private val guidanceCustomizationRetryScreenImageBorderColor: String? = themeBuilder["guidanceCustomizationRetryScreenImageBorderColor"] private val guidanceCustomizationRetryScreenImageBorderWidth: Int? = parseIntThemeValue("guidanceCustomizationRetryScreenImageBorderWidth") private val guidanceCustomizationRetryScreenImageCornerRadius: Int? = parseIntThemeValue("guidanceCustomizationRetryScreenImageCornerRadius") private val guidanceCustomizationRetryScreenOvalStrokeColor: String? = themeBuilder["guidanceCustomizationRetryScreenOvalStrokeColor"] private val resultScreenCustomizationForegroundColor: String? = themeBuilder["resultScreenCustomizationForegroundColor"] private val resultScreenCustomizationBackgroundColors: String? = themeBuilder["resultScreenCustomizationBackgroundColors"] private val resultScreenCustomizationActivityIndicatorColor: String? = themeBuilder["resultScreenCustomizationActivityIndicatorColor"] private val resultScreenCustomizationUploadProgressFillColor: String? = themeBuilder["resultScreenCustomizationUploadProgressFillColor"] private val resultScreenCustomizationUploadProgressTrackColor: String? = themeBuilder["resultScreenCustomizationUploadProgressTrackColor"] private val resultScreenCustomizationResultAnimationBackgroundColor: String? = themeBuilder["resultScreenCustomizationResultAnimationBackgroundColor"] private val resultScreenCustomizationResultAnimationForegroundColor: String? = themeBuilder["resultScreenCustomizationResultAnimationForegroundColor"] private val ovalCustomizationStrokeWidth: Int? = parseIntThemeValue("ovalCustomizationStrokeWidth") private val ovalCustomizationStrokeColor: String? = themeBuilder["ovalCustomizationStrokeColor"] private val ovalCustomizationProgressStrokeWidth: Int? = parseIntThemeValue("ovalCustomizationProgressStrokeWidth") private val ovalCustomizationProgressColor1: String? = themeBuilder["ovalCustomizationProgressColor1"] private val ovalCustomizationProgressColor2: String? = themeBuilder["ovalCustomizationProgressColor2"] private val ovalCustomizationProgressRadialOffset: Int? = parseIntThemeValue("ovalCustomizationProgressRadialOffset") private val frameCustomizationBorderWidth: Int? = parseIntThemeValue("frameCustomizationBorderWidth") private val frameCustomizationCornerRadius: Int? = parseIntThemeValue("frameCustomizationCornerRadius") private val frameCustomizationBorderColor: String? = themeBuilder["frameCustomizationBorderColor"] private val frameCustomizationBackgroundColor: String? = themeBuilder["frameCustomizationBackgroundColor"] private val frameCustomizationElevation: Int? = parseIntThemeValue("frameCustomizationElevation") private val overlayCustomizationBackgroundColor: String? = themeBuilder["overlayCustomizationBackgroundColor"] private val feedbackCustomizationCornerRadius: Int? = parseIntThemeValue("feedbackCustomizationCornerRadius") private val feedbackCustomizationBackgroundColors: String? = themeBuilder["feedbackCustomizationBackgroundColors"] private val feedbackCustomizationTextColor: String? = themeBuilder["feedbackCustomizationTextColor"] fun apply(): Liveness3DTheme { val builder = Liveness3DTheme.Builder() guidanceCustomizationBackgroundColors?.let { builder.guidanceCustomizationBackgroundColors(it) } guidanceCustomizationForegroundColor?.let { builder.guidanceCustomizationForegroundColor(it) } guidanceCustomizationButtonTextNormalColor?.let { builder.guidanceCustomizationButtonTextNormalColor(it) } guidanceCustomizationButtonBackgroundNormalColor?.let { builder.guidanceCustomizationButtonBackgroundNormalColor(it) } guidanceCustomizationButtonTextHighlightColor?.let { builder.guidanceCustomizationButtonTextHighlightColor(it) } guidanceCustomizationButtonBackgroundHighlightColor?.let { builder.guidanceCustomizationButtonBackgroundHighlightColor(it) } guidanceCustomizationButtonTextDisabledColor?.let { builder.guidanceCustomizationButtonTextDisabledColor(it) } guidanceCustomizationButtonBackgroundDisabledColor?.let { builder.guidanceCustomizationButtonBackgroundDisabledColor(it) } guidanceCustomizationButtonBorderColor?.let { builder.guidanceCustomizationButtonBorderColor(it) } guidanceCustomizationButtonBorderWidth?.let { builder.guidanceCustomizationButtonBorderWidth(it) } guidanceCustomizationButtonCornerRadius?.let { builder.guidanceCustomizationButtonCornerRadius(it) } guidanceCustomizationReadyScreenHeaderTextColor?.let { builder.guidanceCustomizationReadyScreenHeaderTextColor(it) } guidanceCustomizationReadyScreenSubtextTextColor?.let { builder.guidanceCustomizationReadyScreenSubtextTextColor(it) } guidanceCustomizationRetryScreenHeaderTextColor?.let { builder.guidanceCustomizationRetryScreenHeaderTextColor(it) } guidanceCustomizationRetryScreenSubtextTextColor?.let { builder.guidanceCustomizationRetryScreenSubtextTextColor(it) } guidanceCustomizationRetryScreenImageBorderColor?.let { builder.guidanceCustomizationRetryScreenImageBorderColor(it) } guidanceCustomizationRetryScreenImageBorderWidth?.let { builder.guidanceCustomizationRetryScreenImageBorderWidth(it) } guidanceCustomizationRetryScreenImageCornerRadius?.let { builder.guidanceCustomizationRetryScreenImageCornerRadius(it) } guidanceCustomizationRetryScreenOvalStrokeColor?.let { builder.guidanceCustomizationRetryScreenOvalStrokeColor(it) } guidanceCustomizationReadyScreenOvalFillColor?.let { builder.guidanceCustomizationReadyScreenOvalFillColor(it) } guidanceCustomizationReadyScreenTextBackgroundColor?.let { builder.guidanceCustomizationReadyScreenTextBackgroundColor(it) } guidanceCustomizationReadyScreenTextBackgroundCornerRadius?.let { builder.guidanceCustomizationReadyScreenTextBackgroundCornerRadius(it) } resultScreenCustomizationForegroundColor?.let { builder.resultScreenCustomizationForegroundColor(it) } resultScreenCustomizationBackgroundColors?.let { builder.resultScreenCustomizationBackgroundColors(it) } resultScreenCustomizationActivityIndicatorColor?.let { builder.resultScreenCustomizationActivityIndicatorColor(it) } resultScreenCustomizationUploadProgressFillColor?.let { builder.resultScreenCustomizationUploadProgressFillColor(it) } resultScreenCustomizationUploadProgressTrackColor?.let { builder.resultScreenCustomizationUploadProgressTrackColor(it) } resultScreenCustomizationResultAnimationBackgroundColor?.let { builder.resultScreenCustomizationResultAnimationBackgroundColor(it) } resultScreenCustomizationResultAnimationForegroundColor?.let { builder.resultScreenCustomizationResultAnimationForegroundColor(it) } ovalCustomizationStrokeWidth?.let { builder.ovalCustomizationStrokeWidth(it) } ovalCustomizationStrokeColor?.let { builder.ovalCustomizationStrokeColor(it) } ovalCustomizationProgressStrokeWidth?.let { builder.ovalCustomizationProgressStrokeWidth(it) } ovalCustomizationProgressColor1?.let { builder.ovalCustomizationProgressColor1(it) } ovalCustomizationProgressColor2?.let { builder.ovalCustomizationProgressColor2(it) } ovalCustomizationProgressRadialOffset?.let { builder.ovalCustomizationProgressRadialOffset(it) } frameCustomizationBorderWidth?.let { builder.frameCustomizationBorderWidth(it) } frameCustomizationCornerRadius?.let { builder.frameCustomizationCornerRadius(it) } frameCustomizationBorderColor?.let { builder.frameCustomizationBorderColor(it) } frameCustomizationBackgroundColor?.let { builder.frameCustomizationBackgroundColor(it) } frameCustomizationElevation?.let { builder.frameCustomizationElevation(it) } overlayCustomizationBackgroundColor?.let { builder.overlayCustomizationBackgroundColor(it) } feedbackCustomizationCornerRadius?.let { builder.feedbackCustomizationCornerRadius(it) } feedbackCustomizationBackgroundColors?.let { builder.feedbackCustomizationBackgroundColors(it) } feedbackCustomizationTextColor?.let { builder.feedbackCustomizationTextColor(it) } return builder.build() } }