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

[PC-185] Bottom Navigation Bar UI 구현 #16

Merged
merged 8 commits into from
Dec 30, 2024
Merged

Conversation

tgyuuAn
Copy link
Member

@tgyuuAn tgyuuAn commented Dec 30, 2024

PC-185

1. ⭐️ 변경된 내용

  • Bottom Navigation Bar UI 구현

2. 🖼️ 스크린샷(선택)

2024-12-30.6.03.08.mov

3. 💡 알게된 부분

  • Compose Navigation Bar 클릭 시 생기는 Ripple Effect 제거하는 방법

image

위 그림과 같은 Ripple Effect를 제거하는 방법 입니다.

아래와 같은 RippleInteractionSource를 구현해줍니다.

해당 InteractionSource는 어떠한 것도 구현하지 않아서 RippleEffect를 사용하지 않음을 뜻합니다.

class NoRippleInteractionSource : MutableInteractionSource {
    override suspend fun emit(interaction: Interaction) {}
    override val interactions: Flow<Interaction> = emptyFlow()
    override fun tryEmit(interaction: Interaction): Boolean = true
}




NavigationBarItem(

                // { ... }

                interactionSource = remember { NoRippleInteractionSource() },     // <---- 요기다가 쏙 넣어줌!

                // { ... }

                },
            )

그리고 위와 같이 쏙 넣어주면 완성입니당!

레퍼런스




그리고 이거와 관련해서 공식문서에 설명이 있는데,

image

공식문서에서 소개하는 코드로는 네비게이션 아이템의 물결 효과를 제거할 수 없습니다.

네비게이션 컴포넌트 내부적으로 Ripple Effect를 다시 CompositionLocal에 넣어주는 것 같더라고요.




  • BottomNavigation에 가운데 우뚝한 버튼(?) 이 있는 UI 만들기

결론만 말하자면 바텀 네비게이션 + Scaffold 에서 제공하는 Floating Action Button 을 이용해서 만들었습니다.

다만, Material3 를 사용하게 되면 FAB가 Navigation Bar 상단에 위치하게 되는데,

image




열심히 스택 오버 플로우를 뒤진 결과 해당 Offset이 Navigation Bar보다 16.dp 상단에 위치함을 알게되었습니다.

image

레퍼런스

위 정보를 이용해서 저희 중앙 버튼 사이즈가 80px인 점을 이용하여 기존 FAB가 그려지기 시작하는 y좌표가 0이라고 하였을 때,

저희가 최종적으로 시작지점으로 선정해야 하는 y 좌표는 (80+4) 가 되어야 하기 때문에 84를 Offset으로 할당하였습니다.

        floatingActionButton = {
            if (currentDestination?.shouldHideBottomNavigation() == false) {
                FloatingActionButton(
                    onClick = { navigateToTopLevelDestination(MatchingGraph) },
                    containerColor = PieceTheme.colors.white,
                    shape = CircleShape,
                    elevation = bottomAppBarFabElevation(),
                    modifier = Modifier.offset(y = 84.dp),
                ) {
                    Image(
                        painter = painterResource(R.drawable.ic_matching),
                        contentDescription = null,
                        modifier = Modifier.size(80.dp),
                    )
                }
            }
        },
        floatingActionButtonPosition = FabPosition.Center,

@tgyuuAn tgyuuAn added UI/UX 🎨 디자인 시스템, 디자인 리소스 관련 코드 🎨 기능 ⚒️ 새로운 기능 구현 ⚒️ 리뷰 원해요🔥 피어의 리뷰를 기다리는 ing.. 🔥 새롭게 알게 됨 📖 프로젝트를 진행하며 새롭게 알게된 부분 📖 ㅌㄱ태규 ☀️ 훗날 크게될 ENFP 남성, tgyuuAn labels Dec 30, 2024
@tgyuuAn tgyuuAn requested a review from sksowk156 December 30, 2024 09:21
@tgyuuAn tgyuuAn self-assigned this Dec 30, 2024
@tgyuuAn tgyuuAn removed the 기능 ⚒️ 새로운 기능 구현 ⚒️ label Dec 30, 2024
Copy link
Contributor

@sksowk156 sksowk156 left a comment

Choose a reason for hiding this comment

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

아주 훌륭합니다! 고생하셨어요 👍

unselectedTextColor = PieceTheme.colors.dark3,
indicatorColor = Color.Transparent,
),
interactionSource = remember { NoRippleInteractionSource() },
Copy link
Contributor

Choose a reason for hiding this comment

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

캬아... 멋지십니다 👍 👍

this?.hierarchy?.any { destination ->
destination.route in HIDDEN_BOTTOM_NAV_ROUTES
} ?: false
this?.hierarchy?.any { destination -> destination.route in HIDDEN_BOTTOM_NAV_ROUTES } ?: false
Copy link
Contributor

Choose a reason for hiding this comment

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

p4 :
이것도 아래에 변경해주신 것처럼

this?.hierarchy?.any { it.route in HIDDEN_BOTTOM_NAV_ROUTES } == true

으로 변경하면 좋을 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 조아용!

Comment on lines +9 to +14
@Immutable
class NoRippleInteractionSource : MutableInteractionSource {
override suspend fun emit(interaction: Interaction) {}
override val interactions: Flow<Interaction> = emptyFlow()
override fun tryEmit(interaction: Interaction): Boolean = true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

이쪽에 두셨군요! 저도 matching ui에서 썼던 CollapsingHeaderNestedScrollConnection 클래스를 어디 둘까 고민하고 있는데 ui에 두면 좋을까요?! 🤔 태규님 의견이 궁금합니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

이쪽에 두셨군요! 저도 matching ui에서 썼던 CollapsingHeaderNestedScrollConnection 클래스를 어디 둘까 고민하고 있는데 ui에 두면 좋을까요?! 🤔 태규님 의견이 궁금합니다!

아하, 생각해보니 별 생각 없이 뒀는데 최소 3군데 이상 다른 모듈에서 쓰이면 common-ui 모듈로 올리는 것이 좋을 것 같아요.

NoRippleInteractionSource 도 일단은 app모듈에서만 사용하니까 app모듈로 돌려두겠습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

아하 죠습니다!!

@sksowk156 sksowk156 added 머지 해도될듯염🌟 현재 코드를 기존 코드에 합쳐도 될 것 같다라고 판단..! 🌟 and removed 리뷰 원해요🔥 피어의 리뷰를 기다리는 ing.. 🔥 labels Dec 30, 2024
@tgyuuAn tgyuuAn merged commit 7c4ec79 into develop Dec 30, 2024
1 check passed
@tgyuuAn tgyuuAn deleted the feature/tgyuu/PC-185 branch December 30, 2024 15:02
sksowk156 added a commit that referenced this pull request Dec 30, 2024
B
Revert "Merge pull request #16 from YAPP-Github/feature/tgyuu/PC-185"

This reverts commit 7c4ec79, reversing
changes made to fef6e67.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UI/UX 🎨 디자인 시스템, 디자인 리소스 관련 코드 🎨 ㅌㄱ태규 ☀️ 훗날 크게될 ENFP 남성, tgyuuAn 머지 해도될듯염🌟 현재 코드를 기존 코드에 합쳐도 될 것 같다라고 판단..! 🌟 새롭게 알게 됨 📖 프로젝트를 진행하며 새롭게 알게된 부분 📖
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants