-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FEAT/#99] 장소 상세 페이지 더미 데이터 구현 #100
Conversation
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.
고생하셨습니다!
확인 부탁드려요~
@@ -52,7 +52,8 @@ fun MainScreen( | |||
) | |||
|
|||
placeDetailNavGraph( | |||
paddingValues = innerPadding | |||
paddingValues = innerPadding, | |||
navController = navigator.navController |
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.
p1) navController를 매개변수로 넘겨주면 좋지 않습니다!
이유를 생각해보시고, 헷갈린다면 편하게 말씀주세요 :)
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.
navController 을 파라미터로 넘기지 않고 아래와 같은 방식으로 전달하게 되면 이동 로직이 한곳에 유지되므로 코드를 쉽게 유지관리할 수 있고 실수로 개별 화면에 앱의 특정 Route 를 자유롭게 허용하지 않음으로써 버그를 방지할 수 있다는 장점이 있습니다.
navController.navigateTo('home')
참고 :
https://developer.android.com/codelabs/basic-android-kotlin-compose-navigation?hl=ko#4
참고해서 수정하겠습니다!
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.
수정했습니다!
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.
순환호출!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
LaunchedEffect(key1 = true) { | ||
viewModel.getPost(postId) | ||
} |
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.
p1) viewModel에서의 init을 통해 구현한 방법과 LaunchedEffect를 활용한 방법 중 어떤 방법이 더 적합할까요?
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.
LaunchedEffect 사용이 적합한 경우
- 네트워크 호출이 화면이나 컴포저블 상태에 강하게 의존하는 경우.
- postId와 같은 동적 파라미터가 자주 변경될 수 있는 경우.
- 특정 컴포저블에서만 호출이 필요할 때.
ViewModel의 init 사용이 적합한 경우
- 고정된 초기 데이터를 항상 불러와야 하는 경우.
- 네트워크 호출이 컴포저블과 독립적으로 실행되어야 하는 경우.
- 여러 컴포저블이 동일한 데이터를 공유해야 할 때.
저희의 상황에서는
동적인 파라미터를 처리하거나 컴포저블 상태와 데이터 로딩을 밀접하게 동기화할 필요는 없다고 생각하고,
ViewModel의 초기화 과정에서 데이터를 준비하고 컴포저블과 독립적으로 관리하는 것이 더 좋아보이기 때문에
ViewModel 에 init 으로 관리하는것이 더 좋아보입니다..!
onBackButtonClick = {}, | ||
onReportButtonClick = {} | ||
onBackButtonClick = navigateToMap, | ||
onReportButtonClick = { navigateToReport() } |
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.
onReportButtonClick = { navigateToReport() } | |
onReportButtonClick = navigateToReport |
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.
수정하겠습니다!
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.
수정했습니다!
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.
했다매!!!!!!!!!!!!!
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.
p1) onBackButton은 navigatUp으로 구현하면 좋을 것 같아요~
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.
진짜 수정함..!
var _state: MutableStateFlow<PlaceDetailState> = MutableStateFlow(PlaceDetailState()) | ||
val state: StateFlow<PlaceDetailState> | ||
get() = _state | ||
|
||
fun useSpoon() { | ||
fun getPost(postId: Int) { |
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.
p3) 지금은 괜찮지만, 추후 서버통신이 실패했을 경우를 대비해 onFailure도 작성해주세요~!
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.
수정했습니다!
navOptions: NavOptions? = null, | ||
postId: Int, | ||
userId: Int |
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.
p1) 필수가 위로가고, 옵셔널이 밑으로 가게 순서 변경부탁드립니다!
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.
수정했습니다!
…ail-dummy # Conflicts: # app/src/main/java/com/spoony/spoony/presentation/placeDetail/PlaceDetailRoute.kt
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.
한번만 더 확인 부탁드려요!
@@ -53,7 +54,7 @@ fun MainScreen( | |||
|
|||
placeDetailNavGraph( | |||
paddingValues = innerPadding, | |||
navController = navigator.navController | |||
navigateToReport = { navigator.navController.navigateToReport() } |
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.
p2) 다른 화면 이동의 예시 파일처럼 MainNavigation 내부에서 함수를 만들어서 구현해주세용~
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.
수정했습니다!
onBackButtonClick = {}, | ||
onReportButtonClick = {} | ||
onBackButtonClick = navigateToMap, | ||
onReportButtonClick = { navigateToReport() } |
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.
했다매!!!!!!!!!!!!!
onBackButtonClick = {}, | ||
onReportButtonClick = {} | ||
onBackButtonClick = navigateToMap, | ||
onReportButtonClick = { navigateToReport() } |
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.
p1) onBackButton은 navigatUp으로 구현하면 좋을 것 같아요~
) : ViewModel() { | ||
var _state: MutableStateFlow<PlaceDetailState> = MutableStateFlow(PlaceDetailState()) | ||
val state: StateFlow<PlaceDetailState> | ||
get() = _state | ||
|
||
private val postId: Int = savedStateHandle.get<Int>("postId") ?: -1 |
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.
p1) 이 변수는 state가 아니라 따로 관리하는 이유가 있나요?
p2) 저희는 직렬화를 사용하고 있기 때문에 String으로 key를 하는게 아니라 클래스 접근의 방식으로도 가능합니다. safety하게 해주세요!
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.
수,,수정했습니다!
navigateToReport = { navigator.navController.navigateToReport() }, | ||
navigateToUp = { navigator.navController.navigateUp() } |
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.
navigateToReport = { navigator.navController.navigateToReport() }, | |
navigateToUp = { navigator.navController.navigateUp() } | |
navigateToReport = navigator.navController::navigateToReport, | |
navigateToUp = navigator.navController::navigateUp |
P2: 짜잔!!
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.
p2) MainNavigator class내부에 navigate 함수를 만드는건 어떨까요?
p3) navigateUp의 경우 navigateToUp이라는 네이밍은 어색한 것 같아요.
fun navigateToReport(navOptions: NavOptions = null) {
navController.navigateToReport(navOptions)
}
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.
수정했습니다! 감사해요!
class PlaceDetailViewModel @Inject constructor( | ||
private val postRepository: PostRepository, | ||
savedStateHandle: SavedStateHandle | ||
) : ViewModel() { | ||
var _state: MutableStateFlow<PlaceDetailState> = MutableStateFlow(PlaceDetailState()) |
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.
P1: 이거 private 안붙이면 state가 외부에서 수정가능해집니다!!
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.
수정했습니다!
val currentPostEntity = (_state.value.postEntity as? UiState.Success)?.data | ||
if (currentPostEntity != null) { |
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.
P3: null 체크를 하시는 이유가 궁금합니다!
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.
최대한 짧게 수정했습니다.
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.
고생하셨습니다! 마지막으로 한번만 부탁드려요 ㅜㅜ
navigateToReport = { navigator.navController.navigateToReport() }, | ||
navigateToUp = { navigator.navController.navigateUp() } |
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.
p2) MainNavigator class내부에 navigate 함수를 만드는건 어떨까요?
p3) navigateUp의 경우 navigateToUp이라는 네이밍은 어색한 것 같아요.
fun navigateToReport(navOptions: NavOptions = null) {
navController.navigateToReport(navOptions)
}
onMenuItemClick = onReportButtonClick | ||
onMenuItemClick = { menu -> | ||
when (menu) { | ||
"신고하기" -> { |
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.
p2) 추후 늘어날 수 있기에 미리 enum으로 만들어둬도 좋을 것 같아요 :)
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.
수정했습니다!
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.
고생했습니다!
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.
어푸푸~~!!🚀🚀
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.
수고하셨습니다~
Related issue 🛠
Work Description ✏️
Screenshot 📸
placeDetailComplete.mp4
To Reviewers 📢