Merge pull request 'feat(CON-238) : Add webview for cookies policy' (#11) from feat-238 into develop

Reviewed-on: #11
Reviewed-by: Simon Tabaka <s.tabaka@openium.fr>
This commit is contained in:
Louis Legrand 2025-01-07 16:19:01 +01:00
commit bf5f7b47b7
7 changed files with 59 additions and 4 deletions

View File

@ -24,7 +24,7 @@ internal object ConsentiumUIMockApi : ConsentiumUIApi {
MainConsentTextTranslationDTO(
id = "UUID",
language = "fr",
consentPageUrl = "https:consentium.fr",
consentPageUrl = "https://www.openium.fr",
mainConsentText = "<p>[Nom de lapplication] utilise des cookies pour différents objectifs : faire fonctionner lapplication, améliorer nos services en mesurant lefficacité de nos contenus et afficher des publicités susceptibles de vous intéresser.<br></p>\n<p>En cliquant sur “Accepter et fermer”, vous acceptez cette utilisation sur lapplication mobile. Vous pouvez également paramétrer vos choix en cliquant sur “Paramétrer mes choix” ou refuser ces cookies en cliquant sur “Continuer sans accepter”. Vous pouvez changer davis à tout moment depuis les paramètres de votre compte via longlet “Notifications et cookies”</p>\n",
durationText = "<p>Nous conservons votre choix pendant 12 mois. Vous pouvez changer davis à tout moment depuis les paramètres de votre compte via longlet “Notification et cookies” tetetettetettetetstts</p>\n"
)

View File

@ -10,6 +10,7 @@ import fr.openium.consentium_ui.ui.components.ConsentiumUIDetailConsentComponent
import fr.openium.consentium_ui.ui.components.ConsentiumUIErrorComponent
import fr.openium.consentium_ui.ui.components.ConsentiumUIGeneralConsentComponent
import fr.openium.consentium_ui.ui.components.ConsentiumUILoadingComponent
import fr.openium.consentium_ui.ui.components.ConsentiumUIWebview
import fr.openium.consentium_ui.ui.model.ConsentiumPageUI
import fr.openium.consentium_ui.ui.model.DetailConsentUI
import fr.openium.consentium_ui.ui.model.LoadingElement
@ -53,7 +54,7 @@ internal fun ConsentiumScreen(
)
}
ConsentiumPageUI.DETAILS_CONSENT -> {
else -> {
slideIn(
initialOffset = { fullSize -> IntOffset(fullSize.width, 0) }
).togetherWith(
@ -92,6 +93,12 @@ internal fun ConsentiumScreen(
loadingElement = loadingElement
)
}
ConsentiumPageUI.COOKIES_POLICY -> {
ConsentiumUIWebview(
url = state.detailConsentUI.cookiePolicyUrl
)
}
}
}

View File

@ -9,6 +9,7 @@ import fr.openium.consentium_ui.ui.model.PurposeUI
internal fun ContentConfigData.toDetailConsentUI(): DetailConsentUI = DetailConsentUI(
conservationDurationText = mainTextTranslation.first().durationText,
purposes = purposes.sortedBy { it.order }.map { it.toPurposeUI() },
cookiePolicyUrl = mainTextTranslation.first().consentPageUrl,
)
internal fun DetailConsentUI.toPurposeChoices(): List<PurposeChoice> = purposes.map {

View File

@ -1,6 +1,7 @@
package fr.openium.consentium_ui.ui.components
import android.widget.Toast
import androidx.activity.compose.BackHandler
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
@ -70,6 +71,22 @@ fun ConsentiumComponent(
}
}
BackHandler {
when {
defaultLandingPage == ConsentiumPageUI.GENERAL_CONSENT && currentPage == ConsentiumPageUI.DETAILS_CONSENT -> {
currentPage = ConsentiumPageUI.GENERAL_CONSENT
}
currentPage == ConsentiumPageUI.COOKIES_POLICY -> {
currentPage = ConsentiumPageUI.GENERAL_CONSENT
}
else -> {
onQuitConsent()
}
}
}
// View
CompositionLocalProvider(
LocalColors provides colors,
@ -112,7 +129,7 @@ fun ConsentiumComponent(
}
},
onClickCookiesPolicies = {
// TODO Open cookies policies
currentPage = ConsentiumPageUI.COOKIES_POLICY
},
)
}

View File

@ -0,0 +1,28 @@
package fr.openium.consentium_ui.ui.components
import android.view.ViewGroup
import android.webkit.WebView
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
@Composable
internal fun ConsentiumUIWebview(
url: String,
modifier: Modifier = Modifier,
) {
AndroidView(
modifier = modifier,
factory = {
WebView(it).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
}
},
update = { webView ->
webView.loadUrl(url)
}
)
}

View File

@ -2,5 +2,6 @@ package fr.openium.consentium_ui.ui.model
enum class ConsentiumPageUI {
GENERAL_CONSENT,
DETAILS_CONSENT
DETAILS_CONSENT,
COOKIES_POLICY,
}

View File

@ -1,6 +1,7 @@
package fr.openium.consentium_ui.ui.model
internal data class DetailConsentUI(
val cookiePolicyUrl: String,
val conservationDurationText: String,
val purposes: List<PurposeUI>,
)