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

Display content edge-to-edge #91

Merged
merged 14 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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 @@ -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 @@ -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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui

import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContent
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material.icons.Icons
Expand All @@ -29,6 +35,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.unit.dp
import androidx.paging.compose.LazyPagingItems
import androidx.paging.compose.collectAsLazyPagingItems
import de.tum.informatics.www1.artemis.native_app.core.data.isSuccess
Expand Down Expand Up @@ -106,9 +113,10 @@ internal fun ConversationChatListScreen(
MetisChatList(
modifier = Modifier
.fillMaxSize()
.padding(padding),
.imePadding()
.padding(bottom = padding.calculateBottomPadding()),
viewModel = viewModel,
listContentPadding = PaddingValues(),
listContentPadding = PaddingValues(top = padding.calculateTopPadding()),
onClickViewPost = onClickViewPost,
isReplyEnabled = isReplyEnabled,
state = chatListState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
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.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
Expand Down Expand Up @@ -58,13 +60,15 @@ internal fun ConversationThreadScreen(
Column(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.imePadding()
.padding(bottom = padding.calculateBottomPadding())
) {
CompositionLocalProvider(LocalReplyAutoCompleteHintProvider provides viewModel) {
MetisThreadUi(
modifier = Modifier
.fillMaxWidth()
.weight(1f),
listContentPadding = PaddingValues(top = padding.calculateTopPadding()),
viewModel = viewModel
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.paging.compose.LazyPagingItems
import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.R
import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.service.EmojiService
import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.service.MetisModificationFailure
import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.ConversationViewModel
import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.DisplayPostOrder
Expand Down Expand Up @@ -124,6 +125,7 @@ fun MetisChatList(
serverUrl: String,
courseId: Long,
state: LazyListState,
emojiService: EmojiService = koinInject(),
isReplyEnabled: Boolean,
onCreatePost: () -> Deferred<MetisModificationFailure?>,
onEditPost: (IStandalonePost, String) -> Deferred<MetisModificationFailure?>,
Expand Down Expand Up @@ -155,7 +157,7 @@ fun MetisChatList(
state = state,
itemCount = posts.itemCount,
order = DisplayPostOrder.REVERSED,
emojiService = koinInject(),
emojiService = emojiService,
bottomItem = bottomItem
) {
when (posts) {
Expand Down
Loading
Loading