diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentThumbnailController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentThumbnailController.swift index a476bb07..c157469c 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentThumbnailController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/AttachmentThumbnailController.swift @@ -16,7 +16,6 @@ class AttachmentThumbnailController: ViewController { @Published private var image: UIImage? @Published private var gifController: GIFController? @Published private var fullSize: Bool = false - @Published private var imageBackground: Color? init(attachment: DraftAttachment) { self.attachment = attachment diff --git a/Packages/MatchedGeometryPresentation/Sources/MatchedGeometryPresentation/MatchedGeometryViewController.swift b/Packages/MatchedGeometryPresentation/Sources/MatchedGeometryPresentation/MatchedGeometryViewController.swift index aea8898e..76a34350 100644 --- a/Packages/MatchedGeometryPresentation/Sources/MatchedGeometryPresentation/MatchedGeometryViewController.swift +++ b/Packages/MatchedGeometryPresentation/Sources/MatchedGeometryPresentation/MatchedGeometryViewController.swift @@ -110,18 +110,20 @@ class MatchedGeometryViewController: UIViewController, UIViewCont } } + @ViewBuilder func matchedView(id: AnyHashable, source: () -> AnyView) -> some View { - let frame = state.currentFrames[id]! - let dest = state.destinations[id]!.0 - return ZStack { - source() - dest - .opacity(state.mode == .presenting ? (state.animating ? 1 : 0) : (state.animating ? 0 : 1)) + if let frame = state.currentFrames[id], + let dest = state.destinations[id]?.0 { + ZStack { + source() + dest + .opacity(state.mode == .presenting ? (state.animating ? 1 : 0) : (state.animating ? 0 : 1)) + } + .frame(width: frame.width, height: frame.height) + .position(x: frame.midX, y: frame.midY) + .ignoresSafeArea() + .animation(.interpolatingSpring(mass: Double(mass), stiffness: Double(state.mode == .presenting ? presentStiffness : dismissStiffness), damping: Double(state.mode == .presenting ? presentDamping : dismissDamping), initialVelocity: 0), value: frame) } - .frame(width: frame.width, height: frame.height) - .position(x: frame.midX, y: frame.midY) - .ignoresSafeArea() - .animation(.interpolatingSpring(mass: Double(mass), stiffness: Double(state.mode == .presenting ? presentStiffness : dismissStiffness), damping: Double(state.mode == .presenting ? presentDamping : dismissDamping), initialVelocity: 0), value: frame) } } @@ -150,6 +152,8 @@ class MatchedGeometryPresentationAnimationController: NSObject, U let container = transitionContext.containerView // add the VC to the container, which kicks off layout out the content hosting controller + matchedGeomVC.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] + matchedGeomVC.view.frame = container.bounds container.addSubview(matchedGeomVC.view) // layout out the content hosting controller and having enough destinations may take a while