@@ -2,9 +2,13 @@ package com.ivy.exchangerates.component
2
2
3
3
import androidx.compose.foundation.border
4
4
import androidx.compose.foundation.clickable
5
+ import androidx.compose.foundation.layout.Column
5
6
import androidx.compose.foundation.layout.Row
6
7
import androidx.compose.foundation.layout.fillMaxWidth
7
8
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
8
12
import androidx.compose.material3.Text
9
13
import androidx.compose.runtime.Composable
10
14
import androidx.compose.ui.Alignment
@@ -26,32 +30,72 @@ fun RateItem(
26
30
rate : RateUi ,
27
31
onDelete : (() -> Unit )? ,
28
32
onClick : () -> Unit ,
33
+ modifier : Modifier = Modifier
29
34
) {
30
35
Row (
31
- modifier = Modifier
32
- .fillMaxWidth()
33
- .border(1 .dp, UI .colors.primary)
36
+ modifier = modifier
37
+ .padding(
38
+ horizontal = 16 .dp
39
+ )
34
40
.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
+
37
43
) {
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 {
38
81
Text (
39
- text = " ${rate.from} - ${rate.to} : " ,
40
- style = UI .typo.nB1 .style(
82
+ text = label ,
83
+ style = UI .typo.c .style(
41
84
fontWeight = FontWeight .Normal
42
85
)
43
86
)
44
- SpacerHor (width = 8 .dp)
45
87
Text (
46
- text = rate.rate.format(currencyCode = rate.to) ,
88
+ text = rate,
47
89
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
49
97
)
50
98
)
51
- if (onDelete != null ) {
52
- SpacerWeight (weight = 1f )
53
- DeleteButton (onClick = onDelete)
54
- }
55
99
}
56
100
}
57
101
@@ -62,10 +106,10 @@ private fun Preview() {
62
106
IvyWalletComponentPreview {
63
107
RateItem (
64
108
rate = RateUi (
65
- from = " BGN" ,
66
- to = " EUR" ,
67
- rate = 1.95583
68
- ),
109
+ from = " BGN" ,
110
+ to = " EUR" ,
111
+ rate = 1.95583
112
+ ),
69
113
onDelete = null ,
70
114
onClick = {}
71
115
)
@@ -81,7 +125,7 @@ private fun Preview_Delete() {
81
125
from = " BGN" ,
82
126
to = " EUR" ,
83
127
rate = 1.95583
84
- ),
128
+ ),
85
129
onDelete = { },
86
130
onClick = {}
87
131
)
0 commit comments