Skip to content

Commit

Permalink
show marks on ScheduleScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
x3lfyn committed Jan 14, 2024
1 parent 97fab98 commit f64189b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ fun ScheduleDto.toDomain(): com.vobbla16.mesh.domain.model.schedule.ScheduleMode
Mark(
mark.id,
mark.value,
mark.weight
mark.weight,
mark.isPoint
)
},
homework = act.lesson.homework,
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/java/com/vobbla16/mesh/domain/model/schedule/Mark.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package com.vobbla16.mesh.domain.model.schedule

import com.vobbla16.mesh.ui.screens.marksScreen.components.MarkDefaultValue

data class Mark(
val id: Long,
val value: String,
val weight: Int
)
val weight: Int,
val isPoint: Boolean
) {
fun toMarkDefaultValue() = MarkDefaultValue(
value.toInt(),
weight, isPoint
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.vobbla16.mesh.domain.model.marks.GradeType
import com.vobbla16.mesh.domain.model.marks.Mark
import com.vobbla16.mesh.domain.model.marks.MarkValue
import kotlinx.datetime.LocalDate

@Composable
fun MarkDefault(mark: MarkDefaultValue, modifier: Modifier = Modifier) {
fun MarkDefault(
mark: MarkDefaultValue,
modifier: Modifier = Modifier,
size: MarkDefaultSize = MarkDefaultSize.Default
) {
OutlinedCard(modifier) {
Box(Modifier.size(48.dp)) {
Box(Modifier.size(size.size)) {
Text(
text = mark.value.toString(),
modifier = Modifier.align(
Expand Down Expand Up @@ -53,6 +58,11 @@ fun MarkDefault(mark: MarkDefaultValue, modifier: Modifier = Modifier) {
}
}

enum class MarkDefaultSize(val size: Dp) {
Default(48.dp),
Small(38.dp)
}

data class MarkDefaultValue(
val value: Int,
val weight: Int,
Expand All @@ -70,13 +80,13 @@ fun MarkDefaultPreview1() {
controlFormName = "Самостоятельная работа",
date = LocalDate(2022, 12, 28),
gradeType = GradeType.Five,
isPoint = false,
isPoint = true,
pointDate = null,
topic = "Что-то там",
value = MarkValue(4f, 80f),
weight = 2
)
MarkDefault(mark = mark.toMarkDefaultValue())
MarkDefault(mark = mark.toMarkDefaultValue(), size = MarkDefaultSize.Small)
}

@Preview(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.vobbla16.mesh.ui.screens.scheduleScreen.components
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -22,9 +24,13 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.vobbla16.mesh.domain.model.schedule.Activity
import com.vobbla16.mesh.domain.model.schedule.LessonType
import com.vobbla16.mesh.ui.screens.marksScreen.components.MarkDefault
import com.vobbla16.mesh.ui.screens.marksScreen.components.MarkDefaultSize
import kotlinx.datetime.LocalTime

@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class,
ExperimentalLayoutApi::class
)
@Composable
fun ScheduleLessonItem(activity: Activity.Lesson, onClick: () -> Unit) {
Card(
Expand Down Expand Up @@ -94,6 +100,13 @@ fun ScheduleLessonItem(activity: Activity.Lesson, onClick: () -> Unit) {
else -> {}
}

FlowRow(
modifier = Modifier.fillMaxWidth().padding(2.dp, 6.dp, 2.dp, 2.dp)
) {
activity.marks.forEach { mark ->
MarkDefault(mark = mark.toMarkDefaultValue(), size = MarkDefaultSize.Small)
}
}
}
}
}
Expand Down

0 comments on commit f64189b

Please sign in to comment.