Skip to content

Commit 7497272

Browse files
committed
style: ktfmt
1 parent 023510c commit 7497272

File tree

1 file changed

+102
-106
lines changed

1 file changed

+102
-106
lines changed

app/src/main/java/com/android/periodpals/ui/components/MapComponents.kt

Lines changed: 102 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ import androidx.compose.material.icons.outlined.Check
1717
import androidx.compose.material.icons.outlined.Edit
1818
import androidx.compose.material3.Button
1919
import androidx.compose.material3.ExperimentalMaterial3Api
20-
import androidx.compose.material3.HorizontalDivider
2120
import androidx.compose.material3.Icon
2221
import androidx.compose.material3.MaterialTheme
2322
import androidx.compose.material3.ModalBottomSheet
24-
import androidx.compose.material3.OutlinedCard
2523
import androidx.compose.material3.SheetState
2624
import androidx.compose.material3.Text
2725
import androidx.compose.runtime.Composable
@@ -78,33 +76,32 @@ enum class CONTENT {
7876
@OptIn(ExperimentalMaterial3Api::class)
7977
@Composable
8078
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,
8886
) {
8987

9088
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),
9492
) {
9593
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),
10097
) {
10198
alertToDisplay?.let { AlertInfo(it) } ?: Log.d(TAG, "Alert is null")
10299

103100
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") },
108105
)
109106
}
110107
}
@@ -118,88 +115,87 @@ fun MapBottomSheet(
118115
@Composable
119116
private fun AlertInfo(alert: Alert) {
120117
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+
)
129138

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) {
141140

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+
)
143148

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)
151151

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+
)
155159

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),
162182
)
163183

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),
170189
)
171190
}
172191
}
173-
}
174-
175-
val periodPalsProduct = productToPeriodPalsIcon(alert.product)
176-
val periodPalsUrgency = urgencyToPeriodPalsIcon(alert.urgency)
177192

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,
193197
)
194198
}
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-
}
203199
}
204200

205201
/**
@@ -212,10 +208,10 @@ private fun AlertInfo(alert: Alert) {
212208
*/
213209
@Composable
214210
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,
219215
) {
220216
Row(
221217
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.dimens.small2),
@@ -228,9 +224,9 @@ private fun InteractionButtons(
228224

229225
// Edit
230226
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(),
234230
) {
235231
Icon(imageVector = Icons.Outlined.Edit, contentDescription = "Edit alert")
236232
Spacer(modifier = Modifier.width(MaterialTheme.dimens.small2))
@@ -239,11 +235,11 @@ private fun InteractionButtons(
239235

240236
// Resolve
241237
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(),
247243
) {
248244
Icon(imageVector = Icons.Outlined.Check, contentDescription = "Resolve alert")
249245
Spacer(modifier = Modifier.width(MaterialTheme.dimens.small2))
@@ -254,11 +250,11 @@ private fun InteractionButtons(
254250

255251
// Accept
256252
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(),
262258
) {
263259
Icon(imageVector = Icons.Outlined.Check, contentDescription = "Accept alert")
264260
Spacer(modifier = Modifier.width(MaterialTheme.dimens.small2))

0 commit comments

Comments
 (0)