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

Commit f5565fb

Browse files
Fix issue 3473 (#3489)
* Redesign Rate Item from ExchangeRatesScreen * Redesign Rate Item from ExchangeRatesScreen
1 parent 485b6d4 commit f5565fb

4 files changed

+79
-34
lines changed

screen/exchange-rates/src/main/java/com/ivy/exchangerates/ExchangeRatesScreen.kt

+16-15
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import androidx.compose.foundation.layout.systemBarsPadding
88
import androidx.compose.foundation.lazy.LazyColumn
99
import androidx.compose.foundation.lazy.LazyListScope
1010
import androidx.compose.foundation.lazy.items
11-
import androidx.compose.material3.Button
12-
import androidx.compose.material3.ButtonDefaults
11+
import androidx.compose.foundation.shape.RoundedCornerShape
12+
import androidx.compose.material.icons.Icons
13+
import androidx.compose.material.icons.filled.Add
14+
import androidx.compose.material3.FloatingActionButton
15+
import androidx.compose.material3.Icon
1316
import androidx.compose.material3.Text
1417
import androidx.compose.runtime.Composable
1518
import androidx.compose.runtime.getValue
@@ -103,27 +106,25 @@ private fun BoxWithConstraintsScope.UI(
103106
var addRateModalVisible by remember {
104107
mutableStateOf(false)
105108
}
106-
Button(
109+
110+
FloatingActionButton(
107111
modifier = Modifier
108112
.systemBarsPadding()
109-
.align(Alignment.BottomCenter)
110-
.padding(bottom = 24.dp),
111-
colors = ButtonDefaults.buttonColors(
112-
containerColor = UI.colors.primary,
113-
contentColor = White,
114-
),
113+
.align(Alignment.BottomEnd)
114+
.padding(all = 24.dp),
115+
containerColor = UI.colors.primary,
116+
contentColor = White,
117+
shape = RoundedCornerShape(100.dp),
115118
onClick = {
116119
addRateModalVisible = true
117120
}
118121
) {
119-
Text(
120-
modifier = Modifier.padding(vertical = 16.dp),
121-
text = "Add rate",
122-
style = UI.typo.b1.style(
123-
color = White
124-
)
122+
Icon(
123+
imageVector = Icons.Filled.Add,
124+
contentDescription = "Add rate Icon",
125125
)
126126
}
127+
127128
AddRateModal(
128129
visible = addRateModalVisible,
129130
baseCurrency = state.baseCurrency,

screen/exchange-rates/src/main/java/com/ivy/exchangerates/component/RateItem.kt

+63-19
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ package com.ivy.exchangerates.component
22

33
import androidx.compose.foundation.border
44
import androidx.compose.foundation.clickable
5+
import androidx.compose.foundation.layout.Column
56
import androidx.compose.foundation.layout.Row
67
import androidx.compose.foundation.layout.fillMaxWidth
78
import androidx.compose.foundation.layout.padding
9+
import androidx.compose.material.icons.Icons
10+
import androidx.compose.material.icons.filled.ArrowForward
11+
import androidx.compose.material3.Icon
812
import androidx.compose.material3.Text
913
import androidx.compose.runtime.Composable
1014
import androidx.compose.ui.Alignment
@@ -26,32 +30,72 @@ fun RateItem(
2630
rate: RateUi,
2731
onDelete: (() -> Unit)?,
2832
onClick: () -> Unit,
33+
modifier: Modifier = Modifier
2934
) {
3035
Row(
31-
modifier = Modifier
32-
.fillMaxWidth()
33-
.border(1.dp, UI.colors.primary)
36+
modifier = modifier
37+
.padding(
38+
horizontal = 16.dp
39+
)
3440
.clickable(onClick = onClick)
35-
.padding(horizontal = 16.dp, vertical = 12.dp),
36-
verticalAlignment = Alignment.CenterVertically
41+
.border(2.dp, UI.colors.medium, UI.shapes.r4)
42+
3743
) {
44+
Row(
45+
modifier = Modifier
46+
.fillMaxWidth()
47+
.padding(horizontal = 16.dp, vertical = 12.dp),
48+
verticalAlignment = Alignment.CenterVertically
49+
50+
) {
51+
val currencyValue: Double = 1.0
52+
RateColumn(
53+
label = "Sell",
54+
rate = rate.from,
55+
value = currencyValue.format(currencyCode = rate.from)
56+
)
57+
58+
SpacerHor(width = 16.dp)
59+
Icon(
60+
imageVector = Icons.Filled.ArrowForward,
61+
contentDescription = "arrow to next"
62+
)
63+
SpacerHor(width = 16.dp)
64+
RateColumn(
65+
label = "Buy",
66+
rate = rate.to,
67+
value = rate.rate.format(currencyCode = rate.to)
68+
)
69+
70+
if (onDelete != null) {
71+
SpacerWeight(weight = 1f)
72+
DeleteButton(onClick = onDelete)
73+
}
74+
}
75+
}
76+
}
77+
78+
@Composable
79+
private fun RateColumn(label: String, rate: String, value: String) {
80+
Column {
3881
Text(
39-
text = "${rate.from}-${rate.to}:",
40-
style = UI.typo.nB1.style(
82+
text = label,
83+
style = UI.typo.c.style(
4184
fontWeight = FontWeight.Normal
4285
)
4386
)
44-
SpacerHor(width = 8.dp)
4587
Text(
46-
text = rate.rate.format(currencyCode = rate.to),
88+
text = rate,
4789
style = UI.typo.nB1.style(
48-
fontWeight = FontWeight.SemiBold
90+
fontWeight = FontWeight.ExtraBold
91+
)
92+
)
93+
Text(
94+
text = value,
95+
style = UI.typo.nB2.style(
96+
fontWeight = FontWeight.Normal
4997
)
5098
)
51-
if (onDelete != null) {
52-
SpacerWeight(weight = 1f)
53-
DeleteButton(onClick = onDelete)
54-
}
5599
}
56100
}
57101

@@ -62,10 +106,10 @@ private fun Preview() {
62106
IvyWalletComponentPreview {
63107
RateItem(
64108
rate = RateUi(
65-
from = "BGN",
66-
to = "EUR",
67-
rate = 1.95583
68-
),
109+
from = "BGN",
110+
to = "EUR",
111+
rate = 1.95583
112+
),
69113
onDelete = null,
70114
onClick = {}
71115
)
@@ -81,7 +125,7 @@ private fun Preview_Delete() {
81125
from = "BGN",
82126
to = "EUR",
83127
rate = 1.95583
84-
),
128+
),
85129
onDelete = { },
86130
onClick = {}
87131
)

0 commit comments

Comments
 (0)