Skip to content

Commit

Permalink
Display content edge-to-edge (#91)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Felber <[email protected]>
  • Loading branch information
julian-wls and FelberMartin authored Nov 20, 2024
1 parent 5e0e776 commit d8cb940
Show file tree
Hide file tree
Showing 33 changed files with 372 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class MainActivity : AppCompatActivity(),

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()

// When the user is logged in, immediately display the course overview.
val startDestination = runBlocking {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContent
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyGridItemScope
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
Expand Down Expand Up @@ -71,7 +81,9 @@ fun CourseItemGrid(
columns = GridCells.Fixed(columnCount),
verticalArrangement = Arrangement.spacedBy(8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(bottom = 90.dp)
contentPadding = PaddingValues(
bottom = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
)
) {
items(courses, key = { it.course.id ?: 0L }) { course ->
courseItem(course, courseItemModifier, isCompact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.GridItemSpan
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
Expand Down Expand Up @@ -140,7 +144,8 @@ internal fun RegisterForCourseScreen(
RegisterForCourseContent(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.padding(top = padding.calculateTopPadding())
.consumeWindowInsets(WindowInsets.systemBars)
.padding(horizontal = 8.dp),
courses = courses,
serverUrl = properServerUrl,
Expand Down Expand Up @@ -235,6 +240,7 @@ private fun RegisterForCourseContent(
.fillMaxSize()
.testTag(TEST_TAG_REGISTRABLE_COURSE_LIST),
columns = GridCells.Fixed(columnCount),
contentPadding = WindowInsets.systemBars.asPaddingValues(),
verticalArrangement = Arrangement.spacedBy(8.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ package de.tum.informatics.www1.artemis.native_app.feature.courseview.ui
import android.os.Parcelable
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -71,7 +75,13 @@ internal fun <T> WeeklyItemsLazyColumn(
}
}

LazyColumn(modifier = modifier, verticalArrangement = verticalArrangement) {
LazyColumn(
modifier = modifier,
verticalArrangement = verticalArrangement,
contentPadding = PaddingValues(
bottom = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
)
) {
weeklyItemGroups.forEachIndexed { index, weeklyItems ->
item {
WeeklyItemsSectionHeader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
import androidx.compose.animation.togetherWith
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
Expand Down Expand Up @@ -331,7 +334,8 @@ internal fun CourseUiScreen(
BasicDataStateUi(
modifier = Modifier
.fillMaxSize()
.padding(padding),
.padding(top = padding.calculateTopPadding())
.consumeWindowInsets(WindowInsets.systemBars),
dataState = courseDataState,
loadingText = stringResource(id = R.string.course_ui_loading_course_loading),
failureText = stringResource(id = R.string.course_ui_loading_course_failed),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
Expand Down Expand Up @@ -188,7 +193,8 @@ internal fun CoursesOverview(
BasicDataStateUi(
modifier = Modifier
.fillMaxSize()
.padding(padding),
.padding(top = padding.calculateTopPadding())
.consumeWindowInsets(WindowInsets.systemBars),
dataState = coursesDataState,
loadingText = stringResource(id = R.string.courses_loading_loading),
failureText = stringResource(id = R.string.courses_loading_failure),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package de.tum.informatics.www1.artemis.native_app.feature.lectureview

import androidx.compose.foundation.clickable
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.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
Expand All @@ -31,7 +35,12 @@ internal fun AttachmentsTab(
onClickOpenLinkAttachment: (Attachment) -> Unit
) {
if (attachments.isNotEmpty()) {
LazyColumn(modifier = modifier) {
LazyColumn(
modifier = modifier,
contentPadding = PaddingValues(
bottom = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
)
) {
items(attachments) { attachment ->
AttachmentItem(
modifier = Modifier.fillMaxWidth(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ internal fun LectureScreen(
) { padding ->
val bodyModifier = Modifier
.fillMaxSize()
.padding(padding)
.padding(top = padding.calculateTopPadding())

contentBody(
bodyModifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ package de.tum.informatics.www1.artemis.native_app.feature.lectureview

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.LazyListState
Expand Down Expand Up @@ -50,7 +55,10 @@ internal fun OverviewTab(
LazyColumn(
modifier = modifier.testTag(TEST_TAG_OVERVIEW_LIST),
verticalArrangement = Arrangement.spacedBy(16.dp),
state = state
state = state,
contentPadding = PaddingValues(
bottom = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
)
) {
if (description != null) {
item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.ClickableText
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -273,7 +278,9 @@ private fun LoginUiScreen(
NavHost(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues),
.imePadding()
.consumeWindowInsets(WindowInsets.systemBars)
.padding(top = paddingValues.calculateTopPadding()),
navController = nestedNavController,
startDestination = if (hasSelectedInstance) NestedDestination.HOME.destination else NestedDestination.INSTANCE_SELECTION.destination
) {
Expand Down Expand Up @@ -463,7 +470,11 @@ private fun AccountUi(
ClickableText(
modifier = Modifier
.align(Alignment.CenterHorizontally)
.padding(bottom = 8.dp),
.padding(
bottom = WindowInsets.systemBars
.asPaddingValues()
.calculateBottomPadding()
),
text = AnnotatedString(stringResource(id = R.string.account_change_artemis_instance_label)),
style = MaterialTheme.typography.bodyMedium.copy(color = MaterialTheme.colorScheme.linkTextColor),
onClick = { onNavigateToInstanceSelection() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -88,8 +89,9 @@ internal fun NotificationSettingsUi(modifier: Modifier, onDone: () -> Unit) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.padding(8.dp)
.imePadding()
.padding(top = padding.calculateTopPadding())
.padding(horizontal = 8.dp)
.verticalScroll(rememberScrollState())
) {
de.tum.informatics.www1.artemis.native_app.feature.push.ui.PushNotificationSettingsUi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
Expand Down Expand Up @@ -79,7 +83,9 @@ internal fun InstanceSelectionScreen(
columns = GridCells.Fixed(columnCount),
horizontalArrangement = Arrangement.spacedBy(16.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
contentPadding = PaddingValues(bottom = 16.dp)
contentPadding = PaddingValues(
bottom = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
)
) {
items(availableInstances) { instance ->
val item = GridCellItem.ArtemisInstanceGridCellItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.tum.informatics.www1.artemis.native_app.feature.login.login
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Divider
Expand Down Expand Up @@ -92,7 +93,7 @@ internal fun RegisterUi(
}

Column(
modifier = modifier,
modifier = modifier.imePadding(),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
val textFieldModifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.tum.informatics.www1.artemis.native_app.feature.login

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -83,6 +84,7 @@ class RegisterEndToEndTest : BaseComposeTest() {
RegisterUi(
modifier = Modifier
.fillMaxSize()
.imePadding()
.verticalScroll(rememberScrollState()),
viewModel = viewModel,
onRegistered = { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
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.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -125,7 +128,11 @@ fun AcceptCodeOfConductUi(
Icon(
modifier = Modifier
.align(Alignment.BottomCenter)
.padding(bottom = 8.dp)
.padding(
bottom = WindowInsets.systemBars
.asPaddingValues()
.calculateBottomPadding()
)
.offset {
val offsetInDp = 4.dp.toPx()
IntOffset(0, (offsetInDp * additionalOffsetPercent).toInt())
Expand Down
Loading

0 comments on commit d8cb940

Please sign in to comment.