From 44069d297613875e4f5bf81ef8ce4954919c9c5b Mon Sep 17 00:00:00 2001 From: "omer.habib" Date: Fri, 4 Oct 2024 20:24:55 +0500 Subject: [PATCH 1/2] chore: Elm theme Improvements on Discussion Module - Update Text, icons colors and button according to elm theme fix: LEARNER-10080 --- .../comments/DiscussionCommentsFragment.kt | 10 +---- .../presentation/ui/DiscussionUI.kt | 37 ++++++------------- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt index 01c266109..54505c20c 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt @@ -191,17 +191,11 @@ private fun DiscussionCommentsScreen( } val sendButtonColor = if (responseValue.isEmpty()) { - MaterialTheme.appColors.textFieldBorder + MaterialTheme.appColors.primaryButtonBackground.copy(alpha = 0.3f) } else { MaterialTheme.appColors.primaryButtonBackground } - val iconButtonColor = if (responseValue.isEmpty()) { - MaterialTheme.appColors.textFieldBackgroundVariant - } else { - Color.White - } - Scaffold( scaffoldState = scaffoldState, modifier = Modifier @@ -419,7 +413,7 @@ private fun DiscussionCommentsScreen( modifier = Modifier.padding(7.dp), painter = painterResource(id = R.drawable.discussion_ic_send), contentDescription = stringResource(id = R.string.discussion_add_response), - tint = iconButtonColor + tint = MaterialTheme.appColors.primaryButtonText ) } } diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt b/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt index 71e84838a..c95790e31 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt @@ -82,11 +82,6 @@ fun ThreadMainItem( } else { painterResource(id = R.drawable.discussion_ic_like) } - val voteColor = if (thread.voted) { - MaterialTheme.appColors.primary - } else { - MaterialTheme.appColors.textPrimaryVariant - } val reportText = if (thread.abuseFlagged) { stringResource(id = R.string.discussion_unreport) } else { @@ -95,7 +90,7 @@ fun ThreadMainItem( val reportColor = if (thread.abuseFlagged) { MaterialTheme.appColors.error } else { - MaterialTheme.appColors.textPrimaryVariant + MaterialTheme.appColors.textPrimary } val context = LocalContext.current @@ -149,7 +144,7 @@ fun ThreadMainItem( text = stringResource(id = R.string.discussion_follow), painter = painterResource(if (thread.following) R.drawable.discussion_star_filled else R.drawable.discussion_star), textStyle = MaterialTheme.appTypography.labelLarge, - color = MaterialTheme.appColors.textPrimaryVariant, + color = MaterialTheme.appColors.textPrimary, onClick = { onClick(DiscussionCommentsFragment.ACTION_FOLLOW_THREAD, !thread.following) }) @@ -174,7 +169,7 @@ fun ThreadMainItem( thread.voteCount ), painter = votePainter, - color = voteColor, + color = MaterialTheme.appColors.textPrimary, textStyle = MaterialTheme.appTypography.labelLarge, onClick = { onClick(DiscussionCommentsFragment.ACTION_UPVOTE_THREAD, !thread.voted) @@ -222,18 +217,13 @@ fun CommentItem( val reportColor = if (comment.abuseFlagged) { MaterialTheme.appColors.error } else { - MaterialTheme.appColors.textPrimaryVariant + MaterialTheme.appColors.textPrimary } val votePainter = if (comment.voted) { painterResource(id = R.drawable.discussion_ic_like_success) } else { painterResource(id = R.drawable.discussion_ic_like) } - val voteColor = if (comment.voted) { - MaterialTheme.appColors.textAccent - } else { - MaterialTheme.appColors.textPrimaryVariant - } val context = LocalContext.current @@ -328,7 +318,7 @@ fun CommentItem( comment.voteCount ), painter = votePainter, - color = voteColor, + color = MaterialTheme.appColors.textPrimary, textStyle = MaterialTheme.appTypography.labelLarge, onClick = { onClick( @@ -345,7 +335,7 @@ fun CommentItem( comment.childCount ), painter = painterResource(id = R.drawable.discussion_ic_comment), - color = MaterialTheme.appColors.textPrimaryVariant, + color = MaterialTheme.appColors.textPrimary, textStyle = MaterialTheme.appTypography.labelLarge, onClick = { onAddCommentClick() @@ -382,7 +372,7 @@ fun CommentMainItem( val reportColor = if (comment.abuseFlagged) { MaterialTheme.appColors.error } else { - MaterialTheme.appColors.textPrimaryVariant + MaterialTheme.appColors.textPrimary } val votePainter = if (comment.voted) { @@ -390,11 +380,6 @@ fun CommentMainItem( } else { painterResource(id = R.drawable.discussion_ic_like) } - val voteColor = if (comment.voted) { - MaterialTheme.appColors.textAccent - } else { - MaterialTheme.appColors.textPrimaryVariant - } val context = LocalContext.current @@ -468,7 +453,7 @@ fun CommentMainItem( comment.voteCount ), painter = votePainter, - color = voteColor, + color = MaterialTheme.appColors.textPrimary, textStyle = MaterialTheme.appTypography.labelLarge, onClick = { onClick( @@ -711,13 +696,13 @@ private fun ThreadMainItemPreview() { private val mockComment = DiscussionComment( "", + "ABC", "", "", "", "", "", - "", - TextConverter.textToLinkedImageText(""), + TextConverter.textToLinkedImageText("mock Comment"), false, true, 20, @@ -737,7 +722,7 @@ private val mockComment = DiscussionComment( private val mockThread = org.openedx.discussion.domain.model.Thread( "", - "", + "ABC", "", "", "", From a4376c4aa8ea0aef5499e65f96ac7947024012d8 Mon Sep 17 00:00:00 2001 From: "omer.habib" Date: Wed, 9 Oct 2024 18:47:10 +0500 Subject: [PATCH 2/2] fix: Address PR comments - 1 --- .../comments/DiscussionCommentsFragment.kt | 11 +++----- .../presentation/ui/DiscussionUI.kt | 26 ++++++++++--------- .../main/res/drawable/discussion_ic_like.xml | 13 ---------- .../drawable/discussion_ic_like_success.xml | 17 ------------ 4 files changed, 18 insertions(+), 49 deletions(-) delete mode 100644 discussion/src/main/res/drawable/discussion_ic_like.xml delete mode 100644 discussion/src/main/res/drawable/discussion_ic_like_success.xml diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt index 54505c20c..164335846 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt @@ -24,8 +24,8 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalSoftwareKeyboardController @@ -190,11 +190,7 @@ private fun DiscussionCommentsScreen( mutableStateOf("") } - val sendButtonColor = if (responseValue.isEmpty()) { - MaterialTheme.appColors.primaryButtonBackground.copy(alpha = 0.3f) - } else { - MaterialTheme.appColors.primaryButtonBackground - } + val sendButtonAlpha = if (responseValue.isEmpty()) 0.3f else 1f Scaffold( scaffoldState = scaffoldState, @@ -398,7 +394,8 @@ private fun DiscussionCommentsScreen( modifier = Modifier .size(48.dp) .clip(CircleShape) - .background(sendButtonColor) + .alpha(sendButtonAlpha) + .background(MaterialTheme.appColors.primaryButtonBackground) .clickable { keyboardController?.hide() focusManager.clearFocus() diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt b/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt index c95790e31..30d78ac9d 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/ui/DiscussionUI.kt @@ -29,6 +29,8 @@ import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.HelpOutline import androidx.compose.material.icons.filled.ChevronRight +import androidx.compose.material.icons.filled.ThumbUp +import androidx.compose.material.icons.outlined.ThumbUp import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi @@ -77,10 +79,10 @@ fun ThreadMainItem( CoreR.drawable.core_ic_default_profile_picture } - val votePainter = if (thread.voted) { - painterResource(id = R.drawable.discussion_ic_like_success) + val voteIcon = if (thread.voted) { + Icons.Filled.ThumbUp } else { - painterResource(id = R.drawable.discussion_ic_like) + Icons.Outlined.ThumbUp } val reportText = if (thread.abuseFlagged) { stringResource(id = R.string.discussion_unreport) @@ -168,7 +170,7 @@ fun ThreadMainItem( thread.voteCount, thread.voteCount ), - painter = votePainter, + icon = voteIcon, color = MaterialTheme.appColors.textPrimary, textStyle = MaterialTheme.appTypography.labelLarge, onClick = { @@ -219,10 +221,10 @@ fun CommentItem( } else { MaterialTheme.appColors.textPrimary } - val votePainter = if (comment.voted) { - painterResource(id = R.drawable.discussion_ic_like_success) + val voteIcon = if (comment.voted) { + Icons.Filled.ThumbUp } else { - painterResource(id = R.drawable.discussion_ic_like) + Icons.Outlined.ThumbUp } val context = LocalContext.current @@ -317,7 +319,7 @@ fun CommentItem( comment.voteCount, comment.voteCount ), - painter = votePainter, + icon = voteIcon, color = MaterialTheme.appColors.textPrimary, textStyle = MaterialTheme.appTypography.labelLarge, onClick = { @@ -375,10 +377,10 @@ fun CommentMainItem( MaterialTheme.appColors.textPrimary } - val votePainter = if (comment.voted) { - painterResource(id = R.drawable.discussion_ic_like_success) + val voteIcon = if (comment.voted) { + Icons.Filled.ThumbUp } else { - painterResource(id = R.drawable.discussion_ic_like) + Icons.Outlined.ThumbUp } val context = LocalContext.current @@ -452,7 +454,7 @@ fun CommentMainItem( comment.voteCount, comment.voteCount ), - painter = votePainter, + icon = voteIcon, color = MaterialTheme.appColors.textPrimary, textStyle = MaterialTheme.appTypography.labelLarge, onClick = { diff --git a/discussion/src/main/res/drawable/discussion_ic_like.xml b/discussion/src/main/res/drawable/discussion_ic_like.xml deleted file mode 100644 index 163cf466f..000000000 --- a/discussion/src/main/res/drawable/discussion_ic_like.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/discussion/src/main/res/drawable/discussion_ic_like_success.xml b/discussion/src/main/res/drawable/discussion_ic_like_success.xml deleted file mode 100644 index cb62acf79..000000000 --- a/discussion/src/main/res/drawable/discussion_ic_like_success.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - -