-
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(speaker-feature): create an adapted experience for SpeakerDetail…
… in landscape.
- Loading branch information
1 parent
a5337b4
commit 465033c
Showing
6 changed files
with
163 additions
and
21 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
93 changes: 93 additions & 0 deletions
93
.../kotlin/org/gdglille/devfest/android/theme/m3/speakers/feature/SpeakerDetailHorizontal.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,93 @@ | ||
package org.gdglille.devfest.android.theme.m3.speakers.feature | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.lazy.grid.GridCells | ||
import androidx.compose.foundation.lazy.grid.GridItemSpan | ||
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid | ||
import androidx.compose.foundation.lazy.grid.items | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.dp | ||
import org.gdglille.devfest.android.theme.m3.schedules.ui.talks.SmallScheduleItem | ||
import org.gdglille.devfest.android.theme.m3.speakers.ui.SpeakerDetailSectionHorizontal | ||
import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme | ||
import org.gdglille.devfest.android.theme.m3.style.R | ||
import org.gdglille.devfest.android.theme.m3.style.appbars.TopAppBar | ||
import org.gdglille.devfest.android.theme.m3.style.placeholder | ||
import org.gdglille.devfest.android.theme.m3.style.previews.PHONE_LANDSCAPE | ||
import org.gdglille.devfest.models.ui.SpeakerUi | ||
import org.gdglille.devfest.models.ui.TalkItemUi | ||
|
||
@ExperimentalMaterial3Api | ||
@Composable | ||
fun SpeakerDetailHorizontal( | ||
speaker: SpeakerUi, | ||
onTalkClicked: (id: String) -> Unit, | ||
onFavoriteClicked: (TalkItemUi) -> Unit, | ||
onLinkClicked: (url: String) -> Unit, | ||
onBackClicked: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
isLoading: Boolean = false | ||
) { | ||
Scaffold( | ||
modifier = modifier, | ||
topBar = { | ||
TopAppBar( | ||
title = stringResource(id = R.string.screen_speaker_detail), | ||
navigationIcon = { Back(onClick = onBackClicked) } | ||
) | ||
}, | ||
content = { | ||
LazyVerticalGrid( | ||
columns = GridCells.Fixed(count = 2), | ||
modifier = Modifier.padding(it), | ||
contentPadding = PaddingValues(vertical = 24.dp, horizontal = 16.dp), | ||
horizontalArrangement = Arrangement.spacedBy(8.dp) | ||
) { | ||
item(span = { GridItemSpan(2) }) { | ||
SpeakerDetailSectionHorizontal( | ||
speaker = speaker, | ||
isLoading = isLoading, | ||
onLinkClicked = onLinkClicked | ||
) | ||
} | ||
item(span = { GridItemSpan(2) }) { | ||
Spacer(modifier = Modifier.height(24.dp)) | ||
} | ||
items(speaker.talks) { | ||
SmallScheduleItem( | ||
talk = it, | ||
modifier = Modifier | ||
.placeholder(visible = isLoading), | ||
onFavoriteClicked = onFavoriteClicked, | ||
onTalkClicked = onTalkClicked | ||
) | ||
Spacer(modifier = Modifier.height(8.dp)) | ||
} | ||
} | ||
} | ||
) | ||
} | ||
|
||
@ExperimentalMaterial3Api | ||
@Preview(device = PHONE_LANDSCAPE) | ||
@Composable | ||
private fun SpeakerDetailPreview() { | ||
Conferences4HallTheme { | ||
SpeakerDetailHorizontal( | ||
speaker = SpeakerUi.fake, | ||
onTalkClicked = {}, | ||
onFavoriteClicked = {}, | ||
onLinkClicked = {}, | ||
onBackClicked = {} | ||
) | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
.../kotlin/org/gdglille/devfest/android/theme/m3/speakers/feature/SpeakerDetailOrientable.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,44 @@ | ||
package org.gdglille.devfest.android.theme.m3.speakers.feature | ||
|
||
import android.content.res.Configuration | ||
import androidx.compose.material3.ExperimentalMaterial3Api | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalConfiguration | ||
import org.gdglille.devfest.models.ui.SpeakerUi | ||
import org.gdglille.devfest.models.ui.TalkItemUi | ||
|
||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun SpeakerDetailOrientable( | ||
speaker: SpeakerUi, | ||
onTalkClicked: (id: String) -> Unit, | ||
onFavoriteClicked: (TalkItemUi) -> Unit, | ||
onLinkClicked: (url: String) -> Unit, | ||
onBackClicked: () -> Unit, | ||
modifier: Modifier = Modifier, | ||
isLoading: Boolean = false | ||
) { | ||
val orientation = LocalConfiguration.current | ||
if (orientation.orientation == Configuration.ORIENTATION_LANDSCAPE) { | ||
SpeakerDetailHorizontal( | ||
speaker = speaker, | ||
modifier = modifier, | ||
onTalkClicked = onTalkClicked, | ||
onFavoriteClicked = onFavoriteClicked, | ||
onLinkClicked = onLinkClicked, | ||
onBackClicked = onBackClicked, | ||
isLoading = isLoading | ||
) | ||
} else { | ||
SpeakerDetailVertical( | ||
speaker = speaker, | ||
modifier = modifier, | ||
onTalkClicked = onTalkClicked, | ||
onFavoriteClicked = onFavoriteClicked, | ||
onLinkClicked = onLinkClicked, | ||
onBackClicked = onBackClicked, | ||
isLoading = isLoading | ||
) | ||
} | ||
} |
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