-
Notifications
You must be signed in to change notification settings - Fork 1
LoginActivity 제거 및 MainActivity로 진입점 통일 #23
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
Changes from all commits
225f8a6
3a20af6
dba4ebb
d13011c
fdda052
0aa98cd
8164b40
a94614e
38bf2f4
ab81281
1c15476
35f5165
6a2d793
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 |
|---|---|---|
| @@ -1,16 +1,14 @@ | ||
| package com.yapp.twix | ||
|
|
||
| import android.app.Application | ||
| import org.koin.android.ext.koin.androidContext | ||
| import org.koin.core.context.startKoin | ||
| import com.yapp.twix.di.initKoin | ||
|
|
||
| class TwixApplication : Application() { | ||
| override fun onCreate() { | ||
| super.onCreate() | ||
|
|
||
| startKoin { | ||
| androidContext(this@TwixApplication) | ||
| modules() | ||
| } | ||
| initKoin( | ||
| context = this | ||
| ) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.yapp.twix.di | ||
|
|
||
| import com.twix.login.di.loginModule | ||
| import org.koin.core.module.Module | ||
|
|
||
| val featureModules: List<Module> = listOf( | ||
| loginModule | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.yapp.twix.di | ||
|
|
||
| import android.content.Context | ||
| import org.koin.android.ext.koin.androidContext | ||
| import org.koin.core.context.startKoin | ||
| import org.koin.core.module.Module | ||
|
|
||
| fun initKoin( | ||
| context: Context? = null, | ||
| extraModules: List<Module> = emptyList() | ||
| ) { | ||
| startKoin { | ||
| context?.let { androidContext(it) } | ||
|
|
||
| modules( | ||
| buildList { | ||
| addAll(extraModules) | ||
| addAll(featureModules) | ||
| } | ||
| ) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.yapp.twix.main | ||
|
|
||
| import android.os.Bundle | ||
| import androidx.activity.ComponentActivity | ||
| import androidx.activity.compose.setContent | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.safeContentPadding | ||
| import androidx.compose.ui.Modifier | ||
| import com.twix.navigation.AppNavHost | ||
|
|
||
| class MainActivity: ComponentActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
|
|
||
| setContent { | ||
| // TODO: 디자인 시스템이 결정되면 테마 구현 및 적용 | ||
| Box( | ||
| modifier = Modifier | ||
| .safeContentPadding() | ||
| .fillMaxSize() | ||
| ) { | ||
| AppNavHost() | ||
| } | ||
| } | ||
| } | ||
| } |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.twix.login | ||
|
|
||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
|
|
||
| @Composable | ||
| fun LoginScreen() { | ||
| LoginContent() | ||
| } | ||
|
|
||
| @Composable | ||
| private fun LoginContent() { | ||
| Box( | ||
| modifier = Modifier.fillMaxSize(), | ||
| contentAlignment = Alignment.Center | ||
| ) { | ||
| Text("임시 화면입니다.") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.twix.login.di | ||
|
|
||
| import com.twix.login.navigation.LoginNavGraph | ||
| import com.twix.navigation.NavRoutes | ||
| import com.twix.navigation.base.NavGraphContributor | ||
| import org.koin.core.qualifier.named | ||
| import org.koin.dsl.module | ||
|
|
||
| val loginModule = module { | ||
| single<NavGraphContributor>(named(NavRoutes.LoginGraph.route)) { LoginNavGraph } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.twix.login.navigation | ||
|
|
||
| import androidx.navigation.NavGraphBuilder | ||
| import androidx.navigation.NavHostController | ||
| import androidx.navigation.compose.composable | ||
| import androidx.navigation.navigation | ||
| import com.twix.login.LoginScreen | ||
| import com.twix.navigation.NavRoutes | ||
| import com.twix.navigation.base.NavGraphContributor | ||
|
|
||
| object LoginNavGraph: NavGraphContributor { | ||
|
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. 요건 단순히 궁금증인데 object로 선언한 이유가 궁금해 ! 😃 내가 생각하기에 어차피
Member
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. 지금 NavGraph는 내부 상태 없이 순수하게 정해진 그래프만 등록하는 역할이에요. 그래서 여러 인스턴스를 만들 필요도 없고 여러 인스턴스를 생성하는 게 가능할 필요도 없다고 생각해요. class로 구현하는 게 불가능한 건 아니지만 class로 구현하면 모듈에 등록하는 과정에서 누군가는 인스턴스 생성을 책임져야 해요. 그리고 이론상 여러곳에서 인스턴스를 생성하는 게 가능해지기 때문에 종합적으로 고려했을 때 class보다는 object로 구현하는 게 맞다고 판단했습니다!
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. 그렇구나 그런 이유라면 너무 좋은 것 같아 ! 😄 |
||
| override val graphRoute: NavRoutes | ||
| get() = NavRoutes.LoginGraph | ||
| override val startDestination: String | ||
| get() = NavRoutes.Login.route | ||
|
|
||
| override fun NavGraphBuilder.registerGraph(navController: NavHostController) { | ||
| navigation( | ||
| route = graphRoute.route, | ||
| startDestination = startDestination | ||
| ) { | ||
| composable(NavRoutes.Login.route) { | ||
| LoginScreen() | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
Context가 nullable 이유가 혹시 있을까 ?지금은 TwixApplication에서만 호출되서 nullable이지 않아도 괜찮을 것 같은데 어떤 확장성을 고려한걸까 ?
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.
CMP로 데스크탑까지 확장하게 되면 Jvm 환경에서는 context가 없어서 일단 nullable로 뒀습니다!
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.
오호 대박 그건 몰랐네 👍