-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/#76 landing #78
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
bffedc7
4ca681c
75d871a
746d1a0
85d4baa
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "mcpServers": { | ||
| "figma-desktop": { | ||
| "type": "http", | ||
| "url": "http://127.0.0.1:3845/mcp" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24"> | ||
| <path | ||
| android:pathData="M17.05,20.28C16.07,21.23 15,21.08 13.97,20.63C12.88,20.17 11.88,20.15 10.73,20.63C9.29,21.25 8.53,21.07 7.67,20.28C2.79,15.25 3.51,7.59 9.05,7.31C10.4,7.38 11.34,8.05 12.13,8.11C13.31,7.87 14.44,7.18 15.7,7.27C17.21,7.39 18.35,7.99 19.1,9.07C15.98,10.94 16.72,15.05 19.57,16.2C19.01,17.7 18.27,19.19 17.04,20.29L17.05,20.28ZM12.03,7.25C11.88,5.02 13.69,3.18 15.77,3C16.06,5.58 13.43,7.5 12.03,7.25Z" | ||
| android:fillColor="#FFFFFF"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24"> | ||
| <path | ||
| android:pathData="M12,3C6.477,3 2,6.463 2,10.691C2,13.392 3.833,15.783 6.585,17.166L5.588,20.69C5.513,20.952 5.816,21.163 6.044,21.006L10.298,18.213C10.855,18.303 11.423,18.382 12,18.382C17.523,18.382 22,14.919 22,10.691C22,6.463 17.523,3 12,3Z" | ||
| android:fillColor="#000000"/> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,31 +27,46 @@ import com.chukchukhaksa.mobile.common.designsystem.theme.White | |||||||||
| import com.chukchukhaksa.mobile.common.kmp.Platform.* | ||||||||||
| import com.chukchukhaksa.mobile.common.kmp.getPlatform | ||||||||||
| import com.chukchukhaksa.mobile.common.ui.collectWithLifecycle | ||||||||||
| import com.chukchukhaksa.mobile.domain.auth.usecase.CheckAuthStateUseCase | ||||||||||
| import com.chukchukhaksa.mobile.presentation.landing.navigation.LandingRoute | ||||||||||
| import com.chukchukhaksa.mobile.presentation.landing.navigation.landingNavGraph | ||||||||||
| import com.chukchukhaksa.mobile.presentation.timetable.navigation.TimetableRoute | ||||||||||
| import com.chukchukhaksa.mobile.presentation.timetable.navigation.timetableNavGraph | ||||||||||
| import dev.gitlive.firebase.Firebase | ||||||||||
| import dev.gitlive.firebase.analytics.FirebaseAnalytics | ||||||||||
| import dev.gitlive.firebase.analytics.analytics | ||||||||||
| import kotlinx.coroutines.delay | ||||||||||
| import org.jetbrains.compose.resources.stringResource | ||||||||||
| import org.koin.compose.KoinContext | ||||||||||
| import org.koin.compose.koinInject | ||||||||||
| import org.koin.compose.viewmodel.koinViewModel | ||||||||||
|
|
||||||||||
| @Composable | ||||||||||
| fun App( | ||||||||||
| modifier: Modifier = Modifier, | ||||||||||
| viewModel: MainViewModel = koinViewModel(), | ||||||||||
| navigator: MainNavigator = rememberMainNavigator(), | ||||||||||
| onReady: () -> Unit = {}, | ||||||||||
| ) { | ||||||||||
| CchTheme { | ||||||||||
| KoinContext { | ||||||||||
| val uiState = viewModel.mviStore.uiState.collectAsState().value | ||||||||||
| val uriHandler = LocalUriHandler.current | ||||||||||
| val checkAuthStateUseCase: CheckAuthStateUseCase = koinInject() | ||||||||||
| var startDestination by remember { mutableStateOf<String?>(null) } | ||||||||||
|
Comment on lines
+55
to
+56
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. ๐งน Nitpick | ๐ต Trivial
โป๏ธ ๊ถ์ฅ ์์ ์- val checkAuthStateUseCase: CheckAuthStateUseCase = koinInject()
+ val checkAuthStateUseCase: CheckAuthStateUseCase = remember { koinInject() }
var startDestination by remember { mutableStateOf<String?>(null) }๋๋ ๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||||||
|
|
||||||||||
| viewModel.mviStore.sideEffects.collectWithLifecycle { sideEffect -> | ||||||||||
| when (sideEffect) { | ||||||||||
| is MainSideEffect.OpenUrl -> uriHandler.openUri(sideEffect.url) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| LaunchedEffect(Unit) { | ||||||||||
| val isAuthenticated = checkAuthStateUseCase().getOrDefault(false) | ||||||||||
| startDestination = if (isAuthenticated) TimetableRoute.route else LandingRoute.route | ||||||||||
| onReady() | ||||||||||
| } | ||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||
|
|
||||||||||
| LaunchedEffect(key1 = Unit) { | ||||||||||
| viewModel.checkNeedForceUpdate() | ||||||||||
|
|
||||||||||
|
|
@@ -73,38 +88,48 @@ fun App( | |||||||||
| contentWindowInsets = WindowInsets(0.dp), | ||||||||||
| modifier = modifier, | ||||||||||
| content = { innerPadding -> | ||||||||||
| val navGraphBuilder: NavGraphBuilder.() -> Unit = { | ||||||||||
| timetableNavGraph( | ||||||||||
| padding = innerPadding, | ||||||||||
| popBackStack = navigator::popBackStackIfNotHome, | ||||||||||
| navigateTimetableNameInput = navigator::navigateTimetableNameInput, | ||||||||||
| navigateTimetableEditor = navigator::navigateTimetableEditor, | ||||||||||
| navigateTimetableList = navigator::navigateTimetableList, | ||||||||||
| navigateOpenLecture = navigator::navigateOpenLecture, | ||||||||||
| handleException = viewModel::handleException, | ||||||||||
| onShowToast = viewModel::onShowToast, | ||||||||||
| navigateCellEditor = navigator::navigateCellEditor, | ||||||||||
| navigateSemesterSelect = navigator::navigateSemesterSelect, | ||||||||||
| navigateTimetable = navigator::navigateTimetable, | ||||||||||
| ) | ||||||||||
| } | ||||||||||
| val currentStartDestination = startDestination | ||||||||||
|
|
||||||||||
| when (getPlatform()) { | ||||||||||
| Android -> NavHost( | ||||||||||
| navController = navigator.navController, | ||||||||||
| startDestination = navigator.startDestination, | ||||||||||
| enterTransition = { slideInHorizontally(tween(350, easing = FastOutSlowInEasing)) { it } }, | ||||||||||
| exitTransition = { slideOutHorizontally(tween(350, easing = FastOutSlowInEasing)) { -it / 3 } }, | ||||||||||
| popEnterTransition = { slideInHorizontally(tween(350, easing = FastOutSlowInEasing)) { -it / 3 } }, | ||||||||||
| popExitTransition = { slideOutHorizontally(tween(350, easing = FastOutSlowInEasing)) { it } }, | ||||||||||
| builder = navGraphBuilder, | ||||||||||
| ) | ||||||||||
| if (currentStartDestination != null) { | ||||||||||
| val navGraphBuilder: NavGraphBuilder.() -> Unit = { | ||||||||||
| landingNavGraph( | ||||||||||
| handleException = viewModel::handleException, | ||||||||||
| onShowToast = viewModel::onShowToast, | ||||||||||
| navigateToHome = navigator::navigateFromLandingToHome, | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| IOS -> NavHost( | ||||||||||
| navController = navigator.navController, | ||||||||||
| startDestination = navigator.startDestination, | ||||||||||
| builder = navGraphBuilder, | ||||||||||
| ) | ||||||||||
| timetableNavGraph( | ||||||||||
| padding = innerPadding, | ||||||||||
| popBackStack = navigator::popBackStackIfNotHome, | ||||||||||
| navigateTimetableNameInput = navigator::navigateTimetableNameInput, | ||||||||||
| navigateTimetableEditor = navigator::navigateTimetableEditor, | ||||||||||
| navigateTimetableList = navigator::navigateTimetableList, | ||||||||||
| navigateOpenLecture = navigator::navigateOpenLecture, | ||||||||||
| handleException = viewModel::handleException, | ||||||||||
| onShowToast = viewModel::onShowToast, | ||||||||||
| navigateCellEditor = navigator::navigateCellEditor, | ||||||||||
| navigateSemesterSelect = navigator::navigateSemesterSelect, | ||||||||||
| navigateTimetable = navigator::navigateTimetable, | ||||||||||
| ) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| when (getPlatform()) { | ||||||||||
| Android -> NavHost( | ||||||||||
| navController = navigator.navController, | ||||||||||
| startDestination = currentStartDestination, | ||||||||||
| enterTransition = { slideInHorizontally(tween(350, easing = FastOutSlowInEasing)) { it } }, | ||||||||||
| exitTransition = { slideOutHorizontally(tween(350, easing = FastOutSlowInEasing)) { -it / 3 } }, | ||||||||||
| popEnterTransition = { slideInHorizontally(tween(350, easing = FastOutSlowInEasing)) { -it / 3 } }, | ||||||||||
| popExitTransition = { slideOutHorizontally(tween(350, easing = FastOutSlowInEasing)) { it } }, | ||||||||||
| builder = navGraphBuilder, | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| IOS -> NavHost( | ||||||||||
| navController = navigator.navController, | ||||||||||
| startDestination = currentStartDestination, | ||||||||||
| builder = navGraphBuilder, | ||||||||||
| ) | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (uiState.showNetworkErrorDialog) { | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| package com.chukchukhaksa.mobile.data.auth.datasource | ||
|
|
||
| import com.chukchukhaksa.mobile.domain.auth.model.RefreshTokenResult | ||
| import com.chukchukhaksa.mobile.domain.auth.model.SignInResult | ||
|
|
||
| interface RemoteAuthDataSource { | ||
| suspend fun signIn(idToken: String, nonce: String): SignInResult | ||
| suspend fun refreshToken(refreshToken: String): RefreshTokenResult | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.chukchukhaksa.mobile.domain.auth.model | ||
|
|
||
| data class RefreshTokenResult( | ||
| val accessToken: String, | ||
| val refreshToken: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package com.chukchukhaksa.mobile.domain.auth.usecase | ||
|
|
||
| import com.chukchukhaksa.mobile.domain.auth.repository.AuthRepository | ||
| import com.chukchukhaksa.mobile.domain.common.runCatchingIgnoreCancelled | ||
| import com.chukchukhaksa.mobile.remote.common.ApiException | ||
| import kotlin.coroutines.cancellation.CancellationException | ||
|
|
||
| class CheckAuthStateUseCase( | ||
| private val authRepository: AuthRepository, | ||
| ) { | ||
| suspend operator fun invoke(): Result<Boolean> = runCatchingIgnoreCancelled { | ||
| val refreshToken = authRepository.getRefreshToken() | ||
| ?: return@runCatchingIgnoreCancelled false | ||
|
|
||
| try { | ||
| authRepository.refreshToken() | ||
| true | ||
| } catch (e: CancellationException) { | ||
| throw e | ||
| } catch (e: ApiException) { | ||
| authRepository.clearTokens() | ||
| false | ||
| } catch (e: Exception) { | ||
| false | ||
| } | ||
| } | ||
|
lluke0 marked this conversation as resolved.
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.chukchukhaksa.mobile.presentation.landing | ||
|
|
||
| data class LandingState( | ||
| val isLoading: Boolean = false, | ||
| ) | ||
|
|
||
| sealed interface LandingSideEffect { | ||
| data object NavigateHome : LandingSideEffect | ||
| data class ShowToast(val message: String) : LandingSideEffect | ||
| data class HandleException(val throwable: Throwable) : LandingSideEffect | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.