Esri / arcgis-maps-sdk-swift-toolkit

Mapping components that will simplify your Swift app development with the ArcGIS Maps SDK for Swift.
https://developers.arcgis.com/swift
Apache License 2.0
28 stars 7 forks source link

Basemap Gallery Re-queries the portal every time it's shown #673

Open rolson opened 4 months ago

rolson commented 4 months ago

The basemap gallery re-queries the portal for the basemaps every time it's shown. Is there a way that we can avoid that?

I'm using the gallery like so:

            .sheet(isPresented: $isBasemapGalleryPresented) {
                    VStack(alignment: .trailing) {
                        DismissButton()
                        BasemapGallery(portal: portal!, geoModel: map)
                            .style(.grid(maxItemWidth: 100))
                    }
                    .padding()
                }
dfeinzimer commented 4 months ago

Seeing that BasemapGalleryViewModel is internal and tied to the lifetime of BasemapGallery I think it'd need to be made external and managed by the view using `BasemapGallery or somewhere higher up. But I don't think that's a great idea as it puts more work on the user to now manage the model and it seems to go against this pattern:

View models should be internal and created by the main component view. Required model properties should be passed in as arguments to the view constructor, with additional properties set via view modifiers.

What I could see as a good alternative is providing a public helper property on Portal that returns [BasemapGalleryItem] to make BasemapGallery(items:geoModel:) easier to use.

dfeinzimer commented 4 months ago

Phil left a similar but different idea on improving usability a while back here.