diff --git a/Tusker/Screens/Compose/ComposeReplyView.swift b/Tusker/Screens/Compose/ComposeReplyView.swift index 6c5d6193..0be41d93 100644 --- a/Tusker/Screens/Compose/ComposeReplyView.swift +++ b/Tusker/Screens/Compose/ComposeReplyView.swift @@ -11,6 +11,7 @@ import SwiftUI struct ComposeReplyView: View { let status: StatusMO let stackPadding: CGFloat + let outerMinY: CGFloat @State private var contentHeight: CGFloat? @@ -48,8 +49,11 @@ struct ComposeReplyView: View { } private func replyAvatarImage(geometry: GeometryProxy) -> some View { - let scrollOffset = geometry.frame(in: .named("outer")).minY - stackPadding - let offset = min(max(-scrollOffset, 0), geometry.size.height - 50 - 8) + // using named coordinate spaces produces an incorrect scroll offset on iOS 13, + // so simply compare the geometry inside and outside the scroll view in the global coordinate space + var scrollOffset = outerMinY - geometry.frame(in: .global).minY + scrollOffset += stackPadding + let offset = min(max(scrollOffset, 0), geometry.size.height - 50 - stackPadding) return ComposeAvatarImageView(url: status.account.avatar) .offset(x: 0, y: offset) } diff --git a/Tusker/Screens/Compose/ComposeView.swift b/Tusker/Screens/Compose/ComposeView.swift index 6f35a1fe..fc23aff9 100644 --- a/Tusker/Screens/Compose/ComposeView.swift +++ b/Tusker/Screens/Compose/ComposeView.swift @@ -57,14 +57,15 @@ struct ComposeView: View { var mostOfTheBody: some View { ZStack(alignment: .top) { - ScrollView(.vertical) { - mainStack + GeometryReader { (outer) in + ScrollView(.vertical) { + mainStack(outerMinY: outer.frame(in: .global).minY) + } } // can't use SwiftUI.ProgressView because there's no UIProgressView.Style.bar equivalent, see FB8587149 WrappedProgressView(value: postProgress, total: postTotalProgress) } - .coordinateSpace(name: "outer") .onAppear(perform: self.didAppear) .navigationBarTitle("Compose") .actionSheet(isPresented: $uiState.isShowingSaveDraftSheet, content: self.saveAndCloseSheet) @@ -77,13 +78,14 @@ struct ComposeView: View { } } - var mainStack: some View { + func mainStack(outerMinY: CGFloat) -> some View { VStack(alignment: .leading, spacing: 8) { if let id = draft.inReplyToID, let status = mastodonController.persistentContainer.status(for: id) { ComposeReplyView( status: status, - stackPadding: stackPadding + stackPadding: stackPadding, + outerMinY: outerMinY ) }