-
Notifications
You must be signed in to change notification settings - Fork 0
[NDGL-10] Navigation3 연동 #4
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
base: develop
Are you sure you want to change the base?
Changes from all commits
da53d59
06fb393
046dc0a
f1f638e
7a16e54
0a773b9
c48c0a7
9c2047a
7da80b2
eba52f5
8dda22c
34bff97
15bc4bb
24b89fa
9203e89
04b023d
58ed989
68b4ecf
3d00f72
1a719e7
cce2823
dc6e712
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.yapp.ndgl.navigation | ||
|
|
||
| import androidx.annotation.DrawableRes | ||
| import androidx.navigation3.runtime.NavKey | ||
| import com.yapp.designsystem.R | ||
|
|
||
| enum class TopLevelRoute( | ||
| @get:DrawableRes val icon: Int, | ||
| val label: String, | ||
| val navKey: NavKey, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Route로 정의되어 있는 탭만 TopLevelRoute로 지정될 것 같아서 타입을 Route로 제한해도 괜찮을 것 같네요
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 반영했습니다~! |
||
| ) { | ||
| TRAVEL_HELPER( | ||
| icon = R.drawable.ic_nav_helper, | ||
| label = "여행 도구", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (nit) 저희 string resource 관리는 따로 안 하나요?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 앞으로는 string resource로 관리하면 좋을 것 같습니다. |
||
| navKey = Route.TravelHelper, | ||
| ), | ||
| HOME( | ||
| icon = R.drawable.ic_nav_home, | ||
| label = "홈", | ||
| navKey = Route.Home, | ||
| ), | ||
| TRAVEL( | ||
| icon = R.drawable.ic_nav_travel, | ||
| label = "여행", | ||
| navKey = Route.Travel, | ||
| ), | ||
| ; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.yapp.ndgl.ui | ||
|
|
||
| import androidx.compose.material3.Icon | ||
| import androidx.compose.material3.NavigationBar | ||
| import androidx.compose.material3.NavigationBarItem | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.navigation3.runtime.NavKey | ||
| import com.yapp.ndgl.navigation.Route | ||
| import com.yapp.ndgl.navigation.TopLevelRoute | ||
|
|
||
| @Composable | ||
| internal fun BottomNavigationBar( | ||
| currentTab : Route, | ||
| onTabSelected : (Route) -> Unit, | ||
| ) { | ||
| NavigationBar { | ||
| TopLevelRoute.entries.forEach { topLevelRoute -> | ||
| NavigationBarItem( | ||
| selected = currentTab == topLevelRoute.navKey, | ||
| onClick = { onTabSelected(topLevelRoute.navKey as Route) }, | ||
| icon = { | ||
| Icon( | ||
| painter = painterResource(id = topLevelRoute.icon), | ||
| contentDescription = topLevelRoute.label | ||
| ) | ||
|
Comment on lines
+24
to
+27
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (nit) 아이콘은 vector만 쓰니까
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 반영했습니다! |
||
| }, | ||
| label = { Text(text = topLevelRoute.label) } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| package com.yapp.ndgl.ui | ||
|
|
||
| import androidx.compose.animation.AnimatedVisibility | ||
| import androidx.compose.animation.slideInVertically | ||
| import androidx.compose.animation.slideOutVertically | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.derivedStateOf | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.navigation3.runtime.entryProvider | ||
| import androidx.navigation3.ui.NavDisplay | ||
| import com.yapp.helper.navigation.travelHelperEntry | ||
| import com.yapp.home.navigation.homeEntry | ||
| import com.yapp.ndgl.navigation.Navigator | ||
| import com.yapp.ndgl.navigation.Route | ||
| import com.yapp.ndgl.navigation.TopLevelRoute | ||
| import com.yapp.ndgl.navigation.rememberNavigationState | ||
| import com.yapp.ndgl.navigation.toEntries | ||
| import com.yapp.travel.navigation.travelEntry | ||
|
|
||
| @Composable | ||
| fun NDGLApp( | ||
| modifier: Modifier = Modifier, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 사용 안 하면 제거하는 게 어떨까요?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 반영했습니다! |
||
| ) { | ||
| val navigationState = rememberNavigationState( | ||
| startRoute = Route.Home, topLevelKeys = TopLevelRoute.entries.map { it.navKey }.toSet() | ||
| ) | ||
| val navigator = remember { Navigator(navigationState) } | ||
|
|
||
| val entryProvider = entryProvider { | ||
| homeEntry(navigator) | ||
| travelEntry(navigator) | ||
| travelHelperEntry(navigator) | ||
| } | ||
|
|
||
| val shouldShowBottomBar by remember { derivedStateOf { navigationState.currentKey in navigationState.topLevelKeys } } | ||
|
|
||
| Scaffold( | ||
| modifier = Modifier.fillMaxSize(), | ||
mj010504 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bottomBar = { | ||
| AnimatedVisibility( | ||
| visible = shouldShowBottomBar, | ||
| ) { | ||
| BottomNavigationBar( | ||
| currentTab = navigationState.currentTopLevelKey as Route, | ||
| onTabSelected = { key -> navigator.navigate(key) }) | ||
| } | ||
| }) { innerPadding -> | ||
| NavDisplay( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .padding(innerPadding), | ||
| onBack = navigator::goBack, | ||
| entries = navigationState.toEntries(entryProvider), | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| plugins { | ||
| id("ndgl.android.library") | ||
| } | ||
|
|
||
| android { | ||
| namespace = "com.yapp.designsystem" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <manifest> | ||
|
|
||
| </manifest> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="15dp" | ||
| android:height="19dp" | ||
| android:viewportWidth="15" | ||
| android:viewportHeight="19"> | ||
| <path | ||
| android:pathData="M4.083,9.166C3.669,9.166 3.333,9.502 3.333,9.916C3.333,10.33 3.669,10.666 4.083,10.666H10.75C11.164,10.666 11.5,10.33 11.5,9.916C11.5,9.502 11.164,9.166 10.75,9.166H4.083Z" | ||
| android:fillColor="#2C2C2C"/> | ||
| <path | ||
| android:pathData="M3.333,13.25C3.333,12.836 3.669,12.5 4.083,12.5H10.75C11.164,12.5 11.5,12.836 11.5,13.25C11.5,13.664 11.164,14 10.75,14H4.083C3.669,14 3.333,13.664 3.333,13.25Z" | ||
| android:fillColor="#2C2C2C"/> | ||
| <path | ||
| android:pathData="M4.083,5.833C3.669,5.833 3.333,6.169 3.333,6.583C3.333,6.997 3.669,7.333 4.083,7.333H5.75C6.164,7.333 6.5,6.997 6.5,6.583C6.5,6.169 6.164,5.833 5.75,5.833H4.083Z" | ||
| android:fillColor="#2C2C2C"/> | ||
| <path | ||
| android:pathData="M0.708,0.708C1.161,0.255 1.776,0 2.417,0H9.083C9.293,0 9.482,0.086 9.618,0.224L14.609,5.215C14.748,5.351 14.833,5.541 14.833,5.75L14.833,5.755L14.833,5.758V15.75C14.833,16.391 14.579,17.006 14.125,17.459C13.672,17.912 13.058,18.167 12.417,18.167H2.417C1.776,18.167 1.161,17.912 0.708,17.459C0.255,17.006 0,16.391 0,15.75V2.417C0,1.776 0.255,1.161 0.708,0.708ZM2.417,1.5H8.333V5.75C8.333,6.164 8.669,6.5 9.083,6.5H13.333V15.75C13.333,15.993 13.237,16.226 13.065,16.398C12.893,16.57 12.66,16.667 12.417,16.667H2.417C2.174,16.667 1.94,16.57 1.768,16.398C1.597,16.226 1.5,15.993 1.5,15.75V2.417C1.5,2.174 1.597,1.94 1.768,1.768C1.94,1.597 2.174,1.5 2.417,1.5ZM9.833,2.561L12.273,5H9.833V2.561Z" | ||
| android:fillColor="#2C2C2C" | ||
| android:fillType="evenOdd"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="17dp" | ||
| android:height="19dp" | ||
| android:viewportWidth="17" | ||
| android:viewportHeight="19"> | ||
| <path | ||
| android:pathData="M8.71,0.158C8.44,-0.053 8.06,-0.053 7.79,0.158L0.29,5.991C0.107,6.133 0,6.352 0,6.583V15.75C0,16.391 0.255,17.006 0.708,17.459C1.161,17.912 1.776,18.167 2.417,18.167H14.083C14.724,18.167 15.339,17.912 15.792,17.459C16.245,17.006 16.5,16.391 16.5,15.75V6.583C16.5,6.352 16.393,6.133 16.211,5.991L8.71,0.158ZM1.5,15.75V6.95L8.25,1.7L15,6.95V15.75C15,15.993 14.903,16.226 14.731,16.398C14.56,16.57 14.326,16.667 14.083,16.667H11.5V9.083C11.5,8.669 11.164,8.333 10.75,8.333H5.75C5.336,8.333 5,8.669 5,9.083V16.667H2.417C2.174,16.667 1.94,16.57 1.768,16.398C1.597,16.226 1.5,15.993 1.5,15.75ZM6.5,16.667H10V9.833H6.5V16.667Z" | ||
| android:fillColor="#2C2C2C" | ||
| android:fillType="evenOdd"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="19dp" | ||
| android:height="17dp" | ||
| android:viewportWidth="19" | ||
| android:viewportHeight="17"> | ||
| <path | ||
| android:pathData="M7.417,0C6.776,0 6.161,0.255 5.708,0.708C5.255,1.161 5,1.776 5,2.417V3.333H2.417C1.082,3.333 0,4.415 0,5.75V14.083C0,15.418 1.082,16.5 2.417,16.5H5.728C5.735,16.5 5.743,16.5 5.75,16.5C5.757,16.5 5.765,16.5 5.772,16.5H12.394C12.402,16.5 12.409,16.5 12.417,16.5C12.424,16.5 12.432,16.5 12.439,16.5H15.75C17.085,16.5 18.167,15.418 18.167,14.083V5.75C18.167,4.415 17.085,3.333 15.75,3.333H13.167V2.417C13.167,1.776 12.912,1.161 12.459,0.708C12.006,0.255 11.391,0 10.75,0H7.417ZM11.667,3.333V2.417C11.667,2.174 11.57,1.94 11.398,1.768C11.226,1.597 10.993,1.5 10.75,1.5H7.417C7.174,1.5 6.94,1.597 6.768,1.768C6.597,1.94 6.5,2.174 6.5,2.417V3.333H11.667ZM6.5,4.833H11.667V15H6.5V4.833ZM5,4.833H2.417C1.91,4.833 1.5,5.243 1.5,5.75V14.083C1.5,14.589 1.91,15 2.417,15H5V4.833ZM13.167,15V4.833H15.75C16.256,4.833 16.667,5.243 16.667,5.75V14.083C16.667,14.589 16.256,15 15.75,15H13.167Z" | ||
| android:fillColor="#2C2C2C" | ||
| android:fillType="evenOdd"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ plugins { | |
| } | ||
|
|
||
| android { | ||
| namespace = "com.yapp.ndgl.core.ui" | ||
| namespace = "com.yapp.ui" | ||
| } | ||
|
|
||
| dependencies { | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package com.yapp.util | ||
|
|
||
| class Extensions { | ||
| } | ||
mj010504 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.yapp.auth | ||
mj010504 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.lazy.LazyColumn | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel | ||
| import com.yapp.auth.AuthViewModel | ||
|
|
||
| @Composable | ||
| fun AuthRoute( | ||
| viewModel: AuthViewModel = hiltViewModel(), | ||
| ) { | ||
|
|
||
| AuthScreen() | ||
| } | ||
|
|
||
| @Composable | ||
| internal fun AuthScreen( | ||
| ) { | ||
| LazyColumn( | ||
| modifier = Modifier.fillMaxSize(), | ||
| verticalArrangement = Arrangement.Center, | ||
| horizontalAlignment = Alignment.CenterHorizontally | ||
| ) { | ||
| item { | ||
| Text(text = "Auth Screen") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| fun AuthScreenPreview() { | ||
| AuthScreen() | ||
| } | ||
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.
(nit) 기획/디자인 쪽에서 공통적으로 메인 탭 이런 느낌의 용어로 많이 사용하는 것 같은데
비슷한 용어로 맞추면 어떨까요? TopLevelRoute가 개발적으로는 잘못된 용어는 아니라고 생각하는데
모두가 비슷한 용어를 사용하면 조금 더 직관적이지 않을까 싶어서요
추가로 현재 네이밍으로 보면 AuthScreen의 경우에도 어떻게 보면 정말 TopLevel의 Route가 아닌가? 하는 생각이 들 수도 있을 것 같습니다!
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.
BottomNavTab 정도가 생각나는데 어떠신가요?? 바꾼다면 navigationState에 toplevelStack도 같이 변경해야할 것 같네요. 좋은 네이밍있으시면 알려주세요~!