-
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 branch 'develop' into feature/communication/message-area-listing
- Loading branch information
Showing
18 changed files
with
452 additions
and
311 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...kotlin/de/tum/informatics/www1/artemis/native_app/core/ui/navigation/DefaultTransition.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,57 @@ | ||
package de.tum.informatics.www1.artemis.native_app.core.ui.navigation | ||
|
||
import androidx.compose.animation.AnimatedContentTransitionScope | ||
import androidx.compose.animation.EnterTransition | ||
import androidx.compose.animation.ExitTransition | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.animation.fadeIn | ||
import androidx.compose.animation.fadeOut | ||
import androidx.compose.animation.slideInHorizontally | ||
import androidx.compose.animation.slideOutHorizontally | ||
import androidx.compose.animation.togetherWith | ||
|
||
|
||
object DefaultTransition { | ||
const val duration = 220 | ||
|
||
val fadeIn = fadeIn(tween(duration)) | ||
val fadeOut = fadeOut(tween(duration)) | ||
|
||
val navigateForward = enter togetherWith exit | ||
val navigateBack = popEnter togetherWith popExit | ||
val navigateNeutral = fadeIn togetherWith fadeOut | ||
|
||
val enter | ||
get() = slideIn(AnimatedContentTransitionScope.SlideDirection.Left) | ||
|
||
val exit | ||
get() = slideOut(AnimatedContentTransitionScope.SlideDirection.Left) | ||
|
||
val popEnter | ||
get() = slideIn(AnimatedContentTransitionScope.SlideDirection.Right) | ||
|
||
val popExit | ||
get() = slideOut(AnimatedContentTransitionScope.SlideDirection.Right) | ||
|
||
fun slideIn( | ||
direction: AnimatedContentTransitionScope.SlideDirection | ||
): EnterTransition = slideInHorizontally( | ||
animationSpec = tween(duration) | ||
) { width -> | ||
return@slideInHorizontally when(direction) { | ||
AnimatedContentTransitionScope.SlideDirection.Left -> width | ||
else -> - width | ||
} | ||
} + fadeIn | ||
|
||
fun slideOut( | ||
direction: AnimatedContentTransitionScope.SlideDirection | ||
): ExitTransition = slideOutHorizontally( | ||
animationSpec = tween(duration) | ||
) { width -> | ||
return@slideOutHorizontally when(direction) { | ||
AnimatedContentTransitionScope.SlideDirection.Left -> - width | ||
else -> width | ||
} | ||
} + fadeOut | ||
} |
46 changes: 46 additions & 0 deletions
46
...lin/de/tum/informatics/www1/artemis/native_app/core/ui/navigation/navigation_animation.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,46 @@ | ||
package de.tum.informatics.www1.artemis.native_app.core.ui.navigation | ||
|
||
import androidx.compose.animation.AnimatedContentScope | ||
import androidx.compose.animation.AnimatedContentTransitionScope | ||
import androidx.compose.animation.EnterTransition | ||
import androidx.compose.animation.ExitTransition | ||
import androidx.compose.animation.SizeTransform | ||
import androidx.compose.runtime.Composable | ||
import androidx.navigation.NavBackStackEntry | ||
import androidx.navigation.NavDeepLink | ||
import androidx.navigation.NavGraphBuilder | ||
import androidx.navigation.NavType | ||
import androidx.navigation.compose.composable | ||
import kotlin.reflect.KType | ||
|
||
|
||
inline fun <reified T : Any> NavGraphBuilder.animatedComposable( | ||
typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(), | ||
deepLinks: List<NavDeepLink> = emptyList(), | ||
noinline enterTransition: | ||
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards | ||
EnterTransition?)? = { DefaultTransition.enter }, | ||
noinline exitTransition: | ||
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards | ||
ExitTransition?)? = { DefaultTransition.exit }, | ||
noinline popEnterTransition: | ||
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards | ||
EnterTransition?)? = { DefaultTransition.popEnter }, | ||
noinline popExitTransition: | ||
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards | ||
ExitTransition?)? = { DefaultTransition.popExit }, | ||
noinline sizeTransform: | ||
(AnimatedContentTransitionScope<NavBackStackEntry>.() -> @JvmSuppressWildcards | ||
SizeTransform?)? = | ||
null, | ||
noinline content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit | ||
) = composable<T>( | ||
enterTransition = enterTransition, | ||
exitTransition = exitTransition, | ||
popEnterTransition = popEnterTransition, | ||
popExitTransition = popExitTransition, | ||
sizeTransform = sizeTransform, | ||
typeMap = typeMap, | ||
deepLinks = deepLinks, | ||
content = content | ||
) |
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
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
Oops, something went wrong.