Skip to content
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

chore: switched from set() to update() #564

Merged
merged 8 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -84,16 +84,16 @@ public fun Circle(
update = {
update(onClick) { this.onCircleClick = it }

set(center) { this.circle.center = it }
set(clickable) { this.circle.isClickable = it }
set(fillColor) { this.circle.fillColor = it.toArgb() }
set(radius) { this.circle.radius = it }
set(strokeColor) { this.circle.strokeColor = it.toArgb() }
set(strokePattern) { this.circle.strokePattern = it }
set(strokeWidth) { this.circle.strokeWidth = it }
set(tag) { this.circle.tag = it }
set(visible) { this.circle.isVisible = it }
set(zIndex) { this.circle.zIndex = it }
update(center) { this.circle.center = it }
update(clickable) { this.circle.isClickable = it }
update(fillColor) { this.circle.fillColor = it.toArgb() }
update(radius) { this.circle.radius = it }
update(strokeColor) { this.circle.strokeColor = it.toArgb() }
update(strokePattern) { this.circle.strokePattern = it }
update(strokeWidth) { this.circle.strokeWidth = it }
update(tag) { this.circle.tag = it }
update(visible) { this.circle.isVisible = it }
update(zIndex) { this.circle.zIndex = it }
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ public fun GroundOverlay(
update = {
update(onClick) { this.onGroundOverlayClick = it }

set(bearing) { this.groundOverlay.bearing = it }
set(clickable) { this.groundOverlay.isClickable = it }
set(image) { this.groundOverlay.setImage(it) }
set(position) { this.groundOverlay.position(it) }
set(tag) { this.groundOverlay.tag = it }
set(transparency) { this.groundOverlay.transparency = it }
set(visible) { this.groundOverlay.isVisible = it }
set(zIndex) { this.groundOverlay.zIndex = it }
update(bearing) { this.groundOverlay.bearing = it }
update(clickable) { this.groundOverlay.isClickable = it }
update(image) { this.groundOverlay.setImage(it) }
update(position) { this.groundOverlay.position(it) }
update(tag) { this.groundOverlay.tag = it }
update(transparency) { this.groundOverlay.transparency = it }
update(visible) { this.groundOverlay.isVisible = it }
update(zIndex) { this.groundOverlay.zIndex = it }
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public fun Marker(
* trigger a rendering of the content composable and thus the rendering of an updated marker.
* @param state the [MarkerState] to be used to control or observe the marker
* state such as its position and info window
* @param contentDescription the content description for accessibility purposes
* @param alpha the alpha (opacity) of the marker
* @param anchor the anchor for the marker image
* @param draggable sets the draggability for the marker
Expand All @@ -226,6 +227,7 @@ public fun Marker(
public fun MarkerComposable(
vararg keys: Any,
state: MarkerState = rememberMarkerState(),
contentDescription: String? = "",
alpha: Float = 1.0f,
anchor: Offset = Offset(0.5f, 1.0f),
draggable: Boolean = false,
Expand All @@ -246,6 +248,7 @@ public fun MarkerComposable(
val icon = rememberComposeBitmapDescriptor(*keys) { content() }

MarkerImpl(
contentDescription = contentDescription,
state = state,
alpha = alpha,
anchor = anchor,
Expand Down Expand Up @@ -497,29 +500,29 @@ private fun MarkerImpl(
update(infoContent) { this.infoContent = it }
update(infoWindow) { this.infoWindow = it }

set(alpha) { this.marker.alpha = it }
set(anchor) { this.marker.setAnchor(it.x, it.y) }
set(draggable) { this.marker.isDraggable = it }
set(flat) { this.marker.isFlat = it }
set(icon) { this.marker.setIcon(it) }
set(infoWindowAnchor) { this.marker.setInfoWindowAnchor(it.x, it.y) }
set(state.position) { this.marker.position = it }
set(rotation) { this.marker.rotation = it }
set(snippet) {
update(alpha) { this.marker.alpha = it }
update(anchor) { this.marker.setAnchor(it.x, it.y) }
update(draggable) { this.marker.isDraggable = it }
update(flat) { this.marker.isFlat = it }
update(icon) { this.marker.setIcon(it) }
update(infoWindowAnchor) { this.marker.setInfoWindowAnchor(it.x, it.y) }
update(state.position) { this.marker.position = it }
update(rotation) { this.marker.rotation = it }
update(snippet) {
this.marker.snippet = it
if (this.marker.isInfoWindowShown) {
this.marker.showInfoWindow()
}
}
set(tag) { this.marker.tag = it }
set(title) {
update(tag) { this.marker.tag = it }
update(title) {
this.marker.title = it
if (this.marker.isInfoWindowShown) {
this.marker.showInfoWindow()
}
}
set(visible) { this.marker.isVisible = it }
set(zIndex) { this.marker.zIndex = it }
update(visible) { this.marker.isVisible = it }
update(zIndex) { this.marker.zIndex = it }
}
)
}
Expand All @@ -528,6 +531,7 @@ private fun MarkerImpl(
/**
* A composable for an advanced marker on the map.
*
* @param contentDescription the content description for accessibility purposes
* @param state the [MarkerState] to be used to control or observe the marker
* state such as its position and info window
* @param alpha the alpha (opacity) of the marker
Expand All @@ -552,6 +556,7 @@ private fun MarkerImpl(
@Composable
@GoogleMapComposable
public fun AdvancedMarker(
contentDescription: String? = "",
kikoso marked this conversation as resolved.
Show resolved Hide resolved
state: MarkerState = rememberMarkerState(),
alpha: Float = 1.0f,
anchor: Offset = Offset(0.5f, 1.0f),
Expand All @@ -574,6 +579,7 @@ public fun AdvancedMarker(
) {

AdvancedMarkerImpl(
contentDescription = contentDescription,
state = state,
alpha = alpha,
anchor = anchor,
Expand All @@ -599,6 +605,7 @@ public fun AdvancedMarker(
/**
* Internal implementation for an advanced marker on a Google map.
*
* @param contentDescription the content description for accessibility purposes
* @param state the [MarkerState] to be used to control or observe the marker
* state such as its position and info window
kikoso marked this conversation as resolved.
Show resolved Hide resolved
* @param alpha the alpha (opacity) of the marker
Expand Down Expand Up @@ -628,7 +635,7 @@ public fun AdvancedMarker(
@Composable
@GoogleMapComposable
private fun AdvancedMarkerImpl(

contentDescription: String? = "",
state: MarkerState = rememberMarkerState(),
kikoso marked this conversation as resolved.
Show resolved Hide resolved
alpha: Float = 1.0f,
anchor: Offset = Offset(0.5f, 1.0f),
Expand Down Expand Up @@ -663,6 +670,18 @@ private fun AdvancedMarkerImpl(
} else if (pinConfig != null) {
advancedMarkerOptions.icon(BitmapDescriptorFactory.fromPinConfig(pinConfig))
}
advancedMarkerOptions.contentDescription(contentDescription)
advancedMarkerOptions.alpha(alpha)
advancedMarkerOptions.anchor(anchor.x, anchor.y)
advancedMarkerOptions.draggable(draggable)
advancedMarkerOptions.flat(flat)
advancedMarkerOptions.infoWindowAnchor(infoWindowAnchor.x, infoWindowAnchor.y)
advancedMarkerOptions.position(state.position)
advancedMarkerOptions.rotation(rotation)
advancedMarkerOptions.snippet(snippet)
advancedMarkerOptions.title(title)
advancedMarkerOptions.visible(visible)
advancedMarkerOptions.zIndex(zIndex)

ComposeNode<MarkerNode, MapApplier>(
factory = {
kikoso marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -689,27 +708,27 @@ private fun AdvancedMarkerImpl(
update(infoContent) { this.infoContent = it }
update(infoWindow) { this.infoWindow = it }

set(alpha) { this.marker.alpha = it }
set(anchor) { this.marker.setAnchor(it.x, it.y) }
set(draggable) { this.marker.isDraggable = it }
set(flat) { this.marker.isFlat = it }
set(infoWindowAnchor) { this.marker.setInfoWindowAnchor(it.x, it.y) }
set(state.position) { this.marker.position = it }
set(rotation) { this.marker.rotation = it }
set(snippet) {
update(alpha) { this.marker.alpha = it }
update(anchor) { this.marker.setAnchor(it.x, it.y) }
update(draggable) { this.marker.isDraggable = it }
update(flat) { this.marker.isFlat = it }
update(infoWindowAnchor) { this.marker.setInfoWindowAnchor(it.x, it.y) }
update(state.position) { this.marker.position = it }
update(rotation) { this.marker.rotation = it }
update(snippet) {
this.marker.snippet = it
if (this.marker.isInfoWindowShown) {
this.marker.showInfoWindow()
}
}
set(tag) { this.marker.tag = it }
set(title) {
update(tag) { this.marker.tag = it }
update(title) {
this.marker.title = it
if (this.marker.isInfoWindowShown) {
this.marker.showInfoWindow()
}
}
set(pinConfig) {
update(pinConfig) {
if (iconView == null) {
this.marker.setIcon(pinConfig?.let { it1 ->
BitmapDescriptorFactory.fromPinConfig(
Expand All @@ -719,8 +738,8 @@ private fun AdvancedMarkerImpl(
}
}

set(visible) { this.marker.isVisible = it }
set(zIndex) { this.marker.zIndex = it }
update(visible) { this.marker.isVisible = it }
update(zIndex) { this.marker.zIndex = it }
kikoso marked this conversation as resolved.
Show resolved Hide resolved
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,18 @@ public fun Polygon(
},
update = {
update(onClick) { this.onPolygonClick = it }

set(points) { this.polygon.points = it }
set(clickable) { this.polygon.isClickable = it }
set(fillColor) { this.polygon.fillColor = it.toArgb() }
set(geodesic) { this.polygon.isGeodesic = it }
set(holes) { this.polygon.holes = it }
set(strokeColor) { this.polygon.strokeColor = it.toArgb() }
set(strokeJointType) { this.polygon.strokeJointType = it }
set(strokePattern) { this.polygon.strokePattern = it }
set(strokeWidth) { this.polygon.strokeWidth = it }
set(tag) { this.polygon.tag = it }
set(visible) { this.polygon.isVisible = it }
set(zIndex) { this.polygon.zIndex = it }
update(points) { this.polygon.points = it }
update(clickable) { this.polygon.isClickable = it }
update(fillColor) { this.polygon.fillColor = it.toArgb() }
update(geodesic) { this.polygon.isGeodesic = it }
update(holes) { this.polygon.holes = it }
update(strokeColor) { this.polygon.strokeColor = it.toArgb() }
update(strokeJointType) { this.polygon.strokeJointType = it }
update(strokePattern) { this.polygon.strokePattern = it }
update(strokeWidth) { this.polygon.strokeWidth = it }
update(tag) { this.polygon.tag = it }
update(visible) { this.polygon.isVisible = it }
update(zIndex) { this.polygon.zIndex = it }
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,19 +198,19 @@ private fun PolylineImpl(
update = {
update(onClick) { this.onPolylineClick = it }

set(points) { this.polyline.points = it }
set(spans) { this.polyline.spans = it }
set(clickable) { this.polyline.isClickable = it }
set(color) { this.polyline.color = it.toArgb() }
set(endCap) { this.polyline.endCap = it }
set(geodesic) { this.polyline.isGeodesic = it }
set(jointType) { this.polyline.jointType = it }
set(pattern) { this.polyline.pattern = it }
set(startCap) { this.polyline.startCap = it }
set(tag) { this.polyline.tag = it }
set(visible) { this.polyline.isVisible = it }
set(width) { this.polyline.width = it }
set(zIndex) { this.polyline.zIndex = it }
update(points) { this.polyline.points = it }
update(spans) { this.polyline.spans = it }
update(clickable) { this.polyline.isClickable = it }
update(color) { this.polyline.color = it.toArgb() }
update(endCap) { this.polyline.endCap = it }
update(geodesic) { this.polyline.isGeodesic = it }
update(jointType) { this.polyline.jointType = it }
update(pattern) { this.polyline.pattern = it }
update(startCap) { this.polyline.startCap = it }
update(tag) { this.polyline.tag = it }
update(visible) { this.polyline.isVisible = it }
update(width) { this.polyline.width = it }
update(zIndex) { this.polyline.zIndex = it }
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public fun TileOverlay(
update = {
update(onClick) { this.onTileOverlayClick = it }

set(tileProvider) {
update(tileProvider) {
this.tileOverlay.remove()
this.tileOverlay = mapApplier?.map?.addTileOverlay {
tileProvider(tileProvider)
Expand All @@ -108,10 +108,10 @@ public fun TileOverlay(
zIndex(zIndex)
} ?: error("Error adding tile overlay")
}
set(fadeIn) { this.tileOverlay.fadeIn = it }
set(transparency) { this.tileOverlay.transparency = it }
set(visible) { this.tileOverlay.isVisible = it }
set(zIndex) { this.tileOverlay.zIndex = it }
update(fadeIn) { this.tileOverlay.fadeIn = it }
update(transparency) { this.tileOverlay.transparency = it }
update(visible) { this.tileOverlay.isVisible = it }
update(zIndex) { this.tileOverlay.zIndex = it }
}
)
}
Expand Down