Skip to content

3주차 미션/2조 김대한#5

Open
about-kim wants to merge 5 commits intoKonkuk-KUIT:about-kimfrom
about-kim:about-kim/week3
Open

3주차 미션/2조 김대한#5
about-kim wants to merge 5 commits intoKonkuk-KUIT:about-kimfrom
about-kim:about-kim/week3

Conversation

@about-kim
Copy link
Copy Markdown

  1. 미션
  • Navigation 구현
    • ✅ 홈 - 뉴스 기사 상세 스크린 연결
    • ✅ Article 객체 HomeScreen → ContactDetailScreen 으로 이동할 때 전달되게 구현
  • 뉴스 기사 상세 화면
    • ✅ UI 구현
    • ✅ 뒤로가기 버튼 기능 구현
  1. 구현에 대한 설명

■ Route.kt: 상세화면 라우트 추가

  • Route sealed interface에 HOME_DETAIL이라는 data object 추가.
  • route 값은 "home_detail" 문자열로 설정해서 NavHost가 이 경로를 인식할 수 있게 만들었으며, 기존에 있던 CONTACT_DETAIL과 동일한 패턴으로 추가.

■ MainNavHost.kt: composable 블록 추가

  • NavHost 안에 Route.HOME_DETAIL.route에 해당하는 composable { } 블록 추가.
  • navController.previousBackStackEntry?.savedStateHandle?.get("article") 로 이전 화면에서 저장해둔 Article 객체를 꺼내기.
  • article?.let { } 으로 null 체크 후 HomeDetailScreen(article = it, navController = navController) 호출.
  • HomeDetailScreen 안에서 뒤로가기 버튼 클릭 시 navController.popBackStack() 으로 이전 화면으로 복귀.
  • 출발지인 HomeScreen에서 기사 클릭 시 currentBackStackEntry?.savedStateHandle?.set("article", article) 로 데이터를 저장
  • navController.navigate(Route.HOME_DETAIL.route) 로 이동하는 코드가 필요한데, 그 부분도 함께 구현 완료
  1. 스크린샷 & 실행영상
2026-04-03.170038.mp4

BearYeWon and others added 5 commits March 27, 2026 20:44
Updated the README to include detailed instructions on forking, cloning, and submitting pull requests for the KUIT 7th Android project.
Copy link
Copy Markdown

@AyoungSe0 AyoungSe0 left a comment

Choose a reason for hiding this comment

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

이번 주차는 간단한 미션이었던 만큼 전체적으로 구조도 깔끔하게 너무 잘 해주셨네요 ㅎㅎ
지금은 HomeDetail 화면과 ContactDetail 화면에서 어떤 하단 탭에도 속하지 않도록 처리되어 있는데, 추후에는 상세화면에서 하단 네비게이션바를 숨김 처리하는 방식도 적용해보시면 좋을 것 같아요~!

composable(Route.CONTACT_DETAIL.route){
val call = navController
.previousBackStackEntry
?.savedStateHandle
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

안전하게 call == null일 때의 처리도 해주면 좋을 것 같습니다(popBackStack() 등)

composable(Route.HOME_DETAIL.route) {
val article = navController
.previousBackStackEntry
?.savedStateHandle
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

안전하게 article == null일 때의 처리도 해주면 좋을 것 같습니다(popBackStack() 등)

article: Article,
navController: NavController,
) {
val imageRes = when (article.newspaper) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

HomeScreen에서 중복돼서 쓰인 코드라, 함수로 만들어서 써도 좋을 것 같습니다!


call?.let{
ContactDetailScreen(call = it,
navController = navController)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

상세 화면에 navController 전체를 넘기지 않고 onClick만 넘겨주셔도 좋을 것 같습니다~!

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.

3 participants