Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-01 14:40:31 +03:00
parent ce76ab4791
commit b07c9ae620
9 changed files with 50 additions and 30 deletions

View file

@ -36,7 +36,7 @@ class AppSettingsFragment : Fragment(), StoreSubscriber<DetailsState> {
return ComposeView(requireContext()).apply {
setContent {
isTransitionGroup = true
AppCompatTheme {
TangemTheme {
AppSettingsScreen(
state = screenState.value,
onBackPressed = {

View file

@ -9,7 +9,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.transition.TransitionInflater
import com.google.accompanist.appcompattheme.AppCompatTheme
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.redux.navigation.NavigationAction
import com.tangem.tap.features.details.redux.DetailsAction
import com.tangem.tap.features.details.redux.DetailsState
@ -39,7 +39,7 @@ class CardSettingsFragment : Fragment(), StoreSubscriber<DetailsState> {
return ComposeView(requireContext()).apply {
setContent {
isTransitionGroup = true
AppCompatTheme {
TangemTheme {
CardSettingsScreen(
state = screenState.value,
onBackPressed = {

View file

@ -15,6 +15,8 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.layout.ContentScale
@ -23,6 +25,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.compose.TangemTypography
import com.tangem.tap.features.details.ui.common.DetailsMainButton
import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
@ -34,14 +37,22 @@ fun CardSettingsScreen(
onBackPressed: () -> Unit,
modifier: Modifier = Modifier,
) {
val needReadCard = state.cardDetails == null
val backgroundColor by rememberUpdatedState(
newValue = if (needReadCard) TangemTheme.colors.background.primary
else TangemTheme.colors.background.secondary,
)
SettingsScreensScaffold(
content =
if (state.cardDetails == null) {
{ CardSettingsReadCard(state.onScanCardClick, modifier = modifier) }
} else {
{ CardSettings(state = state, modifier = modifier) }
content = {
if (needReadCard) {
CardSettingsReadCard(state.onScanCardClick, modifier = modifier)
} else {
CardSettings(state = state, modifier = modifier)
}
},
titleRes = R.string.card_settings_title,
backgroundColor = backgroundColor,
onBackClick = onBackPressed,
)
}

View file

@ -25,18 +25,19 @@ import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.compose.TangemTypography
import com.tangem.wallet.R
@Composable
fun SettingsScreensScaffold(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
background: @Composable (() -> Unit)? = null,
fab: @Composable (() -> Unit)? = null,
backgroundColor: Color = colorResource(id = R.color.background_primary),
backgroundColor: Color = TangemTheme.colors.background.secondary,
titleRes: Int? = null,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) {
BackHandler(true, onBackClick)
@ -58,9 +59,13 @@ fun SettingsScreensScaffold(
Column(modifier = modifier.fillMaxWidth()) {
Text(
text = stringResource(id = titleRes),
modifier = modifier.padding(start = 20.dp, end = 20.dp, bottom = 52.dp),
style = TangemTypography.headline1,
color = colorResource(id = R.color.text_primary_1),
modifier = modifier.padding(
start = TangemTheme.dimens.spacing20,
end = TangemTheme.dimens.spacing20,
bottom = TangemTheme.dimens.spacing54,
),
style = TangemTheme.typography.h1,
color = TangemTheme.colors.text.primary1,
)
content()
}
@ -86,18 +91,20 @@ fun ScreenTitle(
@Composable
fun EmptyTopBarWithNavigation(
onBackClick: () -> Unit,
backgroundColor: Color = colorResource(id = R.color.background_primary),
modifier: Modifier = Modifier,
onBackClick: () -> Unit,
backgroundColor: Color = TangemTheme.colors.background.primary,
) {
TopAppBar(
modifier = modifier,
title = { },
navigationIcon =
{
IconButton(onClick = onBackClick) {
Icon(
painterResource(id = R.drawable.ic_back), "",
tint = colorResource(id = R.color.icon_primary_1),
painter = painterResource(id = R.drawable.ic_back),
contentDescription = null,
tint = TangemTheme.colors.icon.primary1,
)
}
},
@ -108,10 +115,10 @@ fun EmptyTopBarWithNavigation(
@Composable
fun DetailsMainButton(
modifier: Modifier = Modifier,
title: String,
enabled: Boolean = true,
onClick: (() -> Unit),
modifier: Modifier = Modifier,
) {
Button(
onClick = onClick,

View file

@ -33,10 +33,11 @@ import com.tangem.wallet.R
@Composable
fun TangemSwitch(
modifier: Modifier = Modifier,
enabledColor: Color = colorResource(id = R.color.control_checked),
disabledColor: Color = colorResource(id = R.color.icon_informative),
checkedColor: Color = colorResource(id = R.color.control_checked),
uncheckedColor: Color = colorResource(id = R.color.icon_informative),
size: Dp = 48.dp,
checked: Boolean = false,
enabled: Boolean = true,
onCheckedChange: (Boolean) -> Unit,
) {
val transition = updateTransition(checked, label = "SwitchState")
@ -45,8 +46,8 @@ fun TangemSwitch(
tween(durationMillis = 200, easing = FastOutLinearInEasing)
},
label = "",
) { enabled ->
if (enabled) enabledColor else disabledColor
) { isChecked ->
if (isChecked) checkedColor else uncheckedColor
}
val interactionSource = remember { MutableInteractionSource() }
@ -55,6 +56,7 @@ fun TangemSwitch(
.clickable(
interactionSource = interactionSource,
indication = null,
enabled = enabled,
) {
onCheckedChange(!checked)
}

View file

@ -9,7 +9,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.transition.TransitionInflater
import com.google.accompanist.appcompattheme.AppCompatTheme
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.analytics.Analytics
import com.tangem.tap.common.analytics.events.Settings
import com.tangem.tap.common.redux.navigation.NavigationAction
@ -40,7 +40,7 @@ class DetailsFragment : Fragment(), StoreSubscriber<DetailsState> {
return ComposeView(requireContext()).apply {
setContent {
isTransitionGroup = true
AppCompatTheme {
TangemTheme {
DetailsScreen(
state = detailsScreenState.value,
onBackPressed = { store.dispatch(NavigationAction.PopBackTo()) },

View file

@ -9,7 +9,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.transition.TransitionInflater
import com.google.accompanist.appcompattheme.AppCompatTheme
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.redux.navigation.NavigationAction
import com.tangem.tap.features.details.redux.DetailsState
import com.tangem.tap.store
@ -38,7 +38,7 @@ class ResetCardFragment : Fragment(), StoreSubscriber<DetailsState> {
return ComposeView(requireContext()).apply {
setContent {
isTransitionGroup = true
AppCompatTheme {
TangemTheme {
ResetCardScreen(
state = screenState.value,
onBackPressed = { store.dispatch(NavigationAction.PopBackTo()) },

View file

@ -9,7 +9,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.transition.TransitionInflater
import com.google.accompanist.appcompattheme.AppCompatTheme
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.redux.navigation.NavigationAction
import com.tangem.tap.features.details.redux.DetailsState
import com.tangem.tap.store
@ -38,7 +38,7 @@ class SecurityModeFragment : Fragment(), StoreSubscriber<DetailsState> {
return ComposeView(requireContext()).apply {
setContent {
isTransitionGroup = true
AppCompatTheme {
TangemTheme {
SecurityModeScreen(
state = screenState.value,
onBackPressed = { store.dispatch(NavigationAction.PopBackTo()) },

View file

@ -9,7 +9,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.transition.TransitionInflater
import com.google.accompanist.appcompattheme.AppCompatTheme
import com.tangem.core.ui.res.TangemTheme
import com.tangem.tap.common.redux.navigation.NavigationAction
import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction
import com.tangem.tap.features.details.redux.walletconnect.WalletConnectState
@ -36,7 +36,7 @@ class WalletConnectFragment : Fragment(), StoreSubscriber<WalletConnectState> {
return ComposeView(requireContext()).apply {
setContent {
isTransitionGroup = true
AppCompatTheme {
TangemTheme {
WalletConnectScreen(
state = screenState.value,
onBackPressed = {