Rename ShowLocationEvents -> ShowLocationEvent

This commit is contained in:
ganfra 2026-03-12 12:47:52 +01:00
parent d10c3db79e
commit 347bb627d9
7 changed files with 51 additions and 51 deletions

View file

@ -10,11 +10,11 @@ package io.element.android.features.location.impl.show
import io.element.android.features.location.api.Location
sealed interface ShowLocationEvents {
data class Share(val location: Location) : ShowLocationEvents
data class TrackMyLocation(val enabled: Boolean) : ShowLocationEvents
data object DismissDialog : ShowLocationEvents
data object RequestPermissions : ShowLocationEvents
data object OpenAppSettings : ShowLocationEvents
data object OpenLocationSettings : ShowLocationEvents
sealed interface ShowLocationEvent {
data class Share(val location: Location) : ShowLocationEvent
data class TrackMyLocation(val enabled: Boolean) : ShowLocationEvent
data object DismissDialog : ShowLocationEvent
data object RequestPermissions : ShowLocationEvent
data object OpenAppSettings : ShowLocationEvent
data object OpenLocationSettings : ShowLocationEvent
}

View file

@ -68,12 +68,12 @@ class ShowLocationPresenter(
}
}
fun handleEvent(event: ShowLocationEvents) {
fun handleEvent(event: ShowLocationEvent) {
when (event) {
is ShowLocationEvents.Share -> {
is ShowLocationEvent.Share -> {
locationActions.share(event.location, null)
}
is ShowLocationEvents.TrackMyLocation -> {
is ShowLocationEvent.TrackMyLocation -> {
if (event.enabled) {
val locationConstraints = checkLocationConstraints(permissionsState, locationActions)
isTrackMyLocation = locationConstraints is LocationConstraintsCheck.Success
@ -82,16 +82,16 @@ class ShowLocationPresenter(
isTrackMyLocation = false
}
}
ShowLocationEvents.DismissDialog -> dialogState = LocationConstraintsDialogState.None
ShowLocationEvents.OpenAppSettings -> {
ShowLocationEvent.DismissDialog -> dialogState = LocationConstraintsDialogState.None
ShowLocationEvent.OpenAppSettings -> {
locationActions.openAppSettings()
dialogState = LocationConstraintsDialogState.None
}
ShowLocationEvents.OpenLocationSettings -> {
ShowLocationEvent.OpenLocationSettings -> {
locationActions.openLocationSettings()
dialogState = LocationConstraintsDialogState.None
}
ShowLocationEvents.RequestPermissions -> permissionsState.eventSink(PermissionsEvents.RequestPermissions)
ShowLocationEvent.RequestPermissions -> permissionsState.eventSink(PermissionsEvents.RequestPermissions)
}
}

View file

@ -24,7 +24,7 @@ data class ShowLocationState(
val hasLocationPermission: Boolean,
val isTrackMyLocation: Boolean,
val appName: String,
val eventSink: (ShowLocationEvents) -> Unit,
val eventSink: (ShowLocationEvent) -> Unit,
) {
val isSheetDraggable = locationShares.any { item -> item.isLive }
}

View file

@ -53,7 +53,7 @@ fun aShowLocationState(
hasLocationPermission: Boolean = false,
isTrackMyLocation: Boolean = false,
appName: String = APP_NAME,
eventSink: (ShowLocationEvents) -> Unit = {},
eventSink: (ShowLocationEvent) -> Unit = {},
): ShowLocationState {
val effectiveMarkers = markers ?: when (mode) {
is ShowLocationMode.Static -> listOf(

View file

@ -57,10 +57,10 @@ fun ShowLocationView(
LocationConstraintsDialog(
state = state.dialogState,
appName = state.appName,
onRequestPermissions = { state.eventSink(ShowLocationEvents.RequestPermissions) },
onOpenAppSettings = { state.eventSink(ShowLocationEvents.OpenAppSettings) },
onOpenLocationSettings = { state.eventSink(ShowLocationEvents.OpenLocationSettings) },
onDismiss = { state.eventSink(ShowLocationEvents.DismissDialog) },
onRequestPermissions = { state.eventSink(ShowLocationEvent.RequestPermissions) },
onOpenAppSettings = { state.eventSink(ShowLocationEvent.OpenAppSettings) },
onOpenLocationSettings = { state.eventSink(ShowLocationEvent.OpenLocationSettings) },
onDismiss = { state.eventSink(ShowLocationEvent.DismissDialog) },
)
val initialPosition = when (val mode = state.mode) {
@ -74,7 +74,7 @@ fun ShowLocationView(
val userLocationState = rememberUserLocationState(state.hasLocationPermission)
LaunchedEffect(cameraState.isCameraMoving) {
if (cameraState.moveReason == CameraMoveReason.GESTURE) {
state.eventSink(ShowLocationEvents.TrackMyLocation(false))
state.eventSink(ShowLocationEvent.TrackMyLocation(false))
}
}
@ -120,9 +120,9 @@ fun ShowLocationView(
state.locationShares.forEach { locationShare ->
LocationShareRow(
item = locationShare,
onShareClick = { state.eventSink(ShowLocationEvents.Share(locationShare.location)) },
onShareClick = { state.eventSink(ShowLocationEvent.Share(locationShare.location)) },
modifier = Modifier.clickable {
state.eventSink(ShowLocationEvents.TrackMyLocation(false))
state.eventSink(ShowLocationEvent.TrackMyLocation(false))
val position = CameraPosition(
padding = sheetPaddings,
target = Position(locationShare.location.lon, locationShare.location.lat),
@ -146,7 +146,7 @@ fun ShowLocationView(
overlayContent = {
LocationFloatingActionButton(
isMapCenteredOnUser = state.isTrackMyLocation,
onClick = { state.eventSink(ShowLocationEvents.TrackMyLocation(true)) },
onClick = { state.eventSink(ShowLocationEvent.TrackMyLocation(true)) },
modifier = Modifier
.align(Alignment.TopEnd)
.padding(all = 16.dp),