Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Modifier.animateBounds() to JetLagged #1473

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge changes
riggaroo committed Sep 21, 2024
commit b0b05865e3f17ec905e55360d08176165fdc546f
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ fun JetLaggedScreen(
val insets = WindowInsets.safeDrawing.only(
WindowInsetsSides.Bottom + WindowInsetsSides.Horizontal
)
val boundsTransform = { _ : Rect, _: Rect ->
val boundsTransform = { _: Rect, _: Rect ->
spring(
dampingRatio = Spring.DampingRatioNoBouncy,
stiffness = Spring.StiffnessMedium,
@@ -102,42 +102,34 @@ fun JetLaggedScreen(
LookaheadScope {
val animateBoundsModifier = Modifier.animateBounds(
lookaheadScope = this@LookaheadScope,
boundsTransform = boundsTransform)
boundsTransform = boundsTransform
)
val timeSleepSummaryCards = remember {
movableContentOf {
AverageTimeInBedCard(animateBoundsModifier)
AverageTimeAsleepCard(animateBoundsModifier)
}
}
FlowRow(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(insets),
horizontalArrangement = Arrangement.Center,
verticalArrangement = Arrangement.Center,
maxItemsInEachRow = 3
) {
JetLaggedSleepGraphCard(uiState.value.sleepGraphData, Modifier.widthIn(max = 600.dp))
if (windowSizeClass == WindowWidthSizeClass.Compact) {
timeSleepSummaryCards()
} else {
FlowColumn {
FlowRow(
modifier = Modifier
.fillMaxSize()
.windowInsetsPadding(insets),
horizontalArrangement = Arrangement.Center,
verticalArrangement = Arrangement.Center,
maxItemsInEachRow = 3
) {
JetLaggedSleepGraphCard(
uiState.value.sleepGraphData,
Modifier.widthIn(max = 600.dp)
)
if (windowSizeClass == WindowWidthSizeClass.Compact) {
timeSleepSummaryCards()
} else {
FlowColumn {
timeSleepSummaryCards()
}
}
}
if (windowSizeClass == WindowWidthSizeClass.Compact) {
WellnessCard(
wellnessData = uiState.value.wellnessData,
modifier = animateBoundsModifier
.widthIn(max = 400.dp)
.heightIn(min = 200.dp)
)
HeartRateCard(
modifier = animateBoundsModifier.widthIn(max = 400.dp, min = 200.dp),
uiState.value.heartRateData
)
} else {
FlowColumn {
if (windowSizeClass == WindowWidthSizeClass.Compact) {
WellnessCard(
wellnessData = uiState.value.wellnessData,
modifier = animateBoundsModifier
@@ -148,9 +140,21 @@ fun JetLaggedScreen(
modifier = animateBoundsModifier.widthIn(max = 400.dp, min = 200.dp),
uiState.value.heartRateData
)
} else {
FlowColumn {
WellnessCard(
wellnessData = uiState.value.wellnessData,
modifier = animateBoundsModifier
.widthIn(max = 400.dp)
.heightIn(min = 200.dp)
)
HeartRateCard(
modifier = animateBoundsModifier.widthIn(max = 400.dp, min = 200.dp),
uiState.value.heartRateData
)
}
}
}
}
}
}
}