Skip to content

fixes for displaying FloorFilter facilitySelector when Sites are not … #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public fun FloorFilter(
var isFacilitiesSelectorVisible by rememberSaveable { mutableStateOf(false) }

// get the current selected facility
var selectedFacility = floorFilterState.onFacilityChanged.collectAsStateWithLifecycle().value
val selectedFacility = floorFilterState.onFacilityChanged.collectAsStateWithLifecycle().value

// get the selected level ID
val selectedLevelID = floorFilterState.onLevelChanged.collectAsStateWithLifecycle().value?.id
Expand Down Expand Up @@ -207,11 +207,14 @@ public fun FloorFilter(
)

} else {
val selectedLevelName = selectedFacility.levels.find { it.id == selectedLevelID }?.let {
it.shortName.ifBlank { it.levelNumber }
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we fallback to the levelNumber when the level.shortName is Blank

// display only the selected floor level
FloorLevelSelectButton(
index = 0,
selected = true,
floorText = selectedFacility.levels.find { it.id == selectedLevelID }?.shortName.toString(),
floorText = selectedLevelName.toString(),
uiProperties = uiProperties,
onFloorLevelSelected = {
// display all floor levels when clicked
Expand Down Expand Up @@ -286,7 +289,7 @@ internal fun FloorListColumn(
index = index,
selected = currentFacility.levels[index].id == selectedLevelID,
onFloorLevelSelected = onFloorLevelSelected,
floorText = currentFacility.levels[index].shortName,
floorText = currentFacility.levels[index].shortName.ifBlank { currentFacility.levels[index].levelNumber.toString() },
uiProperties = uiProperties,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ internal fun SiteAndFacilitySelector(
)
{
Column {
if (!isFacilitiesSelectorVisible) {
// display the siteSelector
if (!isFacilitiesSelectorVisible && floorFilterState.sites.isNotEmpty()) {
// display the sites top bar
SiteSelectorTopBar(
uiProperties = uiProperties,
Expand All @@ -130,6 +131,8 @@ internal fun SiteAndFacilitySelector(
onFacilitiesSelectorVisible(true)
}
} else {
// display the facilitiesSelector

// display the facilities top bar
Comment on lines +134 to 136
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate comment

Suggested change
// display the facilitiesSelector
// display the facilities top bar
// display the facilitiesSelector

FacilitySelectorTopBar(
floorFilterState = floorFilterState,
Expand Down Expand Up @@ -211,15 +214,18 @@ internal fun FacilitySelectorTopBar(
modifier = Modifier.height(65.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween
) {
// a box is helpful to use a consistent clickable animation
Box(
modifier = Modifier.clickable { backToSiteButtonClicked() }
) {
Icon(
modifier = Modifier.fillMaxHeight().padding(horizontal = 6.dp).size(24.dp),
painter = painterResource(id = R.drawable.ic_chevron_left_32),
contentDescription = "Go Back to Site Selector"
)
// if there are no sites, do not allow going back to the siteSelector from facilitySelector
if (floorFilterState.sites.isNotEmpty()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removes back button from facility selector

// a box is helpful to use a consistent clickable animation
Box(
modifier = Modifier.clickable { backToSiteButtonClicked() }
) {
Icon(
modifier = Modifier.fillMaxHeight().padding(horizontal = 6.dp).size(24.dp),
painter = painterResource(id = R.drawable.ic_chevron_left_32),
contentDescription = "Go Back to Site Selector"
)
}
}
Divider(
color = Color.LightGray,
Expand All @@ -245,7 +251,7 @@ internal fun FacilitySelectorTopBar(

Text(
text = stringResource(R.string.floor_filter_site_selector_top_bar) +
floorFilterState.getSelectedSite()?.name.toString(),
(floorFilterState.getSelectedSite()?.name ?: "not available"),
Copy link
Collaborator Author

@puneet-pdx puneet-pdx Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

displays not available instead of null when selected site is null

fontSize = 15.sp,
color = Color.Gray
)
Expand Down Expand Up @@ -284,6 +290,11 @@ internal fun SitesAndFacilitiesFilter(
// focus manager is used to clear focus from OutlinedTextField on search
val focusManager = LocalFocusManager.current

val facilitiesAtSelectedSite = if (floorFilterState.sites.isNotEmpty())
floorFilterState.getSelectedSite()?.facilities
else
floorFilterState.facilities

// list of all the site/facility names to display when no search prompt is used
val allSitesOrFacilities: MutableList<SiteFacilityWrapper> =
if (!isFacilitiesSelectorVisible)
Expand All @@ -294,7 +305,7 @@ internal fun SitesAndFacilitiesFilter(
)
}.toMutableList()
else
floorFilterState.getSelectedSite()?.facilities?.map { floorFacility ->
facilitiesAtSelectedSite?.map { floorFacility ->
SiteFacilityWrapper(
facility = floorFacility,
isSelected = floorFacility.id == floorFilterState.selectedFacilityId
Expand Down