Updated on 2026-08-14
This commit is contained in:
parent
6d69a5706a
commit
9c1931f7d7
81 changed files with 686 additions and 981 deletions
|
|
@ -41,7 +41,7 @@ class AppSettingsFragment : Fragment(), StoreSubscriber<DetailsState> {
|
|||
TangemTheme {
|
||||
AppSettingsScreen(
|
||||
state = screenState.value,
|
||||
onBackPressed = {
|
||||
onBackClick = {
|
||||
store.dispatch(DetailsAction.ResetCardSettingsData)
|
||||
store.dispatch(NavigationAction.PopBackTo())
|
||||
},
|
||||
|
|
|
|||
|
|
@ -31,25 +31,16 @@ import com.tangem.tap.features.details.ui.common.TangemSwitch
|
|||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
fun AppSettingsScreen(
|
||||
state: AppSettingsScreenState,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun AppSettingsScreen(state: AppSettingsScreenState, onBackClick: () -> Unit) {
|
||||
SettingsScreensScaffold(
|
||||
content = {
|
||||
AppSettings(state = state, modifier = modifier)
|
||||
},
|
||||
content = { AppSettings(state = state) },
|
||||
titleRes = R.string.app_settings_title,
|
||||
onBackClick = onBackPressed,
|
||||
onBackClick = onBackClick,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AppSettings(
|
||||
state: AppSettingsScreenState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
private fun AppSettings(state: AppSettingsScreenState) {
|
||||
var dialogType by remember { mutableStateOf<PrivacySetting?>(null) }
|
||||
val onDialogStateChange: (PrivacySetting?) -> Unit = { dialogType = it }
|
||||
|
||||
|
|
@ -57,21 +48,13 @@ private fun AppSettings(
|
|||
SettingsAlertDialog(
|
||||
element = it,
|
||||
onDialogStateChange = onDialogStateChange,
|
||||
onSettingToggled = state.onSettingToggled,
|
||||
onSettingToggle = { state.onSettingToggled(it, false) },
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize(),
|
||||
) {
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
if (state.showEnrollBiometricsCard) {
|
||||
EnrollBiometricsCard(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = TangemTheme.dimens.spacing8)
|
||||
.fillMaxWidth(),
|
||||
onClick = state.onEnrollBiometrics,
|
||||
)
|
||||
EnrollBiometricsCard(onClick = state.onEnrollBiometrics)
|
||||
SpacerH24()
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +75,6 @@ private fun AppSettings(
|
|||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun AppSettingsElement(
|
||||
modifier: Modifier = Modifier,
|
||||
state: AppSettingsScreenState,
|
||||
setting: PrivacySetting,
|
||||
onDialogStateChange: (PrivacySetting?) -> Unit,
|
||||
|
|
@ -123,7 +105,7 @@ private fun AppSettingsElement(
|
|||
)
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = TangemTheme.dimens.spacing20),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -195,7 +177,7 @@ private fun AppSettingsScreenSample(
|
|||
onSettingToggled = { _, _ -> },
|
||||
onEnrollBiometrics = {},
|
||||
),
|
||||
onBackPressed = { },
|
||||
onBackClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -220,10 +202,7 @@ private fun AppSettingsScreenPreview_Dark() {
|
|||
private fun AppSettingsScreen_EnrollBiometrics_Sample(
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.background(TangemTheme.colors.background.primary),
|
||||
) {
|
||||
Column(modifier = modifier.background(TangemTheme.colors.background.primary)) {
|
||||
AppSettingsScreen(
|
||||
state = AppSettingsScreenState(
|
||||
settings = mapOf(
|
||||
|
|
@ -235,7 +214,7 @@ private fun AppSettingsScreen_EnrollBiometrics_Sample(
|
|||
onSettingToggled = { _, _ -> },
|
||||
onEnrollBiometrics = {},
|
||||
),
|
||||
onBackPressed = { },
|
||||
onBackClick = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.background
|
|||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.ExperimentalMaterialApi
|
||||
import androidx.compose.material.Icon
|
||||
|
|
@ -23,12 +24,11 @@ import com.tangem.wallet.R
|
|||
|
||||
@OptIn(ExperimentalMaterialApi::class)
|
||||
@Composable
|
||||
internal fun EnrollBiometricsCard(
|
||||
modifier: Modifier = Modifier,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
internal fun EnrollBiometricsCard(onClick: () -> Unit) {
|
||||
Surface(
|
||||
modifier = modifier,
|
||||
modifier = Modifier
|
||||
.padding(horizontal = TangemTheme.dimens.spacing8)
|
||||
.fillMaxWidth(),
|
||||
color = TangemTheme.colors.background.primary,
|
||||
shape = TangemTheme.shapes.roundedCornersLarge,
|
||||
onClick = onClick,
|
||||
|
|
@ -67,8 +67,7 @@ private fun EnrollBiometricsCardSample(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.background(TangemTheme.colors.background.secondary),
|
||||
modifier = modifier.background(TangemTheme.colors.background.secondary),
|
||||
) {
|
||||
EnrollBiometricsCard(onClick = {})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ import com.tangem.wallet.R
|
|||
internal fun SettingsAlertDialog(
|
||||
element: PrivacySetting,
|
||||
onDialogStateChange: (PrivacySetting?) -> Unit,
|
||||
onSettingToggled: (PrivacySetting, Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
onSettingToggle: () -> Unit
|
||||
) {
|
||||
val text = when (element) {
|
||||
PrivacySetting.SaveWallets -> R.string.app_settings_off_saved_wallet_alert_message
|
||||
|
|
@ -43,7 +42,7 @@ internal fun SettingsAlertDialog(
|
|||
text = stringResource(id = R.string.common_delete),
|
||||
onClick = {
|
||||
onDialogStateChange(null)
|
||||
onSettingToggled(element, false)
|
||||
onSettingToggle()
|
||||
},
|
||||
)
|
||||
},
|
||||
|
|
@ -62,7 +61,6 @@ internal fun SettingsAlertDialog(
|
|||
)
|
||||
},
|
||||
shape = TangemTheme.shapes.roundedCornersLarge,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +76,7 @@ private fun SettingsAlertDialogSample(
|
|||
SettingsAlertDialog(
|
||||
element = PrivacySetting.SaveAccessCode,
|
||||
onDialogStateChange = {},
|
||||
onSettingToggled = { _, _ -> },
|
||||
onSettingToggle = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class CardSettingsFragment : Fragment(), StoreSubscriber<DetailsState> {
|
|||
TangemTheme {
|
||||
CardSettingsScreen(
|
||||
state = screenState.value,
|
||||
onBackPressed = {
|
||||
onBackClick = {
|
||||
store.dispatch(DetailsAction.ResetCardSettingsData)
|
||||
store.dispatch(NavigationAction.PopBackTo())
|
||||
},
|
||||
|
|
|
|||
|
|
@ -30,44 +30,36 @@ import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
|
|||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
fun CardSettingsScreen(
|
||||
state: CardSettingsScreenState,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun CardSettingsScreen(state: CardSettingsScreenState, onBackClick: () -> Unit) {
|
||||
val needReadCard = state.cardDetails == null
|
||||
|
||||
SettingsScreensScaffold(
|
||||
content = {
|
||||
if (needReadCard) {
|
||||
CardSettingsReadCard(state.onScanCardClick, modifier = modifier)
|
||||
CardSettingsReadCard(state.onScanCardClick)
|
||||
} else {
|
||||
CardSettings(state = state, modifier = modifier)
|
||||
CardSettings(state = state)
|
||||
}
|
||||
},
|
||||
titleRes = R.string.card_settings_title,
|
||||
backgroundColor = TangemTheme.colors.background.secondary,
|
||||
onBackClick = onBackPressed,
|
||||
onBackClick = onBackClick,
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
@Composable
|
||||
fun CardSettingsReadCard(
|
||||
onScanCardClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun CardSettingsReadCard(onScanCardClick: () -> Unit) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize(),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 40.dp),
|
||||
) {
|
||||
Image(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 80.dp, end = 80.dp, top = 70.dp)
|
||||
.rotate(-15f),
|
||||
|
|
@ -76,7 +68,7 @@ fun CardSettingsReadCard(
|
|||
contentScale = ContentScale.FillWidth,
|
||||
)
|
||||
Image(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 60.dp, end = 60.dp)
|
||||
.rotate(-1f),
|
||||
|
|
@ -87,7 +79,7 @@ fun CardSettingsReadCard(
|
|||
}
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, bottom = 32.dp),
|
||||
) {
|
||||
|
|
@ -96,20 +88,19 @@ fun CardSettingsReadCard(
|
|||
color = colorResource(id = R.color.text_primary_1),
|
||||
style = TangemTypography.headline3,
|
||||
)
|
||||
Spacer(modifier = modifier.size(20.dp))
|
||||
Spacer(modifier = Modifier.size(20.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.scan_card_settings_message),
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
style = TangemTypography.body1,
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.verticalScroll(rememberScrollState())
|
||||
.weight(weight = 1f, fill = false),
|
||||
)
|
||||
Spacer(modifier = modifier.size(29.dp))
|
||||
Spacer(modifier = Modifier.size(29.dp))
|
||||
DetailsMainButton(
|
||||
title = stringResource(id = R.string.scan_card_settings_button),
|
||||
onClick = onScanCardClick,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -117,15 +108,11 @@ fun CardSettingsReadCard(
|
|||
|
||||
@Suppress("ComplexMethod")
|
||||
@Composable
|
||||
fun CardSettings(
|
||||
state: CardSettingsScreenState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun CardSettings(state: CardSettingsScreenState) {
|
||||
if (state.cardDetails == null) return
|
||||
|
||||
LazyColumn(
|
||||
modifier = modifier
|
||||
.fillMaxWidth(),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
items(state.cardDetails) {
|
||||
val paddingBottom = when (it) {
|
||||
|
|
@ -144,7 +131,7 @@ fun CardSettings(
|
|||
is CardInfo.ResetToFactorySettings -> 16.dp
|
||||
}
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(
|
||||
enabled = it.clickable,
|
||||
|
|
@ -167,7 +154,7 @@ fun CardSettings(
|
|||
color = titleColor,
|
||||
style = TangemTheme.typography.subtitle1,
|
||||
)
|
||||
Spacer(modifier = modifier.size(4.dp))
|
||||
Spacer(modifier = Modifier.size(4.dp))
|
||||
Text(
|
||||
text = it.subtitle.resolveReference(),
|
||||
color = subtitleColor,
|
||||
|
|
@ -180,6 +167,6 @@ fun CardSettings(
|
|||
|
||||
@Composable
|
||||
@Preview
|
||||
fun CardSettingsPreview() {
|
||||
private fun CardSettingsPreview() {
|
||||
CardSettingsScreen(state = CardSettingsScreenState(onScanCardClick = {}) {}, {})
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.Column
|
|||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.systemBarsPadding
|
||||
|
|
@ -90,12 +90,10 @@ fun ScreenTitle(
|
|||
|
||||
@Composable
|
||||
fun EmptyTopBarWithNavigation(
|
||||
modifier: Modifier = Modifier,
|
||||
onBackClick: () -> Unit,
|
||||
backgroundColor: Color = TangemTheme.colors.background.primary,
|
||||
) {
|
||||
TopAppBar(
|
||||
modifier = modifier,
|
||||
title = { },
|
||||
navigationIcon =
|
||||
{
|
||||
|
|
@ -114,16 +112,16 @@ fun EmptyTopBarWithNavigation(
|
|||
|
||||
@Composable
|
||||
fun DetailsMainButton(
|
||||
modifier: Modifier = Modifier,
|
||||
title: String,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
onClick: (() -> Unit),
|
||||
) {
|
||||
Button(
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.height(48.dp),
|
||||
.heightIn(48.dp),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
enabled = enabled,
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
|
|
@ -134,7 +132,9 @@ fun DetailsMainButton(
|
|||
),
|
||||
) {
|
||||
Text(text = title)
|
||||
Spacer(modifier = modifier.size(8.dp))
|
||||
Spacer(modifier = Modifier
|
||||
.padding(start = 20.dp, end = 20.dp)
|
||||
.size(8.dp))
|
||||
Icon(painter = painterResource(id = R.drawable.ic_tangem_24), contentDescription = "")
|
||||
}
|
||||
}
|
||||
|
|
@ -33,13 +33,12 @@ import com.tangem.wallet.R
|
|||
@Suppress("MagicNumber")
|
||||
@Composable
|
||||
fun TangemSwitch(
|
||||
modifier: Modifier = Modifier,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
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")
|
||||
val color by transition.animateColor(
|
||||
|
|
@ -53,7 +52,7 @@ fun TangemSwitch(
|
|||
val interactionSource = remember { MutableInteractionSource() }
|
||||
|
||||
Box(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
interactionSource = interactionSource,
|
||||
indication = null,
|
||||
|
|
@ -70,7 +69,7 @@ fun TangemSwitch(
|
|||
),
|
||||
) {
|
||||
BoxWithConstraints(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.width(size)
|
||||
.height(size / 2)
|
||||
.indication(interactionSource, null)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.transition.TransitionInflater
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.core.analytics.Analytics
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.tap.common.analytics.events.Settings
|
||||
import com.tangem.tap.common.redux.navigation.NavigationAction
|
||||
import com.tangem.tap.features.details.redux.DetailsState
|
||||
|
|
@ -43,7 +43,7 @@ class DetailsFragment : Fragment(), StoreSubscriber<DetailsState> {
|
|||
TangemTheme {
|
||||
DetailsScreen(
|
||||
state = detailsScreenState.value,
|
||||
onBackPressed = { store.dispatch(NavigationAction.PopBackTo()) },
|
||||
onBackClick = { store.dispatch(NavigationAction.PopBackTo()) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,66 +33,52 @@ import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
|
|||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
fun DetailsScreen(
|
||||
state: DetailsScreenState,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun DetailsScreen(state: DetailsScreenState, onBackClick: () -> Unit) {
|
||||
SystemBarsEffect {
|
||||
setSystemBarsColor(color = TangemColorPalette.Light1)
|
||||
}
|
||||
|
||||
SettingsScreensScaffold(
|
||||
content = { Content(state = state, modifier = modifier) },
|
||||
onBackClick = onBackPressed,
|
||||
content = { Content(state = state) },
|
||||
onBackClick = onBackClick,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Content(
|
||||
state: DetailsScreenState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun Content(state: DetailsScreenState) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
) {
|
||||
ScreenTitle(titleRes = R.string.details_title, modifier.padding(bottom = 52.dp))
|
||||
state.elements.map {
|
||||
if (it == SettingsElement.WalletConnect) {
|
||||
WalletConnectDetailsItem(
|
||||
onItemsClick = state.onItemsClick,
|
||||
modifier = modifier,
|
||||
)
|
||||
ScreenTitle(titleRes = R.string.details_title, Modifier.padding(bottom = 52.dp))
|
||||
state.elements.map { element ->
|
||||
if (element == SettingsElement.WalletConnect) {
|
||||
WalletConnectDetailsItem(onItemsClick = state.onItemsClick)
|
||||
} else {
|
||||
DetailsItem(
|
||||
item = it,
|
||||
item = element,
|
||||
appCurrency = state.appCurrency,
|
||||
onItemsClick = state.onItemsClick,
|
||||
modifier = modifier,
|
||||
onItemsClick = { state.onItemsClick(element) },
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = modifier.weight(1f))
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
TangemSocialAccounts(state.tangemLinks, state.onSocialNetworkClick)
|
||||
Spacer(modifier = Modifier.size(12.dp))
|
||||
Text(
|
||||
text = "${stringResource(id = state.appNameRes)} ${state.tangemVersion}",
|
||||
style = TangemTypography.caption,
|
||||
color = colorResource(id = R.color.text_tertiary),
|
||||
modifier = modifier.padding(start = 16.dp, end = 16.dp, bottom = 40.dp),
|
||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 40.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun WalletConnectDetailsItem(
|
||||
onItemsClick: (SettingsElement) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun WalletConnectDetailsItem(onItemsClick: (SettingsElement) -> Unit) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.defaultMinSize(minHeight = 84.dp)
|
||||
.fillMaxWidth()
|
||||
.clickable { onItemsClick(SettingsElement.WalletConnect) },
|
||||
|
|
@ -102,23 +88,23 @@ fun WalletConnectDetailsItem(
|
|||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_walletconnect),
|
||||
contentDescription = stringResource(id = R.string.wallet_connect_title),
|
||||
modifier = modifier.padding(start = 20.dp, end = 20.dp),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
tint = colorResource(id = R.color.all_colors_azure),
|
||||
)
|
||||
Column(
|
||||
modifier = modifier.defaultMinSize(minHeight = 56.dp),
|
||||
modifier = Modifier.defaultMinSize(minHeight = 56.dp),
|
||||
horizontalAlignment = Alignment.Start,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.wallet_connect_title),
|
||||
modifier = modifier.padding(end = 20.dp, bottom = 4.dp),
|
||||
modifier = Modifier.padding(end = 20.dp, bottom = 4.dp),
|
||||
style = TangemTypography.headline3,
|
||||
color = colorResource(id = R.color.text_primary_1),
|
||||
)
|
||||
Text(
|
||||
text = stringResource(id = R.string.wallet_connect_subtitle),
|
||||
modifier = modifier.padding(end = 20.dp, bottom = 4.dp),
|
||||
modifier = Modifier.padding(end = 20.dp, bottom = 4.dp),
|
||||
style = TangemTypography.body1,
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
)
|
||||
|
|
@ -127,37 +113,31 @@ fun WalletConnectDetailsItem(
|
|||
}
|
||||
|
||||
@Composable
|
||||
fun DetailsItem(
|
||||
item: SettingsElement,
|
||||
appCurrency: String,
|
||||
onItemsClick: (SettingsElement) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun DetailsItem(item: SettingsElement, appCurrency: String, onItemsClick: () -> Unit) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.height(56.dp)
|
||||
.fillMaxWidth()
|
||||
.clickable { onItemsClick(item) },
|
||||
.clickable(onClick = onItemsClick),
|
||||
horizontalArrangement = Arrangement.Start,
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = item.iconRes),
|
||||
contentDescription = stringResource(id = item.titleRes),
|
||||
modifier = modifier.padding(start = 20.dp, end = 20.dp),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
tint = colorResource(id = R.color.icon_secondary),
|
||||
)
|
||||
Column(modifier = modifier.padding(end = 20.dp)) {
|
||||
Column(modifier = Modifier.padding(end = 20.dp)) {
|
||||
Text(
|
||||
text = stringResource(id = item.titleRes),
|
||||
modifier = modifier,
|
||||
modifier = Modifier,
|
||||
style = TangemTypography.subtitle1,
|
||||
color = colorResource(id = R.color.text_primary_1),
|
||||
)
|
||||
if (item == SettingsElement.AppCurrency) {
|
||||
Text(
|
||||
text = appCurrency,
|
||||
modifier = modifier,
|
||||
style = TangemTypography.body2,
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
)
|
||||
|
|
@ -170,16 +150,13 @@ fun DetailsItem(
|
|||
fun TangemSocialAccounts(
|
||||
links: List<SocialNetworkLink>,
|
||||
onSocialNetworkClick: (SocialNetworkLink) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
LazyRow(
|
||||
modifier = modifier.padding(start = 8.dp, end = 8.dp),
|
||||
) {
|
||||
LazyRow(modifier = Modifier.padding(start = 8.dp, end = 8.dp)) {
|
||||
items(links) {
|
||||
Icon(
|
||||
painter = painterResource(id = it.network.iconRes),
|
||||
contentDescription = "",
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.padding(8.dp)
|
||||
.clickable { onSocialNetworkClick(it) },
|
||||
tint = colorResource(id = R.color.icon_informative),
|
||||
|
|
@ -190,7 +167,7 @@ fun TangemSocialAccounts(
|
|||
|
||||
@Composable
|
||||
@Preview
|
||||
fun Preview() {
|
||||
private fun Preview() {
|
||||
DetailsScreen(
|
||||
state = DetailsScreenState(
|
||||
elements = SettingsElement.values().toList(),
|
||||
|
|
@ -199,6 +176,6 @@ fun Preview() {
|
|||
appCurrency = "Dollar",
|
||||
onItemsClick = {}, onSocialNetworkClick = {},
|
||||
),
|
||||
onBackPressed = {},
|
||||
onBackClick = {},
|
||||
)
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ class ResetCardFragment : Fragment(), StoreSubscriber<DetailsState> {
|
|||
TangemTheme {
|
||||
ResetCardScreen(
|
||||
state = screenState.value,
|
||||
onBackPressed = { store.dispatch(NavigationAction.PopBackTo()) },
|
||||
onBackClick = { store.dispatch(NavigationAction.PopBackTo()) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
|
|||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
fun ResetCardScreen(state: ResetCardScreenState, onBackPressed: () -> Unit) {
|
||||
fun ResetCardScreen(state: ResetCardScreenState, onBackClick: () -> Unit) {
|
||||
SettingsScreensScaffold(
|
||||
content = { ResetCardView(state = state) },
|
||||
onBackClick = onBackPressed,
|
||||
onBackClick = onBackClick,
|
||||
backgroundColor = Color.Transparent,
|
||||
)
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ private fun ResetCardScreenSample(
|
|||
onAcceptWarningToggleClick = {},
|
||||
onResetButtonClick = {},
|
||||
),
|
||||
onBackPressed = {},
|
||||
onBackClick = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class SecurityModeFragment : Fragment(), StoreSubscriber<DetailsState> {
|
|||
TangemTheme {
|
||||
SecurityModeScreen(
|
||||
state = screenState.value,
|
||||
onBackPressed = { store.dispatch(NavigationAction.PopBackTo()) },
|
||||
onBackClick = { store.dispatch(NavigationAction.PopBackTo()) },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,36 +28,28 @@ import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
|
|||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
fun SecurityModeScreen(
|
||||
state: SecurityModeScreenState,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun SecurityModeScreen(state: SecurityModeScreenState, onBackClick: () -> Unit) {
|
||||
SettingsScreensScaffold(
|
||||
content = { SecurityModeOptions(state = state, modifier = modifier) },
|
||||
content = { SecurityModeOptions(state = state) },
|
||||
// titleRes = R.string.card_settings_security_mode,
|
||||
onBackClick = onBackPressed,
|
||||
onBackClick = onBackClick,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SecurityModeOptions(
|
||||
state: SecurityModeScreenState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
||||
fun SecurityModeOptions(state: SecurityModeScreenState) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(bottom = 28.dp),
|
||||
verticalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
ScreenTitle(titleRes = R.string.card_settings_security_mode, modifier.padding(bottom = 36.dp))
|
||||
ScreenTitle(titleRes = R.string.card_settings_security_mode, Modifier.padding(bottom = 36.dp))
|
||||
|
||||
|
||||
state.availableOptions.map {
|
||||
SecurityOption(option = it, state = state, modifier = modifier)
|
||||
SecurityOption(option = it, state = state)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
|
@ -66,17 +58,13 @@ fun SecurityModeOptions(
|
|||
title = stringResource(id = R.string.common_save_changes),
|
||||
enabled = state.isSaveChangesEnabled,
|
||||
onClick = state.onSaveChangesClicked,
|
||||
modifier = modifier
|
||||
.padding(start = 20.dp, end = 20.dp),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SecurityOption(
|
||||
option: SecurityOption, state: SecurityModeScreenState,
|
||||
modifier: Modifier,
|
||||
) {
|
||||
fun SecurityOption(option: SecurityOption, state: SecurityModeScreenState) {
|
||||
val selected = option == state.selectedSecurityMode
|
||||
|
||||
val title = option.toTitleRes()
|
||||
|
|
@ -88,7 +76,7 @@ fun SecurityOption(
|
|||
}
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.selectable(
|
||||
selected = selected, onClick = { state.onNewModeSelected(option) },
|
||||
|
|
@ -98,7 +86,7 @@ fun SecurityOption(
|
|||
|
||||
RadioButton(
|
||||
selected = selected, onClick = null,
|
||||
modifier = modifier.padding(end = 20.dp),
|
||||
modifier = Modifier.padding(end = 20.dp),
|
||||
colors = RadioButtonDefaults.colors(
|
||||
unselectedColor = colorResource(id = R.color.icon_secondary),
|
||||
selectedColor = colorResource(id = R.color.icon_accent),
|
||||
|
|
@ -111,7 +99,7 @@ fun SecurityOption(
|
|||
style = TangemTypography.subtitle1,
|
||||
color = colorResource(id = R.color.text_primary_1),
|
||||
)
|
||||
Spacer(modifier = modifier.size(4.dp))
|
||||
Spacer(modifier = Modifier.size(4.dp))
|
||||
Text(
|
||||
text = stringResource(id = subtitle),
|
||||
style = TangemTypography.body2,
|
||||
|
|
@ -123,7 +111,7 @@ fun SecurityOption(
|
|||
|
||||
@Preview
|
||||
@Composable
|
||||
fun SecurityModeScreenPreview() {
|
||||
private fun SecurityModeScreenPreview() {
|
||||
SecurityModeScreen(
|
||||
state = SecurityModeScreenState(
|
||||
availableOptions = SecurityOption.values().toList(),
|
||||
|
|
@ -132,6 +120,6 @@ fun SecurityModeScreenPreview() {
|
|||
onNewModeSelected = {},
|
||||
onSaveChangesClicked = {},
|
||||
),
|
||||
onBackPressed = {},
|
||||
onBackClick = {},
|
||||
)
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ class WalletConnectFragment : Fragment(), StoreSubscriber<WalletConnectState> {
|
|||
TangemTheme {
|
||||
WalletConnectScreen(
|
||||
state = screenState.value,
|
||||
onBackPressed = {
|
||||
onBackClick = {
|
||||
if (screenState.value.isLoading) {
|
||||
store.dispatch(
|
||||
WalletConnectAction.FailureEstablishingSession(
|
||||
|
|
|
|||
|
|
@ -38,19 +38,15 @@ import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
|
|||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
fun WalletConnectScreen(
|
||||
state: WalletConnectScreenState,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun WalletConnectScreen(state: WalletConnectScreenState, onBackClick: () -> Unit) {
|
||||
val context = LocalContext.current
|
||||
|
||||
SettingsScreensScaffold(
|
||||
content = {
|
||||
if (state.sessions.isEmpty()) {
|
||||
EmptyScreen(state, modifier)
|
||||
EmptyScreen(state)
|
||||
} else {
|
||||
WalletConnectSessions(state, modifier)
|
||||
WalletConnectSessions(state)
|
||||
}
|
||||
},
|
||||
fab = {
|
||||
|
|
@ -64,7 +60,7 @@ fun WalletConnectScreen(
|
|||
}
|
||||
},
|
||||
titleRes = R.string.wallet_connect_title,
|
||||
onBackClick = onBackPressed,
|
||||
onBackClick = onBackClick,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -88,15 +84,15 @@ private fun AddSessionFab(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun EmptyScreen(state: WalletConnectScreenState, modifier: Modifier = Modifier) {
|
||||
private fun EmptyScreen(state: WalletConnectScreenState) {
|
||||
if (state.isLoading) {
|
||||
LinearProgressIndicator(
|
||||
modifier = modifier.fillMaxWidth(),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
color = colorResource(id = R.color.icon_accent),
|
||||
)
|
||||
}
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(bottom = 64.dp),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
|
|
@ -107,10 +103,9 @@ private fun EmptyScreen(state: WalletConnectScreenState, modifier: Modifier = Mo
|
|||
contentDescription = "",
|
||||
colorFilter = ColorFilter.tint(colorResource(id = R.color.icon_inactive)),
|
||||
contentScale = ContentScale.FillWidth,
|
||||
modifier = modifier
|
||||
.width(width = 100.dp),
|
||||
modifier = Modifier.width(width = 100.dp),
|
||||
)
|
||||
Spacer(modifier = modifier.size(24.dp))
|
||||
Spacer(modifier = Modifier.size(24.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.wallet_connect_subtitle),
|
||||
style = TangemTypography.body2,
|
||||
|
|
@ -120,28 +115,25 @@ private fun EmptyScreen(state: WalletConnectScreenState, modifier: Modifier = Mo
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun WalletConnectSessions(
|
||||
state: WalletConnectScreenState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
private fun WalletConnectSessions(state: WalletConnectScreenState) {
|
||||
if (state.isLoading) {
|
||||
LinearProgressIndicator(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(2.dp),
|
||||
color = colorResource(id = R.color.icon_accent),
|
||||
)
|
||||
} else {
|
||||
Spacer(modifier = modifier.height(2.dp))
|
||||
Spacer(modifier = Modifier.height(2.dp))
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
items(state.sessions) { session ->
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp, vertical = 16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
|
|
@ -151,7 +143,7 @@ private fun WalletConnectSessions(
|
|||
text = session.description,
|
||||
style = TangemTypography.subtitle1,
|
||||
color = colorResource(id = R.color.text_primary_1),
|
||||
modifier = modifier.weight(1f),
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
IconButton(
|
||||
onClick = {
|
||||
|
|
@ -172,7 +164,7 @@ private fun WalletConnectSessions(
|
|||
|
||||
@Composable
|
||||
@Preview
|
||||
fun WalletConnectScreenPreview() {
|
||||
private fun WalletConnectScreenPreview() {
|
||||
WalletConnectScreen(
|
||||
state = WalletConnectScreenState(
|
||||
sessions = listOf(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue