Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of partners logo in night mode #238

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

3 changes: 2 additions & 1 deletion shared/data/src/commonMain/graphql/operations.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ query GetPartnerGroups {
title
partners {
name
logoUrl
logoUrlLight: logoUrl(dark: false)
logoUrlDark: logoUrl(dark: true)
url
}
}
Expand Down
2 changes: 1 addition & 1 deletion shared/data/src/commonMain/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type PageInfo {
}

type Partner {
logoUrl: String!
logoUrl(dark: Boolean): String!

name: String!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class PartnersGraphQLRepository(private val apolloClient: ApolloClient): Partner
title = partnerGroup.title,
partners = partnerGroup.partners.map { partner ->
Partner(
logoUrl = partner.logoUrl,
logoUrl = partner.logoUrlLight,
name = partner.name,
url = partner.url
url = partner.url,
logoUrlDark = partner.logoUrlDark
)
}
)
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
Loading