Post

Replies

Boosts

Views

Activity

Disabling card zoom effect on certain transitions
I have attached a screenshot showing the type of behavior in Apple's own Weather app that I am looking to disable in my own app. There is a zoom / card effect where the presenting view shrinks / zooms in the background, exposing a different background color that can look out of place. Notice that when dragging the map view to dismiss it, the views behind it are zoomed in exposing a different background. The presenting view that has this "card" effect has hard edges that do not match the screens corner radius as well, so it just looks out of place. Using this as an example, what would be the way to keep this matched zoom transition but keeping the Weather's background still going edge to edge? In my app I am trying to keep my mesh gradient edge to edge and not zoomed in with black or white borders in a similar situation to what we are seeing in the Weather app on 26.4 Let me know if I need to explain it more. Thank you!
Topic: UI Frameworks SubTopic: SwiftUI
0
0
66
3w
Recommended method of passing NSManagedObjectContext to @ObservedObject/@StateObject
I have a view that is pulling the context from the environment using the latest SwiftUI CoreData template (i.e. there is a preview/in-memory context vs the persistent context). I also have an @ObservableObject class that is fetching objects based on the predicates passed in (think dynamic filtering). A random element from these fetched results are then displayed back in the view (i.e. I do not need this ObservableObject class to be a view itself). However, there is an interesting "issue" where I cannot instantiate my @ObservedObject because the property initializers are run before "self" is available and I need to pass it the NSManagedObjectContext. The only way I can think to get around this is to create the ObservableObject class outside of the view and pass it in the view's initializer. However, this isn't completely desirable as I would prefer this data be completely private to the view as other views do not need to know about its existence. I also need it to be an ObserableObject so that the filters can change and it be reflected back in the view observing it. Am I using the wrong tool or thinking about this wrong? class Filter: ObservableObject { @Published var someObjects: [Objects] = [] /* Need to instantiate with the context so objects can be fetched */ private let context: NSManagedObjectContext } struct ContentView: View {     @Environment(\.managedObjectContext) var context 	 /* Cannot initialize here as context isn't available */     @ObservedObject var filter = Filter(context: context) }
4
1
2.8k
Jul ’22
Disabling card zoom effect on certain transitions
I have attached a screenshot showing the type of behavior in Apple's own Weather app that I am looking to disable in my own app. There is a zoom / card effect where the presenting view shrinks / zooms in the background, exposing a different background color that can look out of place. Notice that when dragging the map view to dismiss it, the views behind it are zoomed in exposing a different background. The presenting view that has this "card" effect has hard edges that do not match the screens corner radius as well, so it just looks out of place. Using this as an example, what would be the way to keep this matched zoom transition but keeping the Weather's background still going edge to edge? In my app I am trying to keep my mesh gradient edge to edge and not zoomed in with black or white borders in a similar situation to what we are seeing in the Weather app on 26.4 Let me know if I need to explain it more. Thank you!
Topic: UI Frameworks SubTopic: SwiftUI
Replies
0
Boosts
0
Views
66
Activity
3w
Recommended method of passing NSManagedObjectContext to @ObservedObject/@StateObject
I have a view that is pulling the context from the environment using the latest SwiftUI CoreData template (i.e. there is a preview/in-memory context vs the persistent context). I also have an @ObservableObject class that is fetching objects based on the predicates passed in (think dynamic filtering). A random element from these fetched results are then displayed back in the view (i.e. I do not need this ObservableObject class to be a view itself). However, there is an interesting "issue" where I cannot instantiate my @ObservedObject because the property initializers are run before "self" is available and I need to pass it the NSManagedObjectContext. The only way I can think to get around this is to create the ObservableObject class outside of the view and pass it in the view's initializer. However, this isn't completely desirable as I would prefer this data be completely private to the view as other views do not need to know about its existence. I also need it to be an ObserableObject so that the filters can change and it be reflected back in the view observing it. Am I using the wrong tool or thinking about this wrong? class Filter: ObservableObject { @Published var someObjects: [Objects] = [] /* Need to instantiate with the context so objects can be fetched */ private let context: NSManagedObjectContext } struct ContentView: View {     @Environment(\.managedObjectContext) var context 	 /* Cannot initialize here as context isn't available */     @ObservedObject var filter = Filter(context: context) }
Replies
4
Boosts
1
Views
2.8k
Activity
Jul ’22