ソースを参照

Keep macOS 12 support and rename the app to Gramora.

Replace newer-only SwiftUI APIs with macOS 12-compatible alternatives and set the display name across the bundle and sidebar.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 ヶ月 前
コミット
d920958275

+ 8 - 8
gramora.xcodeproj/project.pbxproj

@@ -264,7 +264,7 @@
 				MACOSX_DEPLOYMENT_TARGET = 12.0;
 				MARKETING_VERSION = 1.0;
 				PRODUCT_BUNDLE_IDENTIFIER = "MQL-DEV.gramora";
-				PRODUCT_NAME = "$(TARGET_NAME)";
+				PRODUCT_NAME = Gramora;
 				STRING_CATALOG_GENERATE_SYMBOLS = YES;
 				SWIFT_APPROACHABLE_CONCURRENCY = YES;
 				SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
@@ -295,7 +295,7 @@
 				MACOSX_DEPLOYMENT_TARGET = 12.0;
 				MARKETING_VERSION = 1.0;
 				PRODUCT_BUNDLE_IDENTIFIER = "MQL-DEV.gramora";
-				PRODUCT_NAME = "$(TARGET_NAME)";
+				PRODUCT_NAME = Gramora;
 				STRING_CATALOG_GENERATE_SYMBOLS = YES;
 				SWIFT_APPROACHABLE_CONCURRENCY = YES;
 				SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor;
@@ -308,20 +308,20 @@
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
-		A100000B2F00000000000001 /* Build configuration list for PBXProject "gramora" */ = {
+		A10000072F00000000000001 /* Build configuration list for PBXNativeTarget "gramora" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
-				A100000C2F00000000000001 /* Debug */,
-				A100000D2F00000000000001 /* Release */,
+				A100000E2F00000000000001 /* Debug */,
+				A100000F2F00000000000001 /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;
 		};
-		A10000072F00000000000001 /* Build configuration list for PBXNativeTarget "gramora" */ = {
+		A100000B2F00000000000001 /* Build configuration list for PBXProject "gramora" */ = {
 			isa = XCConfigurationList;
 			buildConfigurations = (
-				A100000E2F00000000000001 /* Debug */,
-				A100000F2F00000000000001 /* Release */,
+				A100000C2F00000000000001 /* Debug */,
+				A100000D2F00000000000001 /* Release */,
 			);
 			defaultConfigurationIsVisible = 0;
 			defaultConfigurationName = Release;

+ 2 - 2
gramora/App/GramoraApp.swift

@@ -6,9 +6,9 @@ struct GramoraApp: App {
         WindowGroup {
             MainView()
                 .frame(minWidth: AppTheme.windowMinWidth, minHeight: AppTheme.windowMinHeight)
+                .initialWindowSize(width: AppTheme.windowWidth, height: AppTheme.windowHeight)
         }
-        .defaultSize(width: AppTheme.windowWidth, height: AppTheme.windowHeight)
         .windowStyle(.hiddenTitleBar)
-        .windowToolbarStyle(.unifiedCompact(showsTitle: false))
+        .windowToolbarStyle(.unifiedCompact)
     }
 }

+ 3 - 1
gramora/Info.plist

@@ -10,8 +10,10 @@
 	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
+	<key>CFBundleDisplayName</key>
+	<string>Gramora</string>
 	<key>CFBundleName</key>
-	<string>$(PRODUCT_NAME)</string>
+	<string>Gramora</string>
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>

+ 51 - 0
gramora/Utilities/InitialWindowSizeModifier.swift

@@ -0,0 +1,51 @@
+import AppKit
+import SwiftUI
+
+struct InitialWindowSizeModifier: ViewModifier {
+    let width: CGFloat
+    let height: CGFloat
+
+    func body(content: Content) -> some View {
+        content.background(WindowSizeAccessor(width: width, height: height))
+    }
+}
+
+private struct WindowSizeAccessor: NSViewRepresentable {
+    let width: CGFloat
+    let height: CGFloat
+
+    func makeCoordinator() -> Coordinator {
+        Coordinator()
+    }
+
+    func makeNSView(context: Context) -> NSView {
+        let view = NSView(frame: .zero)
+        DispatchQueue.main.async {
+            context.coordinator.configure(window: view.window, width: width, height: height)
+        }
+        return view
+    }
+
+    func updateNSView(_ nsView: NSView, context: Context) {
+        DispatchQueue.main.async {
+            context.coordinator.configure(window: nsView.window, width: width, height: height)
+        }
+    }
+
+    final class Coordinator {
+        private var didConfigure = false
+
+        func configure(window: NSWindow?, width: CGFloat, height: CGFloat) {
+            guard !didConfigure, let window else { return }
+            didConfigure = true
+            window.setContentSize(NSSize(width: width, height: height))
+            window.center()
+        }
+    }
+}
+
+extension View {
+    func initialWindowSize(width: CGFloat, height: CGFloat) -> some View {
+        modifier(InitialWindowSizeModifier(width: width, height: height))
+    }
+}

+ 3 - 4
gramora/Views/GrammarCheckerView.swift

@@ -19,7 +19,7 @@ struct GrammarCheckerView: View {
         .padding(.horizontal, AppTheme.contentPadding)
         .padding(.top, 28)
         .padding(.bottom, 32)
-        .onChange(of: viewModel.text) { _, newValue in
+        .onChange(of: viewModel.text) { newValue in
             if newValue.count > GrammarCheckerViewModel.maxCharacters {
                 viewModel.text = String(newValue.prefix(GrammarCheckerViewModel.maxCharacters))
             }
@@ -37,13 +37,13 @@ struct GrammarCheckerView: View {
                     Text("Write ")
                         .foregroundStyle(AppTheme.textSecondary)
                     Text("better")
+                        .font(.system(size: 14, weight: .semibold))
                         .foregroundStyle(AppTheme.teal)
-                        .fontWeight(.semibold)
                     Text(". Sound ")
                         .foregroundStyle(AppTheme.textSecondary)
                     Text("smarter")
+                        .font(.system(size: 14, weight: .semibold))
                         .foregroundStyle(AppTheme.teal)
-                        .fontWeight(.semibold)
                     Text(".")
                         .foregroundStyle(AppTheme.textSecondary)
                 }
@@ -72,7 +72,6 @@ struct GrammarCheckerView: View {
                 ThinCaretTextEditor(text: $viewModel.text)
                     .font(.system(size: 14))
                     .foregroundStyle(AppTheme.textPrimary)
-                    .scrollContentBackground(.hidden)
                     .padding(12)
                     .frame(minHeight: 220)
                     .background(Color.white)

+ 1 - 1
gramora/Views/SidebarView.swift

@@ -51,7 +51,7 @@ struct SidebarView: View {
                     .foregroundStyle(.white)
             }
 
-            Text("Grammo")
+            Text("Gramora")
                 .font(.system(size: 18, weight: .bold))
                 .foregroundStyle(AppTheme.textPrimary)
         }