From 406c5898d103427193e589b4bbe615d0c739b2c5 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Tue, 02 Jun 2026 19:36:31 +0800
Subject: [PATCH] Prepare 7.8.9 tag navigation drop test package

---
 Apptag/PreferencesView.swift |   83 ++++++++++++++++++++++++++++++++---------
 1 files changed, 65 insertions(+), 18 deletions(-)

diff --git a/Apptag/PreferencesView.swift b/Apptag/PreferencesView.swift
index e856ff9..bc0bd82 100644
--- a/Apptag/PreferencesView.swift
+++ b/Apptag/PreferencesView.swift
@@ -4,8 +4,8 @@
 // MARK: - Preferences View
 
 struct PreferencesView: View {
-    private let settingsWindowWidth: CGFloat = 880
-    private let settingsContentWidth: CGFloat = 820
+    private let settingsWindowWidth: CGFloat = 1000
+    private let settingsContentWidth: CGFloat = 940
     private let generalContentWidth: CGFloat = 720
     private let generalLabelWidth: CGFloat = 190
     private let generalControlWidth: CGFloat = 500
@@ -25,7 +25,7 @@
     @AppStorage("showUncommonAppBubbles") private var showUncommonAppBubbles = AppDefaults.showUncommonAppBubbles
     @AppStorage("mainHotkeyRegistrationState") private var mainHotkeyRegistrationState = LauncherHotkeyRegistrationState.active.rawValue
     @AppStorage("quickSearchHotkeyRegistrationState") private var quickSearchHotkeyRegistrationState = LauncherHotkeyRegistrationState.active.rawValue
-    @State private var selectedLanguage = L10n.currentCode
+    @State private var selectedLanguage = L10n.selectedLanguageCode
     @State private var isRefreshingLanguage = false
     @State private var allApps: [AppInfo] = []
     @State private var tagColors: [String: Int] = [:]
@@ -271,16 +271,12 @@
         isApplyingSystemScheme = true
 
         DispatchQueue.global(qos: .userInitiated).async {
-            let scannedApps = AppIndexer.scan(useCache: false)
-            let result = SmartStartService.applySystemInitialScheme(apps: scannedApps)
-            let store = result.store
-            let apps = TagEditor.annotate(apps: scannedApps, store: store)
-            let colors = store.tags.mapValues { $0.color }
+            let result = AppLibraryController.applySystemInitialScheme()
 
             DispatchQueue.main.async {
                 isApplyingSystemScheme = false
-                allApps = apps
-                tagColors = colors
+                allApps = result.snapshot.apps
+                tagColors = result.snapshot.tagColors
                 refreshDataState()
                 notifyDataChanged()
 
@@ -360,7 +356,7 @@
     }
 
     private func syncSelectedLanguage() {
-        let code = L10n.currentCode
+        let code = L10n.selectedLanguageCode
         guard selectedLanguage != code else { return }
         selectedLanguage = code
     }
@@ -371,10 +367,14 @@
     private var buildVersion: String {
         Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "?"
     }
+    private var helpPDFURL: URL {
+        HelpDocument.currentURL
+    }
     private var languageColumns: [GridItem] {
         [
-            GridItem(.flexible(minimum: 220), spacing: 18, alignment: .top),
-            GridItem(.flexible(minimum: 220), spacing: 18, alignment: .top),
+            GridItem(.flexible(minimum: 180), spacing: 14, alignment: .top),
+            GridItem(.flexible(minimum: 180), spacing: 14, alignment: .top),
+            GridItem(.flexible(minimum: 180), spacing: 14, alignment: .top),
         ]
     }
     private var displayModeColumns: [GridItem] {
@@ -506,6 +506,30 @@
 
                     ScrollView {
                         LazyVGrid(columns: languageColumns, alignment: .leading, spacing: 6) {
+                            Button {
+                                selectedLanguage = L10n.automaticCode
+                            } label: {
+                                HStack(spacing: 8) {
+                                    Image(systemName: selectedLanguage == L10n.automaticCode ? "checkmark" : "circle")
+                                        .font(.system(size: 12, weight: .semibold))
+                                        .foregroundStyle(selectedLanguage == L10n.automaticCode ? Color.accentColor : Color.secondary.opacity(0.28))
+                                        .frame(width: 16)
+                                    Text(tr("settings.language.auto"))
+                                        .foregroundStyle(.primary)
+                                        .lineLimit(1)
+                                    Text("(\(L10n.supported.first(where: { $0.code == L10n.currentCode })?.name ?? "English"))")
+                                        .font(.caption)
+                                        .foregroundStyle(.secondary)
+                                        .lineLimit(1)
+                                    Spacer(minLength: 0)
+                                }
+                                .padding(.horizontal, 8)
+                                .padding(.vertical, 5)
+                                .contentShape(Rectangle())
+                            }
+                            .buttonStyle(.plain)
+                            .accessibilityLabel("\(tr("settings.languagePicker")) \(tr("settings.language.auto"))")
+
                             ForEach(L10n.supported, id: \.code) { language in
                                 Button {
                                     selectedLanguage = language.code
@@ -531,9 +555,7 @@
                         }
                         .padding(.vertical, 4)
                     }
-                    .frame(maxHeight: 250)
-
-                    Spacer(minLength: 0)
+                    .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
                 }
                 .frame(maxWidth: settingsContentWidth, alignment: .leading)
                 .tabItem { Label(tr("settings.language"), systemImage: "globe") }
@@ -816,6 +838,31 @@
                         Divider()
                             .padding(.vertical, 4)
 
+                        HStack(spacing: 8) {
+                            Button {
+                                NSWorkspace.shared.open(helpPDFURL)
+                            } label: {
+                                Label(tr("help.openPDF"), systemImage: "questionmark.circle")
+                            }
+                            .buttonStyle(.borderedProminent)
+                            .controlSize(.regular)
+
+                            Button {
+                                NSPasteboard.general.clearContents()
+                                NSPasteboard.general.setString(helpPDFURL.absoluteString, forType: .string)
+                            } label: {
+                                Image(systemName: "link")
+                            }
+                            .buttonStyle(.bordered)
+                            .controlSize(.regular)
+                            .help(tr("help.copyLink"))
+                        }
+
+                        Text(tr("help.currentLanguage"))
+                            .font(.caption)
+                            .foregroundStyle(.secondary)
+                            .padding(.bottom, 2)
+
                         Text("万物之中,希望最美")
                             .font(.caption)
                             .foregroundStyle(.secondary)
@@ -833,7 +880,7 @@
             .padding()
             }
             .onChange(of: selectedLanguage) { _, code in
-                L10n.switchTo(code)
+                L10n.switchSelection(to: code)
             }
             .onReceive(NotificationCenter.default.publisher(for: .appLanguageDidChange)) { notification in
                 if let code = notification.userInfo?["code"] as? String {
@@ -900,7 +947,7 @@
                 .transition(.opacity.combined(with: .move(edge: .bottom)))
             }
         }
-        .frame(width: settingsWindowWidth, height: 460)
+        .frame(width: settingsWindowWidth, height: 480)
         .onAppear {
             syncSelectedLanguage()
             showPendingHotkeyWarningIfNeeded()

--
Gitblit v1.9.3