From 2f35d20562fafc176eb2cb6408fa202c91187450 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 14 Jun 2023 21:41:01 +0800 Subject: [PATCH] Fix the texteditor on the notebook view --- .../Article/HighlightAnnotationSheet.swift | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift b/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift index 3221fe154..65f965d7e 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/HighlightAnnotationSheet.swift @@ -6,6 +6,12 @@ public struct HighlightAnnotationSheet: View { @Binding var errorAlertMessage: String? @Binding var showErrorAlertMessage: Bool + enum FocusField: Hashable { + case textEditor + } + + @FocusState private var focusedField: FocusField? + let onSave: () -> Void let onCancel: () -> Void @@ -25,30 +31,14 @@ public struct HighlightAnnotationSheet: View { public var body: some View { VStack { -// HStack { -// Button(LocalText.cancelGeneric, action: onCancel) -// Spacer() -// Text("Note").font(Font.system(size: 18, weight: .bold)) -// Spacer() -// Button(LocalText.genericSave) { -// onSave() -// } -// } -// .foregroundColor(.appGrayTextContrast) - - ScrollView { - TextEditor(text: $annotation) - .frame(height: 200) - #if os(iOS) - .introspectTextView { - $0.becomeFirstResponder() - } - #endif - } - - Spacer() + TextEditor(text: $annotation) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) + .focused($focusedField, equals: .textEditor) + .padding(.horizontal) + .task { + focusedField = .textEditor + } } - .padding() .navigationTitle("Note") #if os(iOS) .navigationBarTitleDisplayMode(.inline)