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

[둘리] 뷰 챌린지 미션 1단계 제출합니다. #14

Merged
merged 24 commits into from
Oct 1, 2023

Conversation

hyemdooly
Copy link

@hyemdooly hyemdooly commented Sep 29, 2023

안녕하세요, 부나~! 레벨1 페어 이후로 처음인 것 같네요.
다른 크루들과 다를 수 있는 점이 있다면 버튼을 눌러야만 색상, 두께 변경 UI가 보인다는 것입니다.
저는 색상을 누를 때, 두께를 변경할 때 바로 바뀐 paint가 적용되었으면 해서 이 두 버튼을 어떻게 할까 하다가 show/hide용으로 두었어요.

CanvasView는 lines라는 MutableList를 가지고 있습니다. Line은 path와 Paint를 가지고 있어요.
여러 line을 가지고 있다가 onDraw 시점에 모두 그려버리도록 했습니다.
어려운 코드는 아마 없을 것 같아요.

다만 고민인 부분이 몇가지 있는데요!

  1. CustomColor에서 getAllColors라는 함수가 조금 어색하게 느껴집니다. 하지만, ViewModel에 입력하지 않고 Repository에서 가져오듯이 어딘가에 저장되었으면 하는데... 어떻게 하는게 깔끔할까요?
  2. Activity의 getSpace() 함수에서 margin을 계산하고자 5, 4 상수를 쓰고 있는데요.ㅋㅋㅋ 저는 예제처럼 첫 아이템과 마지막 아이템이 뷰의 양 옆 끝에 닿았으면 합니다. 만약에 색깔이 추가된다면 첫 번째 아이템과 다섯 번째 아이템이 뷰의 양 옆에 끝에 닿았으면 좋겠어요. 이에 대해 조언을 주실 수 있으신가요?

리뷰 하실 때 위 두 가지 질문에 대한 답변도 함께 부탁드립니다.
리뷰 잘 부탁드려요!!!!👍

@hyemdooly hyemdooly self-assigned this Sep 29, 2023
@tmdgh1592
Copy link

tmdgh1592 commented Sep 30, 2023

CustomColor에서 getAllColors라는 함수가 조금 어색하게 느껴집니다. 하지만, ViewModel에 입력하지 않고 Repository에서 가져오듯이 어딘가에 저장되었으면 하는데... 어떻게 하는게 깔끔할까요?

개인적으로 색상을 CRUD 할 것이 아니라면, 이미 enum 상수로 정해져 있는 색상 목록을 Repository에서 가져오는 것은 불필요하다고 느껴집니다.
enum으로 정해져 있지 않다고 하더라도, 지금 상황에서 굳이 Repository를 거쳐서 색상을 가져올 이유도 없구요 😃

현재 색상을 ViewModel에서 관리하고 있지만 꼭 그럴 필요도 없을 것 같습니다!
단순히 화면에 색상 목록을 보여주는 것이기 때문에 리사이클러뷰 Adapter에 바로 색상 목록을 전달해줘도 되기 때문이죠.

그럼 선택된 색상을 어떻게 관리하냐 라는 의문이 생기실 수도 있는데,
이는 fun pickColor(...) 메서드에서 ColorUiModel 대신에 특정 식별자 만을 전달받고 ViewModel 내에서 선택된 색상만 관리하도록 만들 수 있습니다.

결론적으로 getAllColors() 메서드로 색상 목록을 가져오는 것이 어색하지 않다는 것입니다.

@tmdgh1592
Copy link

Activity의 getSpace() 함수에서 margin을 계산하고자 5, 4 상수를 쓰고 있는데요.ㅋㅋㅋ 저는 예제처럼 첫 아이템과 마지막 아이템이 뷰의 양 옆 끝에 닿았으면 합니다. 만약에 색깔이 추가된다면 첫 번째 아이템과 다섯 번째 아이템이 뷰의 양 옆에 끝에 닿았으면 좋겠어요. 이에 대해 조언을 주실 수 있으신가요?

색상을 추가해봤는데도 아래처럼 뷰가 양 옆 끝에 잘 닿고 있습니다..!
혹시 질문해주신 의도와 제가 이해한 바가 다른가요??

스크린샷 2023-09-30 오후 11 15 54

Copy link

@tmdgh1592 tmdgh1592 left a comment

Choose a reason for hiding this comment

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

안녕하세요 둘리!
레벨1 페어가 엊그제같은데 정말 시간이 빠르네요 🥲
몇 가지 코멘트를 남겨놓았으니 확인 부탁드려요 : )

app/build.gradle.kts Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/ChangingState.kt Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/MainActivity.kt Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/MainViewModel.kt Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/canvas/CanvasView.kt Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/canvas/CanvasView.kt Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/canvas/CanvasView.kt Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/canvas/CustomColor.kt Outdated Show resolved Hide resolved
app/src/main/java/woowacourse/paint/canvas/CustomColor.kt Outdated Show resolved Hide resolved
Copy link

@tmdgh1592 tmdgh1592 left a comment

Choose a reason for hiding this comment

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

리뷰 반영하느라 고생하셨습니다 둘리!
크게 변경될 코드가 없다고 느껴져서 바로 Approve하겠습니다.
작은 코멘트를 남겨놓았으니 확인해주세요 🙂

colors.firstOrNull { it.isPicked }?.color ?: PaletteColor.RED
}

private val _width = MutableLiveData(0f)

Choose a reason for hiding this comment

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

Activity의 minWidth와 ViewModel의 width에 불일치가 있을 수 있습니다.
ex) Activity의 minWidth는 10으로 바꾸고 ViewModel은 깜빡하고 그대로 유지하는 경우

Comment on lines 24 to 26
val selectedColor: LiveData<PaletteColor>
get() = Transformations.map(_colors) { colors ->
colors.firstOrNull { it.isPicked }?.color ?: PaletteColor.RED

Choose a reason for hiding this comment

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

지금 코드도 선택 색상을 유지하기에 충분히 좋다고 생각합니다 👍

Comment on lines 16 to 17
private val _colors =
MutableLiveData(

Choose a reason for hiding this comment

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

한 칸 띄신 이유가 있으신가요?

Copy link
Author

Choose a reason for hiding this comment

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

없습니다! 수정과정에 띄어진 것 같네용

@tmdgh1592 tmdgh1592 merged commit a7edc74 into woowacourse:hyemdooly Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants