Skip to content

Commit

Permalink
Dark partner logo support
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Robiez committed Apr 4, 2024
1 parent 18a1780 commit d7043de
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 39 deletions.

This file was deleted.

1 change: 1 addition & 0 deletions shared/data/src/commonMain/graphql/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ query GetPartnerGroups {
partners {
name
logoUrl
logoUrlDark
url
}
}
Expand Down
2 changes: 2 additions & 0 deletions shared/data/src/commonMain/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type PageInfo {
type Partner {
logoUrl: String!

logoUrlDark: String

name: String!

url: String!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fr.androidmakers.domain.model

data class Partner(
val logoUrl: String = "",
val logoUrlDark: String = "",
val name: String = "",
val url: String = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -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()) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -282,9 +280,7 @@ private fun AVANavHost(
route = AVANavigationRoute.SPONSORS.name,
navTransition = defaultNavTransition
) {
SponsorsScreen(
onSponsorClick = {}
)
SponsorsScreen()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,26 +19,22 @@ 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
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) }
)
}

Expand Down Expand Up @@ -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
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<PartnerGroup>>() {
override fun produce(): Flow<Result<List<PartnerGroup>>> {
return getPartnersUseCase()
Expand Down

0 comments on commit d7043de

Please sign in to comment.