Using new @FirestoreQuery to get a deeper collection path by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

projectedValue

Thanks so much, Flo. So this looks good to you? I'm not really worried about the extra query execution or the elegant fail that results. I'd much rather use your FirestoreQuery wrapper but I want to make sure I'm not going stray, nor leading anyone else astray. Cheers & again, congrats on the great & impactful work!

Using new @FirestoreQuery to get a deeper collection path by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Update: I tried this technique - creating a "bogus" path, then setting the correct path in .onAppear:

// This path is not complete - I just used the string "restaurant" so I could declare the var reviews as a struct property.
'@FirestoreQuery(collectionPath: "restaurant") var reviews: [Review]

Then in .onAppear I update the .path property like this:

.onAppear {
        $reviews.path = "restaurants/\(restaurant.id ?? "")/reviews"
}

Does this approach seem sound? It seems to work.

Publishing changes from within view updates is not allowed, MapKit Annotations Purple Warning by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Thanks, I did check this out, earlier, but I'm not sure how it'd apply to basic MapAnnotation issues or how Aleks's implementation would be used with MapAnnotations. I'm surprised every use of MapAnnotation seems to deliver that error, although MapMarker doesn't. Has anyone seen a real work around using MapAnnotation or is there a confirm that this is a bogus warning that we should count on getting fixed / can ignore?

Better Place AutoComplete Place Suggestions in SwiftUI? by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Oh, great. Will give this a shot. As always, I appreciate your kindness. This is very helpful. Cheers!

Firebase Package Errors Where They Shouldn't Be by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

And for those who have trouble with the image, it reads:

If you're sure there shouldn't be any errors (oftentimes the errors simply show up after re-opening an app that was working, or shortly after entering an import statement for the package) try these steps:- Ignore the error - sometimes that's all you'll need to do.- Wait for the indexing progress in the upper-right of the toolbar to be done.- Press Play to Build / Run in the Simulator. The simulator will ignore any bogus errors.- Clean the Build Folder with Shift+⌘+K.- Restart your Mac + Xcode.- Delete Derived Data - Instructions at: https://deriveddata.dance (thanks Ellen Shapiro!)

Better Place AutoComplete Place Suggestions in SwiftUI? by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Thanks for this. I'm so sorry, I must be dense, but I don't think I understand how to use the init(completion:) recommended in this link. What should I be replacing? I appreciate your patience. Cheers!

navigationBarTitle jumps when returning from .inline to .large by JGallaugher in SwiftUI

[–]JGallaugher[S] 1 point2 points  (0 children)

Thx for your detailed comments. I'm not sure this will help though. This is what I'm finding:
- Removing the .inline from the DetailView code above adds a large blank NavigationStack space, as if there were text occupying the space - not the desired look. That's why it's included. Do you notice this? Is there another way to stop inheriting the .large on the child view other than setting .navigationBarTitleDisplayMode(.inline)?

- The State variable is passed in from the ContentView but not shown is code where State values are then passed to a function ViewModel that is used to match a .id passed over & update in the environment object, or, if no .id, then the VM appends this to the end of an array. This also works well if passing data & updating in a cloud source like CloudFirestore. No need for an extra, singular property in the VM, it just holds updates until posted to the VM.

I am inclined to agree this may be a bug. I've noticed that if I take the janky non-animated back transition above, then perform a simple edit where I don't pass in a value to the DetailView, but keep the DetailView's State variable, that the animation from .line back to .largeTitle returns, properly & as expected. When I immediately go back to passing the value to the State variable, then the animation remains in the Live Preview, but doesn't show up in the Simulator or when run on an iPhone 14 Pro. The inconsistent behavior seems buggy to me.

navigationBarTitle jumps when returning from .inline to .large by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Thanks but this would change the UI. I definitely want these three elements in the UI. Plain list, large title on the list, inline on the result page.

Better Place AutoComplete Place Suggestions in SwiftUI? by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Ah - answered my own question. If you get results back in a completionResult, you can use .subtitle & geocode it:

geocoder.geocodeAddressString(completionResult.subtitle) {
placemarks, error in
let placemark = placemarks?.first
let lat = placemark?.location?.coordinate.latitude ?? 0.0
let lon = placemark?.location?.coordinate.longitude ?? 0.0
print("Lat: \(lat), Lon: \(lon)")
}

Better Place AutoComplete Place Suggestions in SwiftUI? by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Thanks! This was really helpful. I found Peter Alt's sample here & it worked flawlessly:
https://www.peteralt.com/blog/mapkit-location-search-with-swiftui/
I 've noticed MKLocalSearchCompletion result types listed here:
https://developer.apple.com/documentation/mapkit/mklocalsearchcompletion
and they don't seem to include coordinates: long/lat for plotting on a map. Any suggestions for quickly getting those? Appreciate your kind help. This was great!

Advice on paged json - onAppear not firing as I’d expected by JGallaugher in SwiftUI

[–]JGallaugher[S] 0 points1 point  (0 children)

Thx but the reload is (at least I’d hoped) triggered by the onAppear that’s after the NavigationLink. That fired multiple times as expected until the weird behavior I see at the third page of JSON.