Fix focused attachment view being incorrect size on iPad

This commit is contained in:
Shadowfacts 2023-05-04 21:03:11 -04:00
parent 99b74559da
commit f68d1009e5
2 changed files with 14 additions and 11 deletions

View File

@ -16,7 +16,6 @@ class AttachmentThumbnailController: ViewController {
@Published private var image: UIImage? @Published private var image: UIImage?
@Published private var gifController: GIFController? @Published private var gifController: GIFController?
@Published private var fullSize: Bool = false @Published private var fullSize: Bool = false
@Published private var imageBackground: Color?
init(attachment: DraftAttachment) { init(attachment: DraftAttachment) {
self.attachment = attachment self.attachment = attachment

View File

@ -110,10 +110,11 @@ class MatchedGeometryViewController<Content: View>: UIViewController, UIViewCont
} }
} }
@ViewBuilder
func matchedView(id: AnyHashable, source: () -> AnyView) -> some View { func matchedView(id: AnyHashable, source: () -> AnyView) -> some View {
let frame = state.currentFrames[id]! if let frame = state.currentFrames[id],
let dest = state.destinations[id]!.0 let dest = state.destinations[id]?.0 {
return ZStack { ZStack {
source() source()
dest dest
.opacity(state.mode == .presenting ? (state.animating ? 1 : 0) : (state.animating ? 0 : 1)) .opacity(state.mode == .presenting ? (state.animating ? 1 : 0) : (state.animating ? 0 : 1))
@ -124,6 +125,7 @@ class MatchedGeometryViewController<Content: View>: UIViewController, UIViewCont
.animation(.interpolatingSpring(mass: Double(mass), stiffness: Double(state.mode == .presenting ? presentStiffness : dismissStiffness), damping: Double(state.mode == .presenting ? presentDamping : dismissDamping), initialVelocity: 0), value: frame) .animation(.interpolatingSpring(mass: Double(mass), stiffness: Double(state.mode == .presenting ? presentStiffness : dismissStiffness), damping: Double(state.mode == .presenting ? presentDamping : dismissDamping), initialVelocity: 0), value: frame)
} }
} }
}
// MARK: UIViewControllerTransitioningDelegate // MARK: UIViewControllerTransitioningDelegate
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
@ -150,6 +152,8 @@ class MatchedGeometryPresentationAnimationController<Content: View>: NSObject, U
let container = transitionContext.containerView let container = transitionContext.containerView
// add the VC to the container, which kicks off layout out the content hosting controller // 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) container.addSubview(matchedGeomVC.view)
// layout out the content hosting controller and having enough destinations may take a while // layout out the content hosting controller and having enough destinations may take a while