diff --git a/app/src/main/java/com/tangem/tap/common/compose/Button.kt b/app/src/main/java/com/tangem/tap/common/compose/Button.kt
index 20f72a0a89..690f35f388 100644
--- a/app/src/main/java/com/tangem/tap/common/compose/Button.kt
+++ b/app/src/main/java/com/tangem/tap/common/compose/Button.kt
@@ -7,6 +7,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
@@ -68,6 +70,7 @@ fun PasteButton(
enabled: Boolean = true,
dpSize: DpSize = DpSize(40.dp, 40.dp),
onClick: () -> Unit,
+ tint: Color? = null,
content: @Composable (() -> Unit)? = null
) {
IconButton(
@@ -77,8 +80,42 @@ fun PasteButton(
) {
when (content) {
null -> {
- val icon = if (enabled) R.drawable.ic_paste else R.drawable.ic_paste_disabled
- Icon(painterResource(id = icon), contentDescription = "Paste")
+ val tintColor = tint
+ ?: colorResource(id = if (enabled) R.color.accent else R.color.accent_disabled)
+ Icon(
+ painterResource(id = R.drawable.ic_paste),
+ contentDescription = "Paste",
+ tint = tintColor,
+ )
+ }
+ else -> content()
+ }
+ }
+}
+
+@Composable
+fun ClearButton(
+ modifier: Modifier = Modifier,
+ enabled: Boolean = true,
+ dpSize: DpSize = DpSize(40.dp, 40.dp),
+ onClick: () -> Unit,
+ tint: Color? = null,
+ content: @Composable (() -> Unit)? = null
+) {
+ IconButton(
+ modifier = modifier.size(dpSize),
+ enabled = enabled,
+ onClick = onClick,
+ ) {
+ when (content) {
+ null -> {
+ val tintColor = tint
+ ?: colorResource(id = if (enabled) R.color.accent else R.color.accent_disabled)
+ Icon(
+ painterResource(id = R.drawable.ic_clear),
+ contentDescription = "Clear",
+ tint = tintColor,
+ )
}
else -> content()
}
diff --git a/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/FormFieldViews.kt b/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/FormFieldViews.kt
index 7a61b5c911..d8a89b6ae8 100644
--- a/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/FormFieldViews.kt
+++ b/app/src/main/java/com/tangem/tap/features/tokens/addCustomToken/compose/FormFieldViews.kt
@@ -2,19 +2,19 @@ package com.tangem.tap.features.tokens.addCustomToken.compose
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.runtime.Composable
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.KeyboardType
+import androidx.compose.ui.tooling.preview.Preview
import com.tangem.domain.common.form.Field
import com.tangem.domain.features.addCustomToken.TokenBlockchainField
import com.tangem.domain.features.addCustomToken.TokenDerivationPathField
import com.tangem.domain.features.addCustomToken.TokenField
-import com.tangem.domain.features.addCustomToken.redux.AddCustomTokenAction
+import com.tangem.domain.features.addCustomToken.redux.AddCustomTokenAction.*
import com.tangem.domain.features.addCustomToken.redux.AddCustomTokenState
import com.tangem.domain.redux.domainStore
-import com.tangem.tap.common.compose.BlockchainSpinner
-import com.tangem.tap.common.compose.OutlinedTextFieldWidget
-import com.tangem.tap.common.compose.SpacerH8
-import com.tangem.tap.common.compose.TitleSubtitle
+import com.tangem.tap.common.compose.*
+import com.tangem.tap.common.extensions.getFromClipboard
import com.tangem.wallet.R
/**
@@ -34,12 +34,38 @@ fun TokenContractAddressView(screenFieldData: ScreenFieldData) {
isLoading = screenFieldData.viewState.isLoading,
error = screenFieldData.error,
errorConverter = screenFieldData.errorConverter,
+// trailingIcon = { PasteClearButton(showFirst = tokenField.data.value.isEmpty()) }
) {
- domainStore.dispatch(AddCustomTokenAction.OnTokenContractAddressChanged(Field.Data(it, true)))
+ domainStore.dispatch(OnTokenContractAddressChanged(Field.Data(it, true)))
}
SpacerH8()
}
+@Composable
+private fun PasteClearButton(
+ showFirst: Boolean,
+) {
+ if (showFirst) {
+ val context = LocalContext.current
+ PasteButton(
+ onClick = {
+ context.getFromClipboard()?.let {
+ val fieldData = Field.Data(it.toString(), false)
+ domainStore.dispatch(OnTokenContractAddressChanged(fieldData))
+ }
+
+ }
+ )
+ } else {
+ ClearButton(
+ onClick = {
+ val fieldData = Field.Data("", false)
+ domainStore.dispatch(OnTokenContractAddressChanged(fieldData))
+ }
+ )
+ }
+}
+
@Composable
fun TokenNameView(screenFieldData: ScreenFieldData) {
if (!screenFieldData.viewState.isVisible) return
@@ -54,7 +80,7 @@ fun TokenNameView(screenFieldData: ScreenFieldData) {
error = screenFieldData.error,
errorConverter = screenFieldData.errorConverter,
) {
- domainStore.dispatch(AddCustomTokenAction.OnTokenNameChanged(Field.Data(it, true)))
+ domainStore.dispatch(OnTokenNameChanged(Field.Data(it, true)))
}
SpacerH8()
}
@@ -72,7 +98,7 @@ fun TokenNetworkView(screenFieldData: ScreenFieldData, state: AddCustomTokenStat
selectedItem = networkField.data,
isEnabled = screenFieldData.viewState.isEnabled,
textFieldConverter = { state.blockchainToName(it) ?: notSelected },
- ) { domainStore.dispatch(AddCustomTokenAction.OnTokenNetworkChanged(Field.Data(it, true))) }
+ ) { domainStore.dispatch(OnTokenNetworkChanged(Field.Data(it, true))) }
SpacerH8()
}
@@ -89,7 +115,7 @@ fun TokenSymbolView(screenFieldData: ScreenFieldData) {
isEnabled = screenFieldData.viewState.isEnabled,
error = screenFieldData.error,
errorConverter = screenFieldData.errorConverter,
- ) { domainStore.dispatch(AddCustomTokenAction.OnTokenSymbolChanged(Field.Data(it, true))) }
+ ) { domainStore.dispatch(OnTokenSymbolChanged(Field.Data(it, true))) }
SpacerH8()
}
@@ -107,7 +133,7 @@ fun TokenDecimalsView(screenFieldData: ScreenFieldData) {
error = screenFieldData.error,
errorConverter = screenFieldData.errorConverter,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
- ) { domainStore.dispatch(AddCustomTokenAction.OnTokenDecimalsChanged(Field.Data(it, true))) }
+ ) { domainStore.dispatch(OnTokenDecimalsChanged(Field.Data(it, true))) }
SpacerH8()
}
@@ -129,6 +155,12 @@ fun TokenDerivationPathView(screenFieldData: ScreenFieldData, state: AddCustomTo
val blockchainName = state.blockchainToName(blockchain) ?: notSelected
TitleSubtitle(derivationPathName, blockchainName)
}
- ) { domainStore.dispatch(AddCustomTokenAction.OnTokenDerivationPathChanged(Field.Data(it, true))) }
+ ) { domainStore.dispatch(OnTokenDerivationPathChanged(Field.Data(it, true))) }
SpacerH8()
+}
+
+@Preview
+@Composable
+fun TestTokenContractAddressView() {
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/tangem/tap/features/tokens/ui/compose/CurrenciesScreen.kt b/app/src/main/java/com/tangem/tap/features/tokens/ui/compose/CurrenciesScreen.kt
index 983f0aaeed..2358743b93 100644
--- a/app/src/main/java/com/tangem/tap/features/tokens/ui/compose/CurrenciesScreen.kt
+++ b/app/src/main/java/com/tangem/tap/features/tokens/ui/compose/CurrenciesScreen.kt
@@ -14,6 +14,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.tangem.blockchain.common.Blockchain
@@ -126,7 +127,7 @@ fun SaveChangesButton(keyboardState: Keyboard, onSaveChanges: () -> Unit) {
)
},
onClick = onSaveChanges,
- backgroundColor = Color(0xFF1ACE80),
+ backgroundColor = colorResource(id = R.color.accent),
contentColor = Color.White,
modifier = Modifier.padding(bottom = padding.dp)
)
diff --git a/app/src/main/res/drawable/ic_clear.xml b/app/src/main/res/drawable/ic_clear.xml
new file mode 100644
index 0000000000..2f59f4cb34
--- /dev/null
+++ b/app/src/main/res/drawable/ic_clear.xml
@@ -0,0 +1,10 @@
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_paste.xml b/app/src/main/res/drawable/ic_paste.xml
index 5bc825fa49..c49d12dc4b 100644
--- a/app/src/main/res/drawable/ic_paste.xml
+++ b/app/src/main/res/drawable/ic_paste.xml
@@ -4,6 +4,6 @@
android:viewportWidth="16"
android:viewportHeight="19">
+ android:fillColor="#1C1C1E"
+ android:pathData="M13.8333,1.6667H10.35C10,0.7 9.0833,0 8,0C6.9167,0 6,0.7 5.65,1.6667H2.1667C1.25,1.6667 0.5,2.4167 0.5,3.3333V16.6667C0.5,17.5833 1.25,18.3333 2.1667,18.3333H13.8333C14.75,18.3333 15.5,17.5833 15.5,16.6667V3.3333C15.5,2.4167 14.75,1.6667 13.8333,1.6667ZM8,1.6667C8.4583,1.6667 8.8333,2.0417 8.8333,2.5C8.8333,2.9583 8.4583,3.3333 8,3.3333C7.5417,3.3333 7.1667,2.9583 7.1667,2.5C7.1667,2.0417 7.5417,1.6667 8,1.6667ZM13.8333,16.6667H2.1667V3.3333H3.8333V5.8333H12.1667V3.3333H13.8333V16.6667Z" />
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index ecb9562aad..70a942b055 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -3,21 +3,23 @@
#0029FF
#0022D4
- #1ACE80
+ #19C878
+ #801ACE80
- @color/backgroundLightGray
+ @color/accent
@color/accent
- #661ACE80
+ @color/accent_disabled
@color/darkGray6
#6A6A6A
- #5AC461
+ @color/accent
#C4291C
#FFB71B
- #FFFFFF
+ @color/backgroundLightGray
+ #FFFFFF
#F3F3F3
#F8F8FB
#DADADF
@@ -62,6 +64,4 @@
#CA0F03
#EFEFF0
-
- #18C077
\ No newline at end of file