Updated on 2026-08-14
This commit is contained in:
parent
b99d91f31b
commit
bdb8389c3f
8 changed files with 19 additions and 7 deletions
|
|
@ -26,6 +26,10 @@ fun Store<*>.dispatchOpenUrl(url: String) {
|
|||
store.dispatch(NavigationAction.OpenUrl(url))
|
||||
}
|
||||
|
||||
fun Store<*>.dispatchShare(url: String) {
|
||||
store.dispatch(NavigationAction.Share(url))
|
||||
}
|
||||
|
||||
fun Store<*>.dispatchNotification(resId: Int) {
|
||||
scope.launch(Dispatchers.Main) {
|
||||
store.dispatch(GlobalAction.ShowNotification(resId))
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ sealed class AppDialog : StateDialog {
|
|||
data class AddressInfoDialog(
|
||||
val addressData: AddressData,
|
||||
val onCopyAddress: VoidCallback,
|
||||
val onExploreAddress: VoidCallback
|
||||
val onShareAddress: VoidCallback
|
||||
) : AppDialog()
|
||||
}
|
||||
|
|
@ -15,6 +15,8 @@ sealed class NavigationAction : Action {
|
|||
|
||||
data class OpenUrl(val url: String) : NavigationAction()
|
||||
|
||||
data class Share(val data: String) : NavigationAction()
|
||||
|
||||
data class ActivityCreated(val activity: WeakReference<FragmentActivity>) : NavigationAction()
|
||||
object ActivityDestroyed : NavigationAction()
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.tap.common.redux.navigation
|
|||
import com.tangem.tap.common.CustomTabsManager
|
||||
import com.tangem.tap.common.extensions.openFragment
|
||||
import com.tangem.tap.common.extensions.popBackTo
|
||||
import com.tangem.tap.common.extensions.shareText
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import org.rekotlin.Middleware
|
||||
|
||||
|
|
@ -31,6 +32,11 @@ val navigationMiddleware: Middleware<AppState> = { dispatch, state ->
|
|||
CustomTabsManager().openUrl(action.url, it)
|
||||
}
|
||||
}
|
||||
is NavigationAction.Share -> {
|
||||
navState?.activity?.get()?.let {
|
||||
it.shareText(action.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
next(action)
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ class AddressInfoBottomSheetDialog(
|
|||
context.copyToClipboard(data.address)
|
||||
stateDialog.onCopyAddress()
|
||||
}
|
||||
btn_fl_explore.setOnClickListener {
|
||||
stateDialog.onExploreAddress()
|
||||
btn_fl_share.setOnClickListener {
|
||||
stateDialog.onShareAddress()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +138,7 @@ private fun handleNoteAction(action: Action, dispatch: DispatchFunction) {
|
|||
val appDialog = AppDialog.AddressInfoDialog(
|
||||
addressData,
|
||||
onCopyAddress = { store.dispatchToastNotification(addressWasCopied) },
|
||||
onExploreAddress = { store.dispatchOpenUrl(addressData.exploreUrl) }
|
||||
onShareAddress = { store.dispatchShare(addressData.shareUrl) }
|
||||
)
|
||||
store.dispatchDialogShow(appDialog)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ private fun handle(action: Action, dispatch: DispatchFunction) {
|
|||
val appDialog = AppDialog.AddressInfoDialog(
|
||||
addressData,
|
||||
onCopyAddress = { store.dispatchToastNotification(addressWasCopied) },
|
||||
onExploreAddress = { store.dispatchOpenUrl(addressData.exploreUrl) }
|
||||
onShareAddress = { store.dispatchShare(addressData.shareUrl) }
|
||||
)
|
||||
store.dispatchDialogShow(appDialog)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
android:backgroundTint="@color/lightGray0"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_fl_explore"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_fl_share"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/guideline3">
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/btn_fl_explore"
|
||||
android:id="@+id/btn_fl_share"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue