diff --git a/androidApp/src/main/java/fr/paug/androidmakers/util/CustomTabUtil.kt b/androidApp/src/main/java/fr/paug/androidmakers/util/CustomTabUtil.kt deleted file mode 100644 index 832fc57a..00000000 --- a/androidApp/src/main/java/fr/paug/androidmakers/util/CustomTabUtil.kt +++ /dev/null @@ -1,16 +0,0 @@ -package fr.paug.androidmakers.util - -import android.content.Context -import android.net.Uri -import androidx.browser.customtabs.CustomTabsIntent -import androidx.core.content.ContextCompat -import fr.paug.androidmakers.R - -object CustomTabUtil { - fun openChromeTab(context: Context?, url: String?) { - val builder = CustomTabsIntent.Builder() - builder.setToolbarColor(ContextCompat.getColor(context!!, R.color.colorPrimary)) - val customTabsIntent = builder.build() - customTabsIntent.launchUrl(context, Uri.parse(url)) - } -} \ No newline at end of file diff --git a/shared/data/src/commonMain/graphql/operations.graphql b/shared/data/src/commonMain/graphql/operations.graphql index 323211bf..798b84e9 100644 --- a/shared/data/src/commonMain/graphql/operations.graphql +++ b/shared/data/src/commonMain/graphql/operations.graphql @@ -69,6 +69,7 @@ query GetPartnerGroups { partners { name logoUrl + logoUrlDark url } } diff --git a/shared/data/src/commonMain/graphql/schema.graphqls b/shared/data/src/commonMain/graphql/schema.graphqls index be86eb0c..01f0caa5 100644 --- a/shared/data/src/commonMain/graphql/schema.graphqls +++ b/shared/data/src/commonMain/graphql/schema.graphqls @@ -79,6 +79,8 @@ type PageInfo { type Partner { logoUrl: String! + logoUrlDark: String + name: String! url: String! diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt index e940bc51..524ba7c5 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/PartnersGraphQLRepository.kt @@ -24,7 +24,8 @@ class PartnersGraphQLRepository(private val apolloClient: ApolloClient): Partner Partner( logoUrl = partner.logoUrl, name = partner.name, - url = partner.url + url = partner.url, + logoUrlDark = partner.logoUrlDark ?: partner.logoUrl ) } ) diff --git a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/model/Logo.kt b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/model/Logo.kt index 238f0051..13bf2388 100644 --- a/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/model/Logo.kt +++ b/shared/domain/src/commonMain/kotlin/fr/androidmakers/domain/model/Logo.kt @@ -2,6 +2,7 @@ package fr.androidmakers.domain.model data class Partner( val logoUrl: String = "", + val logoUrlDark: String = "", val name: String = "", val url: String = "" ) diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/di/ViewModelModule.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/di/ViewModelModule.kt index 37109a52..0782f380 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/di/ViewModelModule.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/di/ViewModelModule.kt @@ -12,7 +12,7 @@ import org.koin.dsl.module val viewModelModule = module { factory { SpeakerListViewModel(get()) } - factory { SponsorsViewModel(get()) } + factory { SponsorsViewModel(get(), get()) } factory { VenueViewModel(get(), get(), get()) } factory { (speakerId: String) -> SpeakerDetailsViewModel(speakerId, get(), get()) } factory { AgendaLayoutViewModel(get()) } diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/navigation/AVALayout.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/navigation/AVALayout.kt index b885acd7..1403fa8b 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/navigation/AVALayout.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/common/navigation/AVALayout.kt @@ -1,6 +1,5 @@ package com.androidmakers.ui.common.navigation -import androidx.compose.animation.ExitTransition import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.Image @@ -54,7 +53,6 @@ import fr.androidmakers.domain.model.User import fr.paug.androidmakers.ui.MR import kotlinx.coroutines.launch import moe.tlaster.precompose.koin.koinViewModel -import moe.tlaster.precompose.navigation.BackStackEntry import moe.tlaster.precompose.navigation.NavHost import moe.tlaster.precompose.navigation.NavOptions import moe.tlaster.precompose.navigation.Navigator @@ -282,9 +280,7 @@ private fun AVANavHost( route = AVANavigationRoute.SPONSORS.name, navTransition = defaultNavTransition ) { - SponsorsScreen( - onSponsorClick = {} - ) + SponsorsScreen() } } } diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorScreen.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorScreen.kt index f4ac2280..6f8a0f7b 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorScreen.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorScreen.kt @@ -2,6 +2,7 @@ package com.androidmakers.ui.sponsors import androidx.compose.foundation.Image import androidx.compose.foundation.clickable +import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth @@ -18,10 +19,8 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import com.androidmakers.ui.model.Lce import com.seiko.imageloader.rememberImagePainter import fr.androidmakers.domain.model.Partner @@ -29,15 +28,13 @@ import fr.androidmakers.domain.model.PartnerGroup import moe.tlaster.precompose.koin.koinViewModel @Composable -fun SponsorsScreen( - onSponsorClick: (partner: Partner) -> Unit -) { +fun SponsorsScreen() { val viewModel = koinViewModel(SponsorsViewModel::class) val sponsors by viewModel.values.collectAsState() SponsorsView( partnerList = sponsors, - onSponsorClick = onSponsorClick + onSponsorClick = { viewModel.openPartnerLink(it) } ) } @@ -73,30 +70,33 @@ fun SponsorsView( }) { Text( modifier = Modifier - .padding(top = 32.dp, bottom = 8.dp) + .padding(top = 48.dp, bottom = 8.dp) .fillMaxWidth(), textAlign = TextAlign.Start, text = partnerGroup.title.replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }, - style = MaterialTheme.typography.titleMedium.copy( - color = MaterialTheme.colorScheme.primary, - fontWeight = FontWeight.Bold, - fontSize = 18.sp - ) + color = MaterialTheme.colorScheme.primary, + style = MaterialTheme.typography.titleMedium ) } // Sponsor logo for (partner in partnerGroup.partners) { item { - val painter = rememberImagePainter(partner.logoUrl) + val logoUrl = if (isSystemInDarkTheme()) { + partner.logoUrlDark + } else { + partner.logoUrl + } + Image( modifier = Modifier .fillMaxWidth() .height(80.dp) .clickable { onSponsorClick(partner) - }, - painter = painter, + } + .padding(12.dp), + painter = rememberImagePainter(logoUrl), contentDescription = partner.name ) } diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt index 7d7417de..f9660b1e 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/sponsors/SponsorsViewModel.kt @@ -2,11 +2,13 @@ package com.androidmakers.ui.sponsors import com.androidmakers.ui.common.LceViewModel import fr.androidmakers.domain.interactor.GetPartnersUseCase +import fr.androidmakers.domain.interactor.OpenPartnerLinkUseCase import fr.androidmakers.domain.model.PartnerGroup import kotlinx.coroutines.flow.Flow class SponsorsViewModel( - private val getPartnersUseCase: GetPartnersUseCase + private val getPartnersUseCase: GetPartnersUseCase, + val openPartnerLink: OpenPartnerLinkUseCase, ) : LceViewModel>() { override fun produce(): Flow>> { return getPartnersUseCase()