@@ -112,7 +112,8 @@ internal fun SiteAndFacilitySelector(
112
112
)
113
113
{
114
114
Column {
115
- if (! isFacilitiesSelectorVisible) {
115
+ // display the siteSelector
116
+ if (! isFacilitiesSelectorVisible && floorFilterState.sites.isNotEmpty()) {
116
117
// display the sites top bar
117
118
SiteSelectorTopBar (
118
119
uiProperties = uiProperties,
@@ -130,6 +131,8 @@ internal fun SiteAndFacilitySelector(
130
131
onFacilitiesSelectorVisible(true )
131
132
}
132
133
} else {
134
+ // display the facilitiesSelector
135
+
133
136
// display the facilities top bar
134
137
FacilitySelectorTopBar (
135
138
floorFilterState = floorFilterState,
@@ -211,15 +214,18 @@ internal fun FacilitySelectorTopBar(
211
214
modifier = Modifier .height(65 .dp).fillMaxWidth(),
212
215
horizontalArrangement = Arrangement .SpaceBetween
213
216
) {
214
- // a box is helpful to use a consistent clickable animation
215
- Box (
216
- modifier = Modifier .clickable { backToSiteButtonClicked() }
217
- ) {
218
- Icon (
219
- modifier = Modifier .fillMaxHeight().padding(horizontal = 6 .dp).size(24 .dp),
220
- painter = painterResource(id = R .drawable.ic_chevron_left_32),
221
- contentDescription = " Go Back to Site Selector"
222
- )
217
+ // if there are no sites, do not allow going back to the siteSelector from facilitySelector
218
+ if (floorFilterState.sites.isNotEmpty()) {
219
+ // a box is helpful to use a consistent clickable animation
220
+ Box (
221
+ modifier = Modifier .clickable { backToSiteButtonClicked() }
222
+ ) {
223
+ Icon (
224
+ modifier = Modifier .fillMaxHeight().padding(horizontal = 6 .dp).size(24 .dp),
225
+ painter = painterResource(id = R .drawable.ic_chevron_left_32),
226
+ contentDescription = " Go Back to Site Selector"
227
+ )
228
+ }
223
229
}
224
230
Divider (
225
231
color = Color .LightGray ,
@@ -245,7 +251,7 @@ internal fun FacilitySelectorTopBar(
245
251
246
252
Text (
247
253
text = stringResource(R .string.floor_filter_site_selector_top_bar) +
248
- floorFilterState.getSelectedSite()?.name.toString( ),
254
+ ( floorFilterState.getSelectedSite()?.name ? : " not available " ),
249
255
fontSize = 15 .sp,
250
256
color = Color .Gray
251
257
)
@@ -284,6 +290,11 @@ internal fun SitesAndFacilitiesFilter(
284
290
// focus manager is used to clear focus from OutlinedTextField on search
285
291
val focusManager = LocalFocusManager .current
286
292
293
+ val facilitiesAtSelectedSite = if (floorFilterState.sites.isNotEmpty())
294
+ floorFilterState.getSelectedSite()?.facilities
295
+ else
296
+ floorFilterState.facilities
297
+
287
298
// list of all the site/facility names to display when no search prompt is used
288
299
val allSitesOrFacilities: MutableList <SiteFacilityWrapper > =
289
300
if (! isFacilitiesSelectorVisible)
@@ -294,7 +305,7 @@ internal fun SitesAndFacilitiesFilter(
294
305
)
295
306
}.toMutableList()
296
307
else
297
- floorFilterState.getSelectedSite()?.facilities ?.map { floorFacility ->
308
+ facilitiesAtSelectedSite ?.map { floorFacility ->
298
309
SiteFacilityWrapper (
299
310
facility = floorFacility,
300
311
isSelected = floorFacility.id == floorFilterState.selectedFacilityId
0 commit comments