Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Improve ExchangeRatesScreen.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Dec 27, 2022
1 parent be86fac commit 0c6c711
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ivy.wallet.ui.exchangerates

import androidx.compose.foundation.layout.BoxWithConstraintsScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
Expand All @@ -12,6 +13,7 @@ import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel
Expand Down Expand Up @@ -87,7 +89,7 @@ private fun BoxWithConstraintsScope.UI(
)
}
item(key = "last_item_spacer") {
SpacerVer(height = 48.dp)
SpacerVer(height = 480.dp)
}
}
}
Expand All @@ -108,6 +110,7 @@ private fun BoxWithConstraintsScope.UI(
}
) {
Text(
modifier = Modifier.padding(vertical = 16.dp),
text = "Add rate",
style = UI.typo.b1.style(
color = White
Expand All @@ -132,6 +135,21 @@ private fun BoxWithConstraintsScope.UI(
amountModalVisible = false
},
decimalCountMax = 12,
Header = {
rateToUpdate?.let {
SpacerVer(height = 24.dp)
Text(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 16.dp),
text = "${it.from}-${it.to}",
style = UI.typo.nH2.style(
textAlign = TextAlign.Center,
color = UI.colors.primary
)
)
}
},
onAmountChanged = { newRate ->
rateToUpdate?.let {
onEvent(RatesEvent.UpdateRate(rateToUpdate!!, newRate))
Expand Down Expand Up @@ -169,6 +187,7 @@ private fun SearchField(
SearchInput(
searchQueryTextFieldValue = searchQueryTextFieldValue,
hint = "Search currency",
focus = false,
onSetSearchQueryTextField = {
searchQueryTextFieldValue = it
onSearch(it.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class ExchangeRatesViewModel @Inject constructor(
} else {
rates
}
}.map { rates ->
// filter not base currency
val baseCurrency = baseCurrencyAct(Unit)
rates.filter { it.baseCurrency == baseCurrency }
}.map { rates ->
RatesState(
baseCurrency = baseCurrencyAct(Unit),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fun RateItem(
)
SpacerHor(width = 8.dp)
Text(
text = rate.rate.format(2),
text = rate.rate.format(currencyCode = rate.to),
style = UI.typo.nB1.style(
fontWeight = FontWeight.SemiBold
)
Expand Down

0 comments on commit 0c6c711

Please sign in to comment.