1
+ package org.mifos.mobilewallet.mifospay.settings.ui
2
+
3
+ import androidx.compose.foundation.background
4
+ import androidx.compose.foundation.clickable
5
+ import androidx.compose.foundation.layout.Column
6
+ import androidx.compose.foundation.layout.ColumnScope
7
+ import androidx.compose.foundation.layout.Row
8
+ import androidx.compose.foundation.layout.fillMaxSize
9
+ import androidx.compose.foundation.layout.fillMaxWidth
10
+ import androidx.compose.foundation.layout.padding
11
+ import androidx.compose.foundation.shape.RoundedCornerShape
12
+ import androidx.compose.material.icons.Icons
13
+ import androidx.compose.material.icons.filled.ArrowBack
14
+ import androidx.compose.material3.Card
15
+ import androidx.compose.material3.CardColors
16
+ import androidx.compose.material3.CardDefaults
17
+ import androidx.compose.material3.ExperimentalMaterial3Api
18
+ import androidx.compose.material3.Icon
19
+ import androidx.compose.material3.IconButton
20
+ import androidx.compose.material3.Scaffold
21
+ import androidx.compose.material3.Text
22
+ import androidx.compose.material3.TopAppBar
23
+ import androidx.compose.material3.TopAppBarDefaults
24
+ import androidx.compose.runtime.Composable
25
+ import androidx.compose.ui.Modifier
26
+ import androidx.compose.ui.graphics.Color
27
+ import androidx.compose.ui.graphics.Shape
28
+ import androidx.compose.ui.res.stringResource
29
+ import androidx.compose.ui.text.TextStyle
30
+ import androidx.compose.ui.text.font.FontWeight
31
+ import androidx.compose.ui.text.style.TextAlign
32
+ import androidx.compose.ui.tooling.preview.Preview
33
+ import androidx.compose.ui.unit.Dp
34
+ import androidx.compose.ui.unit.dp
35
+ import androidx.compose.ui.unit.sp
36
+ import org.mifos.mobilewallet.mifospay.R
37
+
38
+ @OptIn(ExperimentalMaterial3Api ::class )
39
+ @Composable
40
+ fun SettingsScreen (
41
+ backPress : () -> Unit ,
42
+ disable : () -> Unit ,
43
+ logout : () -> Unit
44
+ ) {
45
+ Scaffold (
46
+ topBar = {
47
+ TopAppBar (
48
+ title = {
49
+ Text (
50
+ text = stringResource(id = R .string.settings),
51
+ style = TextStyle (
52
+ color = Color (0xFF212121 ),
53
+ fontWeight = FontWeight .SemiBold ,
54
+ fontSize = 20 .sp
55
+ )
56
+ )
57
+ },
58
+ navigationIcon = {
59
+ IconButton (onClick = { backPress.invoke() }) {
60
+ Icon (
61
+ imageVector = Icons .Filled .ArrowBack ,
62
+ contentDescription = " Back" ,
63
+ tint = Color (0xFF212121 )
64
+ )
65
+ }
66
+ },
67
+ colors = TopAppBarDefaults .mediumTopAppBarColors(containerColor = Color .White )
68
+ )
69
+ }
70
+ ) {
71
+ Column (
72
+ modifier = Modifier
73
+ .fillMaxSize()
74
+ .background(Color .White )
75
+ .padding(it)
76
+ ) {
77
+ Row (modifier = Modifier .padding(20 .dp)) {
78
+ MifosItemCard (
79
+ onClick = { /* TODO*/ },
80
+ colors = CardDefaults .cardColors(Color .White )
81
+ ) {
82
+ Text (
83
+ text = stringResource(id = R .string.notification_settings),
84
+ modifier = Modifier
85
+ .fillMaxWidth()
86
+ .padding(20 .dp),
87
+ style = TextStyle (fontSize = 17 .sp, color = Color (0xFF212121 ))
88
+ )
89
+ }
90
+ }
91
+
92
+ Column (
93
+ modifier = Modifier
94
+ .fillMaxSize()
95
+ .weight(1f )
96
+ ) {}
97
+
98
+ Row (modifier = Modifier .padding(8 .dp)) {
99
+ MifosItemCard (
100
+ onClick = { disable.invoke() },
101
+ colors = CardDefaults .cardColors(Color .Black )
102
+ ) {
103
+ Text (
104
+ text = stringResource(id = R .string.disable_account).uppercase(),
105
+ modifier = Modifier
106
+ .fillMaxWidth()
107
+ .padding(20 .dp),
108
+ style = TextStyle (color = Color .White , textAlign = TextAlign .Center )
109
+ )
110
+ }
111
+ }
112
+
113
+ Row (modifier = Modifier .padding(8 .dp)) {
114
+ MifosItemCard (
115
+ onClick = { logout.invoke() },
116
+ colors = CardDefaults .cardColors(Color .Black )
117
+ ) {
118
+ Text (
119
+ text = stringResource(id = R .string.log_out).uppercase(),
120
+ modifier = Modifier
121
+ .fillMaxWidth()
122
+ .padding(20 .dp),
123
+ style = TextStyle (color = Color .White , textAlign = TextAlign .Center )
124
+ )
125
+ }
126
+ }
127
+ }
128
+ }
129
+
130
+
131
+ }
132
+
133
+ @Composable
134
+ fun MifosItemCard (
135
+ modifier : Modifier = Modifier ,
136
+ shape : Shape = RoundedCornerShape (8.dp),
137
+ elevation : Dp = 1.dp,
138
+ onClick : () -> Unit ,
139
+ colors : CardColors = CardDefaults .cardColors(),
140
+ content : @Composable ColumnScope .() -> Unit
141
+ ) {
142
+ Card (
143
+ shape = shape,
144
+ modifier = modifier
145
+ .fillMaxWidth()
146
+ .clickable(onClick = onClick),
147
+ elevation = CardDefaults .cardElevation(
148
+ defaultElevation = elevation
149
+ ),
150
+ colors = colors,
151
+ content = content
152
+ )
153
+ }
154
+
155
+ @Preview(showSystemUi = true )
156
+ @Composable
157
+ fun SettingsScreenPreview () {
158
+ SettingsScreen ({}, {}, {})
159
+ }
0 commit comments