Updated on 2026-08-14
This commit is contained in:
parent
99d7eec8cd
commit
e6530aa1ee
4 changed files with 28 additions and 8 deletions
|
|
@ -47,9 +47,9 @@ internal class DefaultWalletConnectEntryComponent @AssistedInject constructor(
|
|||
config: ConnectionsInnerRoute,
|
||||
componentContext: ComponentContext,
|
||||
): ComposableContentComponent = when (config) {
|
||||
ConnectionsInnerRoute.Connections -> ConnectionsComponent(
|
||||
ConnectionsInnerRoute.Connections -> WcConnectionsComponent(
|
||||
appComponentContext = childByContext(componentContext),
|
||||
params = ConnectionsComponent.Params(params.userWalletId),
|
||||
params = WcConnectionsComponent.Params(params.userWalletId),
|
||||
)
|
||||
ConnectionsInnerRoute.QrScan -> TODO("[REDACTED_JIRA]")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.tangem.features.walletconnect.connections.components
|
||||
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.arkivanov.decompose.ComponentContext
|
||||
|
|
@ -13,16 +15,19 @@ import com.tangem.core.decompose.context.childByContext
|
|||
import com.tangem.core.decompose.model.getOrCreateModel
|
||||
import com.tangem.core.ui.decompose.ComposableBottomSheetComponent
|
||||
import com.tangem.core.ui.decompose.ComposableContentComponent
|
||||
import com.tangem.core.ui.message.EventMessageEffect
|
||||
import com.tangem.core.ui.message.EventMessageHandler
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.features.walletconnect.connections.model.WcConnectionsModel
|
||||
import com.tangem.features.walletconnect.connections.routes.WcConnectionsBottomSheetConfig
|
||||
import com.tangem.features.walletconnect.connections.ui.WcConnectionsContent
|
||||
|
||||
internal class ConnectionsComponent(
|
||||
internal class WcConnectionsComponent(
|
||||
appComponentContext: AppComponentContext,
|
||||
params: Params,
|
||||
) : AppComponentContext by appComponentContext, ComposableContentComponent {
|
||||
|
||||
private val messageHandler = EventMessageHandler()
|
||||
private val model: WcConnectionsModel = getOrCreateModel(params)
|
||||
private val bottomSheetSlot = childSlot(
|
||||
source = model.bottomSheetNavigation,
|
||||
|
|
@ -35,8 +40,11 @@ internal class ConnectionsComponent(
|
|||
override fun Content(modifier: Modifier) {
|
||||
val state by model.uiState.collectAsStateWithLifecycle()
|
||||
val bottomSheet by bottomSheetSlot.subscribeAsState()
|
||||
WcConnectionsContent(modifier = modifier, state = state)
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
|
||||
WcConnectionsContent(modifier = modifier, state = state, snackbarHostState = snackbarHostState)
|
||||
|
||||
EventMessageEffect(messageHandler = messageHandler, snackbarHostState = snackbarHostState)
|
||||
bottomSheet.child?.instance?.BottomSheet()
|
||||
}
|
||||
|
||||
|
|
@ -44,9 +52,10 @@ internal class ConnectionsComponent(
|
|||
config: WcConnectionsBottomSheetConfig,
|
||||
componentContext: ComponentContext,
|
||||
): ComposableBottomSheetComponent {
|
||||
val context = childByContext(componentContext = componentContext, messageHandler = messageHandler)
|
||||
return when (config) {
|
||||
is WcConnectionsBottomSheetConfig.ConnectedApp -> WcConnectedAppInfoComponent(
|
||||
appComponentContext = childByContext(componentContext),
|
||||
appComponentContext = context,
|
||||
params = WcConnectedAppInfoComponent.Params(
|
||||
topic = config.topic,
|
||||
onDismiss = model.bottomSheetNavigation::dismiss,
|
||||
|
|
@ -22,7 +22,7 @@ import com.tangem.domain.walletconnect.model.WcPairRequest
|
|||
import com.tangem.domain.walletconnect.model.WcSession
|
||||
import com.tangem.domain.walletconnect.usecase.WcSessionsUseCase
|
||||
import com.tangem.domain.walletconnect.usecase.disconnect.WcDisconnectUseCase
|
||||
import com.tangem.features.walletconnect.connections.components.ConnectionsComponent
|
||||
import com.tangem.features.walletconnect.connections.components.WcConnectionsComponent
|
||||
import com.tangem.features.walletconnect.connections.entity.WcConnectionsState
|
||||
import com.tangem.features.walletconnect.connections.entity.WcConnectionsTopAppBarConfig
|
||||
import com.tangem.features.walletconnect.connections.model.transformers.WcSessionsTransformer
|
||||
|
|
@ -48,7 +48,7 @@ internal class WcConnectionsModel @Inject constructor(
|
|||
paramsContainer: ParamsContainer,
|
||||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<ConnectionsComponent.Params>()
|
||||
private val params = paramsContainer.require<WcConnectionsComponent.Params>()
|
||||
val uiState: StateFlow<WcConnectionsState>
|
||||
field = MutableStateFlow<WcConnectionsState>(getInitialState())
|
||||
val bottomSheetNavigation: SlotNavigation<WcConnectionsBottomSheetConfig> = SlotNavigation()
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.tangem.core.ui.components.BottomFade
|
|||
import com.tangem.core.ui.components.PrimaryButton
|
||||
import com.tangem.core.ui.components.dropdownmenu.TangemDropdownItem
|
||||
import com.tangem.core.ui.components.dropdownmenu.TangemDropdownMenu
|
||||
import com.tangem.core.ui.components.snackbar.TangemSnackbarHost
|
||||
import com.tangem.core.ui.extensions.resolveReference
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
|
|
@ -41,10 +42,20 @@ import com.tangem.features.walletconnect.impl.R
|
|||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Composable
|
||||
internal fun WcConnectionsContent(state: WcConnectionsState, modifier: Modifier = Modifier) {
|
||||
internal fun WcConnectionsContent(
|
||||
state: WcConnectionsState,
|
||||
modifier: Modifier = Modifier,
|
||||
snackbarHostState: SnackbarHostState = remember { SnackbarHostState() },
|
||||
) {
|
||||
Scaffold(
|
||||
modifier = modifier,
|
||||
containerColor = TangemTheme.colors.background.secondary,
|
||||
snackbarHost = {
|
||||
TangemSnackbarHost(
|
||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 16.dp),
|
||||
hostState = snackbarHostState,
|
||||
)
|
||||
},
|
||||
topBar = {
|
||||
ConnectionsTopBar(
|
||||
modifier = Modifier.statusBarsPadding(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue