@@ -17,11 +17,9 @@ import androidx.compose.material.icons.outlined.Check
17
17
import androidx.compose.material.icons.outlined.Edit
18
18
import androidx.compose.material3.Button
19
19
import androidx.compose.material3.ExperimentalMaterial3Api
20
- import androidx.compose.material3.HorizontalDivider
21
20
import androidx.compose.material3.Icon
22
21
import androidx.compose.material3.MaterialTheme
23
22
import androidx.compose.material3.ModalBottomSheet
24
- import androidx.compose.material3.OutlinedCard
25
23
import androidx.compose.material3.SheetState
26
24
import androidx.compose.material3.Text
27
25
import androidx.compose.runtime.Composable
@@ -78,33 +76,32 @@ enum class CONTENT {
78
76
@OptIn(ExperimentalMaterial3Api ::class )
79
77
@Composable
80
78
fun MapBottomSheet (
81
- sheetState : SheetState ,
82
- content : CONTENT ,
83
- onSheetDismissRequest : () -> Unit ,
84
- alertToDisplay : Alert ? ,
85
- onEditClick : () -> Unit ,
86
- onAcceptClick : () -> Unit ,
87
- onResolveClick : () -> Unit ,
79
+ sheetState : SheetState ,
80
+ content : CONTENT ,
81
+ onSheetDismissRequest : () -> Unit ,
82
+ alertToDisplay : Alert ? ,
83
+ onEditClick : () -> Unit ,
84
+ onAcceptClick : () -> Unit ,
85
+ onResolveClick : () -> Unit ,
88
86
) {
89
87
90
88
ModalBottomSheet (
91
- onDismissRequest = onSheetDismissRequest,
92
- sheetState = sheetState,
93
- modifier = Modifier .fillMaxWidth().wrapContentHeight().testTag(BOTTOM_SHEET ),
89
+ onDismissRequest = onSheetDismissRequest,
90
+ sheetState = sheetState,
91
+ modifier = Modifier .fillMaxWidth().wrapContentHeight().testTag(BOTTOM_SHEET ),
94
92
) {
95
93
Column (
96
- verticalArrangement =
97
- Arrangement .spacedBy(MaterialTheme .dimens.small2),
98
- horizontalAlignment = Alignment .CenterHorizontally ,
99
- modifier = Modifier .padding(MaterialTheme .dimens.small3),
94
+ verticalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small2),
95
+ horizontalAlignment = Alignment .CenterHorizontally ,
96
+ modifier = Modifier .padding(MaterialTheme .dimens.small3),
100
97
) {
101
98
alertToDisplay?.let { AlertInfo (it) } ? : Log .d(TAG , " Alert is null" )
102
99
103
100
InteractionButtons (
104
- content = content,
105
- onEditClick = onEditClick,
106
- onAccpetClick = { TODO (" TO be implemented" ) },
107
- onResolveClick = { TODO (" To be implemented" ) },
101
+ content = content,
102
+ onEditClick = onEditClick,
103
+ onAccpetClick = { TODO (" TO be implemented" ) },
104
+ onResolveClick = { TODO (" To be implemented" ) },
108
105
)
109
106
}
110
107
}
@@ -118,88 +115,87 @@ fun MapBottomSheet(
118
115
@Composable
119
116
private fun AlertInfo (alert : Alert ) {
120
117
Column (
121
- verticalArrangement =
122
- Arrangement .spacedBy(MaterialTheme .dimens.small2, Alignment .CenterVertically )
123
- ) {
124
- Row (
125
- verticalAlignment = Alignment .CenterVertically ,
126
- horizontalArrangement = Arrangement .SpaceBetween ,
127
- modifier = Modifier .fillMaxWidth(),
128
- ) {
118
+ verticalArrangement =
119
+ Arrangement .spacedBy(MaterialTheme .dimens.small2, Alignment .CenterVertically )) {
120
+ Row (
121
+ verticalAlignment = Alignment .CenterVertically ,
122
+ horizontalArrangement = Arrangement .SpaceBetween ,
123
+ modifier = Modifier .fillMaxWidth(),
124
+ ) {
125
+ Row (
126
+ horizontalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small2),
127
+ verticalAlignment = Alignment .CenterVertically ,
128
+ ) {
129
+ // Profile picture
130
+ Icon (
131
+ imageVector = Icons .Outlined .AccountCircle , // TODO fetch from database
132
+ contentDescription = " Profile picture" ,
133
+ modifier =
134
+ Modifier .size(MaterialTheme .dimens.iconSize)
135
+ .wrapContentSize()
136
+ .testTag(PROFILE_PICTURE ),
137
+ )
129
138
130
- Row (
131
- horizontalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small2),
132
- verticalAlignment = Alignment .CenterVertically ,
133
- ) {
134
- // Profile picture
135
- Icon (
136
- imageVector = Icons .Outlined .AccountCircle , // TODO fetch from database
137
- contentDescription = " Profile picture" ,
138
- modifier =
139
- Modifier .size(MaterialTheme .dimens.iconSize).wrapContentSize().testTag(PROFILE_PICTURE ),
140
- )
139
+ Column (verticalArrangement = Arrangement .Center ) {
141
140
142
- Column (verticalArrangement = Arrangement .Center ) {
141
+ // Name
142
+ Text (
143
+ text = alert.name,
144
+ style = MaterialTheme .typography.bodyLarge,
145
+ textAlign = TextAlign .Left ,
146
+ modifier = Modifier .testTag(PROFILE_NAME ),
147
+ )
143
148
144
- // Name
145
- Text (
146
- text = alert.name,
147
- style = MaterialTheme .typography.bodyLarge,
148
- textAlign = TextAlign .Left ,
149
- modifier = Modifier .testTag(PROFILE_NAME ),
150
- )
149
+ Row (horizontalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small1)) {
150
+ val locationText = trimLocationText(Location .fromString(alert.location).name)
151
151
152
- Row (
153
- horizontalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small1)) {
154
- val locationText = trimLocationText(Location .fromString(alert.location).name)
152
+ // Location
153
+ Text (
154
+ text = locationText,
155
+ style = MaterialTheme .typography.bodySmall,
156
+ textAlign = TextAlign .Left ,
157
+ modifier = Modifier .testTag(ALERT_LOCATION_TEXT ),
158
+ )
155
159
156
- // Location
157
- Text (
158
- text = locationText,
159
- style = MaterialTheme .typography.bodySmall,
160
- textAlign = TextAlign .Left ,
161
- modifier = Modifier .testTag(ALERT_LOCATION_TEXT ),
160
+ // Time
161
+ Text (
162
+ text = formatAlertTime(alert.createdAt),
163
+ style = MaterialTheme .typography.bodySmall,
164
+ textAlign = TextAlign .Left ,
165
+ modifier = Modifier .testTag(ALERT_TIME_TEXT ),
166
+ )
167
+ }
168
+ }
169
+ }
170
+
171
+ val periodPalsProduct = productToPeriodPalsIcon(alert.product)
172
+ val periodPalsUrgency = urgencyToPeriodPalsIcon(alert.urgency)
173
+
174
+ Row (
175
+ horizontalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small2),
176
+ ) {
177
+ // Product type
178
+ Icon (
179
+ painter = painterResource(periodPalsProduct.icon),
180
+ contentDescription = periodPalsProduct.textId + " product" ,
181
+ modifier = Modifier .testTag(ALERT_PRODUCT_ICON ),
162
182
)
163
183
164
- // Time
165
- Text (
166
- text = formatAlertTime(alert.createdAt),
167
- style = MaterialTheme .typography.bodySmall,
168
- textAlign = TextAlign .Left ,
169
- modifier = Modifier .testTag(ALERT_TIME_TEXT ),
184
+ // Urgency level
185
+ Icon (
186
+ painter = painterResource(periodPalsUrgency.icon),
187
+ contentDescription = periodPalsUrgency.textId + " urgency" ,
188
+ modifier = Modifier .testTag(ALERT_URGENCY_ICON ),
170
189
)
171
190
}
172
191
}
173
- }
174
-
175
- val periodPalsProduct = productToPeriodPalsIcon(alert.product)
176
- val periodPalsUrgency = urgencyToPeriodPalsIcon(alert.urgency)
177
192
178
- Row (
179
- horizontalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small2),
180
- ) {
181
- // Product type
182
- Icon (
183
- painter = painterResource(periodPalsProduct.icon),
184
- contentDescription = periodPalsProduct.textId + " product" ,
185
- modifier = Modifier .testTag(ALERT_PRODUCT_ICON ),
186
- )
187
-
188
- // Urgency level
189
- Icon (
190
- painter = painterResource(periodPalsUrgency.icon),
191
- contentDescription = periodPalsUrgency.textId + " urgency" ,
192
- modifier = Modifier .testTag(ALERT_URGENCY_ICON ),
193
+ Text (
194
+ text = alert.message,
195
+ modifier = Modifier .padding(MaterialTheme .dimens.small2).testTag(ALERT_MESSAGE ),
196
+ style = MaterialTheme .typography.bodyMedium,
193
197
)
194
198
}
195
- }
196
-
197
- Text (
198
- text = alert.message,
199
- modifier = Modifier .padding(MaterialTheme .dimens.small2).testTag(ALERT_MESSAGE ),
200
- style = MaterialTheme .typography.bodyMedium,
201
- )
202
- }
203
199
}
204
200
205
201
/* *
@@ -212,10 +208,10 @@ private fun AlertInfo(alert: Alert) {
212
208
*/
213
209
@Composable
214
210
private fun InteractionButtons (
215
- content : CONTENT ,
216
- onEditClick : () -> Unit ,
217
- onAccpetClick : () -> Unit ,
218
- onResolveClick : () -> Unit ,
211
+ content : CONTENT ,
212
+ onEditClick : () -> Unit ,
213
+ onAccpetClick : () -> Unit ,
214
+ onResolveClick : () -> Unit ,
219
215
) {
220
216
Row (
221
217
horizontalArrangement = Arrangement .spacedBy(MaterialTheme .dimens.small2),
@@ -228,9 +224,9 @@ private fun InteractionButtons(
228
224
229
225
// Edit
230
226
Button (
231
- onClick = onEditClick,
232
- modifier = Modifier .wrapContentSize().testTag(EDIT_ALERT_BUTTON ),
233
- colors = getFilledPrimaryContainerButtonColors(),
227
+ onClick = onEditClick,
228
+ modifier = Modifier .wrapContentSize().testTag(EDIT_ALERT_BUTTON ),
229
+ colors = getFilledPrimaryContainerButtonColors(),
234
230
) {
235
231
Icon (imageVector = Icons .Outlined .Edit , contentDescription = " Edit alert" )
236
232
Spacer (modifier = Modifier .width(MaterialTheme .dimens.small2))
@@ -239,11 +235,11 @@ private fun InteractionButtons(
239
235
240
236
// Resolve
241
237
Button (
242
- onClick = {
243
- // TODO Implement alert resolution
244
- },
245
- modifier = Modifier .wrapContentSize().testTag(RESOLVE_ALERT_BUTTON ),
246
- colors = getFilledPrimaryContainerButtonColors(),
238
+ onClick = {
239
+ // TODO Implement alert resolution
240
+ },
241
+ modifier = Modifier .wrapContentSize().testTag(RESOLVE_ALERT_BUTTON ),
242
+ colors = getFilledPrimaryContainerButtonColors(),
247
243
) {
248
244
Icon (imageVector = Icons .Outlined .Check , contentDescription = " Resolve alert" )
249
245
Spacer (modifier = Modifier .width(MaterialTheme .dimens.small2))
@@ -254,11 +250,11 @@ private fun InteractionButtons(
254
250
255
251
// Accept
256
252
Button (
257
- onClick = {
258
- // TODO Implement alert accept
259
- },
260
- modifier = Modifier .wrapContentSize().testTag(ACCEPT_ALERT_BUTTON ),
261
- colors = getFilledPrimaryContainerButtonColors(),
253
+ onClick = {
254
+ // TODO Implement alert accept
255
+ },
256
+ modifier = Modifier .wrapContentSize().testTag(ACCEPT_ALERT_BUTTON ),
257
+ colors = getFilledPrimaryContainerButtonColors(),
262
258
) {
263
259
Icon (imageVector = Icons .Outlined .Check , contentDescription = " Accept alert" )
264
260
Spacer (modifier = Modifier .width(MaterialTheme .dimens.small2))
0 commit comments