Updated on 2026-08-14
This commit is contained in:
parent
b4b6ecd764
commit
e8b81f400d
7 changed files with 176 additions and 20 deletions
|
|
@ -4,6 +4,8 @@ import com.tangem.core.ui.R
|
|||
import com.tangem.feature.wallet.presentation.common.state.NetworkGroupState
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenItemState.TokenOptionsState
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenListState
|
||||
import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensStateHolder
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletCardState
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.WalletStateHolder
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -105,6 +107,20 @@ internal object WalletPreviewData {
|
|||
|
||||
val loadingTokenItemState = TokenItemState.Loading(id = UUID.randomUUID().toString())
|
||||
|
||||
val organizeTokensState = OrganizeTokensStateHolder(
|
||||
tokens = TokenListState.GroupedByNetwork(
|
||||
groups = persistentListOf(),
|
||||
),
|
||||
header = OrganizeTokensStateHolder.HeaderConfig(
|
||||
onSortByBalanceClick = {},
|
||||
onGroupByNetworkClick = {},
|
||||
),
|
||||
actions = OrganizeTokensStateHolder.ActionsConfig(
|
||||
onApplyClick = {},
|
||||
onCancelClick = {},
|
||||
),
|
||||
)
|
||||
|
||||
private val draggableTokenList = persistentListOf(
|
||||
tokenItemDragState.copy(
|
||||
id = "token_1",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.tangem.feature.wallet.presentation.common.state
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
internal sealed interface NetworkGroupState {
|
||||
val id: String
|
||||
val networkName: String
|
||||
val tokens: ImmutableList<TokenItemState>
|
||||
|
||||
data class Draggable(
|
||||
override val id: String,
|
||||
override val networkName: String,
|
||||
override val tokens: ImmutableList<TokenItemState.Draggable>,
|
||||
) : NetworkGroupState
|
||||
|
||||
data class Content(
|
||||
override val id: String,
|
||||
override val networkName: String,
|
||||
override val tokens: ImmutableList<TokenItemState>,
|
||||
) : NetworkGroupState
|
||||
}
|
||||
|
|
@ -13,23 +13,4 @@ internal sealed interface TokenListState {
|
|||
data class Ungrouped(
|
||||
val tokens: ImmutableList<TokenItemState>,
|
||||
) : TokenListState
|
||||
}
|
||||
|
||||
@Immutable
|
||||
internal sealed interface NetworkGroupState {
|
||||
val id: String
|
||||
val networkName: String
|
||||
val tokens: ImmutableList<TokenItemState>
|
||||
|
||||
data class Draggable(
|
||||
override val id: String,
|
||||
override val networkName: String,
|
||||
override val tokens: ImmutableList<TokenItemState.Draggable>,
|
||||
) : NetworkGroupState
|
||||
|
||||
data class Content(
|
||||
override val id: String,
|
||||
override val networkName: String,
|
||||
override val tokens: ImmutableList<TokenItemState>,
|
||||
) : NetworkGroupState
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
// TODO: Remove after components implementation
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
package com.tangem.feature.wallet.presentation.organizetokens
|
||||
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.presentation.common.WalletPreviewData
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenListState
|
||||
|
||||
@Composable
|
||||
internal fun OrganizeTokensScreen(state: OrganizeTokensStateHolder) {
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopBar(state.header)
|
||||
},
|
||||
content = { paddingValues ->
|
||||
TokenList(
|
||||
state = state.tokens,
|
||||
modifier = Modifier.padding(paddingValues),
|
||||
)
|
||||
},
|
||||
floatingActionButtonPosition = FabPosition.Center,
|
||||
floatingActionButton = {
|
||||
Actions(state.actions)
|
||||
},
|
||||
contentColor = TangemTheme.colors.background.primary,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TokenList(state: TokenListState, modifier: Modifier = Modifier) {
|
||||
when (state) {
|
||||
is TokenListState.GroupedByNetwork -> {
|
||||
/* [REDACTED_TODO_COMMENT] */
|
||||
}
|
||||
is TokenListState.Ungrouped -> {
|
||||
/* [REDACTED_TODO_COMMENT] */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
private fun TopBar(config: OrganizeTokensStateHolder.HeaderConfig, modifier: Modifier = Modifier) {
|
||||
TopAppBar(
|
||||
title = {
|
||||
Text(
|
||||
text = "Organize tokens", // TODO: Move to resources
|
||||
style = TangemTheme.typography.subtitle1,
|
||||
color = TangemTheme.colors.text.primary1,
|
||||
maxLines = 1,
|
||||
)
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = TangemTheme.colors.background.secondary,
|
||||
titleContentColor = TangemTheme.colors.text.primary1,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Actions(config: OrganizeTokensStateHolder.ActionsConfig, modifier: Modifier = Modifier) {
|
||||
// TODO: Implement list apply and cancel actions
|
||||
}
|
||||
|
||||
// region Preview
|
||||
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Composable
|
||||
private fun OrganizeTokensScreenPreview_Light() {
|
||||
TangemTheme {
|
||||
OrganizeTokensScreen(state = WalletPreviewData.organizeTokensState)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Composable
|
||||
private fun OrganizeTokensScreenPreview_Dark() {
|
||||
TangemTheme(isDark = true) {
|
||||
OrganizeTokensScreen(state = WalletPreviewData.organizeTokensState)
|
||||
}
|
||||
}
|
||||
// endregion Preview
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.tangem.feature.wallet.presentation.organizetokens
|
||||
|
||||
import com.tangem.feature.wallet.presentation.common.state.TokenListState
|
||||
|
||||
internal data class OrganizeTokensStateHolder(
|
||||
val tokens: TokenListState,
|
||||
val header: HeaderConfig,
|
||||
val actions: ActionsConfig,
|
||||
) {
|
||||
|
||||
data class HeaderConfig(
|
||||
val onSortByBalanceClick: () -> Unit,
|
||||
val onGroupByNetworkClick: () -> Unit,
|
||||
)
|
||||
|
||||
data class ActionsConfig(
|
||||
val onApplyClick: () -> Unit,
|
||||
val onCancelClick: () -> Unit,
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.tangem.feature.wallet.presentation.organizetokens
|
||||
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.tangem.feature.wallet.presentation.common.WalletPreviewData
|
||||
import com.tangem.feature.wallet.presentation.router.InnerWalletRouter
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import javax.inject.Inject
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
@HiltViewModel
|
||||
internal class OrganizeTokensViewModel @Inject constructor() : ViewModel() {
|
||||
|
||||
var router: InnerWalletRouter by Delegates.notNull()
|
||||
|
||||
var uiState: OrganizeTokensStateHolder by mutableStateOf(getInitialState())
|
||||
private set
|
||||
|
||||
private fun getInitialState(): OrganizeTokensStateHolder = WalletPreviewData.organizeTokensState
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ import androidx.navigation.compose.composable
|
|||
import androidx.navigation.compose.rememberNavController
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.feature.wallet.presentation.WalletFragment
|
||||
import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensScreen
|
||||
import com.tangem.feature.wallet.presentation.organizetokens.OrganizeTokensViewModel
|
||||
import com.tangem.feature.wallet.presentation.wallet.ui.WalletScreen
|
||||
import com.tangem.feature.wallet.presentation.wallet.viewmodels.WalletViewModel
|
||||
import kotlin.properties.Delegates
|
||||
|
|
@ -35,7 +37,11 @@ internal class DefaultWalletRouter : InnerWalletRouter {
|
|||
|
||||
composable(WalletScreens.ORGANIZE_TOKENS.name) {
|
||||
BackHandler(onBack = ::popBackStack)
|
||||
// TODO: Add OrganizeTokensScreen
|
||||
|
||||
val viewModel: OrganizeTokensViewModel = hiltViewModel<OrganizeTokensViewModel>()
|
||||
.apply { router = this@DefaultWalletRouter }
|
||||
|
||||
OrganizeTokensScreen(state = viewModel.uiState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue