Quick question about icon usage, I've searched thr...
# multiplatform
m
Quick question about icon usage, I've searched through the channel and quite a bit of googling but haven't found an answer yet... I know that for `Composable`s we can use the
Icons
library to get most icons, this is all nice and well, but it runs into issues when some of the composables are implemented natively. In my case I have a Map, and I've had to implement an
expect fun MapView()
that has 3 `actual`s (Android with GoogleMaps Compose, WasmJs with a JsExternal bridge, and iOS using the native MapKit). What I'm now trying to do, is change the icons of the markers to anything but the default, but because the implementations are native, I obviously can't use
Icons
or even
Res.
. What is the suggested way to do this?
b
Are you trying define the markers as common? Implementing the expect of the marker assets as Painter’s is one option. On the other hand, I had to create them in both actual Map impls for my Airbnb sample I did a few years ago. https://github.com/bmcreations/airbnb-multiplatform-sample
m
@brandonmcansh not really, the Markers are specific to each platform since there isn't a Compose enabled official map library. So similarly to what you have in the sample, I have a an
expect MapView
that I implement in each platform, but then each uses whatever types are native to deal with the map. Once you are in the specific sourceset (be it androidMain, wasmJsMain or iosMain) it requires Map types that are specific to the platform, so for example: • in iOS, to draw a marker I use
MKMarkerAnnotationView
and to change the icon I need a
UIImage
• for wasm I use a
JsGoogleMap
type, and I need to set a
JsPinElement
to it that uses a
glyph
to draw the icon • for Android is the easiest one because its already in compose, so I can use all the assets in the
Icons
class there. I guess I could create a resource in the iOSApp module as an xcasset, and then somehow reference the svg in web, but I'm trying to understand what the best practice method is.
b
Gotcha. Yeah I used a UIImage for iOS as well iirc
m
So yeah, I might need to duplicate the resources for some of those things and have each platform consume it as needed