-
Notifications
You must be signed in to change notification settings - Fork 6
add support for attribution text #187
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
Changes from 1 commit
c8c491b
adfad3d
ec1d693
5e1c9fb
d5ef515
92a3831
d55816b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,9 @@ import kotlinx.coroutines.launch | |
* @param viewLabelProperties the [ViewLabelProperties] used by the composable [com.arcgismaps.toolkit.geocompose.MapView] | ||
* @param selectionProperties the [SelectionProperties] used by the composable [com.arcgismaps.toolkit.geocompose.MapView] | ||
* @param wrapAroundMode the [WrapAroundMode] to specify whether continuous panning across the international date line is enabled | ||
* @param attributionBarVisible specifies the visibility of the attribution bar | ||
* @param onViewpointChanged lambda invoked when the viewpoint of the composable MapView has changed | ||
* @param onAttributionTextChanged lambda invoked when the attribution text for the data that is currently displayed in the MapView has changed | ||
* @param onInteractingChanged lambda invoked when the user starts and ends interacting with the composable MapView | ||
* @param onRotate lambda invoked when a user performs a rotation gesture on the composable MapView | ||
* @param onScale lambda invoked when a user performs a pinch gesture on the composable MapView | ||
|
@@ -85,11 +87,13 @@ public fun MapView( | |
graphicsOverlays: GraphicsOverlayCollection = rememberGraphicsOverlayCollection(), | ||
locationDisplay: LocationDisplay = rememberLocationDisplay(), | ||
wrapAroundMode: WrapAroundMode = WrapAroundMode.EnabledWhenSupported, | ||
attributionBarVisible: Boolean = true, | ||
geometryEditor: GeometryEditor? = null, | ||
mapViewInteractionOptions: MapViewInteractionOptions = MapViewInteractionOptions(), | ||
viewLabelProperties: ViewLabelProperties = ViewLabelProperties(), | ||
selectionProperties: SelectionProperties = SelectionProperties(), | ||
onViewpointChanged: (() -> Unit)? = null, | ||
onAttributionTextChanged: ((String) -> Unit)? = null, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just as a general question, what was the reasoning behind using null rather than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment could be helpful: #159 (comment)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I suppose the difference between these lambdas and |
||
onInteractingChanged: ((isInteracting: Boolean) -> Unit)? = null, | ||
onRotate: ((RotationChangeEvent) -> Unit)? = null, | ||
onScale: ((ScaleChangeEvent) -> Unit)? = null, | ||
|
@@ -131,9 +135,16 @@ public fun MapView( | |
} | ||
} | ||
|
||
val currentAttributionBarVisible by rememberUpdatedState(attributionBarVisible) | ||
LaunchedEffect(Unit) { | ||
// isAttributionBarVisible does not take effect if applied in the AndroidView update callback | ||
mapView.isAttributionBarVisible = currentAttributionBarVisible | ||
} | ||
|
||
MapViewEventHandler( | ||
mapView, | ||
onViewpointChanged, | ||
onAttributionTextChanged, | ||
onInteractingChanged, | ||
onRotate, | ||
onScale, | ||
|
@@ -156,6 +167,7 @@ public fun MapView( | |
private fun MapViewEventHandler( | ||
mapView: MapView, | ||
onViewpointChanged: (() -> Unit)?, | ||
onAttributionTextChanged: ((String) -> Unit)?, | ||
onInteractingChanged: ((isInteracting: Boolean) -> Unit)?, | ||
onRotate: ((RotationChangeEvent) -> Unit)?, | ||
onScale: ((ScaleChangeEvent) -> Unit)?, | ||
|
@@ -168,6 +180,7 @@ private fun MapViewEventHandler( | |
onPan: ((PanChangeEvent) -> Unit)? | ||
) { | ||
val currentViewPointChanged by rememberUpdatedState(onViewpointChanged) | ||
val currentOnAttributionTextChanged by rememberUpdatedState(onAttributionTextChanged) | ||
val currentOnInteractingChanged by rememberUpdatedState(onInteractingChanged) | ||
val currentOnRotate by rememberUpdatedState(onRotate) | ||
val currentOnScale by rememberUpdatedState(onScale) | ||
|
@@ -187,6 +200,13 @@ private fun MapViewEventHandler( | |
} | ||
} | ||
} | ||
launch { | ||
mapView.attributionText.collect { attributionText -> | ||
currentOnAttributionTextChanged?.let { | ||
it(attributionText) | ||
} | ||
} | ||
} | ||
launch(Dispatchers.Main.immediate) { | ||
mapView.isInteracting.collect { isInteracting -> | ||
currentOnInteractingChanged?.let { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the parameter be suffixed with "is"?