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

ReviewFragment & MenuDetailFragment 리팩터링 #52

Open
wants to merge 70 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3c920c7
ItemRatingStars(Compose) 추가 (드래그 불가)
wjshim2003 Nov 11, 2023
135a253
ItemRatingStars 수정
wjshim2003 Nov 18, 2023
090d2ec
ItemRatingStars 수정
wjshim2003 Nov 29, 2023
9bfdc18
ItemReview Composable 추가 (이미지 안 보임)
wjshim2003 Nov 29, 2023
0d80ba1
ComposeUtil 추가 (dpToSp)
wjshim2003 Nov 29, 2023
b8917a3
ItemReview 조금 수정
wjshim2003 Nov 29, 2023
cbd78ef
말풍선 테두리 추가
wjshim2003 Nov 29, 2023
2303050
formatting
wjshim2003 Nov 29, 2023
4812a23
coil 추가
wjshim2003 Nov 29, 2023
79f0ef0
ItemReviewImage Compose 추가
wjshim2003 Nov 29, 2023
783ca8d
ReviewSpeechBubble
wjshim2003 Dec 5, 2023
6386512
ItemRatingStars fix
wjshim2003 Dec 7, 2023
8929a22
ReviewSpeechBubble
wjshim2003 Dec 7, 2023
400909c
ItemReview
wjshim2003 Dec 7, 2023
8cc5be1
ReviewScreen 생성
wjshim2003 Dec 7, 2023
a124250
ItemReview 사진 추가
wjshim2003 Dec 7, 2023
9e87f41
ItemReview 사진 여백 수정
wjshim2003 Dec 9, 2023
be2d752
OrangeMain 값 수정
wjshim2003 Dec 9, 2023
809c582
ReviewScreen(레이아웃만)
wjshim2003 Dec 9, 2023
3aadca3
paging dependencies 추가
wjshim2003 Dec 9, 2023
dc760ff
ReviewFragment ComposeView로 연결 (viewmodel X)
wjshim2003 Dec 17, 2023
dd9807c
fix typo
wjshim2003 Dec 17, 2023
ff9d095
ItemRatingBars
wjshim2003 Dec 17, 2023
4831a4a
ReviewScreen(사진 없음)에 viewModel 연결
wjshim2003 Jan 13, 2024
4d5b1fe
옛날 리뷰를 못 받아오는 오류 발생
wjshim2003 Jan 13, 2024
38b5dea
resolve conflict
wjshim2003 Jan 13, 2024
a21ec70
일단 저장용
wjshim2003 Jan 14, 2024
0dca767
MenuDetailViewModel에 리뷰 목록 프로퍼티로 추가, 로딩 이슈 해결
wjshim2003 Jan 14, 2024
6b14b4e
args 추가가 안 됨
wjshim2003 Jan 16, 2024
187b949
내비게이션 오류 해결!!
wjshim2003 Jan 16, 2024
5291ae3
패키지 리팩터링
wjshim2003 Jan 16, 2024
9f1de0a
MenuDetailScreen(내용부분)
wjshim2003 Feb 11, 2024
328826c
ErrorComponent
wjshim2003 Feb 11, 2024
52727e2
ReviewScreen 수정
wjshim2003 Feb 11, 2024
02093af
LoadingComponent 추가
wjshim2003 Feb 12, 2024
0d08b1c
LoadingComponent(lottianimation)
wjshim2003 Feb 12, 2024
af24429
MenuDetailScreen 사진 미리보기
wjshim2003 Feb 12, 2024
61001ea
리뷰 남기기 버튼 클릭 시 토스트
wjshim2003 Feb 15, 2024
0769f10
폰트 적용
wjshim2003 Feb 15, 2024
9eb5e8b
리뷰 사진 dialog
wjshim2003 Feb 15, 2024
480dc36
formatting
wjshim2003 Feb 15, 2024
8a391ea
이름 수정 + 자잘한 수정
wjshim2003 Feb 27, 2024
e61f25b
MenuRatingStars 크기 계산 방식 수정
wjshim2003 Feb 28, 2024
672295f
MenuReview 파라미터 수정
wjshim2003 Feb 28, 2024
44d4599
NanumFontFamily 삭제
wjshim2003 Feb 28, 2024
fc319df
MenuReviewImageShowMore 분리
wjshim2003 Feb 28, 2024
c6743cb
string 리소스 적용
wjshim2003 Feb 28, 2024
05d8497
폰트 적용
wjshim2003 Mar 3, 2024
c83d812
폰트 적용
wjshim2003 Mar 3, 2024
749b7dd
Merge remote-tracking branch 'origin/wjshim2003/compose-migration' in…
wjshim2003 Mar 3, 2024
4cbe09d
reviews를 StateFlow로 수정
wjshim2003 Mar 3, 2024
93bdd5c
MenuDetailViewModel의 enum class들을 뺌
wjshim2003 Mar 3, 2024
972a7c5
formatting + 빌드 확인
wjshim2003 Mar 3, 2024
cd8e5cd
enum class들 별개 파일로 분리
eastshine2741 Mar 4, 2024
735416b
안쓰이는 StateFlow 삭제
eastshine2741 Mar 4, 2024
3c2c881
fix typo
wjshim2003 Mar 7, 2024
b4e11eb
MenuRatingStars 수정
wjshim2003 Mar 7, 2024
8533cc6
ReviewPhotoFragment 부활
wjshim2003 Mar 11, 2024
cfc1b22
MenuDetailScreen 코드 정리, fix typo
wjshim2003 Mar 7, 2024
f5cc7ac
MenuDetail Screen, Route 분리
eastshine2741 Jul 26, 2024
bd162b5
MenuPhotoPreview -> BriefImageReviews 네이밍 수정
eastshine2741 Jul 26, 2024
b57c323
MenuDetailScreenPreview 추가
eastshine2741 Jul 26, 2024
28826b4
develop -> wjshim2003/compose-migration 머지
eastshine2741 Jul 26, 2024
ddb9076
MenuDetailScreen TopBar 적용
eastshine2741 Jul 26, 2024
d8cdebd
dpToSp 사용
eastshine2741 Jul 26, 2024
503d2d9
Review Route Screen 분리
eastshine2741 Jul 26, 2024
170dfcf
ReviewScreen TopBar 적용
eastshine2741 Jul 26, 2024
4c8c216
Preview 추가
eastshine2741 Jul 26, 2024
8abbabe
layout xml 불필요 주석 제거
eastshine2741 Jul 26, 2024
b345da9
lint
eastshine2741 Jul 26, 2024
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
13 changes: 12 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id("com.google.firebase.crashlytics") version "2.9.5"
id("com.google.gms.google-services") version "4.3.15"
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
id("androidx.navigation.safeargs") version "2.5.3"
id("androidx.navigation.safeargs.kotlin") version "2.5.3"
id("com.google.firebase.appdistribution") version "4.0.0"
}

