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 all 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 @@ -2,7 +2,7 @@ package co.kr.tnt.ui.model

import androidx.annotation.DrawableRes
import co.kr.tnt.core.ui.R
import co.kr.tnt.domain.model.UserType
import co.kr.tnt.domain.model.User

sealed class DefaultUserProfile(
@DrawableRes val image: Int,
Expand All @@ -15,10 +15,10 @@ sealed class DefaultUserProfile(
)

companion object {
fun fromDomain(type: UserType): DefaultUserProfile {
fun fromDomain(type: User): DefaultUserProfile {
return when (type) {
is UserType.Trainee -> Trainer
is UserType.Trainer -> Trainee
is User.Trainee -> Trainer
is User.Trainer -> Trainee
}
Comment on lines -18 to 22
Copy link
Contributor

Choose a reason for hiding this comment

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

굿굿굿 감사합니다👍

}
}
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
@@ -0,0 +1,9 @@
package co.kr.data.network.model

import co.kr.data.network.model.enum.MemberType
import kotlinx.serialization.Serializable

@Serializable
data class CheckSessionResponse(
val memberType: MemberType,
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package co.kr.data.network.model

import co.kr.data.network.model.enum.MemberType
import co.kr.data.network.model.enum.toDomain
import co.kr.tnt.domain.model.AuthType
import co.kr.tnt.domain.model.LoginResult
import kotlinx.serialization.Serializable
Expand All @@ -14,6 +16,7 @@ data class LoginResponse(
val socialEmail: String,
val socialType: AuthType,
val isSignUp: Boolean,
val memberType: MemberType,
)

fun LoginResponse.toDomain(): LoginResult =
Expand All @@ -22,4 +25,5 @@ fun LoginResponse.toDomain(): LoginResult =
email = socialEmail,
authType = socialType,
isSignUp = isSignUp,
userType = runCatching(memberType::toDomain).getOrNull(),
Copy link
Contributor

Choose a reason for hiding this comment

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

😯👍

)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package co.kr.data.network.model

import co.kr.tnt.domain.model.UserType
import co.kr.tnt.domain.model.User
import kotlinx.serialization.Serializable

@Serializable
Expand All @@ -21,14 +21,14 @@ data class SignUpRequest(
val cautionNote: String? = "",
)

fun UserType.toSignUpRequest(
fun User.toSignUpRequest(
socialId: String,
socialType: String,
email: String,
fcmToken: String,
): SignUpRequest {
return when (this) {
is UserType.Trainer -> SignUpRequest(
is User.Trainer -> SignUpRequest(
memberType = "trainer",
name = name,
birthday = null,
Expand All @@ -45,7 +45,7 @@ fun UserType.toSignUpRequest(
advertisementAgreement = true,
)

is UserType.Trainee -> SignUpRequest(
is User.Trainee -> SignUpRequest(
memberType = "trainee",
name = name,
birthday = birthday?.toString(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package co.kr.data.network.model.enum

import co.kr.tnt.domain.model.UserType
import kotlinx.serialization.Serializable

@Serializable
enum class MemberType {
TRAINER,
TRAINEE,
UNREGISTERED,
}

fun MemberType.toDomain(): UserType =
when (this) {
MemberType.TRAINER -> UserType.TRAINER
MemberType.TRAINEE -> UserType.TRAINEE
MemberType.UNREGISTERED -> error("등록되지 않은 유저입니다.")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.kr.data.network.service

import co.kr.data.network.model.CheckSessionResponse
import co.kr.data.network.model.LoginRequest
import co.kr.data.network.model.LoginResponse
import co.kr.data.network.model.SignUpResponse
Expand All @@ -14,7 +15,7 @@ import retrofit2.http.Part

interface ApiService {
@GET(CHECK_SESSION_PATH)
suspend fun getCheckSession()
suspend fun getCheckSession(): CheckSessionResponse

@POST("/login")
suspend fun postLogin(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package co.kr.data.repository

import co.kr.data.network.model.LoginRequest
import co.kr.data.network.model.enum.toDomain
import co.kr.data.network.model.toDomain
import co.kr.data.network.source.LoginRemoteDataSource
import co.kr.data.storage.source.SessionLocalDataSource
import co.kr.tnt.domain.model.AuthType
import co.kr.tnt.domain.model.LoginResult
import co.kr.tnt.domain.model.UserType
import co.kr.tnt.domain.repository.LoginRepository
import javax.inject.Inject
import javax.inject.Singleton
Expand All @@ -15,8 +17,8 @@ internal class LoginRepositoryImpl @Inject constructor(
private val loginRemoteDataSource: LoginRemoteDataSource,
private val sessionLocalDataSource: SessionLocalDataSource,
) : LoginRepository {
override suspend fun isNeedLogin(): Boolean =
runCatching { loginRemoteDataSource.getCheckSession() }.isFailure
override suspend fun getUserType(): UserType =
loginRemoteDataSource.getCheckSession().memberType.toDomain()

override suspend fun login(
authType: AuthType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import co.kr.data.network.model.toSignUpRequest
import co.kr.data.network.source.SignUpRemoteDataSource
import co.kr.data.storage.source.SessionLocalDataSource
import co.kr.tnt.domain.model.SignUpResult
import co.kr.tnt.domain.model.UserType
import co.kr.tnt.domain.model.User
import co.kr.tnt.domain.repository.SignUpRepository
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Expand All @@ -25,7 +25,7 @@ class SignUpRepositoryImpl @Inject constructor(
) : SignUpRepository {
override suspend fun signUp(
profileImage: File?,
userType: UserType,
user: User,
socialId: String,
socialType: String,
email: String,
Expand All @@ -36,13 +36,13 @@ class SignUpRepositoryImpl @Inject constructor(
}

// TODO FCM token
val signUpRequest = userType.toSignUpRequest(
val signUpRequest = user.toSignUpRequest(
socialId = socialId,
socialType = socialType,
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
1 change: 1 addition & 0 deletions domain/src/main/java/co/kr/tnt/domain/model/LoginResult.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ data class LoginResult(
val email: String,
val authType: AuthType,
val isSignUp: Boolean,
val userType: UserType?,
)
49 changes: 49 additions & 0 deletions domain/src/main/java/co/kr/tnt/domain/model/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package co.kr.tnt.domain.model

import java.time.LocalDate

sealed class User {
abstract val id: String
abstract val name: String
abstract val image: String?

data class Trainer(
override val id: String,
override val name: String,
override val image: String?,
) : User() {
companion object {
val EMPTY = Trainer(
id = "",
name = "",
image = null,
)
}
}
Comment on lines +15 to +22
Copy link
Contributor

Choose a reason for hiding this comment

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

아 이런 방법이 있었군요..!


data class Trainee(
override val id: String,
override val name: String,
override val image: String?,
val birthday: LocalDate?,
val age: Int?,
val weight: Double,
val height: Int,
val ptPurpose: List<String>,
val caution: String?,
) : User() {
companion object {
val EMPTY = Trainee(
id = "",
name = "",
image = null,
birthday = null,
age = 0,
weight = 0.0,
height = 0,
ptPurpose = emptyList(),
caution = null,
)
}
}
}
27 changes: 3 additions & 24 deletions domain/src/main/java/co/kr/tnt/domain/model/UserType.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
package co.kr.tnt.domain.model

import java.time.LocalDate

sealed class UserType {
abstract val id: String
abstract val name: String
abstract val image: String?

data class Trainer(
override val id: String,
override val name: String,
override val image: String?,
) : UserType()

data class Trainee(
override val id: String,
override val name: String,
override val image: String?,
val birthday: LocalDate?,
val age: Int?,
val weight: Double,
val height: Int,
val ptPurpose: List<String>,
val caution: String?,
) : UserType()
enum class UserType {
TRAINER,
TRAINEE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package co.kr.tnt.domain.repository

import co.kr.tnt.domain.model.AuthType
import co.kr.tnt.domain.model.LoginResult
import co.kr.tnt.domain.model.UserType

interface LoginRepository {
suspend fun isNeedLogin(): Boolean
suspend fun getUserType(): UserType

suspend fun login(
authType: AuthType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package co.kr.tnt.domain.repository

import co.kr.tnt.domain.model.SignUpResult
import co.kr.tnt.domain.model.UserType
import co.kr.tnt.domain.model.User
import java.io.File

interface SignUpRepository {
suspend fun signUp(
profileImage: File?,
userType: UserType,
user: User,
socialId: String,
socialType: String,
email: String,
Expand Down
3 changes: 2 additions & 1 deletion feature/login/src/main/java/co/kr/tnt/login/LoginContract.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package co.kr.tnt.login
import co.kr.tnt.domain.model.AuthType
import co.kr.tnt.domain.model.LoginResult
import co.kr.tnt.domain.model.Term
import co.kr.tnt.domain.model.UserType
import co.kr.tnt.login.model.TermState
import co.kr.tnt.ui.base.UiEvent
import co.kr.tnt.ui.base.UiSideEffect
Expand Down Expand Up @@ -33,7 +34,7 @@ internal class LoginContract {
sealed interface LoginSideEffect : UiSideEffect {
data object ShowTermBottomSheet : LoginSideEffect
data class ShowToast(val message: String) : LoginSideEffect
data object NavigateToHome : LoginSideEffect
data class NavigateToHome(val userType: UserType) : LoginSideEffect
data class NavigateToSignup(val loginResult: LoginResult) : LoginSideEffect
}
}
Loading