Skip to content

Commit

Permalink
Extract DataFieldFee composable
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed Apr 30, 2024
1 parent 6cc6cea commit 39550c3
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 181 deletions.
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
package io.horizontalsystems.bankwallet.modules.eip20approve

import android.os.Parcelable
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavController
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseComposeFragment
import io.horizontalsystems.bankwallet.core.setNavigationResultX
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.core.slideFromRight
import io.horizontalsystems.bankwallet.modules.confirm.ConfirmTransactionScreen
import io.horizontalsystems.bankwallet.modules.eip20approve.AllowanceMode.OnlyRequired
import io.horizontalsystems.bankwallet.modules.eip20approve.AllowanceMode.Unlimited
import io.horizontalsystems.bankwallet.modules.evmfee.Cautions
import io.horizontalsystems.bankwallet.modules.evmfee.FeeSettingsInfoDialog
import io.horizontalsystems.bankwallet.modules.multiswap.QuoteInfoRow
import io.horizontalsystems.bankwallet.modules.multiswap.TokenRow
import io.horizontalsystems.bankwallet.modules.multiswap.TokenRowUnlimited
import io.horizontalsystems.bankwallet.modules.multiswap.ui.DataFieldFee
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryDefault
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryYellow
Expand All @@ -42,8 +33,6 @@ import io.horizontalsystems.bankwallet.ui.compose.components.TransactionInfoCont
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.cell.BoxBorderedTop
import io.horizontalsystems.bankwallet.ui.compose.components.cell.SectionUniversalLawrence
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_leah
import io.horizontalsystems.core.SnackbarDuration
import io.horizontalsystems.core.helpers.HudHelper
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -162,42 +151,10 @@ fun Eip20ApproveConfirmScreen(navController: NavController) {

VSpacer(height = 16.dp)
SectionUniversalLawrence {
QuoteInfoRow(
title = {
val title = stringResource(id = R.string.FeeSettings_NetworkFee)
val infoText = stringResource(id = R.string.FeeSettings_NetworkFee_Info)

subhead2_grey(text = title)

Image(
modifier = Modifier
.padding(horizontal = 8.dp)
.clickable(
onClick = {
navController.slideFromBottom(
R.id.feeSettingsInfoDialog,
FeeSettingsInfoDialog.Input(title, infoText)
)
},
interactionSource = remember { MutableInteractionSource() },
indication = null
)
,
painter = painterResource(id = R.drawable.ic_info_20),
contentDescription = ""
)

},
value = {
val primary = uiState.networkFee?.primary?.getFormattedPlain() ?: "---"
val secondary = uiState.networkFee?.secondary?.getFormattedPlain() ?: "---"

Column(horizontalAlignment = Alignment.End) {
subhead2_leah(text = primary)
VSpacer(height = 1.dp)
subhead2_grey(text = secondary)
}
}
DataFieldFee(
navController,
uiState.networkFee?.primary?.getFormattedPlain() ?: "---",
uiState.networkFee?.secondary?.getFormattedPlain() ?: "---"
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package io.horizontalsystems.bankwallet.modules.eip20revoke

import android.os.Parcelable
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
Expand All @@ -25,13 +18,11 @@ import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseComposeFragment
import io.horizontalsystems.bankwallet.core.requireInput
import io.horizontalsystems.bankwallet.core.setNavigationResultX
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.core.slideFromRight
import io.horizontalsystems.bankwallet.modules.confirm.ConfirmTransactionScreen
import io.horizontalsystems.bankwallet.modules.evmfee.Cautions
import io.horizontalsystems.bankwallet.modules.evmfee.FeeSettingsInfoDialog
import io.horizontalsystems.bankwallet.modules.multiswap.QuoteInfoRow
import io.horizontalsystems.bankwallet.modules.multiswap.TokenRow
import io.horizontalsystems.bankwallet.modules.multiswap.ui.DataFieldFee
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryDefault
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryYellow
Expand All @@ -40,8 +31,6 @@ import io.horizontalsystems.bankwallet.ui.compose.components.TransactionInfoCont
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.cell.BoxBorderedTop
import io.horizontalsystems.bankwallet.ui.compose.components.cell.SectionUniversalLawrence
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_leah
import io.horizontalsystems.core.SnackbarDuration
import io.horizontalsystems.core.helpers.HudHelper
import io.horizontalsystems.marketkit.models.Token
Expand Down Expand Up @@ -160,41 +149,10 @@ fun Eip20RevokeScreen(navController: NavController, input: Eip20RevokeConfirmFra

VSpacer(height = 16.dp)
SectionUniversalLawrence {
QuoteInfoRow(
title = {
val title = stringResource(id = R.string.FeeSettings_NetworkFee)
val infoText = stringResource(id = R.string.FeeSettings_NetworkFee_Info)

subhead2_grey(text = title)

Image(
modifier = Modifier
.padding(horizontal = 8.dp)
.clickable(
onClick = {
navController.slideFromBottom(
R.id.feeSettingsInfoDialog,
FeeSettingsInfoDialog.Input(title, infoText)
)
},
interactionSource = remember { MutableInteractionSource() },
indication = null
),
painter = painterResource(id = R.drawable.ic_info_20),
contentDescription = ""
)

},
value = {
val primary = uiState.networkFee?.primary?.getFormattedPlain() ?: "---"
val secondary = uiState.networkFee?.secondary?.getFormattedPlain() ?: "---"

Column(horizontalAlignment = Alignment.End) {
subhead2_leah(text = primary)
VSpacer(height = 1.dp)
subhead2_grey(text = secondary)
}
}
DataFieldFee(
navController,
uiState.networkFee?.primary?.getFormattedPlain() ?: "---",
uiState.networkFee?.secondary?.getFormattedPlain() ?: "---"
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package io.horizontalsystems.bankwallet.modules.multiswap

import android.os.Parcelable
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
Expand All @@ -19,7 +15,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
Expand All @@ -30,14 +25,13 @@ import io.horizontalsystems.bankwallet.core.badge
import io.horizontalsystems.bankwallet.core.iconPlaceholder
import io.horizontalsystems.bankwallet.core.imageUrl
import io.horizontalsystems.bankwallet.core.setNavigationResultX
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.core.slideFromRight
import io.horizontalsystems.bankwallet.entities.CoinValue
import io.horizontalsystems.bankwallet.entities.Currency
import io.horizontalsystems.bankwallet.entities.CurrencyValue
import io.horizontalsystems.bankwallet.modules.confirm.ConfirmTransactionScreen
import io.horizontalsystems.bankwallet.modules.evmfee.Cautions
import io.horizontalsystems.bankwallet.modules.evmfee.FeeSettingsInfoDialog
import io.horizontalsystems.bankwallet.modules.multiswap.ui.DataFieldFee
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryDefault
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryYellow
Expand Down Expand Up @@ -213,42 +207,10 @@ fun SwapConfirmScreen(navController: NavController) {

VSpacer(height = 16.dp)
SectionUniversalLawrence {
QuoteInfoRow(
title = {
val title = stringResource(id = R.string.FeeSettings_NetworkFee)
val infoText = stringResource(id = R.string.FeeSettings_NetworkFee_Info)

subhead2_grey(text = title)

Image(
modifier = Modifier
.padding(horizontal = 8.dp)
.clickable(
onClick = {
navController.slideFromBottom(
R.id.feeSettingsInfoDialog,
FeeSettingsInfoDialog.Input(title, infoText)
)
},
interactionSource = remember { MutableInteractionSource() },
indication = null
)
,
painter = painterResource(id = R.drawable.ic_info_20),
contentDescription = ""
)

},
value = {
val primary = uiState.networkFee?.primary?.getFormattedPlain() ?: "---"
val secondary = uiState.networkFee?.secondary?.getFormattedPlain() ?: "---"

Column(horizontalAlignment = Alignment.End) {
subhead2_leah(text = primary)
VSpacer(height = 1.dp)
subhead2_grey(text = secondary)
}
}
DataFieldFee(
navController,
uiState.networkFee?.primary?.getFormattedPlain() ?: "---",
uiState.networkFee?.secondary?.getFormattedPlain() ?: "---"
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.horizontalsystems.bankwallet.modules.multiswap.ui

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.slideFromBottom
import io.horizontalsystems.bankwallet.modules.evmfee.FeeSettingsInfoDialog
import io.horizontalsystems.bankwallet.modules.multiswap.QuoteInfoRow
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_leah

@Composable
fun DataFieldFee(
navController: NavController,
primary: String,
secondary: String,
) {
QuoteInfoRow(
title = {
val title = stringResource(id = R.string.FeeSettings_NetworkFee)
val infoText = stringResource(id = R.string.FeeSettings_NetworkFee_Info)

subhead2_grey(text = title)

Image(
modifier = Modifier
.padding(horizontal = 8.dp)
.clickable(
onClick = {
navController.slideFromBottom(
R.id.feeSettingsInfoDialog,
FeeSettingsInfoDialog.Input(title, infoText)
)
},
interactionSource = remember { MutableInteractionSource() },
indication = null
),
painter = painterResource(id = R.drawable.ic_info_20),
contentDescription = ""
)

},
value = {
Column(horizontalAlignment = Alignment.End) {
subhead2_leah(text = primary)
VSpacer(height = 1.dp)
subhead2_grey(text = secondary)
}
}
)
}
Loading

0 comments on commit 39550c3

Please sign in to comment.