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

Fix bottom space from DayTab offsets in Timetable Screen #919

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ fun TimetableGrid(
val animatedScope = LocalAnimatedVisibilityScope.current

Row(
modifier = Modifier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

modifier = modifier
.testTag(TimetableGridTestTag)
.padding(
top = contentPadding.calculateTopPadding(),
Expand Down Expand Up @@ -171,7 +171,6 @@ fun TimetableGrid(
timetableState = timetableState,
timeLine = timeLine,
selectedDay = selectedDay,
modifier = modifier,
contentPadding = PaddingValues(
top = 16.dp + contentPadding.calculateTopPadding(),
bottom = 16.dp + 80.dp + contentPadding.calculateBottomPadding(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ internal fun TimetableList(

LazyColumn(
modifier = modifier.testTag(TimetableListTestTag)
.offset {
IntOffset(x = 0, y = nestedScrollStateHolder.uiState.dayTabOffsetY.toInt())
}
.nestedScroll(nestedScrollConnection),
state = scrollState,
verticalArrangement = Arrangement.spacedBy(32.dp),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.droidkaigi.confsched.sessions.section

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.calculateEndPadding
import androidx.compose.foundation.layout.calculateStartPadding
Expand All @@ -20,7 +20,9 @@ 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.graphics.Color
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
Expand All @@ -29,6 +31,7 @@ import io.github.droidkaigi.confsched.model.DroidKaigi2024Day
import io.github.droidkaigi.confsched.model.TimeLine
import io.github.droidkaigi.confsched.model.TimetableItem
import io.github.droidkaigi.confsched.sessions.component.TimetableDayTab
import io.github.droidkaigi.confsched.sessions.component.TimetableNestedScrollStateHolder
import io.github.droidkaigi.confsched.sessions.component.rememberTimetableNestedScrollStateHolder
import io.github.droidkaigi.confsched.sessions.section.TimetableUiState.Empty
import io.github.droidkaigi.confsched.sessions.section.TimetableUiState.GridTimetable
Expand Down Expand Up @@ -71,9 +74,8 @@ fun Timetable(
Surface(
modifier = modifier.padding(contentPadding.calculateTopPadding()),
) {
Column(
modifier = Modifier
.fillMaxSize(),
Box(
modifier = Modifier.fillMaxSize(),
) {
TimetableDayTab(
selectedDay = selectedDay,
Expand All @@ -100,9 +102,7 @@ fun Timetable(
scrollState = scrollStates.getValue(selectedDay),
onTimetableItemClick = onTimetableItemClick,
onBookmarkClick = onFavoriteClick,
modifier = Modifier
.fillMaxSize()
.weight(1f),
modifier = timetableModifier(nestedScrollStateHolder),
contentPadding = PaddingValues(
bottom = contentPadding.calculateBottomPadding(),
start = contentPadding.calculateStartPadding(layoutDirection),
Expand All @@ -119,9 +119,7 @@ fun Timetable(
timeLine = uiState.timeLine,
selectedDay = selectedDay,
onTimetableItemClick = onTimetableItemClick,
modifier = Modifier
.fillMaxSize()
.weight(1f),
modifier = timetableModifier(nestedScrollStateHolder),
contentPadding = PaddingValues(
bottom = contentPadding.calculateBottomPadding(),
start = contentPadding.calculateStartPadding(layoutDirection),
Expand Down Expand Up @@ -160,3 +158,19 @@ private fun rememberGridTimetableStates(): Map<DroidKaigi2024Day, TimetableState
}
return remember { timetableStateMap }
}

@Composable
private fun timetableModifier(
nestedScrollStateHolder: TimetableNestedScrollStateHolder,
): Modifier {
val density = LocalDensity.current

return Modifier
.padding(
top = with(density) {
(nestedScrollStateHolder.uiState.scrollConnectionMinOffset + nestedScrollStateHolder.uiState.dayTabOffsetY).toDp()
},
)
.fillMaxSize()
.background(Color.Transparent)
}
Loading