Kaynağa Gözat

Move copy button beside Your Content and align result panels.

Add a compact ToolbarButton style so grammar and spell checker content panels line up with their report panels.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 ay önce
ebeveyn
işleme
4002c27f6b

+ 13 - 6
gramora/Views/Components/GradientButton.swift

@@ -41,26 +41,33 @@ struct GradientButton: View {
 struct ToolbarButton: View {
 struct ToolbarButton: View {
     let title: String
     let title: String
     let iconName: String
     let iconName: String
+    var compact: Bool = false
     let action: () -> Void
     let action: () -> Void
 
 
     @State private var isHovered = false
     @State private var isHovered = false
 
 
+    private var iconFontSize: CGFloat { 12 }
+    private var titleFontSize: CGFloat { 12 }
+    private var horizontalPadding: CGFloat { compact ? 18 : 24 }
+    private var verticalPadding: CGFloat { compact ? 6 : 7 }
+    private var cornerRadius: CGFloat { compact ? 7 : 8 }
+
     var body: some View {
     var body: some View {
         Button(action: action) {
         Button(action: action) {
             HStack(spacing: 6) {
             HStack(spacing: 6) {
                 Image(systemName: iconName)
                 Image(systemName: iconName)
-                    .font(.system(size: 12))
+                    .font(.system(size: iconFontSize))
 
 
                 Text(title)
                 Text(title)
-                    .font(.system(size: 12, weight: .medium))
+                    .font(.system(size: titleFontSize, weight: .medium))
             }
             }
             .foregroundStyle(isHovered ? AppTheme.toolbarForegroundHover : AppTheme.textSecondary)
             .foregroundStyle(isHovered ? AppTheme.toolbarForegroundHover : AppTheme.textSecondary)
-            .padding(.horizontal, 24)
-            .padding(.vertical, 7)
+            .padding(.horizontal, horizontalPadding)
+            .padding(.vertical, verticalPadding)
             .background(isHovered ? AppTheme.toolbarBackgroundHover : Color.white)
             .background(isHovered ? AppTheme.toolbarBackgroundHover : Color.white)
-            .clipShape(RoundedRectangle(cornerRadius: 8))
+            .clipShape(RoundedRectangle(cornerRadius: cornerRadius))
             .overlay(
             .overlay(
-                RoundedRectangle(cornerRadius: 8)
+                RoundedRectangle(cornerRadius: cornerRadius)
                     .stroke(isHovered ? AppTheme.toolbarBorderHover : AppTheme.border, lineWidth: 1)
                     .stroke(isHovered ? AppTheme.toolbarBorderHover : AppTheme.border, lineWidth: 1)
             )
             )
             .shadow(
             .shadow(

+ 13 - 12
gramora/Views/GrammarCheckerView.swift

@@ -213,9 +213,18 @@ struct GrammarCheckerView: View {
 
 
     private var correctedContentPanel: some View {
     private var correctedContentPanel: some View {
         VStack(alignment: .leading, spacing: 14) {
         VStack(alignment: .leading, spacing: 14) {
-            Text("Your Content")
-                .font(.system(size: 18, weight: .bold))
-                .foregroundStyle(AppTheme.textPrimary)
+            HStack(alignment: .center) {
+                Text("Your Content")
+                    .font(.system(size: 18, weight: .bold))
+                    .foregroundStyle(AppTheme.textPrimary)
+
+                Spacer()
+
+                ToolbarButton(title: "Copy", iconName: "doc.on.doc", compact: true) {
+                    viewModel.copyCorrectedText()
+                }
+            }
+            .frame(height: 26)
 
 
             VStack(alignment: .leading, spacing: 0) {
             VStack(alignment: .leading, spacing: 0) {
                 ScrollView(.vertical, showsIndicators: true) {
                 ScrollView(.vertical, showsIndicators: true) {
@@ -227,15 +236,6 @@ struct GrammarCheckerView: View {
                         .padding(20)
                         .padding(20)
                 }
                 }
                 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
                 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
-
-                HStack {
-                    ToolbarButton(title: "Copy Text", iconName: "doc.on.doc") {
-                        viewModel.copyCorrectedText()
-                    }
-                    Spacer()
-                }
-                .padding(.horizontal, 16)
-                .padding(.bottom, 16)
             }
             }
             .frame(maxHeight: .infinity)
             .frame(maxHeight: .infinity)
             .background(panelBackground)
             .background(panelBackground)
@@ -253,6 +253,7 @@ struct GrammarCheckerView: View {
             Text("Grammar Report")
             Text("Grammar Report")
                 .font(.system(size: 18, weight: .bold))
                 .font(.system(size: 18, weight: .bold))
                 .foregroundStyle(AppTheme.textPrimary)
                 .foregroundStyle(AppTheme.textPrimary)
+                .frame(height: 26, alignment: .leading)
 
 
             VStack(alignment: .leading, spacing: 14) {
             VStack(alignment: .leading, spacing: 14) {
                 Text(viewModel.issueCountLabel)
                 Text(viewModel.issueCountLabel)

+ 13 - 12
gramora/Views/SpellCheckerView.swift

@@ -213,9 +213,18 @@ struct SpellCheckerView: View {
 
 
     private var correctedContentPanel: some View {
     private var correctedContentPanel: some View {
         VStack(alignment: .leading, spacing: 14) {
         VStack(alignment: .leading, spacing: 14) {
-            Text("Your Content")
-                .font(.system(size: 18, weight: .bold))
-                .foregroundStyle(AppTheme.textPrimary)
+            HStack(alignment: .center) {
+                Text("Your Content")
+                    .font(.system(size: 18, weight: .bold))
+                    .foregroundStyle(AppTheme.textPrimary)
+
+                Spacer()
+
+                ToolbarButton(title: "Copy", iconName: "doc.on.doc", compact: true) {
+                    viewModel.copyCorrectedText()
+                }
+            }
+            .frame(height: 26)
 
 
             VStack(alignment: .leading, spacing: 0) {
             VStack(alignment: .leading, spacing: 0) {
                 ScrollView(.vertical, showsIndicators: true) {
                 ScrollView(.vertical, showsIndicators: true) {
@@ -227,15 +236,6 @@ struct SpellCheckerView: View {
                         .padding(20)
                         .padding(20)
                 }
                 }
                 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
                 .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
-
-                HStack {
-                    ToolbarButton(title: "Copy Text", iconName: "doc.on.doc") {
-                        viewModel.copyCorrectedText()
-                    }
-                    Spacer()
-                }
-                .padding(.horizontal, 16)
-                .padding(.bottom, 16)
             }
             }
             .frame(maxHeight: .infinity)
             .frame(maxHeight: .infinity)
             .background(panelBackground)
             .background(panelBackground)
@@ -253,6 +253,7 @@ struct SpellCheckerView: View {
             Text("Spelling Report")
             Text("Spelling Report")
                 .font(.system(size: 18, weight: .bold))
                 .font(.system(size: 18, weight: .bold))
                 .foregroundStyle(AppTheme.textPrimary)
                 .foregroundStyle(AppTheme.textPrimary)
+                .frame(height: 26, alignment: .leading)
 
 
             VStack(alignment: .leading, spacing: 14) {
             VStack(alignment: .leading, spacing: 14) {
                 Text(viewModel.mistakeCountLabel)
                 Text(viewModel.mistakeCountLabel)