Destination Diff
9 removals
Words removed | 27 |
Total words | 270 |
Words removed (%) | 10.00 |
101 lines
7 additions
Words added | 7 |
Total words | 250 |
Words added (%) | 2.80 |
99 lines
package com.rapido.payment.presentation.ui.destinations
package com.rapido.payment.presentation.ui.destinations
import android.os.Bundle
import android.os.Bundle
import androidx.annotation.RestrictTo
import androidx.annotation.RestrictTo
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composable
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.SavedStateHandle
import androidx.navigation.NamedNavArgument
import androidx.navigation.NamedNavArgument
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavDeepLink
import androidx.navigation.NavDeepLink
import androidx.navigation.NavHostController
import androidx.navigation.NavHostController
import androidx.navigation.NavType
import androidx.navigation.NavType
import androidx.navigation.navArgument
import androidx.navigation.navArgument
import androidx.navigation.navDeepLink
import androidx.navigation.navDeepLink
import com.ramcosta.composedestinations.navargs.primitives.DestinationsStringNavType
import com.ramcosta.composedestinations.navargs.primitives.DestinationsStringNavType
import com.ramcosta.composedestinations.navigation.DependenciesContainerBuilder
import com.ramcosta.composedestinations.navigation.DependenciesContainerBuilder
import com.ramcosta.composedestinations.navigation.DestinationDependenciesContainer
import com.ramcosta.composedestinations.navigation.DestinationDependenciesContainer
import com.ramcosta.composedestinations.navigation.require
import com.ramcosta.composedestinations.navigation.require
import com.ramcosta.composedestinations.scope.DestinationScope
import com.ramcosta.composedestinations.scope.DestinationScope
import com.ramcosta.composedestinations.spec.DestinationSpec
import com.ramcosta.composedestinations.spec.DestinationSpec
import com.ramcosta.composedestinations.spec.DestinationStyle
import com.ramcosta.composedestinations.spec.DestinationStyle
import com.ramcosta.composedestinations.spec.Direction
import com.ramcosta.composedestinations.spec.Direction
import com.ramcosta.composedestinations.spec.DirectionDestinationSpec
import com.ramcosta.composedestinations.spec.DirectionDestinationSpec
import com.ramcosta.composedestinations.spec.NavGraphSpec
import com.ramcosta.composedestinations.spec.NavGraphSpec
import com.ramcosta.composedestinations.spec.Route
import com.ramcosta.composedestinations.spec.Route
import com.rapido.coreui.transitions.ScreenToScreenTransition
import com.rapido.coreui.transitions.ScreenToScreenTransition
import com.rapido.payment.presentation.ui.destinations.PaymentScreenDestination.NavArgs
import com.rapido.payment.presentation.ui.destinations.PaymentScreenDestination.NavArgs
import com.rapido.payment.presentation.ui.navtype.linkableNavType
import com.rapido.payment.presentation.ui.navtype.linkableNavType
import com.rapido.payment.presentation.ui.payment.screen.PaymentScreen
import com.rapido.payment.presentation.ui.payment.screen.PaymentScreen
import com.rapido.paymentmanager.domain.model.wallet.Wallet.Linkable
import com.rapido.paymentmanager.domain.model.wallet.Wallet.Linkable
@OptIn(ExperimentalAnimationApi::class)
@OptIn(ExperimentalAnimationApi::class)
public object PaymentScreenDestination : PaymentTypedDestination<PaymentScreenDestination.NavArgs> {
public object PaymentScreenDestination : PaymentTypedDestination<PaymentScreenDestination.NavArgs> {
override fun invoke(navArgs: NavArgs): Direction = with(navArgs) {
override fun invoke(navArgs: NavArgs): Direction = with(navArgs) {
invoke(source, linkableWallet)
invoke(source, linkableWallet)
}
}
public operator fun invoke(
public operator fun invoke(
source: String = "menu",
source: String,
linkableWallet: Linkable?,
linkableWallet: Linkable?,
): Direction {
): Direction {
return Direction(
return Direction(
route = "$baseRoute" +
route = "$baseRoute" +
"?source=${DestinationsStringNavType.serializeValue("source", source)}" +
"/${DestinationsStringNavType.serializeValue("source", source)}" +
"&linkableWallet=${linkableNavType.serializeValue(linkableWallet)}"
"?linkableWallet=${linkableNavType.serializeValue(linkableWallet)}"
)
)
}
}
@get:RestrictTo(RestrictTo.Scope.SUBCLASSES)
@get:RestrictTo(RestrictTo.Scope.SUBCLASSES)
override val baseRoute: String = "payment_screen"
override val baseRoute: String = "payment_screen"
override val route: String = "$baseRoute?source={source}&linkableWallet={linkableWallet}"
override val route: String = "$baseRoute/{source}?linkableWallet={linkableWallet}"
override val arguments: List<NamedNavArgument> get() = listOf(
override val arguments: List<NamedNavArgument> get() = listOf(
navArgument("source") {
navArgument("source") {
type = DestinationsStringNavType
type = DestinationsStringNavType
val defValue: String = "menu"
defaultValue = defValue
},
},
navArgument("linkableWallet") {
navArgument("linkableWallet") {
type = linkableNavType
type = linkableNavType
nullable = true
nullable = true
}
}
)
)
override val style: DestinationStyle = ScreenToScreenTransition
override val style: DestinationStyle = ScreenToScreenTransition
@Composable
@Composable
override fun DestinationScope<NavArgs>.Content() {
override fun DestinationScope<NavArgs>.Content() {
val dependencyContainer = buildDependencies()
val dependencyContainer = buildDependencies()
val (source, linkableWallet) = navArgs
val (source, linkableWallet) = navArgs
val animatedVisibilityScope = (this as AnimatedVisibilityScope)
val animatedVisibilityScope = (this as AnimatedVisibilityScope)
animatedVisibilityScope.PaymentScreen(
animatedVisibilityScope.PaymentScreen(
source = source,
source = source,
navigator = dependencyContainer.require(),
navigator = dependencyContainer.require(),
linkableWallet = linkableWallet,
linkableWallet = linkableWallet,
resultBackNavigator = dependencyContainer.require()
resultBackNavigator = dependencyContainer.require()
)
)
}
}
override fun argsFrom(bundle: Bundle?): NavArgs {
override fun argsFrom(bundle: Bundle?): NavArgs {
return NavArgs(
return NavArgs(
source = DestinationsStringNavType.safeGet(bundle, "source") ?: throw RuntimeException("'source' argument is not mandatory and not nullable but was not present!"),
source = DestinationsStringNavType.safeGet(bundle, "source") ?: throw RuntimeException("'source' argument is mandatory, but was not present!"),
linkableWallet = linkableNavType.safeGet(bundle, "linkableWallet"),
linkableWallet = linkableNavType.safeGet(bundle, "linkableWallet"),
)
)
}
}
override fun argsFrom(savedStateHandle: SavedStateHandle): NavArgs {
override fun argsFrom(savedStateHandle: SavedStateHandle): NavArgs {
return NavArgs(
return NavArgs(
source = DestinationsStringNavType.get(savedStateHandle, "source") ?: throw RuntimeException("'source' argument is not mandatory and not nullable but was not present!"),
source = DestinationsStringNavType.get(savedStateHandle, "source") ?: throw RuntimeException("'source' argument is mandatory, but was not present!"),
linkableWallet = linkableNavType.get(savedStateHandle, "linkableWallet"),
linkableWallet = linkableNavType.get(savedStateHandle, "linkableWallet"),
)
)
}
}
public data class NavArgs(
public data class NavArgs(
val source: String = "menu",
val source: String,
val linkableWallet: Linkable?,
val linkableWallet: Linkable?,
)
)
}
}