Updated on 2026-08-14
This commit is contained in:
parent
43b0e6b83b
commit
477a3c11dd
7 changed files with 95 additions and 71 deletions
|
|
@ -15,14 +15,15 @@ dependencies {
|
|||
implementation(deps.androidx.activity.compose)
|
||||
|
||||
/** Compose */
|
||||
implementation(deps.compose.accompanist.systemUiController)
|
||||
implementation(deps.compose.foundation)
|
||||
implementation(deps.compose.material)
|
||||
implementation(deps.compose.material3)
|
||||
implementation(deps.compose.foundation)
|
||||
implementation(deps.compose.navigation)
|
||||
implementation(deps.compose.navigation.hilt)
|
||||
implementation(deps.compose.ui)
|
||||
implementation(deps.compose.ui.tooling)
|
||||
implementation(deps.compose.accompanist.systemUiController)
|
||||
implementation(deps.compose.ui.utils)
|
||||
|
||||
/** DI */
|
||||
implementation(deps.hilt.android)
|
||||
|
|
@ -52,5 +53,6 @@ dependencies {
|
|||
|
||||
/** Other modules */
|
||||
implementation(projects.common.routing)
|
||||
implementation(projects.libs.blockchainSdk)
|
||||
implementation(projects.libs.crypto)
|
||||
}
|
||||
|
|
@ -23,12 +23,14 @@ import com.tangem.feature.tester.presentation.excludedblockchains.ExcludedBlockc
|
|||
import com.tangem.feature.tester.presentation.excludedblockchains.ExcludedBlockchainsViewModel
|
||||
import com.tangem.feature.tester.presentation.featuretoggles.ui.FeatureTogglesScreen
|
||||
import com.tangem.feature.tester.presentation.featuretoggles.viewmodels.FeatureTogglesViewModel
|
||||
import com.tangem.feature.tester.presentation.menu.state.TesterMenuContentState
|
||||
import com.tangem.feature.tester.presentation.menu.state.TesterMenuUM
|
||||
import com.tangem.feature.tester.presentation.menu.state.TesterMenuUM.ButtonUM
|
||||
import com.tangem.feature.tester.presentation.menu.ui.TesterMenuScreen
|
||||
import com.tangem.feature.tester.presentation.navigation.InnerTesterRouter
|
||||
import com.tangem.feature.tester.presentation.navigation.TesterScreen
|
||||
import com.tangem.features.tester.api.TesterRouter
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
import javax.inject.Inject
|
||||
|
||||
/** Activity for testers */
|
||||
|
|
@ -70,14 +72,26 @@ internal class TesterActivity : ComposeActivity() {
|
|||
NavHost(navController = navController, startDestination = TesterScreen.MENU.name) {
|
||||
composable(route = TesterScreen.MENU.name) {
|
||||
TesterMenuScreen(
|
||||
state = TesterMenuContentState(
|
||||
state = TesterMenuUM(
|
||||
onBackClick = { appRouter.pop { finish() } },
|
||||
onFeatureTogglesClick = { innerTesterRouter.open(TesterScreen.FEATURE_TOGGLES) },
|
||||
onEnvironmentTogglesClick = { innerTesterRouter.open(TesterScreen.ENVIRONMENTS_TOGGLES) },
|
||||
onExcludedBlockchainsClick = {
|
||||
innerTesterRouter.open(TesterScreen.EXCLUDED_BLOCKCHAINS)
|
||||
buttons = persistentSetOf(
|
||||
ButtonUM.FEATURE_TOGGLES,
|
||||
ButtonUM.EXCLUDED_BLOCKCHAINS,
|
||||
ButtonUM.ENVIRONMENT_TOGGLES,
|
||||
ButtonUM.BLOCKCHAIN_PROVIDERS,
|
||||
ButtonUM.TESTER_ACTIONS,
|
||||
),
|
||||
onButtonClick = {
|
||||
val route = when (it) {
|
||||
ButtonUM.FEATURE_TOGGLES -> TesterScreen.FEATURE_TOGGLES
|
||||
ButtonUM.EXCLUDED_BLOCKCHAINS -> TesterScreen.EXCLUDED_BLOCKCHAINS
|
||||
ButtonUM.ENVIRONMENT_TOGGLES -> TesterScreen.ENVIRONMENTS_TOGGLES
|
||||
ButtonUM.BLOCKCHAIN_PROVIDERS -> TesterScreen.BLOCKCHAIN_PROVIDERS
|
||||
ButtonUM.TESTER_ACTIONS -> TesterScreen.TESTER_ACTIONS
|
||||
}
|
||||
|
||||
innerTesterRouter.open(route)
|
||||
},
|
||||
onTesterActionsClick = { innerTesterRouter.open(TesterScreen.TESTER_ACTIONS) },
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
package com.tangem.feature.tester.presentation.menu.state
|
||||
|
||||
/**
|
||||
* Content state of tester menu screen
|
||||
*
|
||||
* @property onBackClick the lambda to be invoked when back button is pressed
|
||||
* @property onFeatureTogglesClick the lambda to be invoked when feature toggles button is pressed
|
||||
* @property onEnvironmentTogglesClick the lambda to be invoked when environment toggles button is pressed
|
||||
* @property onTesterActionsClick the lambda to be invoked when tester actions button is pressed
|
||||
*/
|
||||
data class TesterMenuContentState(
|
||||
val onBackClick: () -> Unit,
|
||||
val onFeatureTogglesClick: () -> Unit,
|
||||
val onEnvironmentTogglesClick: () -> Unit,
|
||||
val onExcludedBlockchainsClick: () -> Unit,
|
||||
val onTesterActionsClick: () -> Unit,
|
||||
)
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.tangem.feature.tester.presentation.menu.state
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import com.tangem.feature.tester.impl.R
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
|
||||
/**
|
||||
* Content state of tester menu screen
|
||||
*
|
||||
* @property onBackClick the lambda to be invoked when back button is pressed
|
||||
* @property buttons list of buttons
|
||||
* @property onButtonClick the lambda to be invoked when tester button is pressed
|
||||
*/
|
||||
data class TesterMenuUM(
|
||||
val onBackClick: () -> Unit,
|
||||
val buttons: ImmutableSet<ButtonUM>,
|
||||
val onButtonClick: (ButtonUM) -> Unit,
|
||||
) {
|
||||
|
||||
enum class ButtonUM(@StringRes val textResId: Int) {
|
||||
FEATURE_TOGGLES(R.string.feature_toggles),
|
||||
EXCLUDED_BLOCKCHAINS(R.string.excluded_blockchains),
|
||||
ENVIRONMENT_TOGGLES(R.string.environment_toggles),
|
||||
BLOCKCHAIN_PROVIDERS(R.string.blockchain_providers),
|
||||
TESTER_ACTIONS(R.string.tester_actions),
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,71 +2,62 @@ package com.tangem.feature.tester.presentation.menu.ui
|
|||
|
||||
import android.content.res.Configuration
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.components.PrimaryButton
|
||||
import com.tangem.core.ui.components.appbar.AppBarWithBackButton
|
||||
import com.tangem.core.ui.extensions.stringResourceSafe
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.ui.res.TangemThemePreview
|
||||
import com.tangem.feature.tester.impl.R
|
||||
import com.tangem.feature.tester.presentation.menu.state.TesterMenuContentState
|
||||
import com.tangem.feature.tester.presentation.menu.state.TesterMenuUM
|
||||
import com.tangem.feature.tester.presentation.menu.state.TesterMenuUM.ButtonUM
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
/**
|
||||
* Screen with functionality for testers
|
||||
*
|
||||
* @param state screen state
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
internal fun TesterMenuScreen(state: TesterMenuContentState) {
|
||||
internal fun TesterMenuScreen(state: TesterMenuUM) {
|
||||
BackHandler(onBack = state.onBackClick)
|
||||
|
||||
Column(
|
||||
LazyColumn(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(TangemTheme.colors.background.secondary),
|
||||
.background(TangemTheme.colors.background.primary),
|
||||
) {
|
||||
stickyHeader {
|
||||
AppBarWithBackButton(
|
||||
onBackClick = state.onBackClick,
|
||||
text = stringResourceSafe(id = R.string.tester_menu),
|
||||
containerColor = TangemTheme.colors.background.primary,
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
items(
|
||||
items = state.buttons.toImmutableList(),
|
||||
key = ButtonUM::textResId,
|
||||
contentType = { "button" },
|
||||
) { button ->
|
||||
PrimaryButton(
|
||||
text = stringResourceSafe(button.textResId),
|
||||
onClick = { state.onButtonClick(button) },
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
horizontal = TangemTheme.dimens.spacing18,
|
||||
vertical = TangemTheme.dimens.spacing8,
|
||||
)
|
||||
.verticalScroll(rememberScrollState()),
|
||||
verticalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing16),
|
||||
) {
|
||||
PrimaryButton(
|
||||
text = stringResourceSafe(R.string.feature_toggles),
|
||||
onClick = state.onFeatureTogglesClick,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
|
||||
PrimaryButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResourceSafe(R.string.excluded_blockchains),
|
||||
onClick = state.onExcludedBlockchainsClick,
|
||||
)
|
||||
|
||||
PrimaryButton(
|
||||
text = stringResourceSafe(R.string.environment_toggles),
|
||||
onClick = state.onEnvironmentTogglesClick,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
|
||||
PrimaryButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResourceSafe(id = R.string.tester_actions),
|
||||
onClick = state.onTesterActionsClick,
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -78,12 +69,16 @@ internal fun TesterMenuScreen(state: TesterMenuContentState) {
|
|||
private fun PreviewTesterMenuScreen() {
|
||||
TangemThemePreview {
|
||||
TesterMenuScreen(
|
||||
state = TesterMenuContentState(
|
||||
state = TesterMenuUM(
|
||||
onBackClick = {},
|
||||
onFeatureTogglesClick = {},
|
||||
onEnvironmentTogglesClick = {},
|
||||
onExcludedBlockchainsClick = {},
|
||||
onTesterActionsClick = {},
|
||||
buttons = persistentSetOf(
|
||||
ButtonUM.FEATURE_TOGGLES,
|
||||
ButtonUM.EXCLUDED_BLOCKCHAINS,
|
||||
ButtonUM.ENVIRONMENT_TOGGLES,
|
||||
ButtonUM.BLOCKCHAIN_PROVIDERS,
|
||||
ButtonUM.TESTER_ACTIONS,
|
||||
),
|
||||
onButtonClick = {},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,4 +11,5 @@ internal enum class TesterScreen {
|
|||
ENVIRONMENTS_TOGGLES,
|
||||
TESTER_ACTIONS,
|
||||
EXCLUDED_BLOCKCHAINS,
|
||||
BLOCKCHAIN_PROVIDERS,
|
||||
}
|
||||
|
|
@ -11,4 +11,5 @@
|
|||
<string name="toggle_app_theme" translatable="false">Toggle app theme - %s</string>
|
||||
<string name="excluded_blockchains" translatable="false">Excluded blockchains</string>
|
||||
<string name="excluded_blockchains_search_placeholder" translatable="false">Filter by name or symbol</string>
|
||||
<string name="blockchain_providers" translatable="false">Blockchain providers</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue