Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Exercise Overview adjustments and PR cleanup #100

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Info
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
Expand All @@ -29,6 +31,9 @@ import de.tum.informatics.www1.artemis.native_app.core.model.exercise.latestPart
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.participation.Participation
import de.tum.informatics.www1.artemis.native_app.core.ui.R
import de.tum.informatics.www1.artemis.native_app.core.ui.date.hasPassed
import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.skyBlueBackground
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.skyBlueBorder
import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.textColor

/**
* This composable composes up to two buttons. The modifier parameter is applied to every button
Expand Down Expand Up @@ -211,22 +216,22 @@ class BoundExerciseActions(
fun InfoMessageCard() {
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
Box(
modifier = Modifier
.border(width = 2.dp, color = Color.LightGray)
.background(Color(0xFFB3E5FC)) // Light sky blue background
.padding(10.dp)
.border(width = 1.dp, color = skyBlueBorder, shape = RoundedCornerShape(4.dp))
.background(skyBlueBackground)
.padding(8.dp)
.fillMaxWidth()
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = Icons.Filled.Info,
contentDescription = "Information",
imageVector = Icons.Outlined.Info,
contentDescription = null,
modifier = Modifier.padding(end = 8.dp),
tint = Color(0xFF0288D1)
tint = textColor
)
Text(
text = stringResource(id = R.string.exercise_participation_not_possible),
fontSize = 16.sp,
color = Color.Black
color = textColor
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import de.tum.informatics.www1.artemis.native_app.core.model.exercise.Exercise
import de.tum.informatics.www1.artemis.native_app.core.ui.R
import de.tum.informatics.www1.artemis.native_app.core.ui.date.getRelativeTime
import de.tum.informatics.www1.artemis.native_app.core.ui.getWindowSizeClass
import de.tum.informatics.www1.artemis.native_app.core.ui.material.easyColor
import de.tum.informatics.www1.artemis.native_app.core.ui.material.hardColor
import de.tum.informatics.www1.artemis.native_app.core.ui.material.mediumColor
import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.easyColor
import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.hardColor
import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.mediumColor

/**
* Display a single exercise.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.material
package de.tum.informatics.www1.artemis.native_app.core.ui.material.colors

import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.material.colors

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color

// Colors for the info message card in the exercise screen
val skyBlueBackground: Color
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
@Composable get() = if(isSystemInDarkTheme()) Color(0xFF062A30) else Color(0xFFD1ECF1)
val skyBlueBorder: Color
@Composable get() = if(isSystemInDarkTheme()) Color(0xFF148EA1) else Color(0xFFA2DAE3)
val textColor: Color
@Composable get() = if(isSystemInDarkTheme()) Color(0xFF36CEE6) else Color(0xFF09414A)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.material
package de.tum.informatics.www1.artemis.native_app.core.ui.material.colors

import androidx.compose.material3.ColorScheme
import androidx.compose.runtime.Composable
Expand Down
2 changes: 1 addition & 1 deletion core/ui/src/main/res/values/exercise_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<!-- Exercise action buttons -->
<string name="exercise_actions_view_result_button">View result</string>
<string name="exercise_participation_not_possible">Participating this exercise is currently
not possible in the mobile app.</string>
not possible in the mobile app</string>
<string name="exercise_actions_start_exercise_button">Start exercise</string>
<string name="exercise_actions_open_exercise_button">Open exercise</string>
<string name="exercise_actions_view_submission_button">View submission</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ internal fun TopBarExerciseInformation(
val dueDateTopBarTextInformation =
@Composable { date: Instant, hintRes: @receiver:StringRes Int ->
TopBarTextInformation(
modifier = Modifier.fillMaxWidth().padding(bottom = 1.dp),
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 1.dp),
hintColumnWidth = maxWidth,
hint = stringResource(id = hintRes),
dataText = getRelativeTime(to = date).toString(),
Expand Down Expand Up @@ -235,12 +237,18 @@ internal fun TopBarExerciseInformation(
val complaintPossible = exercise.bind { exercise ->
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
exercise.allowComplaintsForAutomaticAssessments
}.orElse(false)
val complaintPossibleText = stringResource(
R.string.exercise_view_overview_hint_assessment_complaint_possible,
if (complaintPossible == true) stringResource(R.string.exercise_view_overview_hint_assessment_complaint_possible_yes) else stringResource(
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
R.string.exercise_view_overview_hint_assessment_complaint_possible_no
)
)

Text(
modifier = Modifier
.placeholder(exercise !is DataState.Success)
.padding(bottom = 4.dp),
text = "Complaint possible: " + if (complaintPossible == true) "Yes" else "No",
text = complaintPossibleText,
style = MaterialTheme.typography.bodyLarge
)

Expand All @@ -254,7 +262,7 @@ internal fun TopBarExerciseInformation(
) {

Text(
text = "Exercise Details",
text = stringResource(R.string.exercise_view_overview_title),
style = MaterialTheme.typography.titleMedium,
modifier = Modifier
.padding(bottom = 1.dp)
Expand Down Expand Up @@ -385,7 +393,19 @@ private fun TitleText(
inlineContent = inlineContent,
modifier = modifier
.placeholder(exerciseDataState !is DataState.Success)
.semantics { set(SemanticsProperties.Text, listOf(AnnotatedString(exerciseDataState.bind { it.title }.orNull().orEmpty()))) },
.semantics {
set(
SemanticsProperties.Text,
listOf(
AnnotatedString(
exerciseDataState
.bind { it.title }
.orNull()
.orEmpty()
)
)
)
},
style = style,
maxLines = maxLines,
overflow = TextOverflow.Ellipsis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.web.WebViewState
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.Exercise
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.QuizExercise
import de.tum.informatics.www1.artemis.native_app.core.ui.R
import de.tum.informatics.www1.artemis.native_app.core.ui.exercise.ExerciseActions
import de.tum.informatics.www1.artemis.native_app.feature.exerciseview.ArtemisWebView

Expand All @@ -29,12 +31,9 @@ internal fun ExerciseOverviewTab(
) {
Column(
modifier = modifier
.fillMaxSize()
.background(Color.White),
.fillMaxSize(),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {


ParticipationStatusUi(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -56,7 +55,7 @@ internal fun ExerciseOverviewTab(
)
} else {
Text(
text = "No problem statement available.",
text = stringResource(id = de.tum.informatics.www1.artemis.native_app.feature.exerciseview.R.string.exercise_view_overview_problem_statement_not_available),
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.tum.informatics.www1.artemis.native_app.feature.exerciseview.home.overview

import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
Expand All @@ -24,7 +25,7 @@ internal fun ParticipationStatusUi(
) {
ProvideDefaultExerciseTemplateStatus(exercise) {
FlowRow(
modifier = modifier,
modifier = Modifier.padding(8.dp),
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
mainAxisSpacing = 8.dp,
crossAxisAlignment = FlowCrossAxisAlignment.Center
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@
<string name="exercise_view_tab_overview">Overview</string>
<string name="exercise_view_tab_qna">Communication</string>

<string name="exercise_view_overview_title">Exercise Details</string>

<string name="exercise_view_overview_points_max">Points: %1$s</string>
<string name="exercise_view_overview_points_reached">Points: %1$s / %2$s</string>
<string name="exercise_view_overview_points_none">No points</string>
<string name="exercise_view_overview_hint_submission_due_date">Submission due:</string>
<string name="exercise_view_overview_hint_assessment_due_date">Assessment due:</string>
<string name="exercise_view_overview_hint_assessment_complaint_possible">Complaint possible: %1$s</string>
<string name="exercise_view_overview_hint_assessment_release_date">Release date:</string>

<string name="exercise_view_overview_hint_assessment_complaint_possible_yes">Yes</string>
<string name="exercise_view_overview_hint_assessment_complaint_possible_no">No</string>

<string name="exercise_participation_status_title">Your exercise status:</string>

<string name="exercise_view_overview_problem_statement_not_available">No problem statement available.</string>

<string name="exercise_info_title">Exercise info</string>
<string name="exercise_info_exercise_type">Type</string>
<string name="exercise_info_points">Points</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import de.tum.informatics.www1.artemis.native_app.core.datastore.defaults.Artemi
import de.tum.informatics.www1.artemis.native_app.core.model.server_config.ProfileInfo
import de.tum.informatics.www1.artemis.native_app.core.ui.Spacings
import de.tum.informatics.www1.artemis.native_app.core.ui.common.BasicDataStateUi
import de.tum.informatics.www1.artemis.native_app.core.ui.material.linkTextColor
import de.tum.informatics.www1.artemis.native_app.core.ui.material.colors.linkTextColor
import de.tum.informatics.www1.artemis.native_app.feature.login.custom_instance_selection.CustomInstanceSelectionScreen
import de.tum.informatics.www1.artemis.native_app.feature.login.instance_selection.InstanceSelectionScreen
import de.tum.informatics.www1.artemis.native_app.feature.login.login.LoginScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.ConversationCollections
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.R
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.ui.common.ExtraChannelIcons
Expand Down Expand Up @@ -91,7 +92,8 @@ internal fun ConversationList(
onNavigateToConversation = onNavigateToConversation,
onToggleMarkAsFavourite = onToggleMarkAsFavourite,
onToggleHidden = onToggleHidden,
onToggleMuted = onToggleMuted
onToggleMuted = onToggleMuted,
removeSectionPrefix = viewModel::removeSectionPrefix
)
}

Expand Down Expand Up @@ -250,6 +252,7 @@ private fun <T : Conversation> LazyListScope.conversationList(
onToggleMarkAsFavourite: (conversationId: Long, favorite: Boolean) -> Unit,
onToggleHidden: (conversationId: Long, hidden: Boolean) -> Unit,
onToggleMuted: (conversationId: Long, muted: Boolean) -> Unit,
removeSectionPrefix: (value: String) -> String
) {
if (!conversations.isExpanded) return
items(
Expand All @@ -271,6 +274,7 @@ private fun <T : Conversation> LazyListScope.conversationList(
},
onToggleHidden = { onToggleHidden(conversation.id, !conversation.isHidden) },
onToggleMuted = { onToggleMuted(conversation.id, !conversation.isMuted) },
removeSectionPrefix = removeSectionPrefix
)
}
}
Expand All @@ -284,6 +288,7 @@ private fun ConversationListItem(
onToggleMarkAsFavourite: () -> Unit,
onToggleHidden: () -> Unit,
onToggleMuted: () -> Unit,
removeSectionPrefix: (String) -> String
) {
var isContextDialogShown by remember { mutableStateOf(false) }
val onDismissRequest = { isContextDialogShown = false }
Expand All @@ -305,15 +310,15 @@ private fun ConversationListItem(
if (showPrefix) {
channelName
} else {
channelName.removeSectionPrefix()
removeSectionPrefix(channelName)
}
}
is GroupChat, is OneToOneChat -> {
val humanReadableTitle = conversation.humanReadableName
if (showPrefix) {
humanReadableTitle
} else {
humanReadableTitle.removeSectionPrefix()
removeSectionPrefix(humanReadableTitle)
}
}
else -> conversation.humanReadableName
Expand Down Expand Up @@ -482,15 +487,3 @@ private sealed interface ConversationSectionHeaderAction
private data class OnClickAction(val onClick: () -> Unit) : ConversationSectionHeaderAction

private object NoAction : ConversationSectionHeaderAction

private fun String.removeSectionPrefix(): String {
val prefixes = listOf("exercise-", "lecture-", "exam-")
var result = this
for (prefix in prefixes) {
if (result.startsWith(prefix, ignoreCase = true)) {
result = result.removePrefix(prefix)
break
}
}
return result.trim()
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ fun ConversationOverviewBody(
}

ConversationFabMenu(
canCreateChannel = canCreateChannel,
onCreateChat = onRequestCreatePersonalConversation,
onBrowseChannels = onRequestBrowseChannel,
onCreateChannel = onRequestAddChannel,
canCreateChannel = canCreateChannel
onCreateChannel = onRequestAddChannel
)
}

Expand All @@ -200,10 +200,10 @@ fun ConversationOverviewBody(

@Composable
fun ConversationFabMenu(
canCreateChannel: Boolean,
onCreateChat: () -> Unit,
onBrowseChannels: () -> Unit,
onCreateChannel: () -> Unit,
canCreateChannel: Boolean
onCreateChannel: () -> Unit
) {
var expanded by remember { mutableStateOf(false) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,16 @@ class ConversationOverviewViewModel(
isExpanded: Boolean,
showPrefix: Boolean = true
) = ConversationCollection(this, isExpanded, showPrefix)

fun removeSectionPrefix(value: String): String {
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
val prefixes = listOf("exercise-", "lecture-", "exam-")
var result = value
for (prefix in prefixes) {
if (result.startsWith(prefix, ignoreCase = true)) {
result = result.removePrefix(prefix)
break
}
}
return result.trim()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import de.tum.informatics.www1.artemis.native_app.feature.metis.conversation.con
import de.tum.informatics.www1.artemis.native_app.feature.metis.manageconversations.manageConversationsModule
import de.tum.informatics.www1.artemis.native_app.feature.metis.shared.sharedConversationModule
import de.tum.informatics.www1.artemis.native_app.feature.metis.ui.NavigateToUserConversationViewModel
import de.tum.informatics.www1.artemis.native_app.feature.metis.ui.SinglePageConversationBodyViewModel
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.module

Expand All @@ -22,4 +23,15 @@ val communicationModule = module {
get()
)
}

viewModel { params ->
SinglePageConversationBodyViewModel(
params[0],
get(),
get(),
get(),
get(),
get()
)
}
}
Loading
Loading