Revert "Add .frame & .position modifiers to TextEntry using ScrollView geometry"

This reverts commit f7a0370824.
This commit is contained in:
William Casarin
2023-05-30 19:29:23 -07:00
parent 6eecb5ef26
commit cfa1e13887

View File

@@ -207,16 +207,13 @@ struct PostView: View {
} }
} }
func TextEntry(scrollViewGeometry: GeometryProxy) -> some View { var TextEntry: some View {
GeometryReader { (geometry: GeometryProxy) in
ZStack(alignment: .topLeading) { ZStack(alignment: .topLeading) {
TextViewWrapper(attributedText: $post, postTextViewCanScroll: $postTextViewCanScroll, cursorIndex: newCursorIndex, getFocusWordForMention: { word, range in TextViewWrapper(attributedText: $post, postTextViewCanScroll: $postTextViewCanScroll, cursorIndex: newCursorIndex, getFocusWordForMention: { word, range in
focusWordAttributes = (word, range) focusWordAttributes = (word, range)
self.newCursorIndex = nil self.newCursorIndex = nil
}) })
.environmentObject(tagModel) .environmentObject(tagModel)
.frame(maxHeight: scrollViewGeometry.size.height)
.position(x: geometry.frame(in: .local).midX, y: scrollViewGeometry.frame(in: .local).midY)
.focused($focus) .focused($focus)
.textInputAutocapitalization(.sentences) .textInputAutocapitalization(.sentences)
.onChange(of: post) { p in .onChange(of: post) { p in
@@ -232,7 +229,6 @@ struct PostView: View {
} }
} }
} }
}
var TopBar: some View { var TopBar: some View {
VStack { VStack {
@@ -301,12 +297,12 @@ struct PostView: View {
} }
} }
func Editor(deviceSize: GeometryProxy, scrollViewGeometry: GeometryProxy) -> some View { func Editor(deviceSize: GeometryProxy) -> some View {
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .top) { HStack(alignment: .top) {
ProfilePicView(pubkey: damus_state.pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation) ProfilePicView(pubkey: damus_state.pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
TextEntry(scrollViewGeometry: scrollViewGeometry) TextEntry
} }
.frame(height: deviceSize.size.height * multiply_factor) .frame(height: deviceSize.size.height * multiply_factor)
.id("post") .id("post")
@@ -331,20 +327,18 @@ struct PostView: View {
TopBar TopBar
ScrollViewReader { scroller in ScrollViewReader { scroller in
GeometryReader { (geometry: GeometryProxy) in
ScrollView { ScrollView {
if case .replying_to(let replying_to) = self.action { if case .replying_to(let replying_to) = self.action {
ReplyView(replying_to: replying_to, damus: damus_state, originalReferences: $originalReferences, references: $references) ReplyView(replying_to: replying_to, damus: damus_state, originalReferences: $originalReferences, references: $references)
} }
Editor(deviceSize: deviceSize, scrollViewGeometry: geometry) Editor(deviceSize: deviceSize)
} }
.frame(maxHeight: searching == nil ? .infinity : 70) .frame(maxHeight: searching == nil ? .infinity : 70)
.onAppear { .onAppear {
scroll_to_event(scroller: scroller, id: "post", delay: 1.0, animate: true, anchor: .top) scroll_to_event(scroller: scroller, id: "post", delay: 1.0, animate: true, anchor: .top)
} }
} }
}
// This if-block observes @ for tagging // This if-block observes @ for tagging
if let searching { if let searching {