From 61f0044bdba6f38f65cf083c7ad45e2c773d63f7 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 11:41:01 +0100 Subject: [PATCH 01/15] changed arrangement of items in post item and added PostItemViewJoinedType --- .../conversation/ui/chatlist/MetisChatList.kt | 14 +- .../metis/conversation/ui/post/PostItem.kt | 198 ++++++++---------- .../metis/conversation/ui/post/PostUtil.kt | 46 +++- .../ui/post/PostWithBottomSheet.kt | 65 ++++-- .../conversation/ui/thread/MetisThreadUi.kt | 11 +- .../src/main/res/values/post_strings.xml | 4 + 6 files changed, 212 insertions(+), 126 deletions(-) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt index bb2fc6123..5395dcc84 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt @@ -38,6 +38,7 @@ import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui. import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.DisplayPostOrder import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.PostItemViewType import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.PostWithBottomSheet +import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.determinePostItemViewJoinedType import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActionFlags import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.rememberPostActions import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.shouldDisplayHeader @@ -241,7 +242,6 @@ private fun ChatList( ) { LazyColumn( modifier = modifier, - verticalArrangement = Arrangement.spacedBy(4.dp), contentPadding = listContentPadding, state = state, reverseLayout = true @@ -310,6 +310,18 @@ private fun ChatList( } } ), + joinedItemType = determinePostItemViewJoinedType( + index = index, + post = post, + postCount = posts.itemCount, + order = DisplayPostOrder.REVERSED, + getPost = { getPostIndex -> + when (val entry = posts.peek(getPostIndex)) { + is ChatListItem.PostChatListItem -> entry.post + else -> null + } + } + ), onClick = { val standalonePostId = post?.standalonePostId diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index d48b70f41..215c17a3e 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -22,14 +22,10 @@ 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.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Check -import androidx.compose.material.icons.filled.Person -import androidx.compose.material.icons.filled.School -import androidx.compose.material.icons.filled.SupervisorAccount import androidx.compose.material.icons.outlined.PushPin import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -204,6 +200,7 @@ internal fun PostItem( ) } } + is IAnswerPost -> { if (post.resolvesPost) { IconLabel( @@ -213,6 +210,7 @@ internal fun PostItem( ) } } + else -> {} } } @@ -245,66 +243,43 @@ private fun PostHeadline( displayHeader: Boolean = true, content: @Composable () -> Unit ) { - if (expanded) { - Column(modifier = modifier) { - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(16.dp) - ) { - HeadlineProfilePicture( - profilePictureData = profilePictureData, - ) + val doDisplayHeader = displayHeader || postStatus == CreatePostService.Status.FAILED - HeadlineAuthorInfo( - modifier = Modifier.fillMaxWidth(), - authorName = authorName, - authorRole = authorRole, - creationDate = creationDate, - expanded = true - ) - } - - content() - } - } else { + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { Row( - modifier = modifier, - horizontalArrangement = Arrangement.spacedBy(16.dp) + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(12.dp) ) { - val doDisplayHeader = displayHeader || postStatus == CreatePostService.Status.FAILED + if (!doDisplayHeader) { + return@Row + } HeadlineProfilePicture( - profilePictureData = profilePictureData, - displayImage = doDisplayHeader + profilePictureData = profilePictureData ) - Column( - modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(4.dp) - ) { - if (postStatus == CreatePostService.Status.FAILED) { - Text( - text = stringResource(id = R.string.post_sending_failed), - style = MaterialTheme.typography.labelMedium, - color = MaterialTheme.colorScheme.error - ) - } - - if (doDisplayHeader) { - HeadlineAuthorInfo( - modifier = Modifier.fillMaxWidth(), - authorName = authorName, - authorRole = authorRole, - creationDate = creationDate, - expanded = false - ) - } else { - Box(modifier = Modifier.height(4.dp)) - } - - content() + if (postStatus == CreatePostService.Status.FAILED) { + Text( + text = stringResource(id = R.string.post_sending_failed), + style = MaterialTheme.typography.labelMedium, + color = MaterialTheme.colorScheme.error + ) } + + HeadlineAuthorInfo( + modifier = Modifier.fillMaxWidth(), + authorName = authorName, + authorRole = authorRole, + creationDate = creationDate, + expanded = expanded + ) } + + content() } } @@ -339,72 +314,70 @@ private fun HeadlineAuthorInfo( authorName: String?, authorRole: UserRole?, creationDate: Instant?, - expanded: Boolean + expanded: Boolean, ) { - val relativeTimeTo = remember(creationDate) { - creationDate ?: Clock.System.now() - } - - val creationDateContent: @Composable () -> Unit = { - val relativeTime = getRelativeTime(to = relativeTimeTo, showDate = false) + Column(modifier = modifier) { + AuthorRoleAndTimeRow( + expanded = expanded, + authorRole = authorRole, + creationDate = creationDate, + ) Text( - modifier = Modifier.fillMaxWidth(), - text = remember(relativeTime) { relativeTime.toString() }, - style = MaterialTheme.typography.bodySmall + modifier = Modifier, + text = remember(authorName) { authorName ?: "Placeholder" }, + maxLines = 1, + style = MaterialTheme.typography.titleSmall, + fontWeight = FontWeight.Bold ) } - - if (expanded) { - Column(modifier) { - AuthorRoleAndNameRow(authorRole, authorName) - creationDateContent() - } - } else { - Row( - modifier = Modifier.fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(4.dp) - ) { - AuthorRoleAndNameRow(authorRole, authorName) - creationDateContent() - } - } } @Composable -private fun AuthorRoleAndNameRow( +private fun AuthorRoleAndTimeRow( + expanded: Boolean, authorRole: UserRole?, - authorName: String? + creationDate: Instant? ) { Row( - verticalAlignment = Alignment.CenterVertically, + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically ) { - HeadlineAuthorIcon(authorRole) + val relativeTimeTo = remember(creationDate) { + creationDate ?: Clock.System.now() + } - Spacer(modifier = Modifier.width(4.dp)) + val creationDateContent: @Composable () -> Unit = { + val relativeTime = getRelativeTime(to = relativeTimeTo, showDate = false) - Text( - modifier = Modifier, - text = remember(authorName) { authorName ?: "Placeholder" }, - maxLines = 1, - style = MaterialTheme.typography.titleSmall, - fontWeight = FontWeight.Bold - ) + Text( + modifier = Modifier, + text = remember(relativeTime) { relativeTime.toString() }, + style = MaterialTheme.typography.bodySmall + ) + } + + if (expanded) { + //adjust creation date + } + + Row( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically + ) { + HeadlineAuthorIcon(authorRole) + Spacer(modifier = Modifier.weight(1f)) + creationDateContent() + } } } @Composable private fun HeadlineProfilePicture( - profilePictureData: ProfilePictureData, - displayImage: Boolean = true + profilePictureData: ProfilePictureData ) { - val size = 30.dp + val size = 36.dp Box(modifier = Modifier.size(size)) { - if (!displayImage) { - return - } - ProfilePicture( modifier = Modifier .size(size) @@ -418,18 +391,23 @@ private fun HeadlineProfilePicture( private fun HeadlineAuthorIcon( authorRole: UserRole?, ) { - val icon = when (authorRole) { - UserRole.INSTRUCTOR -> Icons.Default.School - UserRole.TUTOR -> Icons.Default.SupervisorAccount - UserRole.USER -> Icons.Default.Person - null -> Icons.Default.Person + val text = when (authorRole) { + UserRole.INSTRUCTOR -> R.string.post_instructor + UserRole.TUTOR -> R.string.post_tutor + UserRole.USER -> R.string.post_student + null -> R.string.post_student } - Icon( - modifier = Modifier.size(16.dp), - imageVector = icon, - contentDescription = null - ) + Box( + modifier = Modifier + .background(Color.Blue, MaterialTheme.shapes.extraSmall) + ) { + Text( + modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp), + text = stringResource(id = text), + style = MaterialTheme.typography.bodySmall + ) + } } /** diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostUtil.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostUtil.kt index f375d2924..618311938 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostUtil.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostUtil.kt @@ -12,6 +12,14 @@ internal enum class DisplayPostOrder { REGULAR } +internal enum class PostItemViewJoinedType { + SINGLE, + HEADER, + JOINED, + FOOTER, + PARENT +} + @Composable internal fun shouldDisplayHeader( index: Int, @@ -32,4 +40,40 @@ internal fun shouldDisplayHeader( postCreationDate - prefPostCreationDate > MaxDurationJoinMessages } else true } -} \ No newline at end of file +} + +@Composable +internal fun determinePostItemViewJoinedType( + index: Int, + post: T?, + postCount: Int, + order: DisplayPostOrder, + getPost: (index: Int) -> T? +): PostItemViewJoinedType { + val isHeader = shouldDisplayHeader(index, post, postCount, order, getPost) + + val nextPostIndex = when (order) { + DisplayPostOrder.REVERSED -> index - 1 + DisplayPostOrder.REGULAR -> index + 1 + } + val nextPost = if (nextPostIndex in 0 until postCount) getPost(nextPostIndex) else null + val isNextHeader = nextPost?.let { + shouldDisplayHeader(nextPostIndex, it, postCount, order, getPost) + } ?: true + + return remember(index, isHeader, post, postCount, nextPost, isNextHeader) { + if (isHeader) { + if (nextPost == null || isNextHeader) { + PostItemViewJoinedType.SINGLE + } else { + PostItemViewJoinedType.HEADER + } + } else { + if (nextPost == null || isNextHeader) { + PostItemViewJoinedType.FOOTER + } else { + PostItemViewJoinedType.JOINED + } + } + } +} diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt index aa7f1b3e5..f1160ba5e 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt @@ -1,11 +1,18 @@ package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.CornerSize +import androidx.compose.material3.Card +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.dp import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActions import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostContextBottomSheet import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.IBasePost @@ -21,23 +28,55 @@ internal fun PostWithBottomSheet( postActions: PostActions, clientId: Long, displayHeader: Boolean, + joinedItemType: PostItemViewJoinedType, onClick: () -> Unit ) { var displayBottomSheet by remember(post, postItemViewType) { mutableStateOf(false) } - PostItem( - modifier = modifier, - post = post, - postItemViewType = postItemViewType, - clientId = clientId, - displayHeader = displayHeader, - onClickOnReaction = postActions.onClickReaction, - onClick = onClick, - onLongClick = { - displayBottomSheet = true - }, - onRequestRetrySend = postActions.onRequestRetrySend - ) + var color = MaterialTheme.colorScheme.surface + + val cardShape: Shape = when (joinedItemType) { + PostItemViewJoinedType.HEADER -> MaterialTheme.shapes.small.copy( + bottomStart = CornerSize(0.dp), + bottomEnd = CornerSize(0.dp) + ) + PostItemViewJoinedType.FOOTER -> MaterialTheme.shapes.small.copy( + topStart = CornerSize(0.dp), + topEnd = CornerSize(0.dp) + ) + PostItemViewJoinedType.JOINED, PostItemViewJoinedType.PARENT -> MaterialTheme.shapes.small.copy(all = CornerSize(0.dp)) + PostItemViewJoinedType.SINGLE -> MaterialTheme.shapes.small + } + + val dynamicModifier = modifier + .let { + when (joinedItemType) { + PostItemViewJoinedType.HEADER -> it.padding(top = 4.dp, bottom = 0.dp) + PostItemViewJoinedType.FOOTER -> it.padding(top = 0.dp, bottom = 4.dp) + PostItemViewJoinedType.SINGLE, PostItemViewJoinedType.PARENT -> it.padding(vertical = 4.dp) + PostItemViewJoinedType.JOINED, -> it.padding(vertical = 0.dp) + } + } + .background(color) + + Card( + modifier = dynamicModifier, + shape = cardShape + ){ + PostItem( + modifier = modifier, + post = post, + postItemViewType = postItemViewType, + clientId = clientId, + displayHeader = displayHeader, + onClickOnReaction = postActions.onClickReaction, + onClick = onClick, + onLongClick = { + displayBottomSheet = true + }, + onRequestRetrySend = postActions.onRequestRetrySend + ) + } if (displayBottomSheet && post != null) { PostContextBottomSheet( diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt index 0c72573c5..a889d4c43 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt @@ -39,8 +39,10 @@ import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui. import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.chatlist.MetisPostListHandler import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.chatlist.testTagForPost import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.DisplayPostOrder +import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.PostItemViewJoinedType import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.PostItemViewType import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.PostWithBottomSheet +import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.determinePostItemViewJoinedType import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActionBar import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActionFlags import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActions @@ -294,7 +296,6 @@ private fun PostAndRepliesList( LazyColumn( modifier = modifier, contentPadding = listContentPadding, - verticalArrangement = Arrangement.spacedBy(8.dp), state = state ) { item { @@ -312,6 +313,7 @@ private fun PostAndRepliesList( postItemViewType = PostItemViewType.ThreadContextPostItem, postActions = postActions, displayHeader = true, + joinedItemType = PostItemViewJoinedType.PARENT, clientId = clientId, onClick = {} ) @@ -347,6 +349,13 @@ private fun PostAndRepliesList( order = DisplayPostOrder.REGULAR, getPost = post.orderedAnswerPostings::get ), + joinedItemType = determinePostItemViewJoinedType( + index = index, + post = answerPost, + postCount = post.orderedAnswerPostings.size, + order = DisplayPostOrder.REGULAR, + getPost = post.orderedAnswerPostings::get + ), onClick = {} ) } diff --git a/feature/metis/conversation/src/main/res/values/post_strings.xml b/feature/metis/conversation/src/main/res/values/post_strings.xml index 12bae2ebf..cdbb6c60e 100644 --- a/feature/metis/conversation/src/main/res/values/post_strings.xml +++ b/feature/metis/conversation/src/main/res/values/post_strings.xml @@ -20,4 +20,8 @@ Sending post failed. Click to try again. + + Instructor + Student + Tutor \ No newline at end of file From 389de55fa38fe30f2e4011b9d82a1c73d7251a86 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 12:03:30 +0100 Subject: [PATCH 02/15] added colors for role badges --- .../core/ui/material/colors/PostColors.kt | 9 ++++++++ .../conversation/ui/chatlist/MetisChatList.kt | 1 + .../metis/conversation/ui/post/PostItem.kt | 23 ++++++++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt index 70de20f8b..d70b05b4c 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt @@ -8,6 +8,15 @@ object PostColors { val delete: Color @Composable get() = Color(0xffdc3545) } + object Roles { + val tutor: Color + @Composable get() = Color(0xff007bff) + val student: Color + @Composable get() = Color(0xff28a745) + val instructor: Color + @Composable get() = Color(0xff6c757d) + } + val editedHintText: Color @Composable get() = Color.Gray diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt index 5395dcc84..0759db800 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt @@ -164,6 +164,7 @@ fun MetisChatList( MetisPostListHandler( modifier = Modifier .fillMaxWidth() + .padding(horizontal = 8.dp) .weight(1f), serverUrl = serverUrl, courseId = courseId, diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 215c17a3e..0c1e3a80f 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -391,16 +391,27 @@ private fun HeadlineProfilePicture( private fun HeadlineAuthorIcon( authorRole: UserRole?, ) { - val text = when (authorRole) { - UserRole.INSTRUCTOR -> R.string.post_instructor - UserRole.TUTOR -> R.string.post_tutor - UserRole.USER -> R.string.post_student - null -> R.string.post_student + var text = R.string.post_student + var color = MaterialTheme.colorScheme.primary + when (authorRole) { + UserRole.INSTRUCTOR -> { + text = R.string.post_instructor + color = PostColors.Roles.instructor + } + UserRole.TUTOR -> { + text = R.string.post_tutor + color = PostColors.Roles.tutor + } + UserRole.USER -> { + text = R.string.post_student + color = PostColors.Roles.student + } + null -> {} } Box( modifier = Modifier - .background(Color.Blue, MaterialTheme.shapes.extraSmall) + .background(color, MaterialTheme.shapes.extraSmall) ) { Text( modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp), From 05476de6c3cf4454a42ea2303342eec2200156ed Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 14:22:30 +0100 Subject: [PATCH 03/15] adjusted post header --- .../core/ui/material/colors/PostColors.kt | 17 ++- .../metis/conversation/ui/post/PostItem.kt | 111 ++++++++---------- .../ui/post/PostWithBottomSheet.kt | 44 +++++-- .../conversation/ui/thread/MetisThreadUi.kt | 1 - 4 files changed, 93 insertions(+), 80 deletions(-) diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt index d70b05b4c..c3fda2344 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt @@ -8,13 +8,21 @@ object PostColors { val delete: Color @Composable get() = Color(0xffdc3545) } + object Roles { val tutor: Color - @Composable get() = Color(0xff007bff) + @Composable get() = Color(0xFFFD7E14) val student: Color - @Composable get() = Color(0xff28a745) + @Composable get() = Color(0xFF0C9EB6) val instructor: Color - @Composable get() = Color(0xff6c757d) + @Composable get() = Color(0xFFB60000) + } + + object StatusBackground { + val resolving: Color + @Composable get() = Color(0xFF28A745).copy(alpha = 0.2f) + val pinned: Color + @Composable get() = Color(0xFFFFA500).copy(alpha = 0.25f) } val editedHintText: Color @@ -22,7 +30,4 @@ object PostColors { val unsentMessageText: Color @Composable get() = Color.Gray - - val pinnedMessageBackground: Color - @Composable get() = Color(0xFFFFA500).copy(alpha = 0.25f) } \ No newline at end of file diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 0c1e3a80f..222ecfc72 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -75,6 +75,7 @@ sealed class PostItemViewType { } private const val PlaceholderContent = "WWWWWWW" +private val postHeadlineHeight = 36.dp /** * Displays a post item or a placeholder for it. @@ -98,15 +99,6 @@ internal fun PostItem( } val isPinned = post is IStandalonePost && post.displayPriority == DisplayPriority.PINNED - val applyPinStatusToModifier: @Composable (Modifier) -> Modifier = { - if (isPinned && !isExpanded) { - modifier - .clip( - MaterialTheme.shapes.small - ) - .background(color = PostColors.pinnedMessageBackground) - } else modifier - } // Retrieve post status val clientPostId = post?.clientPostId @@ -128,7 +120,7 @@ internal fun PostItem( .background(color = MaterialTheme.colorScheme.errorContainer) .clickable(onClick = onRequestRetrySend) } else { - applyPinStatusToModifier(it) + it .combinedClickable( onClick = onClick, onLongClick = onLongClick @@ -141,8 +133,7 @@ internal fun PostItem( if (isPinned) { IconLabel( modifier = Modifier - .fillMaxWidth() - .padding(top = 8.dp), + .fillMaxWidth(), resourceString = R.string.post_is_pinned, icon = Icons.Outlined.PushPin ) @@ -166,53 +157,51 @@ internal fun PostItem( modifier = Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(8.dp) ) { - Column(modifier = Modifier.fillMaxWidth()) { - MarkdownText( - markdown = remember(post?.content, isPlaceholder) { - if (isPlaceholder) { - PlaceholderContent - } else post?.content.orEmpty() - }, - modifier = Modifier - .fillMaxWidth() - .placeholder(visible = isPlaceholder), + MarkdownText( + markdown = remember(post?.content, isPlaceholder) { + if (isPlaceholder) { + PlaceholderContent + } else post?.content.orEmpty() + }, + modifier = Modifier + .fillMaxWidth() + .placeholder(visible = isPlaceholder), + style = MaterialTheme.typography.bodyMedium, + onClick = onClick, + onLongClick = onLongClick, + color = if (post?.serverPostId == null) PostColors.unsentMessageText else Color.Unspecified + ) + + if (post?.updatedDate != null) { + Text( + text = stringResource(id = R.string.post_edited_hint), style = MaterialTheme.typography.bodyMedium, - onClick = onClick, - onLongClick = onLongClick, - color = if (post?.serverPostId == null) PostColors.unsentMessageText else Color.Unspecified + color = PostColors.editedHintText ) + } - if (post?.updatedDate != null) { - Text( - text = stringResource(id = R.string.post_edited_hint), - style = MaterialTheme.typography.bodyMedium, - color = PostColors.editedHintText - ) - } - - when (post) { - is IStandalonePost -> { - if (post.resolved == true) { - IconLabel( - modifier = Modifier.fillMaxWidth(), - resourceString = R.string.post_is_resolved, - icon = Icons.Default.Check - ) - } + when (post) { + is IStandalonePost -> { + if (post.resolved == true) { + IconLabel( + modifier = Modifier.fillMaxWidth(), + resourceString = R.string.post_is_resolved, + icon = Icons.Default.Check + ) } + } - is IAnswerPost -> { - if (post.resolvesPost) { - IconLabel( - modifier = Modifier.fillMaxWidth(), - resourceString = R.string.post_resolves, - icon = Icons.Default.Check - ) - } + is IAnswerPost -> { + if (post.resolvesPost) { + IconLabel( + modifier = Modifier.fillMaxWidth(), + resourceString = R.string.post_resolves, + icon = Icons.Default.Check + ) } - - else -> {} } + + else -> {} } StandalonePostFooter( @@ -222,10 +211,6 @@ internal fun PostItem( postItemViewType = postItemViewType, onClickReaction = onClickOnReaction ) - - if (!post?.reactions.isNullOrEmpty()) { - Box(modifier = Modifier.height(2.dp)) - } } } } @@ -271,7 +256,9 @@ private fun PostHeadline( } HeadlineAuthorInfo( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .height(postHeadlineHeight), authorName = authorName, authorRole = authorRole, creationDate = creationDate, @@ -365,7 +352,7 @@ private fun AuthorRoleAndTimeRow( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically ) { - HeadlineAuthorIcon(authorRole) + HeadlineAuthorRoleBadge(authorRole) Spacer(modifier = Modifier.weight(1f)) creationDateContent() } @@ -376,7 +363,7 @@ private fun AuthorRoleAndTimeRow( private fun HeadlineProfilePicture( profilePictureData: ProfilePictureData ) { - val size = 36.dp + val size = postHeadlineHeight Box(modifier = Modifier.size(size)) { ProfilePicture( modifier = Modifier @@ -388,7 +375,7 @@ private fun HeadlineProfilePicture( } @Composable -private fun HeadlineAuthorIcon( +private fun HeadlineAuthorRoleBadge( authorRole: UserRole?, ) { var text = R.string.post_student @@ -416,7 +403,9 @@ private fun HeadlineAuthorIcon( Text( modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp), text = stringResource(id = text), - style = MaterialTheme.typography.bodySmall + style = MaterialTheme.typography.bodySmall, + color = Color.White, + fontWeight = FontWeight.Medium ) } } diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt index f1160ba5e..0dc061e3b 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt @@ -1,9 +1,9 @@ package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post -import androidx.compose.foundation.background import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.CornerSize import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -12,10 +12,15 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.PostColors import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActions import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostContextBottomSheet +import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.DisplayPriority +import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.IAnswerPost import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.IBasePost +import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.IStandalonePost /** * Wrapps [PostItem] and can display the bottom sheet for the post @@ -33,7 +38,16 @@ internal fun PostWithBottomSheet( ) { var displayBottomSheet by remember(post, postItemViewType) { mutableStateOf(false) } - var color = MaterialTheme.colorScheme.surface + val isPinned = post is IStandalonePost && post.displayPriority == DisplayPriority.PINNED + val isResolving = post is IAnswerPost && post.resolvesPost + val isParentPostInThread = joinedItemType == PostItemViewJoinedType.PARENT + + val cardColor = when { + isParentPostInThread-> MaterialTheme.colorScheme.background + isResolving -> PostColors.StatusBackground.resolving + isPinned -> PostColors.StatusBackground.pinned + else -> CardDefaults.cardColors().containerColor + } val cardShape: Shape = when (joinedItemType) { PostItemViewJoinedType.HEADER -> MaterialTheme.shapes.small.copy( @@ -48,23 +62,29 @@ internal fun PostWithBottomSheet( PostItemViewJoinedType.SINGLE -> MaterialTheme.shapes.small } - val dynamicModifier = modifier - .let { + val applyPaddingToModifier: @Composable (modifier: Modifier, paddingValue: Dp) -> Modifier = + { modifier, paddingValue -> when (joinedItemType) { - PostItemViewJoinedType.HEADER -> it.padding(top = 4.dp, bottom = 0.dp) - PostItemViewJoinedType.FOOTER -> it.padding(top = 0.dp, bottom = 4.dp) - PostItemViewJoinedType.SINGLE, PostItemViewJoinedType.PARENT -> it.padding(vertical = 4.dp) - PostItemViewJoinedType.JOINED, -> it.padding(vertical = 0.dp) + PostItemViewJoinedType.HEADER -> modifier.padding(top = paddingValue, bottom = 0.dp) + PostItemViewJoinedType.FOOTER -> modifier.padding(top = 0.dp, bottom = paddingValue) + PostItemViewJoinedType.SINGLE -> modifier.padding( + vertical = paddingValue + ) + PostItemViewJoinedType.JOINED -> modifier.padding(vertical = 0.dp) + PostItemViewJoinedType.PARENT -> modifier.padding(0.dp) } } - .background(color) + + val cardModifier = applyPaddingToModifier(modifier, 4.dp) + val innerModifier = applyPaddingToModifier(modifier, 8.dp) Card( - modifier = dynamicModifier, - shape = cardShape + modifier = cardModifier, + shape = cardShape, + colors = CardDefaults.cardColors(containerColor = cardColor) ){ PostItem( - modifier = modifier, + modifier = innerModifier, post = post, postItemViewType = postItemViewType, clientId = clientId, diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt index a889d4c43..a4d1b376f 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/thread/MetisThreadUi.kt @@ -307,7 +307,6 @@ private fun PostAndRepliesList( ) { PostWithBottomSheet( modifier = Modifier - .padding(top = 8.dp) .testTag(testTagForPost(post.standalonePostId)), post = post, postItemViewType = PostItemViewType.ThreadContextPostItem, From 1d97c101604edb043d7b7bcfda508e93a57f0d92 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 15:18:20 +0100 Subject: [PATCH 04/15] minor changes --- .../core/ui/material/colors/PostColors.kt | 9 +++ .../metis/conversation/ui/post/PostItem.kt | 60 +++++++++++++++---- .../ui/post/PostWithBottomSheet.kt | 5 +- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt index c3fda2344..220a94de3 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt @@ -1,5 +1,7 @@ package de.tum.informatics.www1.artemis.native_app.core.ui.material.colors +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color @@ -25,6 +27,13 @@ object PostColors { @Composable get() = Color(0xFFFFA500).copy(alpha = 0.25f) } + object EmojiChipColors { + val background: Color + @Composable get() = if (isSystemInDarkTheme()) Color(0xFF282C30) else Color(0xFFD0D2D8) + val selectedBackgound: Color + @Composable get() = MaterialTheme.colorScheme.primaryContainer + } + val editedHintText: Color @Composable get() = Color.Gray diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 222ecfc72..4a8575386 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -8,6 +8,7 @@ import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically import androidx.compose.animation.togetherWith import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.horizontalScroll @@ -87,6 +88,7 @@ internal fun PostItem( postItemViewType: PostItemViewType, clientId: Long, displayHeader: Boolean, + postItemViewJoinedType: PostItemViewJoinedType, onClickOnReaction: ((emojiId: String, create: Boolean) -> Unit)?, onClick: () -> Unit, onLongClick: () -> Unit, @@ -127,13 +129,19 @@ internal fun PostItem( ) } } - .padding(PaddingValues(horizontal = Spacings.ScreenHorizontalSpacing)), - verticalArrangement = Arrangement.spacedBy(8.dp) + .padding(PaddingValues(horizontal = Spacings.ScreenHorizontalSpacing)) ) { if (isPinned) { IconLabel( modifier = Modifier - .fillMaxWidth(), + .fillMaxWidth() + .let { + if (postItemViewJoinedType == PostItemViewJoinedType.JOINED) { + it.padding(top = 4.dp) + } else { + it.padding(bottom = 4.dp) + } + }, resourceString = R.string.post_is_pinned, icon = Icons.Outlined.PushPin ) @@ -205,7 +213,18 @@ internal fun PostItem( } StandalonePostFooter( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .let { + if (postItemViewJoinedType == PostItemViewJoinedType.JOINED && post?.reactions + .orEmpty() + .isNotEmpty() + ) { + it.padding(bottom = 4.dp) + } else { + it + } + }, clientId = clientId, reactions = remember(post?.reactions) { post?.reactions.orEmpty() }, postItemViewType = postItemViewType, @@ -385,14 +404,17 @@ private fun HeadlineAuthorRoleBadge( text = R.string.post_instructor color = PostColors.Roles.instructor } + UserRole.TUTOR -> { text = R.string.post_tutor color = PostColors.Roles.tutor } + UserRole.USER -> { text = R.string.post_student color = PostColors.Roles.student } + null -> {} } @@ -430,7 +452,10 @@ private fun StandalonePostFooter( } } - Column(modifier = modifier) { + Column( + modifier = modifier, + verticalArrangement = Arrangement.spacedBy(4.dp) + ) { Row( modifier = Modifier .fillMaxSize() @@ -470,7 +495,7 @@ private fun StandalonePostFooter( private data class ReactionData(val reactionCount: Int, val hasClientReacted: Boolean) @Composable -private fun AnimatedCounter(currentCount: Int) { +private fun AnimatedCounter(currentCount: Int, selected: Boolean) { AnimatedContent( targetState = currentCount, transitionSpec = { @@ -486,7 +511,11 @@ private fun AnimatedCounter(currentCount: Int) { }, label = "Animate reaction count change" ) { targetCount -> - Text(text = "$targetCount") + Text( + text = "$targetCount", + fontSize = 12.sp, + color = if (selected) MaterialTheme.colorScheme.primary else Color.Unspecified + ) } } @@ -501,24 +530,33 @@ private fun EmojiChip( val shape = CircleShape val backgroundColor = - if (selected) MaterialTheme.colorScheme.secondaryContainer else Color.Transparent + if (selected) PostColors.EmojiChipColors.selectedBackgound else PostColors.EmojiChipColors.background Box( modifier = modifier .background(color = backgroundColor, shape) .clip(shape) .clickable(onClick = onClick) + .let { + if (selected) { + it.border(1.dp, MaterialTheme.colorScheme.primary, shape) + } else { + it + } + } ) { Row( - modifier = Modifier.padding(4.dp), + modifier = Modifier + .padding(2.dp) + .padding(horizontal = 4.dp), horizontalArrangement = Arrangement.spacedBy(4.dp) ) { Text( text = getUnicodeForEmojiId(emojiId = emojiId), - fontSize = 14.sp + fontSize = 12.sp ) - AnimatedCounter(reactionCount) + AnimatedCounter(reactionCount, selected) } } } diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt index 0dc061e3b..8b320e59e 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt @@ -43,7 +43,7 @@ internal fun PostWithBottomSheet( val isParentPostInThread = joinedItemType == PostItemViewJoinedType.PARENT val cardColor = when { - isParentPostInThread-> MaterialTheme.colorScheme.background + isParentPostInThread -> MaterialTheme.colorScheme.background isResolving -> PostColors.StatusBackground.resolving isPinned -> PostColors.StatusBackground.pinned else -> CardDefaults.cardColors().containerColor @@ -61,7 +61,7 @@ internal fun PostWithBottomSheet( PostItemViewJoinedType.JOINED, PostItemViewJoinedType.PARENT -> MaterialTheme.shapes.small.copy(all = CornerSize(0.dp)) PostItemViewJoinedType.SINGLE -> MaterialTheme.shapes.small } - +println(CardDefaults.cardColors().containerColor) val applyPaddingToModifier: @Composable (modifier: Modifier, paddingValue: Dp) -> Modifier = { modifier, paddingValue -> when (joinedItemType) { @@ -89,6 +89,7 @@ internal fun PostWithBottomSheet( postItemViewType = postItemViewType, clientId = clientId, displayHeader = displayHeader, + postItemViewJoinedType = joinedItemType, onClickOnReaction = postActions.onClickReaction, onClick = onClick, onLongClick = { From 456321fb100871972c2ff26ca393e136cfb98727 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 16:26:20 +0100 Subject: [PATCH 05/15] changed time formatting --- .../native_app/core/ui/date/convertToFormat.kt | 13 +++++++++++++ .../native_app/core/ui/date/relativeTime.kt | 10 +++++++++- .../metis/conversation/ui/post/PostItem.kt | 17 ++++++++++------- .../conversation/ui/post/PostWithBottomSheet.kt | 2 +- .../src/main/res/values/post_strings.xml | 2 +- 5 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertToFormat.kt diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertToFormat.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertToFormat.kt new file mode 100644 index 000000000..6de09cf8e --- /dev/null +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertToFormat.kt @@ -0,0 +1,13 @@ +package de.tum.informatics.www1.artemis.native_app.core.ui.date + +import android.icu.text.SimpleDateFormat +import kotlinx.datetime.Instant +import kotlinx.datetime.toJavaInstant +import java.util.Date + +fun convertToFormat(date: Instant?): String { + return SimpleDateFormat.getDateTimeInstance( + SimpleDateFormat.SHORT, + SimpleDateFormat.SHORT + ).format(Date.from(date?.toJavaInstant())) +} \ No newline at end of file diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt index 9ad08bc64..7ac507d4c 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt @@ -27,7 +27,8 @@ fun getRelativeTime( to: Instant, clock: Clock = Clock.System, formatSeconds: Boolean = false, - showDate: Boolean = true + showDate: Boolean = true, + showDateAndTime: Boolean = false ): CharSequence { val timeDifferenceBelowOneMinuteString = stringResource(id = R.string.time_difference_under_one_minute) @@ -44,6 +45,13 @@ fun getRelativeTime( SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT) .format(Date.from(to.toJavaInstant())) ) + } else if (timeDifference >= 1.days && showDateAndTime) { + emit( + SimpleDateFormat.getDateTimeInstance( + SimpleDateFormat.MEDIUM, + SimpleDateFormat.SHORT + ).format(Date.from(to.toJavaInstant())) + ) } else if (formatSeconds || timeDifference >= 1.minutes) { emit( DateUtils.getRelativeTimeSpanString( diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 4a8575386..1938c5e2a 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -45,6 +45,7 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import de.tum.informatics.www1.artemis.native_app.core.ui.Spacings +import de.tum.informatics.www1.artemis.native_app.core.ui.date.convertToFormat import de.tum.informatics.www1.artemis.native_app.core.ui.date.getRelativeTime import de.tum.informatics.www1.artemis.native_app.core.ui.markdown.MarkdownText import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.PostColors @@ -181,9 +182,10 @@ internal fun PostItem( ) if (post?.updatedDate != null) { + val updateTime = convertToFormat(post.updatedDate) Text( - text = stringResource(id = R.string.post_edited_hint), - style = MaterialTheme.typography.bodyMedium, + text = stringResource(id = R.string.post_edited_hint, updateTime), + style = MaterialTheme.typography.bodySmall, color = PostColors.editedHintText ) } @@ -354,7 +356,12 @@ private fun AuthorRoleAndTimeRow( } val creationDateContent: @Composable () -> Unit = { - val relativeTime = getRelativeTime(to = relativeTimeTo, showDate = false) + + val relativeTime = if (expanded) { + getRelativeTime(to = relativeTimeTo, showDateAndTime = true) + } else { + getRelativeTime(to = relativeTimeTo, showDate = false) + } Text( modifier = Modifier, @@ -363,10 +370,6 @@ private fun AuthorRoleAndTimeRow( ) } - if (expanded) { - //adjust creation date - } - Row( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt index 8b320e59e..0c12fec40 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt @@ -61,7 +61,7 @@ internal fun PostWithBottomSheet( PostItemViewJoinedType.JOINED, PostItemViewJoinedType.PARENT -> MaterialTheme.shapes.small.copy(all = CornerSize(0.dp)) PostItemViewJoinedType.SINGLE -> MaterialTheme.shapes.small } -println(CardDefaults.cardColors().containerColor) + val applyPaddingToModifier: @Composable (modifier: Modifier, paddingValue: Dp) -> Modifier = { modifier, paddingValue -> when (joinedItemType) { diff --git a/feature/metis/conversation/src/main/res/values/post_strings.xml b/feature/metis/conversation/src/main/res/values/post_strings.xml index cdbb6c60e..118c649e9 100644 --- a/feature/metis/conversation/src/main/res/values/post_strings.xml +++ b/feature/metis/conversation/src/main/res/values/post_strings.xml @@ -11,7 +11,7 @@ Resolved Pinned - (edited) + Edited (%1$s) %d Replies From 117ecf7d36d8429c5149a9f35d765407b83de155 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 17:34:05 +0100 Subject: [PATCH 06/15] added reply icon --- ...nvertToFormat.kt => convertDateAndTime.kt} | 2 +- .../metis/conversation/ui/post/PostItem.kt | 76 ++++++++++--------- .../src/main/res/drawable/replies.xml | 12 +++ .../src/main/res/values/qna_strings.xml | 4 +- 4 files changed, 57 insertions(+), 37 deletions(-) rename core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/{convertToFormat.kt => convertDateAndTime.kt} (88%) create mode 100644 feature/metis/conversation/src/main/res/drawable/replies.xml diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertToFormat.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertDateAndTime.kt similarity index 88% rename from core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertToFormat.kt rename to core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertDateAndTime.kt index 6de09cf8e..d741837d8 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertToFormat.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertDateAndTime.kt @@ -5,7 +5,7 @@ import kotlinx.datetime.Instant import kotlinx.datetime.toJavaInstant import java.util.Date -fun convertToFormat(date: Instant?): String { +fun converDateAndTime(date: Instant?): String { return SimpleDateFormat.getDateTimeInstance( SimpleDateFormat.SHORT, SimpleDateFormat.SHORT diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 1938c5e2a..413be9790 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -39,13 +39,14 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import de.tum.informatics.www1.artemis.native_app.core.ui.Spacings -import de.tum.informatics.www1.artemis.native_app.core.ui.date.convertToFormat +import de.tum.informatics.www1.artemis.native_app.core.ui.date.converDateAndTime import de.tum.informatics.www1.artemis.native_app.core.ui.date.getRelativeTime import de.tum.informatics.www1.artemis.native_app.core.ui.markdown.MarkdownText import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.PostColors @@ -137,8 +138,12 @@ internal fun PostItem( modifier = Modifier .fillMaxWidth() .let { - if (postItemViewJoinedType == PostItemViewJoinedType.JOINED) { - it.padding(top = 4.dp) + if (postItemViewJoinedType in listOf( + PostItemViewJoinedType.JOINED, + PostItemViewJoinedType.FOOTER + ) + ) { + it.padding(top = 8.dp) } else { it.padding(bottom = 4.dp) } @@ -182,7 +187,7 @@ internal fun PostItem( ) if (post?.updatedDate != null) { - val updateTime = convertToFormat(post.updatedDate) + val updateTime = converDateAndTime(post.updatedDate) Text( text = stringResource(id = R.string.post_edited_hint, updateTime), style = MaterialTheme.typography.bodySmall, @@ -218,11 +223,14 @@ internal fun PostItem( modifier = Modifier .fillMaxWidth() .let { - if (postItemViewJoinedType == PostItemViewJoinedType.JOINED && post?.reactions + if (postItemViewJoinedType in listOf( + PostItemViewJoinedType.JOINED, + PostItemViewJoinedType.HEADER + ) && post?.reactions .orEmpty() .isNotEmpty() ) { - it.padding(bottom = 4.dp) + it.padding(bottom = 8.dp) } else { it } @@ -400,25 +408,11 @@ private fun HeadlineProfilePicture( private fun HeadlineAuthorRoleBadge( authorRole: UserRole?, ) { - var text = R.string.post_student - var color = MaterialTheme.colorScheme.primary - when (authorRole) { - UserRole.INSTRUCTOR -> { - text = R.string.post_instructor - color = PostColors.Roles.instructor - } - - UserRole.TUTOR -> { - text = R.string.post_tutor - color = PostColors.Roles.tutor - } - - UserRole.USER -> { - text = R.string.post_student - color = PostColors.Roles.student - } - - null -> {} + val (text, color) = when (authorRole) { + UserRole.INSTRUCTOR -> R.string.post_instructor to PostColors.Roles.instructor + UserRole.TUTOR -> R.string.post_tutor to PostColors.Roles.tutor + UserRole.USER -> R.string.post_student to PostColors.Roles.student + null -> R.string.post_student to PostColors.Roles.student } Box( @@ -481,15 +475,29 @@ private fun StandalonePostFooter( val replyCount = postItemViewType.answerPosts.size if (replyCount > 0) { - Text( - style = MaterialTheme.typography.bodyMedium, - text = pluralStringResource( - id = R.plurals.communication_standalone_post_view_replies_button, - count = replyCount, - replyCount - ), - color = MaterialTheme.colorScheme.secondary - ) + Row ( + modifier = Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(4.dp) + ) { + Icon( + modifier = Modifier.size(16.dp), + painter = painterResource(id = R.drawable.replies), + contentDescription = null, + tint = MaterialTheme.colorScheme.primary + ) + + Text( + style = MaterialTheme.typography.bodyMedium, + text = pluralStringResource( + id = R.plurals.communication_standalone_post_view_replies_button, + count = replyCount, + replyCount + ), + fontWeight = FontWeight.Normal, + color = MaterialTheme.colorScheme.primary + ) + } } } } diff --git a/feature/metis/conversation/src/main/res/drawable/replies.xml b/feature/metis/conversation/src/main/res/drawable/replies.xml new file mode 100644 index 000000000..684d90530 --- /dev/null +++ b/feature/metis/conversation/src/main/res/drawable/replies.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/feature/metis/conversation/src/main/res/values/qna_strings.xml b/feature/metis/conversation/src/main/res/values/qna_strings.xml index 27384c212..7782dd4c8 100644 --- a/feature/metis/conversation/src/main/res/values/qna_strings.xml +++ b/feature/metis/conversation/src/main/res/values/qna_strings.xml @@ -1,8 +1,8 @@ - Show 1 reply - Show %1$d replies + Show Reply + %1$d Replies Create post From 7a228960ff66c96f8d2adcdb2dbe81568de4411e Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 17:52:15 +0100 Subject: [PATCH 07/15] redesigned DateDivider --- .../conversation/ui/chatlist/MetisChatList.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt index 0759db800..c8d4e4bad 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/chatlist/MetisChatList.kt @@ -5,14 +5,13 @@ 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.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -405,19 +404,16 @@ private fun DateDivider(modifier: Modifier, date: LocalDate) { ) } - Row( - modifier = modifier, - horizontalArrangement = Arrangement.spacedBy(4.dp), - verticalAlignment = Alignment.CenterVertically + Column( + modifier = modifier.padding(vertical = 8.dp), + verticalArrangement = Arrangement.spacedBy(4.dp) ) { - Divider(modifier = Modifier.weight(1f)) - Text( text = dateAsString, style = MaterialTheme.typography.bodyMedium, fontWeight = FontWeight.Bold ) - Divider(modifier = Modifier.weight(1f)) + HorizontalDivider() } } \ No newline at end of file From 49a3fe5a7c9dfe942d1cbe8e4ba4027a368b9101 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 18:41:16 +0100 Subject: [PATCH 08/15] added emojiDialogButton to posts that already have reactions and parent posts --- .../metis/conversation/ui/post/PostItem.kt | 45 ++++++++++++++++--- .../ui/post/PostWithBottomSheet.kt | 2 +- .../post_actions/PostContextBottomSheet.kt | 2 +- .../src/main/res/values/qna_strings.xml | 4 +- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 413be9790..84eb135eb 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -21,18 +21,21 @@ 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.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Check +import androidx.compose.material.icons.filled.InsertEmoticon import androidx.compose.material.icons.outlined.PushPin import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -53,6 +56,8 @@ import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.PostCo import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.R import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.service.CreatePostService import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.getUnicodeForEmojiId +import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.EmojiDialog +import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActions import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.DisplayPriority import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.IAnswerPost import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.content.dto.IBasePost @@ -91,7 +96,7 @@ internal fun PostItem( clientId: Long, displayHeader: Boolean, postItemViewJoinedType: PostItemViewJoinedType, - onClickOnReaction: ((emojiId: String, create: Boolean) -> Unit)?, + postActions: PostActions, onClick: () -> Unit, onLongClick: () -> Unit, onRequestRetrySend: () -> Unit @@ -238,7 +243,7 @@ internal fun PostItem( clientId = clientId, reactions = remember(post?.reactions) { post?.reactions.orEmpty() }, postItemViewType = postItemViewType, - onClickReaction = onClickOnReaction + postActions = postActions ) } } @@ -438,7 +443,7 @@ private fun StandalonePostFooter( clientId: Long, reactions: List, postItemViewType: PostItemViewType, - onClickReaction: ((emojiId: String, create: Boolean) -> Unit)? + postActions: PostActions ) { val reactionCount: Map = remember(reactions, clientId) { reactions.groupBy { it.emojiId }.mapValues { groupedReactions -> @@ -448,6 +453,17 @@ private fun StandalonePostFooter( ) } } + val showEmojiDialog = remember { mutableStateOf(false) } + + if (showEmojiDialog.value) { + EmojiDialog( + onDismissRequest = { showEmojiDialog.value = false }, + onSelectEmoji = { emojiId -> + postActions.onClickReaction?.invoke(emojiId, true) + showEmojiDialog.value = false + } + ) + } Column( modifier = modifier, @@ -457,7 +473,7 @@ private fun StandalonePostFooter( modifier = Modifier .fillMaxSize() .horizontalScroll(rememberScrollState()), - horizontalArrangement = Arrangement.spacedBy(4.dp) + horizontalArrangement = Arrangement.spacedBy(12.dp) ) { reactionCount.forEach { (emoji, reactionData) -> EmojiChip( @@ -465,10 +481,28 @@ private fun StandalonePostFooter( emojiId = emoji, reactionCount = reactionData.reactionCount, onClick = { - onClickReaction?.invoke(emoji, !reactionData.hasClientReacted) + postActions.onClickReaction?.invoke(emoji, !reactionData.hasClientReacted) } ) } + if (reactionCount.isNotEmpty() || postItemViewType is PostItemViewType.ThreadContextPostItem) { + Box( + modifier = modifier + .background(color = PostColors.EmojiChipColors.background, CircleShape) + .clip(CircleShape) + .clickable(onClick = { + showEmojiDialog.value = true + }) + ) { + Icon( + modifier = Modifier + .size(27.dp) + .padding(5.dp), + imageVector = Icons.Default.InsertEmoticon, + contentDescription = null, + ) + } + } } if (postItemViewType is PostItemViewType.ChatListItem) { @@ -547,6 +581,7 @@ private fun EmojiChip( modifier = modifier .background(color = backgroundColor, shape) .clip(shape) + .heightIn(max = 27.dp) .clickable(onClick = onClick) .let { if (selected) { diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt index 0c12fec40..652265d64 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt @@ -90,7 +90,7 @@ internal fun PostWithBottomSheet( clientId = clientId, displayHeader = displayHeader, postItemViewJoinedType = joinedItemType, - onClickOnReaction = postActions.onClickReaction, + postActions = postActions, onClick = onClick, onLongClick = { displayBottomSheet = true diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/post_actions/PostContextBottomSheet.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/post_actions/PostContextBottomSheet.kt index 5ba8bc934..ea6354a2f 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/post_actions/PostContextBottomSheet.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/post_actions/PostContextBottomSheet.kt @@ -287,7 +287,7 @@ private fun ActionButton( } @Composable -private fun EmojiDialog( +fun EmojiDialog( onDismissRequest: () -> Unit, onSelectEmoji: (emojiId: String) -> Unit ) { diff --git a/feature/metis/conversation/src/main/res/values/qna_strings.xml b/feature/metis/conversation/src/main/res/values/qna_strings.xml index 7782dd4c8..326ef2f63 100644 --- a/feature/metis/conversation/src/main/res/values/qna_strings.xml +++ b/feature/metis/conversation/src/main/res/values/qna_strings.xml @@ -1,8 +1,8 @@ - Show Reply - %1$d Replies + 1 reply + %1$d replies Create post From fc66b76d075c81634e2b5766181624d97c669480 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 16 Dec 2024 19:26:04 +0100 Subject: [PATCH 09/15] changed chat settings icon --- .../metis/conversation/ui/ConversationChatListScreen.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/ConversationChatListScreen.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/ConversationChatListScreen.kt index 5b2472fed..a52673a98 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/ConversationChatListScreen.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/ConversationChatListScreen.kt @@ -13,7 +13,7 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack import androidx.compose.material.icons.filled.Search -import androidx.compose.material.icons.filled.Settings +import androidx.compose.material.icons.outlined.Info import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -203,7 +203,7 @@ fun ConversationChatListScreen( } IconButton(onClick = onNavigateToSettings) { - Icon(imageVector = Icons.Default.Settings, contentDescription = null) + Icon(imageVector = Icons.Outlined.Info, contentDescription = null) } } } From d5cc2a937f6ca88a230c807b16a976c434f9f3ee Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Tue, 17 Dec 2024 12:30:02 +0100 Subject: [PATCH 10/15] changed changed resolving label location and added date to answer posts --- .../metis/conversation/ui/post/PostItem.kt | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 84eb135eb..899120f6f 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -138,26 +138,36 @@ internal fun PostItem( } .padding(PaddingValues(horizontal = Spacings.ScreenHorizontalSpacing)) ) { + val applyDistancePaddingToModifier: @Composable (Modifier) -> Modifier = { + if (postItemViewJoinedType in listOf( + PostItemViewJoinedType.JOINED, + PostItemViewJoinedType.FOOTER + ) + ) { + it.padding(top = 8.dp) + } else { + it.padding(bottom = 4.dp) + } + } + if (isPinned) { IconLabel( - modifier = Modifier - .fillMaxWidth() - .let { - if (postItemViewJoinedType in listOf( - PostItemViewJoinedType.JOINED, - PostItemViewJoinedType.FOOTER - ) - ) { - it.padding(top = 8.dp) - } else { - it.padding(bottom = 4.dp) - } - }, + modifier = applyDistancePaddingToModifier(Modifier) + .fillMaxWidth(), resourceString = R.string.post_is_pinned, icon = Icons.Outlined.PushPin ) } + if (post is IAnswerPost && post.resolvesPost) { + IconLabel( + modifier = applyDistancePaddingToModifier(Modifier) + .fillMaxWidth(), + resourceString = R.string.post_resolves, + icon = Icons.Default.Check + ) + } + PostHeadline( modifier = Modifier.fillMaxWidth(), postStatus = postStatus, @@ -170,6 +180,7 @@ internal fun PostItem( ), creationDate = post?.creationDate, expanded = isExpanded, + isAnswerPost = post is IAnswerPost, displayHeader = displayHeader ) { Column( @@ -200,28 +211,12 @@ internal fun PostItem( ) } - when (post) { - is IStandalonePost -> { - if (post.resolved == true) { - IconLabel( - modifier = Modifier.fillMaxWidth(), - resourceString = R.string.post_is_resolved, - icon = Icons.Default.Check - ) - } - } - - is IAnswerPost -> { - if (post.resolvesPost) { - IconLabel( - modifier = Modifier.fillMaxWidth(), - resourceString = R.string.post_resolves, - icon = Icons.Default.Check - ) - } - } - - else -> {} + if (post is IStandalonePost && post.resolved == true) { + IconLabel( + modifier = Modifier.fillMaxWidth(), + resourceString = R.string.post_is_resolved, + icon = Icons.Default.Check + ) } StandalonePostFooter( @@ -259,6 +254,7 @@ private fun PostHeadline( creationDate: Instant?, postStatus: CreatePostService.Status, expanded: Boolean = false, + isAnswerPost: Boolean, displayHeader: Boolean = true, content: @Composable () -> Unit ) { @@ -296,7 +292,8 @@ private fun PostHeadline( authorName = authorName, authorRole = authorRole, creationDate = creationDate, - expanded = expanded + expanded = expanded, + isAnswerPost = isAnswerPost ) } @@ -336,12 +333,14 @@ private fun HeadlineAuthorInfo( authorRole: UserRole?, creationDate: Instant?, expanded: Boolean, + isAnswerPost: Boolean ) { Column(modifier = modifier) { AuthorRoleAndTimeRow( expanded = expanded, authorRole = authorRole, creationDate = creationDate, + isAnswerPost = isAnswerPost ) Text( @@ -358,7 +357,8 @@ private fun HeadlineAuthorInfo( private fun AuthorRoleAndTimeRow( expanded: Boolean, authorRole: UserRole?, - creationDate: Instant? + creationDate: Instant?, + isAnswerPost: Boolean ) { Row( modifier = Modifier.fillMaxWidth(), @@ -370,7 +370,7 @@ private fun AuthorRoleAndTimeRow( val creationDateContent: @Composable () -> Unit = { - val relativeTime = if (expanded) { + val relativeTime = if (expanded || isAnswerPost) { getRelativeTime(to = relativeTimeTo, showDateAndTime = true) } else { getRelativeTime(to = relativeTimeTo, showDate = false) From c8ef563fd172f2139bb0b9f7a04e69b17697b8dc Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Fri, 3 Jan 2025 14:52:38 +0100 Subject: [PATCH 11/15] added DateFormats --- .../native_app/core/ui/date/DateFormats.kt | 16 ++++++++++++++++ .../core/ui/date/convertDateAndTime.kt | 13 ------------- .../native_app/core/ui/date/relativeTime.kt | 14 ++++++-------- .../metis/conversation/ui/post/PostItem.kt | 8 +++++--- 4 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/DateFormats.kt delete mode 100644 core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertDateAndTime.kt diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/DateFormats.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/DateFormats.kt new file mode 100644 index 000000000..23fe078b1 --- /dev/null +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/DateFormats.kt @@ -0,0 +1,16 @@ +package de.tum.informatics.www1.artemis.native_app.core.ui.date + +import android.icu.text.DateFormat +import android.icu.text.SimpleDateFormat + +enum class DateFormats(val format: DateFormat) { + DefaultDateAndTime(SimpleDateFormat.getDateTimeInstance( + SimpleDateFormat.MEDIUM, + SimpleDateFormat.SHORT + )), + OnlyTime(SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT)), + EditTimestamp(SimpleDateFormat.getDateTimeInstance( + SimpleDateFormat.SHORT, + SimpleDateFormat.SHORT + )) +} diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertDateAndTime.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertDateAndTime.kt deleted file mode 100644 index d741837d8..000000000 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/convertDateAndTime.kt +++ /dev/null @@ -1,13 +0,0 @@ -package de.tum.informatics.www1.artemis.native_app.core.ui.date - -import android.icu.text.SimpleDateFormat -import kotlinx.datetime.Instant -import kotlinx.datetime.toJavaInstant -import java.util.Date - -fun converDateAndTime(date: Instant?): String { - return SimpleDateFormat.getDateTimeInstance( - SimpleDateFormat.SHORT, - SimpleDateFormat.SHORT - ).format(Date.from(date?.toJavaInstant())) -} \ No newline at end of file diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt index 7ac507d4c..ef6cd8be7 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt @@ -1,6 +1,6 @@ package de.tum.informatics.www1.artemis.native_app.core.ui.date -import android.icu.text.SimpleDateFormat +import android.icu.text.DateFormat import android.text.format.DateUtils import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState @@ -42,15 +42,11 @@ fun getRelativeTime( if (timeDifference >= 1.days && !showDate) { emit( - SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT) - .format(Date.from(to.toJavaInstant())) + to.format(DateFormats.OnlyTime.format) ) } else if (timeDifference >= 1.days && showDateAndTime) { emit( - SimpleDateFormat.getDateTimeInstance( - SimpleDateFormat.MEDIUM, - SimpleDateFormat.SHORT - ).format(Date.from(to.toJavaInstant())) + to.format(DateFormats.DefaultDateAndTime.format) ) } else if (formatSeconds || timeDifference >= 1.minutes) { emit( @@ -89,4 +85,6 @@ fun getRelativeTime( } return flow.collectAsState(initial = "").value -} \ No newline at end of file +} + +fun Instant.format(f: DateFormat) = f.format(Date.from(this.toJavaInstant())) \ No newline at end of file diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 32f7fefee..c527f52c2 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -49,7 +49,8 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import de.tum.informatics.www1.artemis.native_app.core.ui.Spacings -import de.tum.informatics.www1.artemis.native_app.core.ui.date.converDateAndTime +import de.tum.informatics.www1.artemis.native_app.core.ui.date.DateFormats +import de.tum.informatics.www1.artemis.native_app.core.ui.date.format import de.tum.informatics.www1.artemis.native_app.core.ui.date.getRelativeTime import de.tum.informatics.www1.artemis.native_app.core.ui.markdown.MarkdownText import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.PostColors @@ -199,8 +200,9 @@ internal fun PostItem( color = if (post?.serverPostId == null) PostColors.unsentMessageText else Color.Unspecified ) - if (post?.updatedDate != null) { - val updateTime = converDateAndTime(post.updatedDate) + val instant = post?.updatedDate + if (instant != null) { + val updateTime = instant.format(DateFormats.EditTimestamp.format) Text( text = stringResource(id = R.string.post_edited_hint, updateTime), style = MaterialTheme.typography.bodySmall, From a9c407542d50380aac6ce1cd560bab09981ed8ab Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Sat, 4 Jan 2025 10:31:27 +0100 Subject: [PATCH 12/15] fixed postHeadlineHeight and added require statement to getRelativeTime --- .../www1/artemis/native_app/core/ui/date/relativeTime.kt | 3 +++ .../feature/metis/conversation/ui/post/PostItem.kt | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt index ef6cd8be7..b609d9c23 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/date/relativeTime.kt @@ -30,6 +30,9 @@ fun getRelativeTime( showDate: Boolean = true, showDateAndTime: Boolean = false ): CharSequence { + val isShowDateParameterCombinationIllegal = showDateAndTime && !showDate + require(!isShowDateParameterCombinationIllegal) + val timeDifferenceBelowOneMinuteString = stringResource(id = R.string.time_difference_under_one_minute) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index c527f52c2..47e413910 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -346,6 +346,8 @@ private fun HeadlineAuthorInfo( isAnswerPost = isAnswerPost ) + Spacer(modifier = Modifier.weight(1f)) + Text( modifier = Modifier, text = remember(authorName) { authorName ?: "Placeholder" }, @@ -405,7 +407,7 @@ private fun HeadlineProfilePicture( userRole: UserRole?, displayImage: Boolean = true ) { - val size = 30.dp + val size = postHeadlineHeight Box(modifier = Modifier.size(size)) { if (!displayImage) { return @@ -437,7 +439,7 @@ private fun HeadlineAuthorRoleBadge( .background(color, MaterialTheme.shapes.extraSmall) ) { Text( - modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp), + modifier = Modifier.padding(horizontal = 8.dp, vertical = 1.dp), text = stringResource(id = text), style = MaterialTheme.typography.bodySmall, color = Color.White, From 0aca9f33ac62f95ebe9519c9f8b043469591bd7d Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Sat, 4 Jan 2025 11:15:20 +0100 Subject: [PATCH 13/15] fixed background color for selected emoji chips --- .../artemis/native_app/core/ui/material/colors/PostColors.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt index 220a94de3..81fc403a3 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/material/colors/PostColors.kt @@ -31,7 +31,7 @@ object PostColors { val background: Color @Composable get() = if (isSystemInDarkTheme()) Color(0xFF282C30) else Color(0xFFD0D2D8) val selectedBackgound: Color - @Composable get() = MaterialTheme.colorScheme.primaryContainer + @Composable get() = MaterialTheme.colorScheme.primaryContainer.copy(alpha = 0.25f) } val editedHintText: Color From 8e47364db958837e22d28b25fa8e2df2a41d6b0f Mon Sep 17 00:00:00 2001 From: Julian Waluschyk <37155504+julian-wls@users.noreply.github.com> Date: Sat, 4 Jan 2025 11:34:24 +0100 Subject: [PATCH 14/15] `Bugfix`: Fix author role changing when updating post (#266) Co-authored-by: Martin Felber <45291671+FelberMartin@users.noreply.github.com> --- .../feature/metis/conversation/ui/post/PostItem.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 47e413910..295f75853 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -427,7 +427,12 @@ private fun HeadlineProfilePicture( private fun HeadlineAuthorRoleBadge( authorRole: UserRole?, ) { - val (text, color) = when (authorRole) { + /* + * remember is needed here to prevent the value from being reset after an update + * (the author role is not sent when updating a post) + */ + val initialAuthorRole = remember { mutableStateOf(authorRole) } + val (text, color) = when (initialAuthorRole.value) { UserRole.INSTRUCTOR -> R.string.post_instructor to PostColors.Roles.instructor UserRole.TUTOR -> R.string.post_tutor to PostColors.Roles.tutor UserRole.USER -> R.string.post_student to PostColors.Roles.student From a9e54d781936ffdcaa373953d538d10a499a4ce4 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Sat, 4 Jan 2025 12:35:49 +0100 Subject: [PATCH 15/15] adjusted inner spacing for posts --- .../artemis/native_app/core/ui/Spacings.kt | 6 ++++- .../metis/conversation/ui/post/PostItem.kt | 25 +++++++++++++------ .../ui/post/PostWithBottomSheet.kt | 3 ++- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/Spacings.kt b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/Spacings.kt index fc81f4c82..8d01238a2 100644 --- a/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/Spacings.kt +++ b/core/ui/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/Spacings.kt @@ -4,6 +4,10 @@ import androidx.compose.ui.unit.dp object Spacings { val ScreenHorizontalSpacing = 16.dp - + val ScreenHorizontalInnerSpacing = 8.dp val FabContentBottomPadding = 80.dp + + object Post { + val innerSpacing = 8.dp + } } \ No newline at end of file diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 295f75853..bef18c0bc 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -109,6 +109,8 @@ internal fun PostItem( } val isPinned = post is IStandalonePost && post.displayPriority == DisplayPriority.PINNED + val hasFooter = (post is IStandalonePost && post.answers.orEmpty() + .isNotEmpty()) || post?.reactions.orEmpty().isNotEmpty() || isExpanded // Retrieve post status val clientPostId = post?.clientPostId @@ -137,7 +139,7 @@ internal fun PostItem( ) } } - .padding(PaddingValues(horizontal = Spacings.ScreenHorizontalSpacing)) + .padding(PaddingValues(horizontal = Spacings.ScreenHorizontalInnerSpacing)) ) { val applyDistancePaddingToModifier: @Composable (Modifier) -> Modifier = { if (postItemViewJoinedType in listOf( @@ -145,7 +147,7 @@ internal fun PostItem( PostItemViewJoinedType.FOOTER ) ) { - it.padding(top = 8.dp) + it.padding(top = Spacings.Post.innerSpacing) } else { it.padding(bottom = 4.dp) } @@ -182,8 +184,7 @@ internal fun PostItem( displayHeader = displayHeader ) { Column( - modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(8.dp) + modifier = Modifier.fillMaxWidth() ) { MarkdownText( markdown = remember(post?.content, isPlaceholder) { @@ -203,6 +204,8 @@ internal fun PostItem( val instant = post?.updatedDate if (instant != null) { val updateTime = instant.format(DateFormats.EditTimestamp.format) + Spacer(modifier = Modifier.height(Spacings.Post.innerSpacing)) + Text( text = stringResource(id = R.string.post_edited_hint, updateTime), style = MaterialTheme.typography.bodySmall, @@ -211,6 +214,8 @@ internal fun PostItem( } if (post is IStandalonePost && post.resolved == true) { + Spacer(modifier = Modifier.height(Spacings.Post.innerSpacing)) + IconLabel( modifier = Modifier.fillMaxWidth(), resourceString = R.string.post_is_resolved, @@ -218,6 +223,10 @@ internal fun PostItem( ) } + if (hasFooter) { + Spacer(modifier = Modifier.height(Spacings.Post.innerSpacing)) + } + StandalonePostFooter( modifier = Modifier .fillMaxWidth() @@ -229,7 +238,7 @@ internal fun PostItem( .orEmpty() .isNotEmpty() ) { - it.padding(bottom = 8.dp) + it.padding(bottom = Spacings.Post.innerSpacing) } else { it } @@ -262,12 +271,12 @@ private fun PostHeadline( Column( modifier = modifier, - verticalArrangement = Arrangement.spacedBy(8.dp) + verticalArrangement = Arrangement.spacedBy(Spacings.Post.innerSpacing) ) { Row( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(12.dp) + horizontalArrangement = Arrangement.spacedBy(Spacings.Post.innerSpacing) ) { if (!doDisplayHeader) { return@Row @@ -528,7 +537,7 @@ private fun StandalonePostFooter( val replyCount = postItemViewType.answerPosts.size if (replyCount > 0) { - Row ( + Row( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt index 652265d64..e21d35acf 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostWithBottomSheet.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Shape import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import de.tum.informatics.www1.artemis.native_app.core.ui.Spacings import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.PostColors import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostActions import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.ui.post.post_actions.PostContextBottomSheet @@ -76,7 +77,7 @@ internal fun PostWithBottomSheet( } val cardModifier = applyPaddingToModifier(modifier, 4.dp) - val innerModifier = applyPaddingToModifier(modifier, 8.dp) + val innerModifier = applyPaddingToModifier(modifier, Spacings.Post.innerSpacing) Card( modifier = cardModifier,