Updated on 2026-08-14
This commit is contained in:
parent
2e07841398
commit
d1bf017319
16 changed files with 84 additions and 20 deletions
1
core/navigation/.gitignore
vendored
Normal file
1
core/navigation/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
14
core/navigation/build.gradle.kts
Normal file
14
core/navigation/build.gradle.kts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
plugins {
|
||||
alias(deps.plugins.android.library)
|
||||
alias(deps.plugins.kotlin.android)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.tangem.core.navigation"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(deps.material)
|
||||
implementation(deps.reKotlin)
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.tangem.core.navigation
|
||||
|
||||
import android.view.View
|
||||
import androidx.transition.TransitionSet
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
data class FragmentShareTransition(
|
||||
val shareElements: List<ShareElement>,
|
||||
val enterTransitionSet: TransitionSet,
|
||||
val exitTransitionSet: TransitionSet,
|
||||
)
|
||||
|
||||
/**
|
||||
* For ease of use, the name is used as transitionName\name into the FragmentTransaction.addSharedElement
|
||||
*/
|
||||
class ShareElement(view: View, name: String? = null) {
|
||||
|
||||
val wView: WeakReference<View>
|
||||
val elementName: String
|
||||
|
||||
init {
|
||||
name?.let { view.transitionName = it }
|
||||
elementName = view.transitionName
|
||||
?: throw UnsupportedOperationException("ShareElement require the name")
|
||||
wView = WeakReference(view)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val imvFrontCard = "imv_front_card"
|
||||
const val imvBackCard = "imv_back_card"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.tangem.core.navigation
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.rekotlin.Action
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
sealed class NavigationAction : Action {
|
||||
|
||||
data class NavigateTo(
|
||||
val screen: AppScreen,
|
||||
val fragmentShareTransition: FragmentShareTransition? = null,
|
||||
val addToBackstack: Boolean = true,
|
||||
val bundle: Bundle? = null,
|
||||
) : NavigationAction()
|
||||
|
||||
data class PopBackTo(val screen: AppScreen? = null, val inclusive: Boolean = false) : NavigationAction()
|
||||
|
||||
data class OpenUrl(val url: String) : NavigationAction()
|
||||
|
||||
data class OpenDocument(val url: Uri) : NavigationAction()
|
||||
|
||||
object OpenBiometricsSettings : NavigationAction()
|
||||
|
||||
data class Share(val data: String) : NavigationAction()
|
||||
|
||||
data class ActivityCreated(val activity: WeakReference<AppCompatActivity>) : NavigationAction()
|
||||
|
||||
data class ActivityDestroyed(val activity: WeakReference<AppCompatActivity>) : NavigationAction()
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.tangem.core.navigation
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.rekotlin.StateType
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
data class NavigationState(
|
||||
val backStack: List<AppScreen> = emptyList(),
|
||||
val activity: WeakReference<AppCompatActivity>? = null,
|
||||
) : StateType
|
||||
|
||||
enum class AppScreen(val isDialogFragment: Boolean = false) {
|
||||
Home,
|
||||
Shop,
|
||||
Disclaimer,
|
||||
OnboardingNote,
|
||||
OnboardingWallet,
|
||||
OnboardingTwins,
|
||||
OnboardingOther,
|
||||
Wallet,
|
||||
WalletDetails,
|
||||
Send,
|
||||
Details,
|
||||
DetailsSecurity,
|
||||
CardSettings,
|
||||
AppSettings,
|
||||
ResetToFactory,
|
||||
AccessCodeRecovery,
|
||||
AddTokens,
|
||||
AddCustomToken,
|
||||
WalletConnectSessions,
|
||||
QrScan,
|
||||
ReferralProgram,
|
||||
Swap,
|
||||
Welcome,
|
||||
SaveWallet(isDialogFragment = true),
|
||||
WalletSelector(isDialogFragment = true),
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.tangem.core.navigation
|
||||
|
||||
/**
|
||||
* Navigation state holder
|
||||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
interface NavigationStateHolder {
|
||||
|
||||
/** Navigate by [action] */
|
||||
fun navigate(action: NavigationAction)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue