Post

Replies

Boosts

Views

Activity

Reply to Tile & Scale an Image
Figured it out, I think. This seems to work: ZStack { Rectangle() .foregroundStyle(.image(image, scale: mapImage.scale * mapZoom)) .offset(mapImage.offset) .frame(width: scaledImageSize.width, height: scaledImageSize.height) } .frame(width: mapSize.width, height: mapSize.height) .clipped()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’24
Reply to Auxiliary window control in Mac SwiftUI & SwiftData app
I've been diverted on another project for a bit, so I'm coming back to this after a bit: This answer put me on the right track, I think, but there's something I'm still missing: If I have a DocumentGroup that drives the main document interface, and I want to use WindowGroup to display auxiliary information about a particular model, those two root-level objects need to share the same SwiftData ModelContext, no? But DocumentGroup auto-injects the ModelContext through the (editing: .encounterList, migrationPlan: EncounterListMigrationPlan.self) initializer. How can I then share that context with the WindowGroup? I can get the binding to the id just fine, but I can't figure out how to load the model from that point.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’24
Reply to Tile & Scale an Image
Figured it out, I think. This seems to work: ZStack { Rectangle() .foregroundStyle(.image(image, scale: mapImage.scale * mapZoom)) .offset(mapImage.offset) .frame(width: scaledImageSize.width, height: scaledImageSize.height) } .frame(width: mapSize.width, height: mapSize.height) .clipped()
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’24
Reply to Auxiliary window control in Mac SwiftUI & SwiftData app
I've been diverted on another project for a bit, so I'm coming back to this after a bit: This answer put me on the right track, I think, but there's something I'm still missing: If I have a DocumentGroup that drives the main document interface, and I want to use WindowGroup to display auxiliary information about a particular model, those two root-level objects need to share the same SwiftData ModelContext, no? But DocumentGroup auto-injects the ModelContext through the (editing: .encounterList, migrationPlan: EncounterListMigrationPlan.self) initializer. How can I then share that context with the WindowGroup? I can get the binding to the id just fine, but I can't figure out how to load the model from that point.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’24