-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from skaengus2012/feature/issue343
Compose nav-component migration
- Loading branch information
Showing
33 changed files
with
322 additions
and
501 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/nlab/reminder/apps/ui/NavComposeExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2024 The N's lab Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nlab.reminder.apps.ui | ||
|
||
import androidx.compose.animation.AnimatedContentTransitionScope | ||
import androidx.compose.animation.EnterTransition | ||
import androidx.compose.animation.ExitTransition | ||
import androidx.navigation.NavBackStackEntry | ||
|
||
/** | ||
* @author Thalys | ||
*/ | ||
typealias EnterTransitionFactory = | ||
AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards EnterTransition? | ||
typealias ExitTransitionFactory = | ||
AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards ExitTransition? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
app/src/main/java/com/nlab/reminder/apps/ui/PlaneatNavHost.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (C) 2024 The N's lab Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.nlab.reminder.apps.ui | ||
|
||
import androidx.compose.animation.AnimatedContentTransitionScope | ||
import androidx.compose.animation.EnterTransition | ||
import androidx.compose.animation.ExitTransition | ||
import androidx.compose.animation.core.EaseIn | ||
import androidx.compose.animation.core.EaseOut | ||
import androidx.compose.animation.core.LinearEasing | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.compose.NavHost | ||
import com.nlab.reminder.domain.feature.home.navigation.HomeEntryPointRoute | ||
import com.nlab.reminder.domain.feature.home.navigation.homeEntryPoint | ||
import com.nlab.reminder.domain.feature.home.navigation.homeScreen | ||
import com.nlab.reminder.domain.feature.schedule.all.navigation.allScheduleScreen | ||
import com.nlab.reminder.domain.feature.schedule.all.navigation.navigateToAllSchedule | ||
|
||
/** | ||
* @author Thalys | ||
*/ | ||
private const val HOME_TRANSITION_DURATION = 300 | ||
|
||
@Composable | ||
fun PlaneatNavHost( | ||
appState: PlaneatAppState, | ||
modifier: Modifier = Modifier | ||
) { | ||
val navController = appState.navController | ||
NavHost( | ||
navController = navController, | ||
startDestination = HomeEntryPointRoute, | ||
modifier = modifier, | ||
enterTransition = { EnterTransition.None }, | ||
exitTransition = { ExitTransition.None }, | ||
popEnterTransition = { EnterTransition.None }, | ||
popExitTransition = { ExitTransition.None } | ||
) { | ||
homeEntryPoint { | ||
val enterTransitionFactoryFromHome = createFromHomeEnterTransitionFactory() | ||
val popExitTransitionFactoryFromHome = createFromHomePopExitTransitionFactory() | ||
homeScreen( | ||
provideExitTransition = createHomeExitTransition(), | ||
providePopEnterTransition = createHomePopEnterTransitionFactory(), | ||
onAllScheduleClicked = { navController.navigateToAllSchedule() } | ||
) | ||
allScheduleScreen( | ||
provideEnterTransition = enterTransitionFactoryFromHome, | ||
providePopExitTransition = popExitTransitionFactoryFromHome, | ||
onBackClicked = { navController.popBackStack() } | ||
) | ||
} | ||
} | ||
} | ||
|
||
private fun createFromHomeEnterTransitionFactory(): EnterTransitionFactory = { | ||
slideIntoContainer( | ||
animationSpec = tween(HOME_TRANSITION_DURATION, easing = EaseIn), | ||
towards = AnimatedContentTransitionScope.SlideDirection.Start | ||
) | ||
} | ||
|
||
private fun createHomeExitTransition(): ExitTransitionFactory = { | ||
slideOutOfContainer( | ||
animationSpec = tween(HOME_TRANSITION_DURATION, easing = EaseOut), | ||
towards = AnimatedContentTransitionScope.SlideDirection.Start, | ||
targetOffset = { (it * 0.3f).toInt() } | ||
) + fadeOut(animationSpec = tween(HOME_TRANSITION_DURATION, easing = LinearEasing), targetAlpha = 0.2f) | ||
} | ||
|
||
private fun createHomePopEnterTransitionFactory(): EnterTransitionFactory = { | ||
slideIntoContainer( | ||
animationSpec = tween(HOME_TRANSITION_DURATION, easing = EaseIn), | ||
towards = AnimatedContentTransitionScope.SlideDirection.End, | ||
initialOffset = { (it * 0.3f).toInt() } | ||
) + fadeIn(animationSpec = tween(HOME_TRANSITION_DURATION, easing = LinearEasing), initialAlpha = 0.2f) | ||
} | ||
|
||
private fun createFromHomePopExitTransitionFactory(): ExitTransitionFactory = { | ||
slideOutOfContainer( | ||
animationSpec = tween(HOME_TRANSITION_DURATION, easing = EaseOut), | ||
towards = AnimatedContentTransitionScope.SlideDirection.End | ||
) | ||
} |
45 changes: 0 additions & 45 deletions
45
app/src/main/java/com/nlab/reminder/core/android/navigation/NavGraph.kt
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
app/src/main/java/com/nlab/reminder/core/android/navigation/NavGraphBuilder.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.