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

UI adjustments to align with iOS; exercise and lecture list item redesign #43

Merged
merged 7 commits into from
Oct 23, 2024
Merged
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 @@ -5,6 +5,7 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.material3.windowsizeclass.WindowSizeClass
Expand Down Expand Up @@ -130,6 +131,7 @@ class MainActivity : AppCompatActivity(),
}

setContent {
enableEdgeToEdge()
AppTheme {
ProvideLocalVisibleMetisContextManager(
visibleMetisContextManager = visibleMetisContextManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,6 @@ private fun collectExerciseCategoryChips(
)
) else emptyList()

val difficulty = exercise.difficulty
val difficultyChips = if (difficulty != null) {
val data = when (difficulty) {
Exercise.Difficulty.EASY ->
ExerciseCategoryChipData(
context.getString(de.tum.informatics.www1.artemis.native_app.core.ui.R.string.exercise_difficulty_easy),
Color(0xff28a745)
)

Exercise.Difficulty.MEDIUM ->
ExerciseCategoryChipData(
context.getString(de.tum.informatics.www1.artemis.native_app.core.ui.R.string.exercise_difficulty_medium),
Color(0xffffc107)
)

Exercise.Difficulty.HARD ->
ExerciseCategoryChipData(
context.getString(de.tum.informatics.www1.artemis.native_app.core.ui.R.string.exercise_difficulty_hard),
Color(0xffdc3545)
)
}
listOf(data)
} else emptyList()

val bonusChips =
if (exercise.includedInOverallScore == Exercise.IncludedInOverallScore.INCLUDED_AS_BONUS) {
listOf(
Expand All @@ -155,5 +131,5 @@ private fun collectExerciseCategoryChips(
)
}

return liveQuizChips + categoryChips + difficultyChips + bonusChips
return liveQuizChips + categoryChips + bonusChips
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.exercise

import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
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.material3.Card
import androidx.compose.material3.Icon
Expand All @@ -18,6 +23,9 @@ import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.Exercise
Expand All @@ -41,32 +49,55 @@ fun ExerciseListItem(
modifier = modifier,
onClick = onClickExercise
) {
Column(
Row(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
.height(IntrinsicSize.Min)
) {
Row(modifier = Modifier.fillMaxWidth()) {
ExerciseTypeIcon(modifier = Modifier.size(80.dp), exercise = exercise)
if (exercise.difficulty != null) {
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
DifficultyRectangle(exercise.difficulty!!)
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
}

Column(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
ExerciseTypeIcon(
modifier = Modifier.size(40.dp)
.padding(horizontal = 8.dp),
exercise = exercise
)

//Displays the title of the exercise
Text(
text = exercise.title.orEmpty(),
style = MaterialTheme.typography.titleMedium
)
}

ExerciseDataText(
modifier = Modifier
.weight(1f)
.padding(horizontal = 16.dp),
.padding(horizontal = 8.dp),
exercise = exercise,
displayActionButtons = displayActionButtons,
exerciseActions = exerciseActions
)
}

//Display a row of chips
ExerciseCategoryChipRow(
modifier = Modifier
.fillMaxWidth()
.horizontalScroll(rememberScrollState()),
exercise = exercise
)
//Display a row of chips
ExerciseCategoryChipRow(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 8.dp)
.horizontalScroll(rememberScrollState()),
exercise = exercise
)
}
}
}
}
Expand All @@ -79,16 +110,40 @@ private fun ExerciseTypeIcon(modifier: Modifier, exercise: Exercise) {
Box(modifier = modifier) {
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
Icon(
modifier = Modifier
.fillMaxSize()
.padding(8.dp),
.fillMaxSize(),
painter = getExerciseTypeIconPainter(exercise),
contentDescription = null
)
}
}

/**
* Displays the exercise title, the due data and the participation info. The participation info is automatically updated.
* Displays a rectangle next to the text to show the difficulty of the exercise.
*/
@Composable
private fun DifficultyRectangle(difficulty: Exercise.Difficulty) {
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
Box(modifier = Modifier
.fillMaxHeight()
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
.height(40.dp)
.width(10.dp)
.clip(RectangleShape)
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
.background(
color = when (difficulty) {
Exercise.Difficulty.EASY ->
Color(0xff28a745)
julian-wls marked this conversation as resolved.
Show resolved Hide resolved

Exercise.Difficulty.MEDIUM ->
Color(0xffffc107)

Exercise.Difficulty.HARD ->
Color(0xffdc3545)
}
)
)
}

/**
* Displays the exercise due data and the participation info. The participation info is automatically updated.
*/
@Composable
private fun ExerciseDataText(
Expand All @@ -107,11 +162,6 @@ private fun ExerciseDataText(
} else stringResource(id = R.string.exercise_item_due_date_not_set)

Column(modifier = modifier) {
Text(
text = exercise.title.orEmpty(),
style = MaterialTheme.typography.titleMedium
)

Text(
text = formattedDueDate,
style = MaterialTheme.typography.bodyMedium
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 @@ -3,7 +3,7 @@
<resources>

<string name="exercise_item_due_date_set">Due date: %1$s</string>
<string name="exercise_item_due_date_not_set">No date associated</string>
<string name="exercise_item_due_date_not_set">No due date</string>

<!-- Difficulty -->
<string name="exercise_difficulty_easy">Easy</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package de.tum.informatics.www1.artemis.native_app.feature.courseview.ui
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Card
import androidx.compose.material3.ListItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand Down Expand Up @@ -45,7 +47,9 @@ internal fun LectureListUi(
getItemId = { id ?: 0L }
) { lecture ->
LectureListItem(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
lecture = lecture,
onClick = { onClickLecture(lecture) }
)
Expand All @@ -63,9 +67,26 @@ private fun LectureListItem(modifier: Modifier, lecture: Lecture, onClick: () ->
)
} else stringResource(id = R.string.course_ui_lecture_item_start_date_not_set)

ListItem(
modifier = modifier.clickable(onClick = onClick),
headlineContent = { Text(text = lecture.title) },
supportingContent = { Text(text = startTimeText) }
)
Card(
modifier = modifier,
onClick = onClick
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
// TODO: add teacher image next to title
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
Text(
text = lecture.title,
style = MaterialTheme.typography.titleMedium
)

Text(
text = startTimeText,
style = MaterialTheme.typography.bodyMedium
)
}
}
}
Loading