-
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(style-speakers): create LabeledSpeakersAvatar component.
- Loading branch information
1 parent
19e2ef1
commit c43a670
Showing
8 changed files
with
159 additions
and
41 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
43 changes: 43 additions & 0 deletions
43
...lin/org/gdglille/devfest/android/theme/m3/style/speakers/avatars/LabeledSpeakersAvatar.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,43 @@ | ||
package org.gdglille.devfest.android.theme.m3.style.speakers.avatars | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import kotlinx.collections.immutable.ImmutableList | ||
import kotlinx.collections.immutable.persistentListOf | ||
import org.gdglille.devfest.android.theme.m3.style.Conferences4HallTheme | ||
|
||
@Composable | ||
fun SmallLabeledSpeakersAvatar( | ||
label: String, | ||
urls: ImmutableList<String>, | ||
modifier: Modifier = Modifier, | ||
color: Color = LabeledSpeakersAvatarDefaults.contentColor, | ||
style: TextStyle = LabeledSpeakersAvatarDefaults.smallTextStyle | ||
) { | ||
Row( | ||
verticalAlignment = Alignment.CenterVertically, | ||
horizontalArrangement = Arrangement.spacedBy(LabeledSpeakersAvatarSizingTokens.SmallSpacing.toDp()), | ||
modifier = modifier | ||
) { | ||
SmallBorderedSpeakersAvatar(urls = urls, descriptions = null) | ||
Text(text = label, style = style, color = color) | ||
} | ||
} | ||
|
||
@Preview(showBackground = true) | ||
@Composable | ||
private fun HorizontalSpeakersListPreview() { | ||
Conferences4HallTheme { | ||
SmallLabeledSpeakersAvatar( | ||
label = "John Doe and Janne Doe", | ||
urls = persistentListOf("", "") | ||
) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...lille/devfest/android/theme/m3/style/speakers/avatars/LabeledSpeakersAvatarColorTokens.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,23 @@ | ||
package org.gdglille.devfest.android.theme.m3.style.speakers.avatars | ||
|
||
import androidx.compose.material3.ColorScheme | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.ui.graphics.Color | ||
|
||
enum class LabeledSpeakersAvatarColorTokens { | ||
OnSurface | ||
} | ||
|
||
internal fun ColorScheme.fromToken(value: LabeledSpeakersAvatarColorTokens): Color { | ||
return when (value) { | ||
LabeledSpeakersAvatarColorTokens.OnSurface -> onSurface | ||
} | ||
} | ||
|
||
@Composable | ||
@ReadOnlyComposable | ||
internal fun LabeledSpeakersAvatarColorTokens.toColor(): Color { | ||
return MaterialTheme.colorScheme.fromToken(this) | ||
} |
15 changes: 15 additions & 0 deletions
15
...gdglille/devfest/android/theme/m3/style/speakers/avatars/LabeledSpeakersAvatarDefaults.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,15 @@ | ||
package org.gdglille.devfest.android.theme.m3.style.speakers.avatars | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.text.TextStyle | ||
|
||
object LabeledSpeakersAvatarDefaults { | ||
val smallTextStyle: TextStyle | ||
@Composable | ||
get() = LabeledSpeakersAvatarSmallTokens.LabelTextStyle.toTextStyle() | ||
|
||
val contentColor: Color | ||
@Composable | ||
get() = LabeledSpeakersAvatarSmallTokens.ContentColor.toColor() | ||
} |
22 changes: 22 additions & 0 deletions
22
...ille/devfest/android/theme/m3/style/speakers/avatars/LabeledSpeakersAvatarSizingTokens.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,22 @@ | ||
package org.gdglille.devfest.android.theme.m3.style.speakers.avatars | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
|
||
enum class LabeledSpeakersAvatarSizingTokens { | ||
SmallSpacing | ||
} | ||
|
||
internal fun fromToken(value: LabeledSpeakersAvatarSizingTokens): Dp { | ||
return when (value) { | ||
LabeledSpeakersAvatarSizingTokens.SmallSpacing -> 8.dp | ||
} | ||
} | ||
|
||
@Composable | ||
@ReadOnlyComposable | ||
internal fun LabeledSpeakersAvatarSizingTokens.toDp(): Dp { | ||
return fromToken(this) | ||
} |
7 changes: 7 additions & 0 deletions
7
...lille/devfest/android/theme/m3/style/speakers/avatars/LabeledSpeakersAvatarSmallTokens.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,7 @@ | ||
package org.gdglille.devfest.android.theme.m3.style.speakers.avatars | ||
|
||
internal object LabeledSpeakersAvatarSmallTokens { | ||
val ContentColor = LabeledSpeakersAvatarColorTokens.OnSurface | ||
val LabelTextStyle = LabeledSpeakersAvatarTextStyleTokens.BodyMedium | ||
val SpacingBetween = LabeledSpeakersAvatarSizingTokens.SmallSpacing | ||
} |
23 changes: 23 additions & 0 deletions
23
...e/devfest/android/theme/m3/style/speakers/avatars/LabeledSpeakersAvatarTextStyleTokens.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,23 @@ | ||
package org.gdglille.devfest.android.theme.m3.style.speakers.avatars | ||
|
||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Typography | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.ReadOnlyComposable | ||
import androidx.compose.ui.text.TextStyle | ||
|
||
enum class LabeledSpeakersAvatarTextStyleTokens { | ||
BodyMedium | ||
} | ||
|
||
internal fun Typography.fromToken(value: LabeledSpeakersAvatarTextStyleTokens): TextStyle { | ||
return when (value) { | ||
LabeledSpeakersAvatarTextStyleTokens.BodyMedium -> bodyMedium | ||
} | ||
} | ||
|
||
@Composable | ||
@ReadOnlyComposable | ||
internal fun LabeledSpeakersAvatarTextStyleTokens.toTextStyle(): TextStyle { | ||
return MaterialTheme.typography.fromToken(this) | ||
} |
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