-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature/#46] 화면 연결 네비게이션 구현 #47
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2fa03a0
FEAT: 홈, 추천 루틴, 마이페이지 바텀 네이게이션 초안 구현
l5x5l c04f349
FEAT: 홈 화면 관련 네비게이션 구현, 온보딩/로그인 화면에서 홈 화면으로 이동시 이전 화면들 제거하도록 수정
l5x5l db9cf2a
FEAT: 추천 루틴 화면 관련 네비게이션 구현
l5x5l 68604ec
FEAT: 설정 화면 관련 네비게이션 구현
l5x5l a27868a
FIX: 홈 바텀 네비게이션 로직 수정 및 뒤로가기 2번 연속 클릭시 앱 종료되도록 구현
l5x5l 28cca43
FEATURE: 설정 화면에서 로그아웃/회원탈퇴 성공시 로그인 화면 이동 로직 추가 및 로그아웃/회원탈퇴 API 연동
l5x5l 457fa4b
CHORE: ktlint 적용
l5x5l 58aa6f3
FIX: 로그아웃/회원탈퇴 실패시 로딩 상태를 false로 수정, 로그아웃/회원탈퇴 성공시 내부 토큰 데이터를 초기화하도록 수정
l5x5l 8cd3932
CHORE: runCatching 사용 일관성 통일
l5x5l d0a1c2b
FIX: 로그아웃/회원탈퇴시 로그인 화면이 아닌, 인트로 화면으로 이동하도록 수정
l5x5l f12ae26
FIX: BottomNavigation내 각 속성값(이름, 아이콘, 이동 경로)를 enum class로 수정
l5x5l File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
app/src/main/java/com/threegap/bitnagil/navigation/home/HomeBottomNavigationBar.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| package com.threegap.bitnagil.navigation.home | ||
|
|
||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.clickable | ||
| import androidx.compose.foundation.interaction.MutableInteractionSource | ||
| import androidx.compose.foundation.interaction.collectIsPressedAsState | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Row | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.ColorFilter | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.dp | ||
| import androidx.navigation.NavController | ||
| import androidx.navigation.compose.currentBackStackEntryAsState | ||
| import com.threegap.bitnagil.designsystem.BitnagilTheme | ||
|
|
||
| @Composable | ||
| fun HomeBottomNavigationBar( | ||
| navController: NavController, | ||
| ) { | ||
| val navBackStackEntry by navController.currentBackStackEntryAsState() | ||
|
|
||
| Row( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .background(color = BitnagilTheme.colors.white) | ||
| .padding(horizontal = 16.dp, vertical = 7.dp), | ||
| horizontalArrangement = Arrangement.spacedBy(12.dp), | ||
| ) { | ||
| HomeRoute.entries.map { homeRoute -> | ||
| HomeBottomNavigationItem( | ||
| modifier = Modifier.weight(1f), | ||
| selectIconResourceId = homeRoute.selectIconResourceId, | ||
| unSelectIconResourceId = homeRoute.unSelectIconResourceId, | ||
| title = homeRoute.title, | ||
| onClick = { | ||
| navController.navigate(homeRoute.route) { | ||
| popUpTo(0) { inclusive = true } | ||
| } | ||
| }, | ||
| selected = navBackStackEntry?.destination?.route == homeRoute.route, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun HomeBottomNavigationItem( | ||
| modifier: Modifier = Modifier, | ||
| selectIconResourceId: Int, | ||
| unSelectIconResourceId: Int, | ||
| title: String, | ||
| onClick: () -> Unit, | ||
| selected: Boolean, | ||
| ) { | ||
| val interactionSource = remember { MutableInteractionSource() } | ||
| val isPressed by interactionSource.collectIsPressedAsState() | ||
|
|
||
| val contentTintColor = when { | ||
| isPressed -> BitnagilTheme.colors.navy300 | ||
| selected -> BitnagilTheme.colors.navy500 | ||
| else -> BitnagilTheme.colors.navy100 | ||
| } | ||
| val iconResourceId = if (selected) selectIconResourceId else unSelectIconResourceId | ||
|
|
||
| Column( | ||
| modifier = modifier.clickable( | ||
| onClick = onClick, | ||
| interactionSource = interactionSource, | ||
| indication = null, | ||
| ), | ||
| horizontalAlignment = Alignment.CenterHorizontally, | ||
| ) { | ||
| Image( | ||
| painter = painterResource(id = iconResourceId), | ||
| contentDescription = title, | ||
| modifier = Modifier.padding(4.dp).size(24.dp), | ||
| colorFilter = ColorFilter.tint(color = contentTintColor), | ||
| ) | ||
|
|
||
| Text( | ||
| text = title, | ||
| style = BitnagilTheme.typography.caption2Medium, | ||
| color = contentTintColor, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| @Preview | ||
| private fun HomeBottomNavigationBarPreview() { | ||
| val navigator = rememberHomeNavigator() | ||
|
|
||
| HomeBottomNavigationBar( | ||
| navController = navigator.navController, | ||
|
|
||
| ) | ||
| } |
90 changes: 90 additions & 0 deletions
90
app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavHost.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package com.threegap.bitnagil.navigation.home | ||
|
|
||
| import android.annotation.SuppressLint | ||
| import android.app.Activity | ||
| import androidx.activity.compose.BackHandler | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.material3.Scaffold | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableLongStateOf | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.LocalContext | ||
| import androidx.navigation.compose.NavHost | ||
| import androidx.navigation.compose.composable | ||
| import com.threegap.bitnagil.presentation.home.HomeScreenContainer | ||
| import com.threegap.bitnagil.presentation.mypage.MyPageScreenContainer | ||
| import com.threegap.bitnagil.presentation.recommendroutine.RecommendRoutineScreenContainer | ||
|
|
||
| @Composable | ||
| @SuppressLint("UnusedMaterial3ScaffoldPaddingParameter") | ||
| fun HomeNavHost( | ||
| modifier: Modifier = Modifier, | ||
| navigateToSetting: () -> Unit, | ||
| navigateToOnBoarding: () -> Unit, | ||
| navigateToNotice: () -> Unit, | ||
| navigateToQnA: () -> Unit, | ||
| navigateToRegisterRoutine: (String?) -> Unit, | ||
| navigateToEditRoutine: (String) -> Unit, | ||
| navigateToEmotion: () -> Unit, | ||
| ) { | ||
| val navigator = rememberHomeNavigator() | ||
|
|
||
| DoubleBackButtonPressedHandler() | ||
|
wjdrjs00 marked this conversation as resolved.
|
||
|
|
||
| Scaffold( | ||
| modifier = Modifier.fillMaxSize(), | ||
| bottomBar = { | ||
| HomeBottomNavigationBar(navController = navigator.navController) | ||
| }, | ||
| content = { _ -> | ||
| NavHost( | ||
| navController = navigator.navController, | ||
| startDestination = navigator.startDestination, | ||
| modifier = modifier, | ||
| ) { | ||
| composable(HomeRoute.Home.route) { | ||
| HomeScreenContainer( | ||
| navigateToRegisterRoutine = { | ||
| navigateToRegisterRoutine(null) | ||
| }, | ||
| navigateToEditRoutine = navigateToEditRoutine, | ||
| navigateToEmotion = navigateToEmotion, | ||
| ) | ||
| } | ||
|
|
||
| composable(HomeRoute.RecommendRoutine.route) { | ||
| RecommendRoutineScreenContainer( | ||
| navigateToEmotion = navigateToEmotion, | ||
| navigateToRegisterRoutine = navigateToRegisterRoutine, | ||
| ) | ||
| } | ||
|
|
||
| composable(HomeRoute.MyPage.route) { | ||
| MyPageScreenContainer( | ||
| navigateToSetting = navigateToSetting, | ||
| navigateToOnBoarding = navigateToOnBoarding, | ||
| navigateToNotice = navigateToNotice, | ||
| navigateToQnA = navigateToQnA, | ||
| ) | ||
| } | ||
| } | ||
| }, | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| fun DoubleBackButtonPressedHandler() { | ||
| val context = LocalContext.current | ||
| var backPressedTimeMillis by remember { mutableLongStateOf(0L) } | ||
| BackHandler { | ||
| if (System.currentTimeMillis() - backPressedTimeMillis < 2000) { | ||
| backPressedTimeMillis = 0 | ||
| (context as? Activity)?.finish() | ||
| } else { | ||
| backPressedTimeMillis = System.currentTimeMillis() | ||
| } | ||
| } | ||
| } | ||
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/threegap/bitnagil/navigation/home/HomeNavigator.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.threegap.bitnagil.navigation.home | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.remember | ||
| import androidx.navigation.NavHostController | ||
| import androidx.navigation.compose.rememberNavController | ||
|
|
||
| class HomeNavigator( | ||
| val navController: NavHostController, | ||
| ) { | ||
| val startDestination = HomeRoute.Home.route | ||
| } | ||
|
|
||
| @Composable | ||
| fun rememberHomeNavigator(navController: NavHostController = rememberNavController()): HomeNavigator = | ||
| remember(navController) { | ||
| HomeNavigator(navController) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.