@@ -2,18 +2,26 @@ package org.mifos.mobilewallet.mifospay.home.ui
2
2
3
3
import androidx.compose.foundation.layout.Arrangement
4
4
import androidx.compose.foundation.layout.Column
5
+ import androidx.compose.foundation.layout.ExperimentalLayoutApi
6
+ import androidx.compose.foundation.layout.FlowRow
5
7
import androidx.compose.foundation.layout.Row
6
- import androidx.compose.foundation.layout.Spacer
7
8
import androidx.compose.foundation.layout.fillMaxSize
8
9
import androidx.compose.foundation.layout.fillMaxWidth
9
- import androidx.compose.foundation.layout.height
10
10
import androidx.compose.foundation.layout.padding
11
- import androidx.compose.foundation.layout.width
11
+ import androidx.compose.material.icons.Icons
12
+ import androidx.compose.material.icons.filled.ArrowDropDown
13
+ import androidx.compose.material3.Icon
14
+ import androidx.compose.material3.IconButton
12
15
import androidx.compose.material3.Text
13
16
import androidx.compose.runtime.Composable
14
17
import androidx.compose.runtime.collectAsState
15
18
import androidx.compose.runtime.getValue
19
+ import androidx.compose.runtime.mutableStateOf
20
+ import androidx.compose.runtime.remember
21
+ import androidx.compose.runtime.setValue
22
+ import androidx.compose.ui.Alignment
16
23
import androidx.compose.ui.Modifier
24
+ import androidx.compose.ui.graphics.Color
17
25
import androidx.compose.ui.text.TextStyle
18
26
import androidx.compose.ui.text.font.FontWeight
19
27
import androidx.compose.ui.tooling.preview.Preview
@@ -25,68 +33,101 @@ import org.mifos.mobilewallet.mifospay.designsystem.component.ProfileImage
25
33
import org.mifos.mobilewallet.mifospay.home.presenter.ProfileViewModel
26
34
import org.mifos.mobilewallet.mifospay.ui.utility.Orientation
27
35
36
+ @OptIn(ExperimentalLayoutApi ::class )
28
37
@Composable
29
38
fun ProfileScreen (
30
39
viewModel : ProfileViewModel = hiltViewModel(),
31
40
onEditProfile : () -> Unit ,
32
41
onSettings : () -> Unit ,
33
42
) {
34
43
val bitmap by viewModel.bitmapImage.collectAsState()
44
+ val name = viewModel.name.collectAsState().value
45
+ val email = viewModel.email.collectAsState().value
46
+ val vpa = viewModel.vpa.collectAsState().value
47
+ val mobile = viewModel.mobile.collectAsState().value
48
+
49
+ var showDetails by remember { mutableStateOf(false ) }
35
50
36
51
Column (modifier = Modifier .fillMaxSize()) {
37
52
ProfileImage (bitmap = bitmap)
38
53
Row (
39
54
modifier = Modifier
40
55
.fillMaxWidth()
41
- .padding(top = 12 .dp, bottom = 20 .dp),
42
- horizontalArrangement = Arrangement .Center
56
+ .padding(top = 12 .dp, bottom = 8 .dp),
57
+ horizontalArrangement = Arrangement .Center ,
58
+ verticalAlignment = Alignment .CenterVertically
43
59
) {
44
60
Text (
45
- text = " John Doe " ,
46
- style = TextStyle (fontSize = 24 .sp, fontWeight = FontWeight .Medium )
61
+ text = name.toString() ,
62
+ style = TextStyle (fontSize = 24 .sp, fontWeight = FontWeight .Medium ),
47
63
)
64
+ IconButton (onClick = { showDetails = ! showDetails }) {
65
+ Icon (
66
+ imageVector = Icons .Default .ArrowDropDown ,
67
+ tint = Color .Black ,
68
+ contentDescription = null
69
+ )
70
+ }
71
+ }
72
+
73
+ if (showDetails) {
74
+ Column (
75
+ modifier = Modifier .fillMaxWidth(),
76
+ verticalArrangement = Arrangement .Center ,
77
+ horizontalAlignment = Alignment .CenterHorizontally
78
+ ) {
79
+ DetailItem (label = " Email" , value = email.toString())
80
+ DetailItem (label = " VPA" , value = vpa.toString())
81
+ DetailItem (label = " Mobile" , value = mobile.toString())
82
+ }
48
83
}
49
84
50
85
Column (
51
86
modifier = Modifier
52
87
.fillMaxSize()
53
88
.padding(start = 24 .dp, end = 24 .dp)
54
89
) {
55
- Row (
90
+ FlowRow (
56
91
modifier = Modifier
57
- .fillMaxWidth()
58
- .padding(bottom = 24 .dp)
92
+ .fillMaxWidth(),
93
+ maxItemsInEachRow = 2
59
94
) {
60
- ItemCard (
61
- modifier = Modifier .weight(1f ),
95
+ ProfileItemCard (
96
+ modifier = Modifier
97
+ .padding(end = 8 .dp, bottom = 8 .dp)
98
+ .weight(1f ),
62
99
icon = R .drawable.qrcode_black,
63
100
text = R .string.personal_qr_code,
64
- onClick = {},
65
- orientation = Orientation .VERTICAL
101
+ onClick = {}
66
102
)
67
- Spacer (modifier = Modifier .width(16 .dp))
68
- ItemCard (
69
- modifier = Modifier .weight(1f ),
103
+
104
+ ProfileItemCard (
105
+ modifier = Modifier
106
+ .padding(start = 8 .dp, bottom = 8 .dp)
107
+ .weight(1f ),
70
108
icon = R .drawable.ic_bank,
71
109
text = R .string.link_bank_account,
72
- onClick = {},
73
- orientation = Orientation .VERTICAL
110
+ onClick = {}
74
111
)
75
- }
76
- ItemCard (
77
- icon = R .drawable.ic_contact,
78
- text = R .string.edit_profile,
79
- onClick = { onEditProfile.invoke() },
80
- orientation = Orientation .HORIZONTAL
81
- )
82
- Spacer (modifier = Modifier .height(24 .dp))
83
- ItemCard (
84
- icon = R .drawable.ic_setting,
85
- text = R .string.settings,
86
- onClick = { onSettings.invoke() },
87
- orientation = Orientation .HORIZONTAL
88
- )
89
112
113
+ ProfileItemCard (
114
+ modifier = Modifier
115
+ .padding(top = 8 .dp, bottom = 8 .dp),
116
+ icon = R .drawable.ic_contact,
117
+ text = R .string.edit_profile,
118
+ onClick = { onEditProfile.invoke() },
119
+ orientation = Orientation .HORIZONTAL
120
+ )
121
+
122
+ ProfileItemCard (
123
+ modifier = Modifier
124
+ .padding(top = 8 .dp),
125
+ icon = R .drawable.ic_setting,
126
+ text = R .string.settings,
127
+ onClick = { onSettings.invoke() },
128
+ orientation = Orientation .HORIZONTAL
129
+ )
130
+ }
90
131
}
91
132
}
92
133
}
0 commit comments