
Pairel
Discover
package com.composables.pairel
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.VectorConverter
import androidx.compose.animation.core.animate
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.movableContentOf
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.composables.pairel.components.AppBar
import com.composables.pairel.components.Button
import com.composables.pairel.components.Icon
import com.composables.pairel.components.IconButton
import com.composables.pairel.components.ScreenScaffold
import com.composables.pairel.components.Tag
import com.composables.pairel.components.TagVariant
import com.composables.pairel.components.Text
import com.composables.pairel.theme.Check
import com.composables.pairel.theme.Heart
import com.composables.pairel.theme.Icons
import com.composables.pairel.theme.SlidersHorizontal
import com.composables.pairel.theme.Theme
import com.composables.pairel.theme.X
import com.composables.systembars.SystemBarContent
import com.composables.systembars.SystemBars
import com.composables.uripainter.rememberUriPainter
import com.composeunstyled.DialogPanel
import com.composeunstyled.UnstyledDialog
import kotlin.math.abs
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.launch
@Composable
fun DiscoverScreen(
navigateToProfile: (Person) -> Unit,
navigateToConversation: (Person) -> Unit,
navigateToDiscoveryPreferences: () -> Unit,
navigateToMatches: () -> Unit,
navigateToMyProfile: () -> Unit,
modifier: Modifier = Modifier,
) {
MainNavigationLayout(
navigationBar = {
MainNavigationBar(
selected = MainDestination.Discover,
navigateToDiscover = {},
navigateToMatches = navigateToMatches,
navigateToMyProfile = navigateToMyProfile,
)
},
modifier = modifier,
) { contentPadding ->
DiscoverDestination(
navigateToProfile,
navigateToConversation,
navigateToDiscoveryPreferences,
contentPadding = contentPadding,
)
}
}
@Composable
fun DiscoverDestination(
navigateToProfile: (Person) -> Unit,
navigateToConversation: (Person) -> Unit,
navigateToDiscoveryPreferences: () -> Unit,
contentPadding: PaddingValues,
modifier: Modifier = Modifier,
) {
var currentIndex by rememberSaveable { mutableIntStateOf(0) }
var match by remember { mutableStateOf<Person?>(null) }
var matchContent by remember { mutableStateOf<Person?>(null) }
var hasMatched by rememberSaveable { mutableStateOf(false) }
var completedSwipes by rememberSaveable { mutableIntStateOf(0) }
var reveal by remember(currentIndex) { mutableFloatStateOf(0f) }
val profileCards = remember {
people.map { person ->
movableContentOf { cardModifier: Modifier -> ProfileCard(person, cardModifier) }
}
}
val bottomPadding = contentPadding.calculateBottomPadding()
ScreenScaffold(
modifier = modifier,
topBar = {
AppBar(
title = { Text("Discover") },
actions = {
IconButton(onClick = navigateToDiscoveryPreferences) {
Icon(
Icons.SlidersHorizontal,
contentDescription = "Discovery preferences",
modifier = Modifier.size(24.dp),
)
}
},
)
},
overlay = {
UnstyledDialog(
visible = match != null,
onDismissRequest = { match = null },
) {
DialogPanel(
modifier = Modifier.fillMaxSize(),
paneTitle = "It's a match!",
enter =
fadeIn(tween(260)) +
scaleIn(initialScale = 0.94f, animationSpec = tween(380)),
exit =
fadeOut(tween(260)) +
slideOutVertically(
targetOffsetY = { it / 10 },
animationSpec = tween(260, easing = FastOutSlowInEasing),
),
) {
SystemBars(
statusBar = SystemBarContent.Light,
navigationBar = SystemBarContent.Light,
)
matchContent?.let { person ->
MatchMoment(
person,
onContinue = { match = null },
onConversation = {
match = null
navigateToConversation(person)
},
)
}
}
}
},
) {
Box(
Modifier.align(Alignment.Center)
.padding(start = 8.dp, end = 8.dp, top = 8.dp, bottom = bottomPadding + 8.dp)
.widthIn(max = 480.dp)
.fillMaxSize(),
contentAlignment = Alignment.Center,
) {
if (currentIndex < people.size) {
// Invisible until the top card is dragged, so screen readers skip it.
Box(
Modifier.fillMaxSize()
.clearAndSetSemantics {}
.graphicsLayer {
alpha = reveal
scaleX = 0.93f + 0.07f * reveal
scaleY = 0.93f + 0.07f * reveal
translationY = (1f - reveal) * 22.dp.toPx()
}
) {
val next = people.getOrNull(currentIndex + 1)
if (next != null) profileCards[currentIndex + 1](Modifier.fillMaxSize())
else EndOfPile(Modifier.fillMaxSize())
}
val current = people[currentIndex]
key(currentIndex) {
SwipeCard(
profile = current,
profileCard = profileCards[currentIndex],
modifier = Modifier.fillMaxSize(),
onDragProgress = { reveal = it },
onOpenProfile = { navigateToProfile(current) },
onSwiped = { liked ->
completedSwipes++
currentIndex++
if (liked && completedSwipes >= 3 && !hasMatched) {
hasMatched = true
matchContent = current
match = current
}
},
)
}
} else {
EndOfPile(Modifier.fillMaxSize())
}
}
}
}
@Composable
private fun EndOfPile(modifier: Modifier = Modifier) {
Column(
modifier,
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Text("You're all caught up", style = Theme.typography.headline.copy(fontSize = 26.sp))
Spacer(Modifier.height(10.dp))
Text("Check back soon for new people.", color = Theme.colors.onBackgroundMuted)
}
}
@Composable
private fun SwipeCard(
profile: Person,
profileCard: @Composable (Modifier) -> Unit,
modifier: Modifier = Modifier,
onDragProgress: (Float) -> Unit,
onOpenProfile: () -> Unit,
onSwiped: (Boolean) -> Unit,
) {
var offset by remember { mutableStateOf(Offset.Zero) }
var settling by remember { mutableStateOf(false) }
var cardWidth by remember { mutableIntStateOf(1) }
val scope = rememberCoroutineScope()
fun moveTo(value: Offset) {
offset = value
onDragProgress((abs(value.x) / (cardWidth * 0.3f)).coerceIn(0f, 1f))
}
fun settle(target: Offset, decision: Boolean?) {
settling = true
scope.launch {
animate(Offset.VectorConverter, offset, target, animationSpec = tween(260)) { value, _
->
moveTo(value)
}
if (decision == null) {
settling = false
} else {
onSwiped(decision)
}
}
}
Box(
modifier
.onSizeChanged { cardWidth = it.width }
.graphicsLayer {
translationX = offset.x
translationY = offset.y
rotationZ = (offset.x / size.width * 13f).coerceIn(-13f, 13f)
}
.pointerInput(profile.name) {
detectDragGestures(
onDragEnd = {
if (!settling) {
val threshold = size.width * 0.27f
when {
offset.x > threshold ->
settle(Offset(size.width * 1.5f, offset.y), true)
offset.x < -threshold ->
settle(Offset(-size.width * 1.5f, offset.y), false)
else -> settle(Offset.Zero, null)
}
}
},
onDragCancel = { if (!settling) settle(Offset.Zero, null) },
onDrag = { change, amount ->
change.consume()
if (!settling) moveTo(offset + amount)
},
)
}
.testTag("swipe-card")
.semantics { contentDescription = "${profile.name}, ${profile.age}" }
) {
profileCard(
Modifier.fillMaxSize()
.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = null,
onClickLabel = "View ${profile.name}'s profile",
onClick = onOpenProfile,
)
)
val progress = (abs(offset.x) / 130f).coerceIn(0f, 1f)
if (offset.x > 1f)
SwipeMark(true, Modifier.align(Alignment.TopStart).padding(24.dp), progress)
if (offset.x < -1f)
SwipeMark(false, Modifier.align(Alignment.TopEnd).padding(24.dp), progress)
}
}
@Composable
private fun SwipeMark(liked: Boolean, modifier: Modifier = Modifier, progress: Float) {
Box(
modifier
.graphicsLayer {
alpha = progress
translationX = if (liked) progress * 12f else -progress * 12f
}
.size(68.dp)
.clip(CircleShape)
.background(Theme.colors.surface)
.semantics { contentDescription = if (liked) "Like" else "Pass" },
contentAlignment = Alignment.Center,
) {
Icon(
imageVector = if (liked) Icons.Check else Icons.X,
contentDescription = null,
modifier = Modifier.size(40.dp),
tint = Theme.colors.onSurface,
)
}
}
@Composable
private fun MatchMoment(
person: Person,
modifier: Modifier = Modifier,
onContinue: () -> Unit,
onConversation: () -> Unit,
) {
val entrance = remember(person) { Animatable(0f) }
LaunchedEffect(person) {
entrance.animateTo(
1f,
tween(durationMillis = 480, delayMillis = 90, easing = FastOutSlowInEasing),
)
}
BoxWithConstraints(
modifier
.fillMaxSize()
.background(
Brush.linearGradient(
listOf(Theme.colors.accent, Theme.colors.onBackground, Color(0xFF102B29))
)
),
contentAlignment = Alignment.Center,
) {
val compact = maxHeight < 500.dp
val portraitSize = if (compact) 120.dp else 154.dp
Column(
Modifier.graphicsLayer {
alpha = entrance.value
translationY = (1f - entrance.value) * 28.dp.toPx()
}
.padding(horizontal = 24.dp, vertical = 12.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
"Pairel".uppercase(),
color = Theme.colors.primary,
style = Theme.typography.caption.copy(fontSize = 13.sp, letterSpacing = 3.sp),
)
Spacer(Modifier.height(if (compact) 7.dp else 18.dp))
Text(
"It's a match!",
color = Theme.colors.background,
style =
Theme.typography.display.copy(
fontSize = if (compact) 35.sp else 46.sp,
textAlign = TextAlign.Center,
),
)
Spacer(Modifier.height(if (compact) 5.dp else 12.dp))
Text(
"You and ${person.name} like each other.",
color = Theme.colors.background.copy(alpha = 0.86f),
style = Theme.typography.body.copy(textAlign = TextAlign.Center),
)
Spacer(Modifier.height(if (compact) 17.dp else 38.dp))
Box(
Modifier.size(width = portraitSize * 1.85f, height = portraitSize + 8.dp)
.graphicsLayer {
scaleX = 0.72f + 0.28f * entrance.value
scaleY = 0.72f + 0.28f * entrance.value
},
contentAlignment = Alignment.Center,
) {
MatchPortrait(
photoUrl = YourPhotoUrl,
modifier =
Modifier.align(Alignment.CenterStart)
.graphicsLayer { rotationZ = -9f }
.size(portraitSize),
description = "Your photo",
)
MatchPortrait(
photoUrl = person.photoUrl,
modifier =
Modifier.align(Alignment.CenterEnd)
.graphicsLayer { rotationZ = 9f }
.size(portraitSize),
description = "${person.name}'s photo",
)
Box(
Modifier.align(Alignment.BottomCenter)
.size(if (compact) 44.dp else 54.dp)
.border(4.dp, Theme.colors.onBackground, CircleShape)
.clip(CircleShape)
.background(Theme.colors.primary),
contentAlignment = Alignment.Center,
) {
Icon(
imageVector = Icons.Heart,
contentDescription = null,
modifier = Modifier.size(if (compact) 26.dp else 32.dp),
tint = Theme.colors.background,
)
}
}
Spacer(Modifier.height(if (compact) 12.dp else 20.dp))
Row(
Modifier.width(portraitSize * 1.85f),
horizontalArrangement = Arrangement.SpaceBetween,
) {
val labelStyle = Theme.typography.caption.copy(letterSpacing = 1.sp)
Text(
"You".uppercase(),
color = Theme.colors.background.copy(alpha = 0.8f),
style = labelStyle,
)
Text(
person.name.uppercase(),
color = Theme.colors.background.copy(alpha = 0.8f),
style = labelStyle,
)
}
Spacer(Modifier.height(if (compact) 18.dp else 42.dp))
Button(onClick = onConversation) { Text("Send a message") }
Spacer(Modifier.height(8.dp))
Button(onClick = onContinue) { Text("Keep discovering") }
}
}
}
@Composable
private fun MatchPortrait(
photoUrl: String,
description: String,
modifier: Modifier = Modifier,
) {
Box(
modifier.border(5.dp, Theme.colors.background, CircleShape).padding(5.dp).clip(CircleShape)
) {
Image(
painter =
rememberUriPainter(
photoUrl,
crossfade = 300.milliseconds,
contentScale = ContentScale.Crop,
),
contentDescription = description,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize(),
)
}
}
@Composable
private fun ProfileCard(profile: Person, modifier: Modifier = Modifier) {
Box(modifier.clip(Theme.shapes.large).background(Theme.colors.onBackground)) {
Image(
painter =
rememberUriPainter(
profile.photoUrl,
crossfade = 300.milliseconds,
contentScale = ContentScale.Crop,
),
contentDescription = null,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize(),
)
Column(
Modifier.align(Alignment.BottomStart)
.fillMaxWidth()
.background(
Brush.verticalGradient(
0f to Color.Transparent,
0.4f to Color.Black.copy(alpha = 0.6f),
1f to Color.Black.copy(alpha = 0.82f),
)
)
.padding(start = 24.dp, end = 24.dp, bottom = 24.dp, top = 96.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
Text(
"${profile.name}, ${profile.age}",
color = Color.White,
style = Theme.typography.headline,
)
Text(
profile.bio,
color = Color.White.copy(alpha = 0.88f),
maxLines = 2,
overflow = TextOverflow.Ellipsis,
)
FlowRow(
modifier = Modifier.padding(top = 4.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
) {
for (interest in profile.interests.take(3)) {
Tag(TagVariant.OnPhoto) { Text("${interest.emoji} ${interest.label}") }
}
}
}
}
}
package com.composables.pairel
data class Interest(val emoji: String, val label: String)
internal val interestGroups =
listOf(
"Outdoors" to
listOf(
Interest("๐ฅพ", "Hiking"),
Interest("๐", "Running"),
Interest("๐ฒ", "Cycling"),
Interest("๐ง", "Climbing"),
Interest("โบ", "Camping"),
Interest("๐ฑ", "Gardening"),
),
"Food and drink" to
listOf(
Interest("๐ต", "Tea"),
Interest("โ", "Coffee"),
Interest("๐ณ", "Cooking"),
Interest("๐ง", "Baking"),
Interest("๐ท", "Wine"),
Interest("๐ฅ", "Brunch"),
),
"Culture" to
listOf(
Interest("๐", "Bookshops"),
Interest("๐จ", "Museums"),
Interest("๐ถ", "Live music"),
Interest("๐ฌ", "Film"),
Interest("๐ญ", "Theatre"),
Interest("๐ท", "Photography"),
),
"At home" to
listOf(
Interest("๐ถ", "Dogs"),
Interest("๐ฑ", "Cats"),
Interest("๐ฒ", "Board games"),
Interest("๐ง", "Podcasts"),
Interest("๐งถ", "Crafts"),
Interest("๐ง", "Yoga"),
),
)
internal fun interests(vararg labels: String): List<Interest> {
val all = interestGroups.flatMap { it.second }
return labels.map { label -> all.first { it.label == label } }
}
package com.composables.pairel
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.composables.pairel.components.BottomBar
import com.composables.pairel.components.BottomBarHeight
import com.composables.pairel.components.BottomBarItem
import com.composables.pairel.components.Icon
import com.composables.pairel.components.PairelDialogHost
import com.composables.pairel.components.Text
import com.composables.pairel.theme.Compass
import com.composables.pairel.theme.Heart
import com.composables.pairel.theme.Icons
import com.composables.pairel.theme.User
internal val MainNavigationBarHeight = BottomBarHeight
@Composable
internal fun mainNavigationContentPadding(): PaddingValues =
PaddingValues(
bottom =
MainNavigationBarHeight +
WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
)
@Composable
internal fun MainNavigationLayout(
navigationBar: @Composable () -> Unit,
modifier: Modifier = Modifier,
content: @Composable (contentPadding: PaddingValues) -> Unit,
) {
PairelDialogHost(modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize()) {
content(mainNavigationContentPadding())
Box(Modifier.align(Alignment.BottomCenter)) { navigationBar() }
}
}
}
enum class MainDestination {
Discover,
Matches,
MyProfile,
}
@Composable
internal fun MainNavigationBar(
selected: MainDestination,
navigateToDiscover: () -> Unit,
navigateToMatches: () -> Unit,
navigateToMyProfile: () -> Unit,
modifier: Modifier = Modifier,
) {
BottomBar(modifier = modifier) {
BottomBarItem(
selected = selected == MainDestination.Matches,
onClick = { if (selected != MainDestination.Matches) navigateToMatches() },
icon = {
Icon(Icons.Heart, contentDescription = null, modifier = Modifier.size(24.dp))
},
label = { Text("Matches") },
)
BottomBarItem(
selected = selected == MainDestination.Discover,
onClick = { if (selected != MainDestination.Discover) navigateToDiscover() },
icon = {
Icon(Icons.Compass, contentDescription = null, modifier = Modifier.size(24.dp))
},
label = { Text("Discover") },
)
BottomBarItem(
selected = selected == MainDestination.MyProfile,
onClick = { if (selected != MainDestination.MyProfile) navigateToMyProfile() },
icon = { Icon(Icons.User, contentDescription = null, modifier = Modifier.size(24.dp)) },
label = { Text("My profile") },
)
}
}
package com.composables.pairel
internal const val YourPhotoUrl =
"https://images.unsplash.com/photo-1492562080023-ab3db95bfbce?fit=crop&w=700&h=900&q=85"
data class Person(
val name: String,
val age: Int,
val photoUrl: String,
val bio: String,
val interests: List<Interest>,
)
internal val people =
listOf(
Person(
"Nina",
29,
"https://images.unsplash.com/photo-1487412720507-e7ab37603c6f?fit=crop&w=900&h=1350&q=85",
"Here for real conversation, little adventures, and excellent noodles.",
interests("Climbing", "Board games", "Cooking"),
),
Person(
"Chloe",
30,
"https://images.unsplash.com/photo-1567532939604-b6b5b0db2604?fit=crop&w=900&h=1350&q=85",
"A curious cook who likes slow mornings and last-minute plans.",
interests("Cooking", "Brunch", "Coffee"),
),
Person(
"Sofia",
31,
"https://images.unsplash.com/photo-1772989665252-7cb41ae759cc?fit=crop&w=900&h=1350&q=85",
"Usually looking for a new place to walk, a good bookshop, or both.",
interests("Bookshops", "Cooking", "Coffee"),
),
Person(
"Ivy",
27,
"https://images.unsplash.com/photo-1489424731084-a5d8b219a5bb?fit=crop&w=900&h=1350&q=85",
"Big on live music, kind people, and getting outside.",
interests("Live music", "Hiking", "Cycling"),
),
Person(
"Amara",
33,
"https://images.unsplash.com/photo-1531123897727-8f129e1688ce?fit=crop&w=900&h=1350&q=85",
"Designer by day, enthusiastic home cook by night.",
interests("Cooking", "Photography", "Museums"),
),
)
package com.composables.pairel.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.union
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.composables.pairel.theme.ProvideContentColor
import com.composables.pairel.theme.ProvideTextStyle
import com.composables.pairel.theme.Space
import com.composables.pairel.theme.Theme
val AppBarHeight = 64.dp
@Composable
fun AppBar(
title: @Composable () -> Unit,
navigation: @Composable () -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
modifier: Modifier = Modifier,
) {
ProvideContentColor(Theme.colors.onBackground) {
Row(
modifier =
modifier
.fillMaxWidth()
.background(Theme.colors.background)
.pointerInput(Unit) {
awaitPointerEventScope { while (true) awaitPointerEvent() }
}
.windowInsetsPadding(
WindowInsets.statusBars.union(
WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)
)
)
.height(AppBarHeight)
.padding(horizontal = 20.dp),
verticalAlignment = Alignment.CenterVertically,
) {
Box(Modifier.offset(x = -(Space * 3))) { navigation() }
Box(Modifier.weight(1f), contentAlignment = Alignment.CenterStart) {
Box(Modifier.heightIn(min = 48.dp), contentAlignment = Alignment.CenterStart) {
ProvideTextStyle(
Theme.typography.title.copy(fontSize = 26.sp, lineHeight = 38.sp),
title,
)
}
}
Row(verticalAlignment = Alignment.CenterVertically, content = actions)
}
}
}
package com.composables.pairel.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.union
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.unit.dp
import com.composables.pairel.theme.Theme
val BottomBarHeight = 64.dp
@Composable
fun BottomBar(
modifier: Modifier = Modifier,
content: @Composable RowScope.() -> Unit,
) {
val borderColor = Theme.colors.border
Row(
modifier =
modifier
.fillMaxWidth()
.background(Theme.colors.surface)
.drawBehind {
val stroke = 1.dp.toPx()
drawLine(
borderColor,
Offset(0f, stroke / 2),
Offset(size.width, stroke / 2),
stroke,
)
}
.pointerInput(Unit) { awaitPointerEventScope { while (true) awaitPointerEvent() } }
.windowInsetsPadding(
WindowInsets.navigationBars.union(
WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal)
)
)
.height(BottomBarHeight)
.padding(horizontal = 20.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
content = content,
)
}
package com.composables.pairel.components
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.indication
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.selection.selectable
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.dp
import com.composables.compose.ripple.rememberRippleIndication
import com.composables.pairel.theme.ProvideContentColor
import com.composables.pairel.theme.ProvideTextStyle
import com.composables.pairel.theme.Theme
@Composable
fun BottomBarItem(
selected: Boolean,
onClick: () -> Unit,
icon: @Composable () -> Unit,
label: @Composable () -> Unit,
modifier: Modifier = Modifier,
) {
val interactionSource = remember { MutableInteractionSource() }
val contentColor by
animateColorAsState(
if (selected) Theme.colors.onSurface else Theme.colors.onSurfaceInactive,
label = "Bottom bar item content",
)
val indicatorAlpha by
animateFloatAsState(
if (selected) 1f else 0f,
label = "Bottom bar item indicator",
)
Column(
modifier =
modifier
.clip(Theme.shapes.small)
.selectable(
selected = selected,
onClick = onClick,
role = Role.Tab,
interactionSource = interactionSource,
indication = null,
)
.padding(horizontal = 12.dp, vertical = 6.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(4.dp),
) {
ProvideContentColor(contentColor) {
Box(
Modifier.clip(Theme.shapes.fullyRounded)
.background(
Theme.colors.surfaceVariant.copy(alpha = indicatorAlpha.coerceIn(0f, 1f))
)
.indication(
interactionSource = interactionSource,
indication =
rememberRippleIndication(
color = Theme.colors.onSurface,
bounded = false,
),
)
.padding(horizontal = 20.dp, vertical = 4.dp),
contentAlignment = Alignment.Center,
) {
icon()
}
ProvideTextStyle(Theme.typography.caption, label)
}
}
}
package com.composables.pairel.components
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import com.composables.compose.ripple.rememberRippleIndication
import com.composables.pairel.theme.ProvideContentColor
import com.composables.pairel.theme.ProvideTextStyle
import com.composables.pairel.theme.Space
import com.composables.pairel.theme.Theme
import com.composeunstyled.UnstyledButton
@Composable
fun Button(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
content: @Composable () -> Unit,
) {
val interactionSource = remember { MutableInteractionSource() }
UnstyledButton(
onClick = onClick,
enabled = enabled,
modifier =
modifier
.alpha(if (enabled) 1f else 0.45f)
.clip(Theme.shapes.large)
.background(Theme.colors.primary),
contentPadding = PaddingValues(horizontal = Space * 6, vertical = Space * 3.5f),
indication = rememberRippleIndication(color = Theme.colors.onPrimary),
interactionSource = interactionSource,
) {
ProvideContentColor(Theme.colors.onPrimary) {
ProvideTextStyle(Theme.typography.label, content)
}
}
}
package com.composables.pairel.components
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.graphics.vector.ImageVector
import com.composables.pairel.theme.LocalContentColor
import com.composeunstyled.UnstyledIcon
@Composable
fun Icon(
imageVector: ImageVector,
contentDescription: String?,
modifier: Modifier = Modifier,
tint: Color = LocalContentColor.current,
) {
val resolvedTint = if (tint.isSpecified) tint else LocalContentColor.current
UnstyledIcon(
imageVector = imageVector,
contentDescription = contentDescription,
modifier = modifier,
tint = resolvedTint,
)
}
package com.composables.pairel.components
import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import com.composables.compose.ripple.rememberRippleIndication
import com.composables.pairel.theme.ProvideContentColor
import com.composables.pairel.theme.Space
import com.composables.pairel.theme.Theme
import com.composeunstyled.UnstyledButton
enum class IconButtonVariant {
Neutral,
Primary,
}
@Composable
fun IconButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
variant: IconButtonVariant = IconButtonVariant.Neutral,
content: @Composable () -> Unit,
) {
val interactionSource = remember { MutableInteractionSource() }
val primary = variant == IconButtonVariant.Primary && enabled
val background = if (primary) Theme.colors.primary else Theme.colors.background
val contentColor = if (primary) Theme.colors.onPrimary else Theme.colors.onBackground
UnstyledButton(
onClick = onClick,
enabled = enabled,
modifier =
modifier
.alpha(if (enabled) 1f else 0.45f)
.size(Space * 12)
.clip(Theme.shapes.fullyRounded)
.background(background),
contentPadding = PaddingValues(Space * 3),
indication = rememberRippleIndication(color = contentColor),
interactionSource = interactionSource,
) {
ProvideContentColor(contentColor, content)
}
}
package com.composables.pairel.components
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import com.composeunstyled.DialogHost
private val LocalHasDialogHost = staticCompositionLocalOf { false }
@Composable
internal fun PairelDialogHost(modifier: Modifier = Modifier, content: @Composable () -> Unit) {
if (LocalHasDialogHost.current) {
content()
} else {
CompositionLocalProvider(LocalHasDialogHost provides true) {
DialogHost(modifier = modifier, content = content)
}
}
}
package com.composables.pairel.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
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.graphics.luminance
import com.composables.pairel.theme.ProvideContentColor
import com.composables.pairel.theme.Theme
import com.composables.systembars.SystemBarContent
import com.composables.systembars.SystemBars
import com.composeunstyled.DrawerHost
import com.composeunstyled.TooltipHost
enum class ScreenBackground {
Paper,
Surface,
}
@Composable
fun ScreenScaffold(
modifier: Modifier = Modifier,
background: ScreenBackground = ScreenBackground.Paper,
topBar: @Composable () -> Unit = {},
bottomBar: @Composable () -> Unit = {},
overlay: @Composable BoxScope.() -> Unit = {},
content: @Composable BoxScope.() -> Unit,
) {
val backgroundColor =
when (background) {
ScreenBackground.Paper -> Theme.colors.background
ScreenBackground.Surface -> Theme.colors.surface
}
SystemBars(all = systemBarContentOn(backgroundColor))
val contentColor =
when (background) {
ScreenBackground.Paper -> Theme.colors.onBackground
ScreenBackground.Surface -> Theme.colors.onSurface
}
DrawerHost(modifier = modifier.fillMaxSize()) {
PairelDialogHost(Modifier.fillMaxSize()) {
TooltipHost(Modifier.fillMaxSize()) {
Box(Modifier.fillMaxSize().background(backgroundColor)) {
ProvideContentColor(contentColor) {
Column(Modifier.fillMaxSize()) {
topBar()
Box(Modifier.weight(1f).fillMaxWidth(), content = content)
}
Box(Modifier.align(Alignment.BottomCenter)) { bottomBar() }
overlay()
}
}
}
}
}
}
private fun systemBarContentOn(background: Color): SystemBarContent =
if (background.luminance() > 0.5f) SystemBarContent.Dark else SystemBarContent.Light
package com.composables.pairel.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.composables.pairel.theme.ProvideContentColor
import com.composables.pairel.theme.ProvideTextStyle
import com.composables.pairel.theme.Theme
enum class TagVariant {
Neutral,
OnPhoto,
}
@Composable
fun Tag(
variant: TagVariant,
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
val (background, contentColor) =
when (variant) {
TagVariant.Neutral -> Theme.colors.surfaceVariant to Theme.colors.onSurfaceVariant
TagVariant.OnPhoto -> Color.White.copy(alpha = 0.22f) to Color.White
}
Box(
modifier
.clip(Theme.shapes.fullyRounded)
.background(background)
.padding(horizontal = 12.dp, vertical = 6.dp)
) {
ProvideContentColor(contentColor) {
ProvideTextStyle(
Theme.typography.label.copy(fontSize = 14.sp, lineHeight = 18.sp),
content,
)
}
}
}
package com.composables.pairel.components
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextOverflow
import com.composables.pairel.theme.LocalContentColor
import com.composables.pairel.theme.LocalTextStyle
@Composable
fun Text(
text: String,
modifier: Modifier = Modifier,
color: Color = Color.Unspecified,
style: TextStyle = LocalTextStyle.current,
overflow: TextOverflow = TextOverflow.Clip,
softWrap: Boolean = true,
maxLines: Int = Int.MAX_VALUE,
) {
val resolvedColor =
when {
color.isSpecified -> color
style.color.isSpecified -> style.color
else -> LocalContentColor.current
}
BasicText(
text = text,
modifier = modifier,
style = LocalTextStyle.current.merge(style).copy(color = resolvedColor),
overflow = overflow,
softWrap = softWrap,
maxLines = maxLines,
)
}
package com.composables.pairel.theme
/*
* Icon from Lucide (lucide).
* License: ISC
*
* ISC License
*
* Copyright (c) 2026 Lucide Icons and Contributors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* ---
*
* The following Lucide icons are derived from the Feather project:
*
* airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
*
* The MIT License (MIT) (for the icons listed above)
*
* Copyright (c) 2013-present Cole Bemis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.StrokeJoin
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp
object Icons
val Icons.ArrowLeft: ImageVector
get() {
if (_ArrowLeft != null) return _ArrowLeft!!
_ArrowLeft =
ImageVector.Builder(
name = "arrow-left",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(12f, 19f)
lineToRelative(-7f, -7f)
lineToRelative(7f, -7f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(19f, 12f)
horizontalLineTo(5f)
}
}
.build()
return _ArrowLeft!!
}
private var _ArrowLeft: ImageVector? = null
val Icons.X: ImageVector
get() {
if (_X != null) return _X!!
_X =
ImageVector.Builder(
name = "x",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(18f, 6f)
lineTo(6f, 18f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(6f, 6f)
lineToRelative(12f, 12f)
}
}
.build()
return _X!!
}
private var _X: ImageVector? = null
val Icons.Check: ImageVector
get() {
if (_Check != null) return _Check!!
_Check =
ImageVector.Builder(
name = "check",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(20f, 6f)
lineTo(9f, 17f)
lineToRelative(-5f, -5f)
}
}
.build()
return _Check!!
}
private var _Check: ImageVector? = null
val Icons.Heart: ImageVector
get() {
if (_Heart != null) return _Heart!!
_Heart =
ImageVector.Builder(
name = "heart",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(2f, 9.5f)
arcToRelative(5.5f, 5.5f, 0f, false, true, 9.591f, -3.676f)
arcToRelative(0.56f, 0.56f, 0f, false, false, 0.818f, 0f)
arcTo(5.49f, 5.49f, 0f, false, true, 22f, 9.5f)
curveToRelative(0f, 2.29f, -1.5f, 4f, -3f, 5.5f)
lineToRelative(-5.492f, 5.313f)
arcToRelative(2f, 2f, 0f, false, true, -3f, 0.019f)
lineTo(5f, 15f)
curveToRelative(-1.5f, -1.5f, -3f, -3.2f, -3f, -5.5f)
}
}
.build()
return _Heart!!
}
private var _Heart: ImageVector? = null
val Icons.Ellipsis: ImageVector
get() {
if (_Ellipsis != null) return _Ellipsis!!
_Ellipsis =
ImageVector.Builder(
name = "ellipsis",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
for (x in listOf(5f, 12f, 19f)) {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(x + 1f, 12f)
arcTo(1f, 1f, 0f, false, true, x, 13f)
arcTo(1f, 1f, 0f, false, true, x - 1f, 12f)
arcTo(1f, 1f, 0f, false, true, x + 1f, 12f)
close()
}
}
}
.build()
return _Ellipsis!!
}
private var _Ellipsis: ImageVector? = null
val Icons.SendHorizontal: ImageVector
get() {
if (_SendHorizontal != null) return _SendHorizontal!!
_SendHorizontal =
ImageVector.Builder(
name = "send-horizontal",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(3.714f, 3.048f)
arcToRelative(0.498f, 0.498f, 0f, false, false, -0.683f, 0.627f)
lineToRelative(2.843f, 7.627f)
arcToRelative(2f, 2f, 0f, false, true, 0f, 1.396f)
lineToRelative(-2.842f, 7.627f)
arcToRelative(0.498f, 0.498f, 0f, false, false, 0.682f, 0.627f)
lineToRelative(18f, -8.5f)
arcToRelative(0.5f, 0.5f, 0f, false, false, 0f, -0.904f)
close()
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(6f, 12f)
horizontalLineToRelative(16f)
}
}
.build()
return _SendHorizontal!!
}
private var _SendHorizontal: ImageVector? = null
val Icons.SlidersHorizontal: ImageVector
get() {
if (_SlidersHorizontal != null) return _SlidersHorizontal!!
_SlidersHorizontal =
ImageVector.Builder(
name = "sliders-horizontal",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(10f, 5f)
horizontalLineTo(3f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(12f, 19f)
horizontalLineTo(3f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(14f, 3f)
verticalLineToRelative(4f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(16f, 17f)
verticalLineToRelative(4f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(21f, 12f)
horizontalLineToRelative(-9f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(21f, 19f)
horizontalLineToRelative(-5f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(21f, 5f)
horizontalLineToRelative(-7f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(8f, 10f)
verticalLineToRelative(4f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(8f, 12f)
horizontalLineTo(3f)
}
}
.build()
return _SlidersHorizontal!!
}
private var _SlidersHorizontal: ImageVector? = null
val Icons.Compass: ImageVector
get() {
if (_Compass != null) return _Compass!!
_Compass =
ImageVector.Builder(
name = "compass",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(22f, 12f)
arcTo(10f, 10f, 0f, false, true, 12f, 22f)
arcTo(10f, 10f, 0f, false, true, 2f, 12f)
arcTo(10f, 10f, 0f, false, true, 22f, 12f)
close()
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(16.24f, 7.76f)
lineToRelative(-1.804f, 5.411f)
arcToRelative(2f, 2f, 0f, false, true, -1.265f, 1.265f)
lineTo(7.76f, 16.24f)
lineToRelative(1.804f, -5.411f)
arcToRelative(2f, 2f, 0f, false, true, 1.265f, -1.265f)
close()
}
}
.build()
return _Compass!!
}
private var _Compass: ImageVector? = null
val Icons.User: ImageVector
get() {
if (_User != null) return _User!!
_User =
ImageVector.Builder(
name = "user",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(19f, 21f)
verticalLineToRelative(-2f)
arcToRelative(4f, 4f, 0f, false, false, -4f, -4f)
horizontalLineTo(9f)
arcToRelative(4f, 4f, 0f, false, false, -4f, 4f)
verticalLineToRelative(2f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(16f, 7f)
arcTo(4f, 4f, 0f, false, true, 12f, 11f)
arcTo(4f, 4f, 0f, false, true, 8f, 7f)
arcTo(4f, 4f, 0f, false, true, 16f, 7f)
close()
}
}
.build()
return _User!!
}
private var _User: ImageVector? = null
val Icons.ChevronRight: ImageVector
get() {
if (_ChevronRight != null) return _ChevronRight!!
_ChevronRight =
ImageVector.Builder(
name = "chevron-right",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(9f, 18f)
lineToRelative(6f, -6f)
lineToRelative(-6f, -6f)
}
}
.build()
return _ChevronRight!!
}
private var _ChevronRight: ImageVector? = null
val Icons.Plus: ImageVector
get() {
if (_Plus != null) return _Plus!!
_Plus =
ImageVector.Builder(
name = "plus",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f,
)
.apply {
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(5f, 12f)
horizontalLineToRelative(14f)
}
path(
fill = SolidColor(Color.Transparent),
stroke = SolidColor(Color.Black),
strokeLineWidth = 2f,
strokeLineCap = StrokeCap.Round,
strokeLineJoin = StrokeJoin.Round,
) {
moveTo(12f, 5f)
verticalLineToRelative(14f)
}
}
.build()
return _Plus!!
}
private var _Plus: ImageVector? = null
package com.composables.pairel.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.graphics.*
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.*
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.*
import androidx.compose.ui.unit.*
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.composables.googlefonts.rememberGoogleFontFamily
@Immutable
data class ThemeColors(
val `background`: Color = Color(0xFFF8F5EF),
val `onBackground`: Color = Color(0xFF173D3A),
val `surface`: Color = Color(0xFFFFFFFF),
val `onSurface`: Color = Color(0xFF173D3A),
val `surfaceVariant`: Color = Color(0xFFECE8DD),
val `onSurfaceVariant`: Color = Color(0xFF173D3A),
val `primary`: Color = Color(0xFFF58C76),
val `onPrimary`: Color = Color(0xFF173D3A),
val `accent`: Color = Color(0xFF24675D),
val `onAccent`: Color = Color(0xFFF8F5EF),
val `textSelection`: Color = Color(0x6624675D),
val `onBackgroundMuted`: Color = Color(0xFF5A6B67),
val `onSurfaceInactive`: Color = Color(0xFF5A6B67),
val `border`: Color = Color(0xFFDCDDD4),
val `destructive`: Color = Color(0xFFB42318),
)
@Immutable
data class ThemeTypography(
val `display`: TextStyle =
TextStyle(
fontFamily = FontFamily.SansSerif,
fontSize = 46.sp,
lineHeight = 52.sp,
fontWeight = FontWeight(700),
),
val `headline`: TextStyle =
TextStyle(
fontFamily = FontFamily.SansSerif,
fontSize = 32.sp,
lineHeight = 38.sp,
fontWeight = FontWeight(700),
),
val `title`: TextStyle =
TextStyle(
fontFamily = FontFamily.SansSerif,
fontSize = 22.sp,
lineHeight = 28.sp,
fontWeight = FontWeight(700),
),
val `quote`: TextStyle =
TextStyle(
fontFamily = FontFamily.SansSerif,
fontSize = 23.sp,
lineHeight = 31.sp,
fontWeight = FontWeight(400),
),
val `body`: TextStyle =
TextStyle(
fontFamily = FontFamily.SansSerif,
fontSize = 16.sp,
lineHeight = 24.sp,
fontWeight = FontWeight(400),
),
val `label`: TextStyle =
TextStyle(
fontFamily = FontFamily.SansSerif,
fontSize = 16.sp,
lineHeight = 20.sp,
fontWeight = FontWeight(700),
),
val `caption`: TextStyle =
TextStyle(
fontFamily = FontFamily.SansSerif,
fontSize = 12.sp,
lineHeight = 16.sp,
fontWeight = FontWeight(700),
),
)
@Immutable
data class ThemeShapes(
val `small`: Shape = RoundedCornerShape(12.dp),
val `large`: Shape = RoundedCornerShape(24.dp),
val `fullyRounded`: Shape = RoundedCornerShape(50),
)
fun themeColors(dark: Boolean = false): ThemeColors = ThemeColors()
@Composable
fun resolveThemeTypography(typography: ThemeTypography = ThemeTypography()): ThemeTypography {
val font0 = rememberGoogleFontFamily("Fraunces", weights = intArrayOf(400, 700))
val font1 = rememberGoogleFontFamily("DM Sans", weights = intArrayOf(400, 700))
return typography.copy(
`display` = typography.`display`.copy(fontFamily = font0),
`headline` = typography.`headline`.copy(fontFamily = font1),
`title` = typography.`title`.copy(fontFamily = font1),
`quote` = typography.`quote`.copy(fontFamily = font0),
`body` = typography.`body`.copy(fontFamily = font1),
`label` = typography.`label`.copy(fontFamily = font1),
`caption` = typography.`caption`.copy(fontFamily = font1),
)
}
private val LocalColors = staticCompositionLocalOf<ThemeColors> { error("Theme is missing") }
private val LocalTypography =
staticCompositionLocalOf<ThemeTypography> { error("Theme is missing") }
private val LocalSpace = staticCompositionLocalOf { 4.dp }
private val LocalShapes = staticCompositionLocalOf<ThemeShapes> { error("Theme is missing") }
val LocalContentColor = compositionLocalOf<Color> { error("Theme is missing") }
val LocalTextStyle = compositionLocalOf<TextStyle> { error("Theme is missing") }
object Theme {
val colors: ThemeColors
@Composable get() = LocalColors.current
val typography: ThemeTypography
@Composable get() = LocalTypography.current
val shapes: ThemeShapes
@Composable get() = LocalShapes.current
}
val Space: Dp
@Composable get() = LocalSpace.current
@Composable
fun PairelTheme(
colors: ThemeColors = themeColors(isSystemInDarkTheme()),
typography: ThemeTypography = resolveThemeTypography(),
space: Dp = 4.dp,
shapes: ThemeShapes = ThemeShapes(),
contentColor: Color = colors.onBackground,
textStyle: TextStyle = typography.body,
content: @Composable () -> Unit,
) {
CompositionLocalProvider(
LocalColors provides colors,
LocalTypography provides typography,
LocalSpace provides space,
LocalShapes provides shapes,
LocalContentColor provides contentColor,
LocalTextStyle provides textStyle,
LocalTextSelectionColors provides
TextSelectionColors(
handleColor = colors.accent,
backgroundColor = colors.textSelection,
),
content = content,
)
}
@Composable
fun ProvideContentColor(color: Color, content: @Composable () -> Unit) {
CompositionLocalProvider(LocalContentColor provides color, content = content)
}
@Composable
fun ProvideTextStyle(style: TextStyle, content: @Composable () -> Unit) {
CompositionLocalProvider(
LocalTextStyle provides LocalTextStyle.current.merge(style),
content = content,
)
}















