-
Notifications
You must be signed in to change notification settings - Fork 2
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
wjshim2003
wants to merge
70
commits into
develop
Choose a base branch
from
wjshim2003/compose-migration
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 48 commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
3c920c7
ItemRatingStars(Compose) 추가 (드래그 불가)
wjshim2003 135a253
ItemRatingStars 수정
wjshim2003 090d2ec
ItemRatingStars 수정
wjshim2003 9bfdc18
ItemReview Composable 추가 (이미지 안 보임)
wjshim2003 0d80ba1
ComposeUtil 추가 (dpToSp)
wjshim2003 b8917a3
ItemReview 조금 수정
wjshim2003 cbd78ef
말풍선 테두리 추가
wjshim2003 2303050
formatting
wjshim2003 4812a23
coil 추가
wjshim2003 79f0ef0
ItemReviewImage Compose 추가
wjshim2003 783ca8d
ReviewSpeechBubble
wjshim2003 6386512
ItemRatingStars fix
wjshim2003 8929a22
ReviewSpeechBubble
wjshim2003 400909c
ItemReview
wjshim2003 8cc5be1
ReviewScreen 생성
wjshim2003 a124250
ItemReview 사진 추가
wjshim2003 9e87f41
ItemReview 사진 여백 수정
wjshim2003 be2d752
OrangeMain 값 수정
wjshim2003 809c582
ReviewScreen(레이아웃만)
wjshim2003 3aadca3
paging dependencies 추가
wjshim2003 dc760ff
ReviewFragment ComposeView로 연결 (viewmodel X)
wjshim2003 dd9807c
fix typo
wjshim2003 ff9d095
ItemRatingBars
wjshim2003 4831a4a
ReviewScreen(사진 없음)에 viewModel 연결
wjshim2003 4d5b1fe
옛날 리뷰를 못 받아오는 오류 발생
wjshim2003 38b5dea
resolve conflict
wjshim2003 a21ec70
일단 저장용
wjshim2003 0dca767
MenuDetailViewModel에 리뷰 목록 프로퍼티로 추가, 로딩 이슈 해결
wjshim2003 6b14b4e
args 추가가 안 됨
wjshim2003 187b949
내비게이션 오류 해결!!
wjshim2003 5291ae3
패키지 리팩터링
wjshim2003 9f1de0a
MenuDetailScreen(내용부분)
wjshim2003 328826c
ErrorComponent
wjshim2003 52727e2
ReviewScreen 수정
wjshim2003 02093af
LoadingComponent 추가
wjshim2003 0d08b1c
LoadingComponent(lottianimation)
wjshim2003 af24429
MenuDetailScreen 사진 미리보기
wjshim2003 61001ea
리뷰 남기기 버튼 클릭 시 토스트
wjshim2003 0769f10
폰트 적용
wjshim2003 9eb5e8b
리뷰 사진 dialog
wjshim2003 480dc36
formatting
wjshim2003 8a391ea
이름 수정 + 자잘한 수정
wjshim2003 e61f25b
MenuRatingStars 크기 계산 방식 수정
wjshim2003 672295f
MenuReview 파라미터 수정
wjshim2003 44d4599
NanumFontFamily 삭제
wjshim2003 fc319df
MenuReviewImageShowMore 분리
wjshim2003 c6743cb
string 리소스 적용
wjshim2003 05d8497
폰트 적용
wjshim2003 c83d812
폰트 적용
wjshim2003 749b7dd
Merge remote-tracking branch 'origin/wjshim2003/compose-migration' in…
wjshim2003 4cbe09d
reviews를 StateFlow로 수정
wjshim2003 93bdd5c
MenuDetailViewModel의 enum class들을 뺌
wjshim2003 972a7c5
formatting + 빌드 확인
wjshim2003 cd8e5cd
enum class들 별개 파일로 분리
eastshine2741 735416b
안쓰이는 StateFlow 삭제
eastshine2741 3c2c881
fix typo
wjshim2003 b4e11eb
MenuRatingStars 수정
wjshim2003 8533cc6
ReviewPhotoFragment 부활
wjshim2003 cfc1b22
MenuDetailScreen 코드 정리, fix typo
wjshim2003 f5cc7ac
MenuDetail Screen, Route 분리
eastshine2741 bd162b5
MenuPhotoPreview -> BriefImageReviews 네이밍 수정
eastshine2741 b57c323
MenuDetailScreenPreview 추가
eastshine2741 28826b4
develop -> wjshim2003/compose-migration 머지
eastshine2741 ddb9076
MenuDetailScreen TopBar 적용
eastshine2741 d8cdebd
dpToSp 사용
eastshine2741 503d2d9
Review Route Screen 분리
eastshine2741 170dfcf
ReviewScreen TopBar 적용
eastshine2741 4c8c216
Preview 추가
eastshine2741 8abbabe
layout xml 불필요 주석 제거
eastshine2741 b345da9
lint
eastshine2741 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/wafflestudio/siksha2/components/compose/ErrorPlaceHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/wafflestudio/siksha2/components/compose/LoadingPlaceHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/wafflestudio/siksha2/components/compose/menuDetail/LikeButton.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() } | ||
) | ||
} |
92 changes: 92 additions & 0 deletions
92
app/src/main/java/com/wafflestudio/siksha2/components/compose/menuDetail/MenuRatingBars.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
) | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/wafflestudio/siksha2/components/compose/menuDetail/MenuRatingStars.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
dragEnabled: Boolean = false | ||
) { | ||
val rounds = (rating * 2).roundToInt() | ||
Row( | ||
modifier = modifier, | ||
horizontalArrangement = Arrangement.SpaceBetween | ||
) { | ||
for (i in 1..5) { | ||
MenuReviewSingleStar( | ||
flag = i * 2 - rounds | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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를 다른 파라미터로 받는 게 좋을듯?