From febdc105f26e3321008b4a3ac95d5ff659454f4f Mon Sep 17 00:00:00 2001 From: Gerard Paligot Date: Thu, 9 Nov 2023 00:09:45 +0100 Subject: [PATCH] feat(partners-feature): create an adapted experience for Partners in landscape. --- settings.gradle.kts | 1 + .../gdglille/devfest/database/PartnerDao.kt | 3 +- .../devfest/models/ui/PartnerGroupUi.kt | 10 ++-- .../devfest/models/ui/PartnerGroupsUi.kt | 24 +++----- .../partners-feature/build.gradle.kts | 1 + .../theme/m3/partners/feature/Partners.kt | 59 +++++++++++++++---- .../m3/partners/feature/PartnersOrientable.kt | 38 ++++++++++++ .../theme/m3/partners/feature/PartnersVM.kt | 5 +- .../partners/partners-ui/build.gradle.kts | 1 + .../ui/partners/PartnerDetailSection.kt | 17 +++--- .../m3/partners/ui/partners/PartnerRow.kt | 55 ----------------- theme-m3/style/partners/.gitignore | 1 + theme-m3/style/partners/build.gradle.kts | 20 +++++++ .../theme/m3/style}/partners/PartnerItem.kt | 51 ++++++++-------- .../m3/style/partners/PartnerItemDefaults.kt | 21 +++++++ .../m3/style/partners/PartnerItemTokens.kt | 12 ++++ .../theme/m3/style/ColorSchemeTokens.kt | 4 +- 17 files changed, 197 insertions(+), 126 deletions(-) create mode 100644 theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersOrientable.kt delete mode 100644 theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerRow.kt create mode 100644 theme-m3/style/partners/.gitignore create mode 100644 theme-m3/style/partners/build.gradle.kts rename theme-m3/{partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui => style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style}/partners/PartnerItem.kt (53%) create mode 100644 theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemDefaults.kt create mode 100644 theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemTokens.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 830b1e5c9..cfba1d696 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -35,6 +35,7 @@ include(":theme-m3:infos:infos-feature") include(":theme-m3:event-list:event-list-ui") include(":theme-m3:event-list:event-list-feature") include(":theme-m3:navigation") +include(":theme-m3:style:partners") include(":theme-m3:style:schedules") include(":theme-m3:style:speakers") include(":theme-m3:style:theme") diff --git a/shared/core/src/commonMain/kotlin/org/gdglille/devfest/database/PartnerDao.kt b/shared/core/src/commonMain/kotlin/org/gdglille/devfest/database/PartnerDao.kt index 3f5371835..d2ab2109d 100644 --- a/shared/core/src/commonMain/kotlin/org/gdglille/devfest/database/PartnerDao.kt +++ b/shared/core/src/commonMain/kotlin/org/gdglille/devfest/database/PartnerDao.kt @@ -74,7 +74,7 @@ class PartnerDao(private val db: Conferences4HallDatabase, private val platform: db.partnerQueries.selectPartners(eventId, type.name, partnerMapper) .asFlow() .mapToList(Dispatchers.IO) - .map { type.name to it.chunked(3).toImmutableList() } + .map { type.name to it } }, transform = { results -> PartnerGroupsUi( @@ -82,7 +82,6 @@ class PartnerDao(private val db: Conferences4HallDatabase, private val platform: PartnerGroupUi( type = type.name, partners = results.find { it.first == type.name }!!.second - .map { it.toImmutableList() } .toImmutableList() ) }.toImmutableList() diff --git a/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupUi.kt b/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupUi.kt index ef8093350..d74aa56ff 100644 --- a/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupUi.kt +++ b/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupUi.kt @@ -5,17 +5,15 @@ import kotlinx.collections.immutable.persistentListOf data class PartnerGroupUi( val type: String, - val partners: ImmutableList> + val partners: ImmutableList ) { companion object { val fake = PartnerGroupUi( type = "Gold", partners = persistentListOf( - persistentListOf( - PartnerItemUi.fake, - PartnerItemUi.fake, - PartnerItemUi.fake - ) + PartnerItemUi.fake.copy(id = "1"), + PartnerItemUi.fake.copy(id = "2"), + PartnerItemUi.fake.copy(id = "3") ) ) } diff --git a/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupsUi.kt b/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupsUi.kt index 29b5ba215..2d1eecd59 100644 --- a/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupsUi.kt +++ b/shared/ui-models/src/commonMain/kotlin/org/gdglille/devfest/models/ui/PartnerGroupsUi.kt @@ -12,31 +12,25 @@ data class PartnerGroupsUi( PartnerGroupUi( type = "Gold", partners = persistentListOf( - persistentListOf( - PartnerItemUi.fake, - PartnerItemUi.fake, - PartnerItemUi.fake - ) + PartnerItemUi.fake.copy(id = "1"), + PartnerItemUi.fake.copy(id = "2"), + PartnerItemUi.fake.copy(id = "3") ) ), PartnerGroupUi( type = "Silver", partners = persistentListOf( - persistentListOf( - PartnerItemUi.fake, - PartnerItemUi.fake, - PartnerItemUi.fake - ) + PartnerItemUi.fake.copy(id = "4"), + PartnerItemUi.fake.copy(id = "5"), + PartnerItemUi.fake.copy(id = "6") ) ), PartnerGroupUi( type = "Bronze", partners = persistentListOf( - persistentListOf( - PartnerItemUi.fake, - PartnerItemUi.fake, - PartnerItemUi.fake - ) + PartnerItemUi.fake.copy(id = "7"), + PartnerItemUi.fake.copy(id = "8"), + PartnerItemUi.fake.copy(id = "9") ) ) ) diff --git a/theme-m3/partners/partners-feature/build.gradle.kts b/theme-m3/partners/partners-feature/build.gradle.kts index a75d61710..5ae14a569 100644 --- a/theme-m3/partners/partners-feature/build.gradle.kts +++ b/theme-m3/partners/partners-feature/build.gradle.kts @@ -12,6 +12,7 @@ dependencies { implementation(projects.shared.core) implementation(projects.themeM3.partners.partnersUi) implementation(projects.themeM3.navigation) + implementation(projects.themeM3.style.partners) implementation(projects.themeM3.style.theme) implementation(libs.kotlinx.collections) diff --git a/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/Partners.kt b/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/Partners.kt index 0d669c526..2a99d4c1e 100644 --- a/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/Partners.kt +++ b/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/Partners.kt @@ -1,36 +1,73 @@ package org.gdglille.devfest.android.theme.m3.partners.feature +import android.annotation.SuppressLint import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.items -import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.GridItemSpan +import androidx.compose.foundation.lazy.grid.LazyGridState +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.items +import androidx.compose.foundation.lazy.grid.rememberLazyGridState +import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.gdglille.devfest.android.theme.m3.partners.ui.partners.PartnerDivider -import org.gdglille.devfest.android.theme.m3.partners.ui.partners.PartnerRow +import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme +import org.gdglille.devfest.android.theme.m3.style.partners.PartnerItem +import org.gdglille.devfest.android.theme.m3.style.placeholder import org.gdglille.devfest.models.ui.PartnerGroupsUi -@ExperimentalMaterial3Api @Composable fun Partners( partners: PartnerGroupsUi, modifier: Modifier = Modifier, + state: LazyGridState = rememberLazyGridState(), isLoading: Boolean = false, + columnCount: Int = 3, onPartnerClick: (id: String) -> Unit ) { - LazyColumn( - modifier = modifier.padding(horizontal = 8.dp), - contentPadding = PaddingValues(vertical = 4.dp), + LazyVerticalGrid( + columns = GridCells.Fixed(columnCount), + horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp), + contentPadding = PaddingValues(vertical = 16.dp), + state = state, + modifier = modifier ) { partners.groups.forEach { - item { PartnerDivider(title = it.type) } + item(span = { GridItemSpan(currentLineSpan = columnCount) }) { + PartnerDivider(title = it.type) + } items(it.partners) { - PartnerRow(partners = it, onPartnerClick = onPartnerClick, isLoading = isLoading) + PartnerItem( + url = it.logoUrl, + contentDescription = it.name, + modifier = Modifier + .fillMaxWidth() + .aspectRatio(1f) + .placeholder(visible = isLoading), + onClick = { onPartnerClick(it.id) } + ) } } } } + +@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") +@Preview +@Composable +fun PartnersPreview() { + Conferences4HallTheme { + Scaffold { + Partners( + partners = PartnerGroupsUi.fake, + onPartnerClick = {} + ) + } + } +} diff --git a/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersOrientable.kt b/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersOrientable.kt new file mode 100644 index 000000000..94ef079f8 --- /dev/null +++ b/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersOrientable.kt @@ -0,0 +1,38 @@ +package org.gdglille.devfest.android.theme.m3.partners.feature + +import android.content.res.Configuration +import androidx.compose.foundation.lazy.grid.rememberLazyGridState +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration +import org.gdglille.devfest.models.ui.PartnerGroupsUi + +@Composable +fun PartnersOrientable( + partners: PartnerGroupsUi, + modifier: Modifier = Modifier, + isLoading: Boolean = false, + onPartnerClick: (id: String) -> Unit +) { + val orientation = LocalConfiguration.current + val state = rememberLazyGridState() + if (orientation.orientation == Configuration.ORIENTATION_LANDSCAPE) { + Partners( + partners = partners, + modifier = modifier, + columnCount = 6, + state = state, + isLoading = isLoading, + onPartnerClick = onPartnerClick + ) + } else { + Partners( + partners = partners, + modifier = modifier, + columnCount = 3, + state = state, + isLoading = isLoading, + onPartnerClick = onPartnerClick + ) + } +} diff --git a/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersVM.kt b/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersVM.kt index d98dca803..ea4769d92 100644 --- a/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersVM.kt +++ b/theme-m3/partners/partners-feature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersVM.kt @@ -10,7 +10,6 @@ import androidx.lifecycle.viewmodel.compose.viewModel import org.gdglille.devfest.android.theme.m3.style.R import org.gdglille.devfest.repositories.AgendaRepository -@OptIn(ExperimentalMaterial3Api::class) @Composable fun PartnersVM( agendaRepository: AgendaRepository, @@ -22,7 +21,7 @@ fun PartnersVM( ) { val uiState = viewModel.uiState.collectAsState() when (uiState.value) { - is PartnersUiState.Loading -> Partners( + is PartnersUiState.Loading -> PartnersOrientable( partners = (uiState.value as PartnersUiState.Loading).partners, modifier = modifier, isLoading = true, @@ -30,7 +29,7 @@ fun PartnersVM( ) is PartnersUiState.Failure -> Text(text = stringResource(id = R.string.text_error)) - is PartnersUiState.Success -> Partners( + is PartnersUiState.Success -> PartnersOrientable( partners = (uiState.value as PartnersUiState.Success).partners, modifier = modifier, onPartnerClick = onPartnerClick diff --git a/theme-m3/partners/partners-ui/build.gradle.kts b/theme-m3/partners/partners-ui/build.gradle.kts index 12a989c86..46f952871 100644 --- a/theme-m3/partners/partners-ui/build.gradle.kts +++ b/theme-m3/partners/partners-ui/build.gradle.kts @@ -11,6 +11,7 @@ android { dependencies { implementation(projects.shared.uiModels) implementation(projects.themeM3.navigation) + implementation(projects.themeM3.style.partners) implementation(projects.themeM3.style.theme) implementation(libs.kotlinx.collections) diff --git a/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerDetailSection.kt b/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerDetailSection.kt index e4318d1d4..73cb911e0 100644 --- a/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerDetailSection.kt +++ b/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerDetailSection.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import org.gdglille.devfest.android.theme.m3.style.socials.SocialsSection import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme +import org.gdglille.devfest.android.theme.m3.style.partners.PartnerItem import org.gdglille.devfest.models.ui.PartnerItemUi @ExperimentalMaterial3Api @@ -33,14 +34,14 @@ fun PartnerDetailSection( .padding(horizontal = 16.dp) ) { Spacer(modifier = Modifier.height(24.dp)) - Conferences4HallTheme(useDarkTheme = false) { - PartnerItem( - partnerUi = partnerItemUi, - isLoading = isLoading, - modifier = Modifier.size(128.dp).clearAndSetSemantics { }, - onClick = {} - ) - } + PartnerItem( + url = partnerItemUi.logoUrl, + contentDescription = partnerItemUi.name, + onClick = {}, + modifier = Modifier + .size(128.dp) + .clearAndSetSemantics { }, + ) Spacer(modifier = Modifier.height(16.dp)) SocialsSection( title = partnerItemUi.name, diff --git a/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerRow.kt b/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerRow.kt deleted file mode 100644 index e4d740e69..000000000 --- a/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerRow.kt +++ /dev/null @@ -1,55 +0,0 @@ -package org.gdglille.devfest.android.theme.m3.partners.ui.partners - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.BoxWithConstraints -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.aspectRatio -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.width -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import kotlinx.collections.immutable.ImmutableList -import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme -import org.gdglille.devfest.models.ui.PartnerGroupUi -import org.gdglille.devfest.models.ui.PartnerItemUi - -@ExperimentalMaterial3Api -@Composable -fun PartnerRow( - partners: ImmutableList, - modifier: Modifier = Modifier, - isLoading: Boolean = false, - maxItems: Int = 3, - onPartnerClick: (id: String) -> Unit, -) { - BoxWithConstraints(modifier = modifier.fillMaxWidth()) { - val width = (this.maxWidth - (8.dp * (maxItems - 1))) / maxItems - Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - partners.forEach { - Conferences4HallTheme(useDarkTheme = false) { - PartnerItem( - partnerUi = it, - modifier = Modifier.width(width).aspectRatio(1f), - isLoading = isLoading, - onClick = onPartnerClick - ) - } - } - } - } -} - -@ExperimentalMaterial3Api -@Preview -@Composable -private fun PartnerRowPreview() { - Conferences4HallTheme { - PartnerRow( - partners = PartnerGroupUi.fake.partners.first(), - onPartnerClick = {} - ) - } -} diff --git a/theme-m3/style/partners/.gitignore b/theme-m3/style/partners/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/theme-m3/style/partners/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/theme-m3/style/partners/build.gradle.kts b/theme-m3/style/partners/build.gradle.kts new file mode 100644 index 000000000..fdda16119 --- /dev/null +++ b/theme-m3/style/partners/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + id("conferences4hall.android.library") + id("conferences4hall.android.library.compose") + id("conferences4hall.quality") +} + +android { + namespace = "org.gdglille.devfest.android.theme.m3.style.partners" +} + +dependencies { + implementation(projects.themeM3.style.theme) + + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.compose.material3) + implementation(libs.androidx.compose.tooling) + implementation(libs.androidx.compose.icons) + + implementation(libs.coil.compose) +} diff --git a/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerItem.kt b/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItem.kt similarity index 53% rename from theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerItem.kt rename to theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItem.kt index bc020e500..8fe9d60d6 100644 --- a/theme-m3/partners/partners-ui/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerItem.kt +++ b/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItem.kt @@ -1,68 +1,69 @@ -package org.gdglille.devfest.android.theme.m3.partners.ui.partners +package org.gdglille.devfest.android.theme.m3.style.partners import androidx.compose.foundation.Image import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.layout.aspectRatio +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape -import androidx.compose.ui.graphics.painter.ColorPainter +import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp import coil.compose.rememberAsyncImagePainter import coil.imageLoader import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme -import org.gdglille.devfest.android.theme.m3.style.placeholder -import org.gdglille.devfest.models.ui.PartnerItemUi +import org.gdglille.devfest.android.theme.m3.style.toDp -@ExperimentalMaterial3Api @Composable fun PartnerItem( - partnerUi: PartnerItemUi, + url: String, + contentDescription: String?, + onClick: () -> Unit, modifier: Modifier = Modifier, - isLoading: Boolean = false, - backgroundColor: Color = MaterialTheme.colorScheme.surface, - shape: Shape = MaterialTheme.shapes.medium, + backgroundColor: Color = PartnerItemDefaults.containerColor, + placeholder: Painter = PartnerItemDefaults.placeholderPainter, + shape: Shape = PartnerItemDefaults.shape, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, - contentScale: ContentScale = ContentScale.Fit, - onClick: (id: String) -> Unit + contentScale: ContentScale = ContentScale.Fit ) { Surface( - onClick = { onClick(partnerUi.id) }, - modifier = modifier.placeholder(visible = isLoading), + onClick = onClick, + modifier = modifier, shape = shape, color = backgroundColor, interactionSource = interactionSource ) { Image( painter = rememberAsyncImagePainter( - model = partnerUi.logoUrl, - placeholder = ColorPainter(backgroundColor), + model = url, + placeholder = placeholder, imageLoader = LocalContext.current.imageLoader ), - contentDescription = partnerUi.name, + contentDescription = contentDescription, contentScale = contentScale, - modifier = Modifier.padding(8.dp) + modifier = Modifier.padding(PartnerItemTokens.PaddingSpacing.toDp()) ) } } -@ExperimentalMaterial3Api @Preview @Composable private fun PartnerItemPreview() { Conferences4HallTheme { PartnerItem( - partnerUi = PartnerItemUi.fake, - modifier = Modifier.size(200.dp) - ) {} + url = "", + contentDescription = "Gerard Inc.", + onClick = {}, + modifier = Modifier + .fillMaxWidth() + .aspectRatio(1f) + ) } } + diff --git a/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemDefaults.kt b/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemDefaults.kt new file mode 100644 index 000000000..62ff72129 --- /dev/null +++ b/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemDefaults.kt @@ -0,0 +1,21 @@ +package org.gdglille.devfest.android.theme.m3.style.partners + +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.painter.ColorPainter +import androidx.compose.ui.graphics.painter.Painter +import org.gdglille.devfest.android.theme.m3.style.toColor +import org.gdglille.devfest.android.theme.m3.style.toShape + +object PartnerItemDefaults { + val containerColor: Color + @Composable + get() = PartnerItemTokens.ContainerColor.toColor() + val placeholderPainter: Painter + @Composable + get() = ColorPainter(PartnerItemTokens.PlaceHolderColor.toColor()) + val shape: Shape + @Composable + get() = PartnerItemTokens.ContainerShape.toShape() +} diff --git a/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemTokens.kt b/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemTokens.kt new file mode 100644 index 000000000..752b3fd8b --- /dev/null +++ b/theme-m3/style/partners/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/partners/PartnerItemTokens.kt @@ -0,0 +1,12 @@ +package org.gdglille.devfest.android.theme.m3.style.partners + +import org.gdglille.devfest.android.theme.m3.style.ColorSchemeTokens +import org.gdglille.devfest.android.theme.m3.style.ShapeTokens +import org.gdglille.devfest.android.theme.m3.style.SpacingTokens + +object PartnerItemTokens { + val ContainerColor = ColorSchemeTokens.WhiteBackgroundColor + val PlaceHolderColor = ColorSchemeTokens.WhiteBackgroundColor + val ContainerShape = ShapeTokens.MediumShape + val PaddingSpacing = SpacingTokens.MediumSpacing +} diff --git a/theme-m3/style/theme/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/ColorSchemeTokens.kt b/theme-m3/style/theme/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/ColorSchemeTokens.kt index d80e1f864..949d1722f 100644 --- a/theme-m3/style/theme/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/ColorSchemeTokens.kt +++ b/theme-m3/style/theme/src/main/kotlin/org/gdglille/devfest/android/theme/m3/style/ColorSchemeTokens.kt @@ -12,7 +12,8 @@ enum class ColorSchemeTokens { SurfaceColor, OnSurfaceColor, OnSurfaceVariant, - OnBackgroundColor + OnBackgroundColor, + WhiteBackgroundColor } internal fun ColorScheme.fromToken(value: ColorSchemeTokens): Color { @@ -23,6 +24,7 @@ internal fun ColorScheme.fromToken(value: ColorSchemeTokens): Color { ColorSchemeTokens.OnSurfaceColor -> onSurface ColorSchemeTokens.OnSurfaceVariant -> onSurfaceVariant ColorSchemeTokens.OnBackgroundColor -> onBackground + ColorSchemeTokens.WhiteBackgroundColor -> Color.White } }