Skip to content

Commit

Permalink
Merge pull request #112 from uswLectureEvaluation/feature/#103-lectur…
Browse files Browse the repository at this point in the history
…e-evaluation-detail

Feature/#103 lecture evaluation detail
  • Loading branch information
jinukeu authored Jan 23, 2024
2 parents 985511b + 20d2f2e commit d783de9
Show file tree
Hide file tree
Showing 38 changed files with 773 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import com.suwiki.core.ui.extension.suwikiClickable
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SuwikiBottomSheet(
sheetState: SheetState = rememberModalBottomSheetState(),
sheetState: SheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true,
),
isSheetOpen: Boolean,
onDismissRequest: () -> Unit = {},
content: @Composable ColumnScope.() -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import com.suwiki.core.designsystem.component.badge.SuwikiBadge
import com.suwiki.core.designsystem.shadow.cardShadow
import com.suwiki.core.designsystem.theme.Black
import com.suwiki.core.designsystem.theme.Gray6A
import com.suwiki.core.designsystem.theme.Gray95
import com.suwiki.core.designsystem.theme.GrayDA
import com.suwiki.core.designsystem.theme.Primary
import com.suwiki.core.designsystem.theme.SuwikiTheme
Expand All @@ -48,7 +47,6 @@ fun SuwikiClassReviewCard(
openMajor: String,
professor: String,
rating: Float,
reviewCount: Int? = null,
classType: String,
onClick: () -> Unit,
) {
Expand Down Expand Up @@ -102,6 +100,7 @@ fun SuwikiClassReviewCard(
Spacer(modifier = Modifier.height(3.dp))
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(2.dp),
modifier = Modifier.wrapContentWidth(),
) {
Image(
Expand All @@ -113,13 +112,6 @@ fun SuwikiClassReviewCard(
style = SuwikiTheme.typography.body1,
color = Primary,
)
if (reviewCount != null) {
Text(
text = "($reviewCount)",
style = SuwikiTheme.typography.body3,
color = Gray95,
)
}
}
}

Expand All @@ -141,7 +133,6 @@ fun CardPreview() {
openMajor = "개설학과",
professor = "교수명",
rating = 4.0f,
reviewCount = 3,
classType = "강의 유형",
onClick = {},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,23 @@ import com.suwiki.core.designsystem.R
import com.suwiki.core.designsystem.component.ratingbar.SuwikiRatingBar
import com.suwiki.core.designsystem.shadow.cardShadow
import com.suwiki.core.designsystem.theme.Black
import com.suwiki.core.designsystem.theme.Gray95
import com.suwiki.core.designsystem.theme.GrayDA
import com.suwiki.core.designsystem.theme.GrayF6
import com.suwiki.core.designsystem.theme.Primary
import com.suwiki.core.designsystem.theme.SuwikiTheme
import com.suwiki.core.designsystem.theme.White
import java.util.Locale

@Composable
fun SuwikiReviewGradeCard(
modifier: Modifier = Modifier,
reviewCount: Int,
rating: Float,
honeyRating: Float,
learningRating: Float,
satisfactionRating: Float,
) {
val reviewCountColor = if (reviewCount > 0) Primary else GrayDA
val reviewIndicatorColor = if (reviewCount > 0) Black else GrayDA
val reviewCountColor = if (rating > 0) Primary else GrayDA
val reviewIndicatorColor = if (rating > 0) Black else GrayDA
Row(
modifier = modifier
.fillMaxWidth()
Expand All @@ -59,20 +58,13 @@ fun SuwikiReviewGradeCard(
horizontalAlignment = Alignment.CenterHorizontally,
) {
Text(
text = "$rating",
text = "%.1f".format(Locale.US, rating),
style = SuwikiTheme.typography.header1,
color = reviewCountColor,
)
SuwikiRatingBar(
rating = rating,
)
if (reviewCount > 0) {
Text(
text = stringResource(id = R.string.review_count, reviewCount),
style = SuwikiTheme.typography.caption7,
color = Gray95,
)
}
}
VerticalDivider(
color = GrayF6,
Expand Down Expand Up @@ -131,7 +123,7 @@ fun SuwikiProgressLine(
strokeCap = StrokeCap.Round,
)
Text(
text = "$rating",
text = "%.1f".format(Locale.US, rating),
style = SuwikiTheme.typography.caption1,
color = textColor,
)
Expand All @@ -147,7 +139,6 @@ fun SuwikiReviewGradeCardPreview() {
) {
SuwikiReviewGradeCard(
modifier = Modifier,
reviewCount = 4,
rating = 4.3f,
honeyRating = 3.4f,
learningRating = 3.4f,
Expand All @@ -156,7 +147,6 @@ fun SuwikiReviewGradeCardPreview() {
Spacer(modifier = Modifier.height(20.dp))
SuwikiReviewGradeCard(
modifier = Modifier,
reviewCount = 0,
rating = 0.0f,
honeyRating = 0.0f,
learningRating = 0.0f,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ fun SuwikiExamReviewContainer(
modifier: Modifier = Modifier,
difficulty: String,
examType: String,
text: String,
isAuthor: Boolean,
content: String,
isAuthor: Boolean = false,
onClickButton: () -> Unit,
) {
val buttonText = if (isAuthor) stringResource(id = R.string.word_edit) else stringResource(id = R.string.word_report)
Expand Down Expand Up @@ -66,7 +66,7 @@ fun SuwikiExamReviewContainer(
Spacer(modifier = Modifier.height(10.dp))
Row(
modifier = modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(2.dp),
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
Text(
text = stringResource(id = R.string.word_difficulcy),
Expand All @@ -82,7 +82,7 @@ fun SuwikiExamReviewContainer(
Spacer(modifier = Modifier.height(2.dp))
Row(
modifier = modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(2.dp),
horizontalArrangement = Arrangement.spacedBy(6.dp),
) {
Text(
text = stringResource(id = R.string.word_type_exam),
Expand All @@ -97,7 +97,7 @@ fun SuwikiExamReviewContainer(
}
Spacer(modifier = Modifier.height(10.dp))
Text(
text = text,
text = content,
style = SuwikiTheme.typography.body7,
color = Black,
)
Expand All @@ -113,14 +113,14 @@ fun SuwikiExamReviewContainerPreview() {
isAuthor = false,
difficulty = "어려움",
examType = "응용,실습,과제,PPT",
text = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
content = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
onClickButton = {},
)
SuwikiExamReviewContainer(
isAuthor = true,
difficulty = "어려움",
examType = "응용,실습,과제,PPT",
text = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
content = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
onClickButton = {},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import com.suwiki.core.designsystem.theme.White
@Composable
fun SuwikiUserReviewContainer(
modifier: Modifier = Modifier,
text: String,
isAuthor: Boolean,
content: String,
semester: String,
rating: Float,
isAuthor: Boolean = false,
onClickButton: () -> Unit = {},
) {
val buttonText = if (isAuthor) stringResource(id = R.string.word_edit) else stringResource(id = R.string.word_report)
Expand All @@ -49,14 +51,14 @@ fun SuwikiUserReviewContainer(
}
SuwikiBadge(
color = BadgeColor.Gray,
text = stringResource(id = R.string.word_semester),
text = semester,
)
Spacer(modifier = Modifier.weight(1f))
SuwikiContainedSmallButton(text = buttonText, onClick = onClickButton)
}
SuwikiRatingBar(rating = 3.0f)
SuwikiRatingBar(rating = rating)
Text(
text = text,
text = content,
style = SuwikiTheme.typography.body7,
color = Black,
)
Expand All @@ -70,11 +72,15 @@ fun ReviewContainerPreview() {
Column {
SuwikiUserReviewContainer(
isAuthor = false,
text = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
semester = "2023-1",
rating = 3.0f,
content = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
)
SuwikiUserReviewContainer(
rating = 3.0f,
semester = "2023-1",
isAuthor = true,
text = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
content = "거의 한 학기 팀플하시는데... 팀원 잘 만나면 잘 모르겠네요. 굉장히 오픈 마인드시긴해요.",
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ fun SuwikiTabBar(
tabItem: @Composable () -> Unit,
) {
Surface(
modifier = Modifier,
color = White,
) {
SubcomposeLayout(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,48 @@ enum class GradeLevel(val value: Int) {
EASY(2),
NORMAL(1),
DIFFICULT(0),
;

companion object {
fun valueOf(value: Int): GradeLevel = when (value) {
0 -> DIFFICULT
1 -> NORMAL
2 -> EASY
else -> throw IllegalArgumentException("존재하지 않는 GradeLevel 입니다.")
}
}
}

@Stable
enum class HomeworkLevel(val value: Int) {
NONE(0),
NORMAL(1),
MANY(2),
;

companion object {
fun valueOf(value: Int): HomeworkLevel = when (value) {
0 -> NONE
1 -> NORMAL
2 -> MANY
else -> throw IllegalArgumentException("존재하지 않는 HomeworkLevel 입니다.")
}
}
}

@Stable
enum class TeamLevel(val value: Int) {
NOT_EXIST(0),
EXIST(1),
;

companion object {
fun valueOf(value: Int): TeamLevel = when (value) {
0 -> NOT_EXIST
1 -> EXIST
else -> throw IllegalArgumentException("존재하지 않는 TeamLevel 입니다.")
}
}
}

// TODO api v2 리팩토링 필요
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.suwiki.core.model.enums

enum class LectureEvaluationTab(
val position: Int,
val title: String,
) {
LECTURE_EVALUATION(
position = 0,
title = "강의평가",
),
EXAM_INFO(
position = 1,
title = "시험정보",
),
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.suwiki.core.model.lectureevaluation.exam

import androidx.compose.runtime.Stable

@Stable
data class ExamEvaluationList(
val data: List<ExamEvaluation>,
val needBuyExam: Boolean,
val written: Boolean,
)

@Stable
data class ExamEvaluation(
val id: Long,
val selectedSemester: String,
val examInfo: String,
val examType: String?,
val examType: String,
val examDifficulty: String,
val content: String,
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.suwiki.core.model.lectureevaluation.lecture

import androidx.compose.runtime.Stable
import com.suwiki.core.model.enums.GradeLevel
import com.suwiki.core.model.enums.HomeworkLevel
import com.suwiki.core.model.enums.TeamLevel

@Stable
data class LectureEvaluationExtraAverage(
val id: Long,
val lectureInfo: LectureInfo,
val lectureTotalAvg: Float,
val lectureSatisfactionAvg: Float,
val lectureHoneyAvg: Float,
val lectureLearningAvg: Float,
val lectureTeamAvg: Float,
val lectureDifficultyAvg: Float,
val lectureHomeworkAvg: Float,
val id: Long = 0,
val info: LectureInfo = LectureInfo(),
val totalAvg: Float = 0f,
val satisfactionAvg: Float = 0f,
val honeyAvg: Float = 0f,
val learningAvg: Float = 0f,
val teamAvg: TeamLevel = TeamLevel.EXIST,
val gradeAvg: GradeLevel = GradeLevel.DIFFICULT,
val homeworkAvg: HomeworkLevel = HomeworkLevel.MANY,
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.suwiki.core.model.lectureevaluation.lecture

import androidx.compose.runtime.Stable

@Stable
data class LectureEvaluationList(
val data: List<LectureEvaluation>,
val written: Boolean,
)

@Stable
data class LectureEvaluation(
val id: Long,
val selectedSemester: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ data class LectureInfo(
val semesterList: List<String> = listOf(""),
val professor: String = "",
val majorType: String = "",
val lectureType: String? = null,
val lectureType: String = "",
val lectureName: String = "",
) : java.io.Serializable
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import kotlinx.coroutines.flow.collectLatest
fun LazyListState.OnBottomReached(
// tells how many items before we reach the bottom of the list
// to call onLoadMore function
buffer: Int = 3,
buffer: Int = 0,
onLoadMore: () -> Unit,
) {
// Buffer must be positive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ class GetLectureEvaluationListUseCase @Inject constructor(
data class Param(
val lectureId: Long,
val page: Int,
val majorType: String,
)
}
Loading

0 comments on commit d783de9

Please sign in to comment.