-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(partners-feature): create an adapted experience for Partners in …
…landscape.
- Loading branch information
1 parent
2e70429
commit febdc10
Showing
17 changed files
with
197 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 48 additions & 11 deletions
59
...eature/src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/Partners.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = {} | ||
) | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../main/kotlin/org/gdglille/devfest/android/theme/m3/partners/feature/PartnersOrientable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 0 additions & 55 deletions
55
.../src/main/kotlin/org/gdglille/devfest/android/theme/m3/partners/ui/partners/PartnerRow.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
Oops, something went wrong.