-
Notifications
You must be signed in to change notification settings - Fork 2
๐ :: (#803) ์จ๋ณด๋ฉ ๊ธฐ๋ฅ ๊ตฌํ #806
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
The head ref may contain hidden characters: "feature/803-\uC628\uBCF4\uB529-\uAE30\uB2A5-\uAD6C\uD604"
Changes from all commits
006156c
13663ba
f7d4ccc
8e64624
6cb7e5b
6f01946
2b39cbe
4800669
0ca756e
aed0ad2
c9fceb8
4910699
8991c1d
131e1ca
a872ad4
720bc54
eb1e22a
5a984ef
9c18a5c
e09b799
f304ef1
4cd2a14
c45903f
8fa4b06
b4c1458
e9204a4
9f9a13c
8fe3da9
ae79d45
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,12 @@ | ||
| package team.aliens.dms.android.app | ||
|
|
||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.systemBarsPadding | ||
| import androidx.compose.material3.Button | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.material3.windowsizeclass.WindowSizeClass | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.LaunchedEffect | ||
| import androidx.compose.runtime.collectAsState | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.navigation3.runtime.NavKey | ||
| import androidx.navigation3.runtime.entryProvider | ||
|
|
@@ -19,59 +15,64 @@ import androidx.navigation3.ui.NavDisplay | |
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.serialization.Serializable | ||
| import team.aliens.dms.android.core.designsystem.DmsTheme | ||
| import team.aliens.dms.android.core.designsystem.LocalToast | ||
| import team.aliens.dms.android.feature.onboarding.navigation.OnboardingRoute | ||
| import team.aliens.dms.android.feature.signin.navigation.SignInRoute | ||
|
|
||
| @Serializable | ||
| data object ScreenA : NavKey | ||
| data object OnboardingScreenNav : NavKey | ||
|
|
||
| @Serializable | ||
| data object ScreenB : NavKey | ||
| data object SignInScreenNav : NavKey | ||
|
|
||
| @Serializable | ||
| data object MainScreenNav : NavKey | ||
|
|
||
| @Composable | ||
| fun DmsApp( | ||
| windowSizeClass: WindowSizeClass, | ||
| // displayFeatures: List<DisplayFeature>, | ||
| isJwtAvailable: StateFlow<Boolean>, | ||
| // appState: DmsAppState = rememberDmsAppState( | ||
| // isJwtAvailable = isJwtAvailable, | ||
| // ), | ||
| mainViewModel: MainActivityViewModel, | ||
| ) { | ||
| val backStack = rememberNavBackStack(ScreenA) | ||
| val isUpdateFailed by mainViewModel.isUpdateFailed.collectAsState() | ||
| val toast = LocalToast.current | ||
| val isOnboardingCompleted by mainViewModel.isOnboardingCompleted.collectAsState() | ||
| val isJwtAvailableState by isJwtAvailable.collectAsState() | ||
|
|
||
| val backStack = rememberNavBackStack(OnboardingScreenNav) | ||
|
|
||
| if (isUpdateFailed) { | ||
| LaunchedEffect(Unit) { | ||
| toast.showErrorToast( | ||
| message = "์ ๋ฐ์ดํธ ์ ๋ณด๋ฅผ ๋ถ๋ฌ์ฌ ์ ์์ต๋๋ค", | ||
| ) | ||
| LaunchedEffect(isOnboardingCompleted, isJwtAvailableState) { | ||
| val initialScreen = when { | ||
| !isOnboardingCompleted -> OnboardingScreenNav | ||
| isJwtAvailableState -> MainScreenNav | ||
| else -> SignInScreenNav | ||
| } | ||
| mainViewModel.consumeUpdateFailed() | ||
| } | ||
|
|
||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxSize() | ||
| .systemBarsPadding(), | ||
| contentAlignment = Alignment.Center, | ||
| ) { | ||
| NavDisplay( | ||
| backStack = backStack, | ||
| onBack = { backStack.removeLastOrNull() }, | ||
| entryProvider = entryProvider { | ||
| entry<ScreenA> { | ||
| Button(onClick = { backStack.add(ScreenB) }) { | ||
| Text("Go to Screen B") | ||
| } | ||
| } | ||
| entry<ScreenB> { | ||
| Text( | ||
| text = "Screen B", | ||
| color = DmsTheme.colorScheme.onSurface, | ||
| ) | ||
| } | ||
| }, | ||
| ) | ||
| if (backStack.lastOrNull() != initialScreen) { | ||
| backStack.clear() | ||
| backStack.add(initialScreen) | ||
| } | ||
|
Comment on lines
+41
to
+51
|
||
| } | ||
|
|
||
| NavDisplay( | ||
| modifier = Modifier.systemBarsPadding(), | ||
| backStack = backStack, | ||
| onBack = { backStack.removeLastOrNull() }, | ||
| entryProvider = entryProvider { | ||
| entry<OnboardingScreenNav> { | ||
| OnboardingRoute( | ||
| navigateToSignIn = { | ||
| backStack.clear() | ||
| backStack.add(SignInScreenNav) | ||
| }, | ||
| ) | ||
| } | ||
| entry<SignInScreenNav> { | ||
| SignInRoute() | ||
| } | ||
| entry<MainScreenNav> { | ||
| Text( | ||
| text = "Main Screen (TODO)", | ||
| color = DmsTheme.colorScheme.onSurface, | ||
| ) | ||
| } | ||
| }, | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,36 @@ | ||
| package team.aliens.dms.android.app | ||
|
|
||
| import androidx.lifecycle.viewModelScope | ||
| import dagger.hilt.android.lifecycle.HiltViewModel | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.flow.asStateFlow | ||
| import kotlinx.coroutines.launch | ||
| import team.aliens.dms.android.core.jwt.JwtProvider | ||
| import team.aliens.dms.android.core.ui.viewmodel.BaseViewModel | ||
| import team.aliens.dms.android.onboarding.datastore.OnboardingDataStoreDataSource | ||
| import javax.inject.Inject | ||
|
|
||
| @HiltViewModel | ||
| class MainActivityViewModel @Inject constructor( | ||
| private val jwtProvider: JwtProvider, | ||
| private val onboardingDataSource: OnboardingDataStoreDataSource, | ||
| ) : BaseViewModel() { | ||
| val autoSignInAvailable: StateFlow<Boolean> = jwtProvider.isCachedAccessTokenAvailable | ||
|
|
||
| private val _isUpdateFailed = MutableStateFlow(false) | ||
| val isUpdateFailed = _isUpdateFailed.asStateFlow() | ||
|
|
||
| fun onUpdateFailed() { | ||
| _isUpdateFailed.value = true | ||
| private val _isOnboardingCompleted = MutableStateFlow(false) | ||
| val isOnboardingCompleted: StateFlow<Boolean> = _isOnboardingCompleted.asStateFlow() | ||
|
|
||
| init { | ||
| viewModelScope.launch { | ||
| _isOnboardingCompleted.value = onboardingDataSource.getOnboardingCompleted() | ||
| } | ||
| } | ||
|
|
||
| fun consumeUpdateFailed() { | ||
| _isUpdateFailed.value = false | ||
| fun onUpdateFailed() { | ||
| _isUpdateFailed.value = true | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package team.aliens.dms.android.app | ||
|
|
||
| import android.app.Application | ||
| import androidx.core.content.res.ResourcesCompat | ||
| import androidx.hilt.work.HiltWorkerFactory | ||
| import androidx.work.Configuration | ||
| import dagger.hilt.android.HiltAndroidApp | ||
|
|
@@ -16,4 +17,28 @@ class DmsApplication : Application(), Configuration.Provider { | |
| get() = Configuration.Builder() | ||
| .setWorkerFactory(workFactory) | ||
| .build() | ||
|
|
||
| override fun onCreate() { | ||
| super.onCreate() | ||
| preloadFonts() | ||
| } | ||
|
|
||
| private fun preloadFonts() { | ||
| // Preload fonts to prevent text rendering delay | ||
| try { | ||
| val fontIds = listOf( | ||
| team.aliens.dms.android.core.designsystem.R.font.noto_sans_kr_black, | ||
| team.aliens.dms.android.core.designsystem.R.font.noto_sans_kr_bold, | ||
| team.aliens.dms.android.core.designsystem.R.font.noto_sans_kr_light, | ||
| team.aliens.dms.android.core.designsystem.R.font.noto_sans_kr_medium, | ||
| team.aliens.dms.android.core.designsystem.R.font.noto_sans_kr_regular, | ||
| team.aliens.dms.android.core.designsystem.R.font.noto_sans_kr_thin, | ||
| ) | ||
| fontIds.forEach { fontId -> | ||
| ResourcesCompat.getFont(this, fontId) | ||
| } | ||
| } catch (e: Exception) { | ||
| // Font preloading failed, but continue app initialization | ||
|
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.
// Font preloading failed, but continue app initialization
e.printStackTrace() // ๋๋ Logger๋ฅผ ์ฌ์ฉํด ๋ก๊ทธ๋ฅผ ๋จ๊ธฐ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค. |
||
| } | ||
| } | ||
| } | ||
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.
hilt-navigation-compose์ข ์์ฑ์ดprodImplementation๊ณผdevImplementation์ ์ค๋ณต์ผ๋ก ์ถ๊ฐ๋์์ต๋๋ค. ์ด ์ข ์์ฑ์ด ๋ ๋น๋ ์ ํ ๋ชจ๋์ ํ์ํ๋ค๋ฉดimplementation์ผ๋ก ํ ๋ฒ๋ง ์ ์ธํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ด๋ ๊ฒ ํ๋ฉด ์ค๋ณต์ ํผํ๊ณ Gradle ์คํฌ๋ฆฝํธ๋ฅผ ๋ ๊น๋ํ๊ฒ ์ ์งํ ์ ์์ต๋๋ค.implementation(libs.androidx.hilt.navigation.compose) add("devImplementation", libs.androidx.navigation3.runtime) add("devImplementation", libs.androidx.navigation3.ui)