Просмотр исходного кода

Add top and left inset to the grammar text editor so the caret and placeholder are not cramped against the border.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 месяц назад
Родитель
Сommit
d68858c413

+ 2 - 0
gramora/Utilities/AppTheme.swift

@@ -12,6 +12,8 @@ enum AppTheme {
     static let buttonCornerRadius: CGFloat = 14
     static let navItemCornerRadius: CGFloat = 10
     static let inputCornerRadius: CGFloat = 12
+    static let textEditorHorizontalInset: CGFloat = 16
+    static let textEditorVerticalInset: CGFloat = 18
 
     static let background = Color(red: 0.973, green: 0.980, blue: 0.984)
     static let sidebarBackground = Color.white

+ 4 - 1
gramora/Views/Components/ThinCaretTextEditor.swift

@@ -35,7 +35,10 @@ struct ThinCaretTextEditor: NSViewRepresentable {
         textView.drawsBackground = false
         textView.backgroundColor = .clear
         textView.textContainer?.lineFragmentPadding = 0
-        textView.textContainerInset = NSSize(width: 0, height: 0)
+        textView.textContainerInset = NSSize(
+            width: AppTheme.textEditorHorizontalInset,
+            height: AppTheme.textEditorVerticalInset
+        )
         textView.isAutomaticQuoteSubstitutionEnabled = false
         textView.isAutomaticDashSubstitutionEnabled = false
         textView.isAutomaticTextReplacementEnabled = false

+ 2 - 2
gramora/Views/GrammarCheckerView.swift

@@ -73,7 +73,6 @@ struct GrammarCheckerView: View {
                 ThinCaretTextEditor(text: $viewModel.text)
                     .font(.system(size: 14))
                     .foregroundStyle(AppTheme.textPrimary)
-                    .padding(14)
                     .frame(minHeight: 320)
                     .background(Color.white)
                     .clipShape(RoundedRectangle(cornerRadius: AppTheme.inputCornerRadius))
@@ -86,7 +85,8 @@ struct GrammarCheckerView: View {
                             Text("Type or paste your text here and press the check button...")
                                 .font(.system(size: 14))
                                 .foregroundStyle(AppTheme.textMuted)
-                                .padding(14)
+                                .padding(.leading, AppTheme.textEditorHorizontalInset)
+                                .padding(.top, AppTheme.textEditorVerticalInset)
                                 .allowsHitTesting(false)
                         }
                     }