Expand Down Expand Up @@ -116,6 +116,8 @@ dependencies {
// Android arch lifecycle
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.7.0")

// Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
Expand Down Expand Up @@ -185,4 +187,13 @@ dependencies {
implementation("androidx.paging:paging-compose:${Deps.Version.PagingCompose}")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:${Deps.Version.ComposeViewModel}")
implementation("androidx.hilt:hilt-navigation-compose:${Deps.Version.ComposeHiltNavigation}")
implementation("com.airbnb.android:lottie-compose:6.3.0")

// Coil
implementation("io.coil-kt:coil:2.5.0")
implementation("io.coil-kt:coil-compose:2.5.0")

// Paging
implementation("androidx.paging:paging-runtime-ktx:3.2.1")
implementation("androidx.paging:paging-compose:3.2.1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.wafflestudio.siksha2.components.compose

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.wafflestudio.siksha2.R
import com.wafflestudio.siksha2.ui.SikshaColors
import com.wafflestudio.siksha2.utils.dpToSp

@Composable
fun ErrorPlaceHolder(
modifier: Modifier = Modifier
) {
Column(
modifier = modifier,
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Image(
painter = painterResource(R.drawable.ic_warning),
contentDescription = null,
colorFilter = ColorFilter.tint(SikshaColors.Gray800),
modifier = Modifier.size(34.dp)
)
Text(
text = "네트워크 연결이 불안정합니다.",
fontSize = dpToSp(20.dp),
fontWeight = FontWeight.Light,
modifier = Modifier.padding(top = 20.dp)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.wafflestudio.siksha2.components.compose

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.airbnb.lottie.compose.LottieAnimation
import com.airbnb.lottie.compose.LottieCompositionSpec
import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import com.wafflestudio.siksha2.R

@Composable
fun LoadingPlaceHolder(
modifier: Modifier = Modifier
) {
val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.ani_loading))
val progress by animateLottieCompositionAsState(composition)
Box(
modifier = modifier,
contentAlignment = Alignment.Center
) {
LottieAnimation(
composition = composition,
progress = { progress },
modifier = Modifier.size(70.dp)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.wafflestudio.siksha2.components.compose.menuDetail

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import com.wafflestudio.siksha2.R

@Composable
fun LikeButton(
isChecked: Boolean,
modifier: Modifier = Modifier,
onClick: () -> Unit = {}
) {
Image(
painter = painterResource(
if (isChecked) {
R.drawable.ic_full_heart_small
} else {
R.drawable.ic_empty_heart_small
}
),
contentDescription = "좋아요",
modifier = modifier.clickable { onClick() }
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.wafflestudio.siksha2.components.compose.menuDetail

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.wafflestudio.siksha2.R
import com.wafflestudio.siksha2.ui.SikshaColors
import com.wafflestudio.siksha2.utils.dpToSp
import kotlin.math.max

@Composable
fun MenuRatingBar(
ratingIndex: Int,
ratio: Float,
modifier: Modifier = Modifier
) {
Row(
modifier = modifier,
horizontalArrangement = Arrangement.Start,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = ratingIndex.toString(),
modifier = Modifier.padding(end = 3.dp),
fontSize = dpToSp(8.dp),
fontWeight = FontWeight.Bold,
color = SikshaColors.Gray500
)
Image(
painter = painterResource(R.drawable.ic_gray_star),
contentDescription = null,
modifier = Modifier
.padding(end = 9.dp)
.width(8.dp)
.height(8.dp)
)
if (ratio > 0.0f) {
Box(
modifier = Modifier
.weight(ratio)
.height(5.dp)
.background(
color = SikshaColors.OrangeMain,
shape = RoundedCornerShape(
topStart = CornerSize(0.dp),
topEnd = CornerSize(2.dp),
bottomEnd = CornerSize(2.dp),
bottomStart = CornerSize(0.dp)
)
)
) {}
}
if (ratio < 1.0f) {
Spacer(modifier = Modifier.weight(1.0f - ratio))
}
}
}

@Composable
fun MenuRatingBars(
distributions: List<Long>,
modifier: Modifier = Modifier
) {
val maxCount = max(distributions.max(), 1L)
Column(
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(5.dp)
) {
distributions.reversed().forEachIndexed { index, cnt ->
MenuRatingBar(
ratingIndex = 5 - index,
ratio = cnt.toFloat() / maxCount.toFloat()
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.wafflestudio.siksha2.components.compose.menuDetail

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wafflestudio.siksha2.R
import kotlin.math.roundToInt

@Composable
private fun MenuReviewSingleStar(
modifier: Modifier = Modifier,
flag: Int
) {
Image(
painter = painterResource(
when {
flag <= 0 -> R.drawable.ic_full_star
flag == 1 -> R.drawable.ic_half_star
else -> R.drawable.ic_empty_star
}
),
contentDescription = null,
modifier = modifier.heightIn(max = 48.dp).fillMaxHeight().aspectRatio(1f)
)
}

@Composable
fun MenuRatingStars(
rating: Float,
modifier: Modifier = Modifier.width(100.dp).height(18.dp),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사실 modifier 파라미터가 default argument 가지는 게 권장되지 않긴 해
https://stackoverflow.com/questions/73415055/why-was-i-warned-optional-modifier-parameter-should-have-a-default-value-of-mod
이 링크에 있는대로 size: Dp를 다른 파라미터로 받는 게 좋을듯?

dragEnabled: Boolean = false
) {
val rounds = (rating * 2).roundToInt()
Row(
modifier = modifier,
horizontalArrangement = Arrangement.SpaceBetween
) {
for (i in 1..5) {
MenuReviewSingleStar(
flag = i * 2 - rounds
)
}
}
}
Loading
Loading