Skip to content

Commit

Permalink
fix: [ANDROAPP-6646] Location/accuracy visibility does not affect map…
Browse files Browse the repository at this point in the history
… size (#3876)

* Map is kept the same size even if location/accuracy composable is not visible

* Map is kept the same size even if location/accuracy composable is not visible
  • Loading branch information
ferdyrod authored Nov 13, 2024
1 parent f732d99 commit 0dfdaee
Showing 1 changed file with 97 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,86 +310,61 @@ private fun LocationInfoContent(
accuracyRange: AccuracyRange,
configurePolygonInfoRecycler: (RecyclerView) -> Unit,
) {
when {
displayPolygonInfo -> {
AndroidView(
modifier = Modifier
.fillMaxWidth()
.heightIn(max = 200.dp),
factory = { context ->
RecyclerView(context).also {
configurePolygonInfoRecycler(it)
}
},
update = {
// no-op
},
)
}

(captureMode.isManual() or captureMode.isNone()) && selectedLocation is SelectedLocation.ManualResult -> {
LocationItem(
locationItemModel = LocationItemModel.SearchResult(
searchedTitle = stringResource(R.string.selected_location),
searchedSubtitle = stringResource(
R.string.latitude_longitude,
selectedLocation.latitude.truncate(),
selectedLocation.longitude.truncate(),
),
searchedLatitude = selectedLocation.latitude,
searchedLongitude = selectedLocation.longitude,
),
icon = {
LocationItemIcon(
icon = Icons.Outlined.Place,
tintedColor = SurfaceColor.Primary,
bgColor = SurfaceColor.PrimaryContainer,
)
},
) { }
}
Box(
modifier = Modifier
.fillMaxWidth()
.height(64.dp),
) {
when {
displayPolygonInfo -> {
AndroidView(
modifier = Modifier
.fillMaxWidth()
.heightIn(max = 200.dp),
factory = { context ->
RecyclerView(context).also {
configurePolygonInfoRecycler(it)
}
},
update = {
// no-op
},
)
}

captureMode.isSwipe() -> {
LocationItem(
locationItemModel = LocationItemModel.SearchResult(
searchedTitle = stringResource(R.string.drop_to_select),
searchedSubtitle = stringResource(
R.string.latitude_longitude,
selectedLocation.latitude.truncate(),
selectedLocation.longitude.truncate(),
(captureMode.isManual() or captureMode.isNone()) && selectedLocation is SelectedLocation.ManualResult -> {
LocationItem(
locationItemModel = LocationItemModel.SearchResult(
searchedTitle = stringResource(R.string.selected_location),
searchedSubtitle = stringResource(
R.string.latitude_longitude,
selectedLocation.latitude.truncate(),
selectedLocation.longitude.truncate(),
),
searchedLatitude = selectedLocation.latitude,
searchedLongitude = selectedLocation.longitude,
),
searchedLatitude = selectedLocation.latitude,
searchedLongitude = selectedLocation.longitude,
),
icon = {
LocationItemIcon(
icon = Icons.Outlined.TouchApp,
tintedColor = TextColor.OnWarningContainer,
bgColor = SurfaceColor.WarningContainer,
)
},
) { }
}

captureMode.isGps() -> {
Box(
modifier = Modifier
.height(64.dp)
.padding(horizontal = 16.dp),
contentAlignment = Alignment.Center,
) {
AccuracyIndicator(accuracyRange = accuracyRange)
icon = {
LocationItemIcon(
icon = Icons.Outlined.Place,
tintedColor = SurfaceColor.Primary,
bgColor = SurfaceColor.PrimaryContainer,
)
},
) { }
}
}

captureMode.isSearch() -> {
if (selectedLocation is SelectedLocation.None) {
captureMode.isSwipe() -> {
LocationItem(
locationItemModel = LocationItemModel.SearchResult(
searchedTitle = stringResource(R.string.select_location_title),
searchedSubtitle = stringResource(R.string.selet_location_subtitle),
searchedLatitude = 0.0,
searchedLongitude = 0.0,
searchedTitle = stringResource(R.string.drop_to_select),
searchedSubtitle = stringResource(
R.string.latitude_longitude,
selectedLocation.latitude.truncate(),
selectedLocation.longitude.truncate(),
),
searchedLatitude = selectedLocation.latitude,
searchedLongitude = selectedLocation.longitude,
),
icon = {
LocationItemIcon(
Expand All @@ -398,33 +373,63 @@ private fun LocationInfoContent(
bgColor = SurfaceColor.WarningContainer,
)
},
) { }
}

captureMode.isGps() -> {
Box(
modifier = Modifier
.padding(horizontal = 16.dp),
contentAlignment = Alignment.Center,
) {
AccuracyIndicator(accuracyRange = accuracyRange)
}
} else if (selectedLocation is SelectedLocation.SearchResult) {
with(selectedLocation) {
}

captureMode.isSearch() -> {
if (selectedLocation is SelectedLocation.None) {
LocationItem(
locationItemModel = LocationItemModel.SearchResult(
searchedTitle = title
.takeIf { it.isNotBlank() }
?: stringResource(R.string.selected_location),
searchedSubtitle = address
.takeIf { it.isNotBlank() }
?: stringResource(
R.string.latitude_longitude,
selectedLocation.latitude.truncate(),
selectedLocation.longitude.truncate(),
),
searchedLatitude = latitude,
searchedLongitude = longitude,
searchedTitle = stringResource(R.string.select_location_title),
searchedSubtitle = stringResource(R.string.selet_location_subtitle),
searchedLatitude = 0.0,
searchedLongitude = 0.0,
),
icon = {
LocationItemIcon(
icon = Icons.Outlined.Place,
tintedColor = SurfaceColor.Primary,
bgColor = SurfaceColor.PrimaryContainer,
icon = Icons.Outlined.TouchApp,
tintedColor = TextColor.OnWarningContainer,
bgColor = SurfaceColor.WarningContainer,
)
},
) { }
) {
}
} else if (selectedLocation is SelectedLocation.SearchResult) {
with(selectedLocation) {
LocationItem(
locationItemModel = LocationItemModel.SearchResult(
searchedTitle = title
.takeIf { it.isNotBlank() }
?: stringResource(R.string.selected_location),
searchedSubtitle = address
.takeIf { it.isNotBlank() }
?: stringResource(
R.string.latitude_longitude,
selectedLocation.latitude.truncate(),
selectedLocation.longitude.truncate(),
),
searchedLatitude = latitude,
searchedLongitude = longitude,
),
icon = {
LocationItemIcon(
icon = Icons.Outlined.Place,
tintedColor = SurfaceColor.Primary,
bgColor = SurfaceColor.PrimaryContainer,
)
},
) { }
}
}
}
}
Expand Down

0 comments on commit 0dfdaee

Please sign in to comment.