Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Pull to Refresh Support
I found this: swiftui-lab.com/scrollview-pull-to-refresh So far, this is the closest I've gotten to a pull to refresh that works. I was able to adapt it for my needs in one project. That being said, there only seem to be a small handful of examples of people attempting this on their own, none of which work flawlessly. I'm really hoping to see native pull to refresh added simply so we're all doing it in a consistent and preferred manner.
Oct ’20
Reply to SwiftUI - Returning a variable from a function
I have several of these types of calls within my app. It's going to look something like this: private func findSomething(completion: @escaping (Object?) -> Void) { &#9;loadJsonData(url: URL!) { (data, response, error) in &#9;&#9;if (error != nil) { &#9;&#9;&#9;let myObject = Object(<params>) - Or JSON decode here &#9;&#9;&#9;&#9;completion(myObject) &#9;&#9;&#9;} &#9;&#9;&#9;else { completion(nil) } &#9;}      } Notice there is no return type, only a completion function that you can name whatever you like. Then just call it: findSomething() { (object) in &#9;if (object != nil) { &#9;&#9;print(object) &#9;} else { &#9;&#9;print("Did not find anything") &#9;} }
Oct ’20
Reply to iOS 14 (SwiftUI) Sheet Modals not dismissing and acting randomly weird
I'm having the same issue. I noticed late in the day yesterday that my simulator was running iOS 14.1 and my device was still on 14.0. I was having pretty good luck in the simulator getting my modals to close, so I updated the phone and it didn't help. Now this morning, the simulator won't close them either. Like you, I've tried both methods as well. It seems to only get stuck once a control on the view becomes first responder and the keyboard is activated. As long as I don't click into a TextView, the view closes just fine all day long. Help!!
Oct ’20
Reply to iOS 14 (SwiftUI) Sheet Modals not dismissing and acting randomly weird
I seem to be having some better luck now. While I can't for the life of me explain why it works one way and not the other, here's what I had to do to get a more consistent closing action for my modal view. And doing it this way, the environment presentationMode method works just fine. @State private var openComposer = false var body: some View { &#9;NavigationView { &#9;&#9;ZStack { &#9;&#9;&#9;Color("LightGray").edgesIgnoringSafeArea([.all]) &#9;&#9;&#9;ScrollView { &#9;&#9;&#9;&#9;VStack { &#9;&#9;&#9;&#9;&#9;<view stuff here> &#9;&#9;&#9;&#9;} &#9;&#9;&#9;} &#9;&#9;&#9;.toolbar {   &#9;    ToolbarItem(placement: .navigationBarTrailing) {   &#9;      Button(action: {   &#9;        self.openComposer.toggle()   &#9;      }) {   &#9;        Image(systemName: "ellipsis.bubble.fill") &#9;&#9;&#9;&#9;&#9;} /* &#9;&#9;&#9;&#9;&#9;NO, NO, NO - Causes problems placed here &#9;&#9;&#9;&#9;&#9;.fullScreenCover(isPresented: $openComposer) { &#9;&#9;&#9;&#9;&#9;&#9;ActivityCreatorView() &#9;&#9;&#9;&#9;&#9;}/   &#9;    }   &#9;  }  &#9; } &#9;} &#9;.fullScreenCover(isPresented: $openComposer) { &#9;&#9;ActivityCreatorView() &#9;} } So I guess the trick here is to tie the full screen cover views to the outermost container of the view and not to the buttons that trigger them. Here's wishing you similar luck!
Oct ’20
Reply to iOS 14 (SwiftUI) Sheet Modals not dismissing and acting randomly weird
After further research into my issue, I determined it had more to do with the way I was implementing tab item badges. I found some examples on YouTube to implement them over the top of the tab bar, but they seem to be overtaking the entire screen, blocking out my close buttons on the full screen modal. I've since disabled the tab item badges, and that's ultimately what fixed my problem. @Claude31, I would agree that it makes more sense to have the fullScreenCover attached to the outermost view, in this case my NavigationView. I think that's how I'll do it from now on.
Oct ’20