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

[TNT-176] 트레이너, 트레이니 메인 네비게이션 기초 세팅 #64

Merged
merged 23 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fd10026
[TNT-176] remove: 불필요한 코드 제거
hoyahozz Feb 2, 2025
7dd11b1
[TNT-176] refactor: 회원가입 네비게이션 로직 개선
hoyahozz Feb 2, 2025
ffb5898
[TNT-176] chore: feature:trainer:home 모듈 최초 생성
hoyahozz Feb 2, 2025
d133796
[TNT-176] chore: feature:trainee:home 모듈 최초 생성
hoyahozz Feb 2, 2025
ce19dc9
[TNT-176] chore: feature:trainer:main 모듈 최초 생성
hoyahozz Feb 2, 2025
d065755
[TNT-176] feat: 트레이너 메인 Navigation 기초 구현
hoyahozz Feb 3, 2025
18e2b5e
[TNT-176] chore: feature:trainer:feedback 모듈 최초 생성
hoyahozz Feb 3, 2025
a015414
[TNT-176] chore: feature:trainer:members 모듈 최초 생성
hoyahozz Feb 3, 2025
75c5a86
[TNT-176] chore: feature:trainer:mypage 모듈 최초 생성
hoyahozz Feb 3, 2025
8804a14
[TNT-176] feat: 트레이너 임시 MainTab 구현
hoyahozz Feb 3, 2025
85cf8a2
[TNT-176] chore: feature:trainee:main 모듈 최초 생성
hoyahozz Feb 3, 2025
b4168e0
[TNT-176] feat: 트레이니 메인 Navigation 기초 구현
hoyahozz Feb 4, 2025
f9fb1ef
[TNT-176] refactor: Signup NavGraph 제거
hoyahozz Feb 4, 2025
e00f461
[TNT-176] remove: feature:home 모듈 제거
hoyahozz Feb 4, 2025
96a6d92
[TNT-176] fix: MainScreen 내 scaffold inner padding 제거
hoyahozz Feb 4, 2025
55b2e66
[TNT-176] fix: apply detekt
hoyahozz Feb 4, 2025
153b238
[TNT-176] fix: MainScreen 내부에서 NavController 를 생성하도록 수정
hoyahozz Feb 4, 2025
6abbc60
[TNT-176] fix: clearBackStack 로직 수정
hoyahozz Feb 4, 2025
2714349
[TNT-176] Merge branch 'develop' into feature/TNT-176
hoyahozz Feb 4, 2025
fc1e747
[TNT-176] refactor: 알람 화면 Navigation 로직 이관 처리
hoyahozz Feb 4, 2025
6d47a33
[TNT-176] refactor: UserType enum 생성 및 User 클래스 분리
hoyahozz Feb 5, 2025
c0fc779
[TNT-176] feat: 자동 로그인 후 직군에 따라 이동 화면 지정 처리
hoyahozz Feb 5, 2025
5389e6f
[TNT-176] feat: 로그인 후 직군에 따라 이동 화면 지정 처리
hoyahozz Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions core/navigation/src/main/java/co/kr/tnt/navigation/RouteModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,49 @@ sealed interface Route {
@Serializable
data class TraineeConnect(val isSkippable: Boolean) : Route

@Serializable
data object TrainerMain : Route

sealed interface TrainerMainTab : Route {
@Serializable
data object Home : TrainerMainTab

@Serializable
data object Members : TrainerMainTab

@Serializable
data object Feedback : TrainerMainTab

@Serializable
data object MyPage : TrainerMainTab
}

@Serializable
data object TrainerHome : Route

@Serializable
data object TrainerMembers : Route

@Serializable
data object TrainerFeedback : Route

@Serializable
data object TrainerMyPage : Route

@Serializable
data object TraineeMain : Route

sealed interface TraineeMainTab : Route {
@Serializable
data object Home : TraineeMainTab

@Serializable
data object MyPage : TraineeMainTab
}

@Serializable
data object TraineeHome : Route

@Serializable
data object TraineeMyPage : Route

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal class SessionInterceptor @Inject constructor(
val requestBuilder = originRequest.newBuilder()

requestBuilder.addHeader(
"AUTHORIZATION",
"Authorization",
"SESSION-ID ${runBlocking { sessionProvider.getSessionId() }}",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SignUpRepositoryImpl @Inject constructor(
email = email,
fcmToken = "EMPTY",
)
val requestBody = signUpRequest.toRequestBody(Json)
val requestBody = signUpRequest.toRequestBody()

val response = signupRemoteDataSource.postSignUp(
profileImage = profileImagePart,
Expand All @@ -54,7 +54,7 @@ class SignUpRepositoryImpl @Inject constructor(
return response.toDomain()
}

private fun SignUpRequest.toRequestBody(json: Json): RequestBody {
private fun SignUpRequest.toRequestBody(): RequestBody {
Copy link
Contributor

Choose a reason for hiding this comment

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

앗,, 감사합니다

val jsonString = json.encodeToString(this)
return jsonString.toRequestBody("application/json".toMediaTypeOrNull())
}
Expand Down
3 changes: 0 additions & 3 deletions feature/login/src/main/java/co/kr/tnt/login/LoginViewModel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package co.kr.tnt.login

import android.util.Log
import androidx.lifecycle.viewModelScope
import co.kr.tnt.domain.model.AuthType
import co.kr.tnt.domain.model.LoginResult
Expand Down Expand Up @@ -28,8 +27,6 @@ internal class LoginViewModel @Inject constructor(

is LoginUiEvent.OnAuthFail -> {
if (event.throwable !is LoginException.CancelException) {
// TODO resource
Log.w("test", "exception : ${event.throwable}")
sendEffect(LoginSideEffect.ShowToast("로그인에 실패하였습니다. 다시 시도해주세요."))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fun NavController.navigateToLogin(
route = Route.Login,
navOptions = navOptions {
if (clearBackStack) {
popUpTo(graph.startDestinationId) { inclusive = true }
popUpTo(graph.id) { inclusive = true }
}
navOptions()
},
Expand Down
6 changes: 2 additions & 4 deletions feature/main/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ android {
}

dependencies {
implementation(projects.feature.home)
implementation(projects.feature.webview)
implementation(projects.feature.login)
implementation(projects.feature.roleselect)
implementation(projects.feature.trainer.main)
implementation(projects.feature.trainee.main)
implementation(projects.feature.trainee.signup)
implementation(projects.feature.trainer.signup)
implementation(projects.feature.trainer.connect)
implementation(projects.feature.trainer.notification)
implementation(projects.feature.trainee.connect)
implementation(projects.feature.trainee.mypage)
implementation(projects.feature.trainee.notification)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
Expand Down
2 changes: 1 addition & 1 deletion feature/main/src/main/java/co/kr/tnt/main/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class MainViewModel @Inject constructor(
val startDestination: Route = if (isNeedLogin) {
Route.Login
} else {
Route.HomeBase
Route.TraineeMain
}

updateState {
Expand Down
84 changes: 27 additions & 57 deletions feature/main/src/main/java/co/kr/tnt/main/ui/TnTNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import co.kr.tnt.home.navigation.homeNavGraph
import co.kr.tnt.home.navigation.navigateToHome
import co.kr.tnt.login.navigation.loginScreen
import co.kr.tnt.login.navigation.navigateToLogin
import co.kr.tnt.navigation.Route
import co.kr.tnt.roleselect.navigateToRoleSelection
import co.kr.tnt.roleselect.roleSelectionScreen
import co.kr.tnt.trainee.connect.navigation.navigateToTraineeConnect
import co.kr.tnt.trainee.connect.navigation.traineeConnectScreen
import co.kr.tnt.trainee.mypage.navigation.traineeMyPageScreen
import co.kr.tnt.trainee.notification.navigation.traineeNotification
import co.kr.tnt.trainee.main.navigation.navigateToTraineeMain
import co.kr.tnt.trainee.main.navigation.traineeMainScreen
import co.kr.tnt.trainee.signup.navigation.navigateToTraineeSignUp
import co.kr.tnt.trainee.signup.navigation.traineeSignUpScreen
import co.kr.tnt.trainer.connect.navigation.navigateToTrainerConnect
import co.kr.tnt.trainer.connect.navigation.trainerConnectScreen
import co.kr.tnt.trainer.notification.navigation.trainerNotification
import co.kr.tnt.trainer.main.navigation.navigateToTrainerMain
import co.kr.tnt.trainer.main.navigation.trainerMainScreen
import co.kr.tnt.trainer.signup.navigation.navigateToTrainerSignUp
import co.kr.tnt.trainer.signup.navigation.trainerSignUpScreen
import co.kr.tnt.webview.navigateToWebView
Expand All @@ -42,13 +40,7 @@ fun TnTNavHost(
) {
loginScreen(
navigateToHome = {
navController.navigateToHome {
popUpTo(Route.Login) {
inclusive = true
}
launchSingleTop = true
restoreState = true
}
navController.navigateToTraineeMain(clearBackStack = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

여기 navigateToTrainerMain은 아직 추가 안 된건가용?

Copy link
Member Author

Choose a reason for hiding this comment

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

어라 이거 API 반영 됐었군요!.. 이따 집가서 수정해두겠습니다 '-'

},
navigateToSignup = { loginResult ->
navController.navigateToRoleSelection(
Expand All @@ -59,23 +51,11 @@ fun TnTNavHost(
},
)
roleSelectionScreen(
navigateToTraineeSignUp = { authId, authType, email ->
navController.navigateToTraineeSignUp(
authId = authId,
authType = authType,
email = email,
)
},
navigateToTrainerSignUp = { authId, authType, email ->
navController.navigateToTrainerSignUp(
authId = authId,
authType = authType,
email = email,
)
},
navigateToTraineeSignUp = navController::navigateToTraineeSignUp,
navigateToTrainerSignUp = navController::navigateToTrainerSignUp,
)
trainerSignUpScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToPrevious = navController::popBackStack,
navigateToConnect = {
navController.navigateToTrainerConnect(
isSkippable = true,
Expand All @@ -84,45 +64,35 @@ fun TnTNavHost(
},
)
traineeSignUpScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToConnect = { navController.navigateToTraineeConnect(isSkippable = true) },
navigateToPrevious = navController::popBackStack,
navigateToConnect = {
navController.navigateToTrainerConnect(
isSkippable = true,
isCompleted = false,
)
},
)
trainerConnectScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToHome = {
navController.navigateToHome(clearBackStack = true)
},
navigateToPrevious = navController::popBackStack,
navigateToHome = { navController.navigateToTrainerMain(clearBackStack = true) },
)
traineeConnectScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToHome = {
navController.navigateToHome(clearBackStack = true)
},
navigateToPrevious = navController::popBackStack,
navigateToHome = { navController.navigateToTraineeMain(clearBackStack = true) },
)
traineeMyPageScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToTraineeConnect = { navController.navigateToTraineeConnect(isSkippable = false) },
trainerMainScreen(
navigateToConnect = navController::navigateToTrainerConnect,
navigateToWebView = navController::navigateToWebView,
Comment on lines +84 to +86
Copy link
Contributor

Choose a reason for hiding this comment

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

연결 화면으로 이동하기 위해
trainerMainScreen에서는 함수 참조 방식(::)을 사용하고
traineeMainScreen에서는 람다({})를 사용하는 방식인데

둘이 다른 방식을 선택한 이유와, 두 방식으로 나눠 사용하는 기준이 있는지 궁금합니다!!

통일성을 위해 함수 참조를 우선적으로 사용하도록 수정하는게 좋을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

우선 일전에 말씀드렸듯이 람다 타입을 넘길 경우 함수 객체의 인스턴스를 넘겨주는 개념이므로 리컴포지션 카운트가 증가합니다!

참조를 사용할 경우 동일한 인스턴스를 지속적으로 재사용하는 개념이므로, 리컴포지션이 최적화됩니다 !_!
그래서 가능하다면 참조를 사용하는 것이 가장 좋구요..!

그리고 동일한 connect 지만 넘겨주는 방식이 달랐던 이유는, trainerConnect 에서는 (boolean, boolean) -> Unit 형태로 함수 타입을 넘겨주고 있어 참조가 가능하지만 traineeConnect 에서는 () -> Unit 형태로 전달하고 있기 때문에 참조가 불가능합니다 '-'

Copy link
Contributor

Choose a reason for hiding this comment

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

아하 이해했습니다! 머지되면 기존 코드들 함수 타입을 넘겨주도록 수정해보겠습니다 👍👍

navigateToLogin = { navController.navigateToLogin(clearBackStack = true) },
navigateToWebView = { url ->
navController.navigateToWebView(url = url)
},
)
traineeNotification(
navigateToPrevious = { navController.popBackStack() },
)
trainerNotification(
navigateToPrevious = { navController.popBackStack() },
navigateToConnect = {
navController.navigateToTrainerConnect(
isSkippable = false,
isCompleted = true,
)
},
traineeMainScreen(
navigateToConnect = { navController.navigateToTraineeConnect(true) },
navigateToWebView = navController::navigateToWebView,
navigateToLogin = { navController.navigateToLogin(clearBackStack = true) },
)
webViewScreen(
navigateToPrevious = { navController.popBackStack() },
navigateToPrevious = navController::popBackStack,
)
homeNavGraph()
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

android {
setNamespace("feature.home")
setNamespace("feature.trainee.home")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package co.kr.tnt.trainee.home

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel

@Composable
@Suppress("UnusedParameter")
internal fun TraineeHomeRoute(
viewModel: TraineeHomeViewModel = hiltViewModel(),
navigateToNotification: () -> Unit,
) {
TraineeHomeScreen(navigateToNotification)
}

@Composable
fun TraineeHomeScreen(
navigateToNotification: () -> Unit,
) {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Column {
Text(
text = "trainee home",
modifier = Modifier.padding(innerPadding),
)
Button(onClick = navigateToNotification) {
Text("navigate to notification")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package co.kr.tnt.home
package co.kr.tnt.trainee.home

import androidx.lifecycle.ViewModel
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HomeViewModel @Inject constructor() : ViewModel()
class TraineeHomeViewModel @Inject constructor() : ViewModel()
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package co.kr.tnt.trainee.home.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptionsBuilder
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import co.kr.tnt.navigation.Route
import co.kr.tnt.trainee.home.TraineeHomeRoute

fun NavController.navigateToTraineeHome(
navOptions: NavOptionsBuilder.() -> Unit = {},
) = navigate(
route = Route.TraineeHome,
builder = navOptions,
)

fun NavGraphBuilder.traineeHomeNavGraph(
navigateToNotification: () -> Unit,
homeDestination: NavGraphBuilder.() -> Unit = { },
) {
navigation<Route.TraineeMainTab.Home>(startDestination = Route.TraineeHome) {
composable<Route.TraineeHome> {
TraineeHomeRoute(
navigateToNotification = navigateToNotification,
)
}
homeDestination()
}
}
1 change: 1 addition & 0 deletions feature/trainee/main/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
17 changes: 17 additions & 0 deletions feature/trainee/main/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import co.kr.tnt.setNamespace

plugins {
id("tnt.android.feature")
}

android {
setNamespace("feature.trainee.main")
}

dependencies {
implementation(projects.feature.trainee.home)
implementation(projects.feature.trainee.mypage)
implementation(projects.feature.trainee.notification)

implementation(libs.kotlinx.immutable)
}
2 changes: 2 additions & 0 deletions feature/trainee/main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
Loading