From 0764a38bb879b91eab99bc6d00be71956d7c33d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Orzech?= Date: Sun, 18 Jan 2026 21:25:49 +0000 Subject: [PATCH] fix: Resolve SwiftUI constraint update loop in MenuBarExtra - Add .transaction { $0.animation = nil } to prevent constraint recalculation loops - Add CreditsView.swift to Xcode project (was missing after git pull) - Fixes NSGenericException for Update Constraints in Window passes --- MacTorn/MacTorn.xcodeproj/project.pbxproj | 4 ++++ MacTorn/MacTorn/MacTornApp.swift | 19 +++++++++++-------- MacTorn/MacTorn/Views/StatusView.swift | 3 ++- MacTorn/MacTorn/Views/TravelView.swift | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/MacTorn/MacTorn.xcodeproj/project.pbxproj b/MacTorn/MacTorn.xcodeproj/project.pbxproj index 608ac0d..f7079eb 100644 --- a/MacTorn/MacTorn.xcodeproj/project.pbxproj +++ b/MacTorn/MacTorn.xcodeproj/project.pbxproj @@ -29,6 +29,7 @@ AAA00020 /* PropertiesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA10021 /* PropertiesView.swift */; }; AAA00021 /* NetworkSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA10022 /* NetworkSession.swift */; }; AAA00022 /* TravelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA10023 /* TravelView.swift */; }; + AAA00023 /* CreditsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAA10024 /* CreditsView.swift */; }; /* Unit Tests */ BBB00001 /* MockNetworkSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB10001 /* MockNetworkSession.swift */; }; BBB00002 /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBB10002 /* TestHelpers.swift */; }; @@ -87,6 +88,7 @@ AAA10021 /* PropertiesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropertiesView.swift; sourceTree = ""; }; AAA10022 /* NetworkSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkSession.swift; sourceTree = ""; }; AAA10023 /* TravelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TravelView.swift; sourceTree = ""; }; + AAA10024 /* CreditsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreditsView.swift; sourceTree = ""; }; AAA10000 /* MacTorn.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MacTorn.app; sourceTree = BUILT_PRODUCTS_DIR; }; /* Unit Test Files */ BBB10001 /* MockNetworkSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockNetworkSession.swift; sourceTree = ""; }; @@ -190,6 +192,7 @@ AAA10006 /* SettingsView.swift */, AAA10007 /* StatusView.swift */, AAA10023 /* TravelView.swift */, + AAA10024 /* CreditsView.swift */, AAA10017 /* MoneyView.swift */, AAA10018 /* AttacksView.swift */, AAA10019 /* FactionView.swift */, @@ -441,6 +444,7 @@ AAA00020 /* PropertiesView.swift in Sources */, AAA00021 /* NetworkSession.swift in Sources */, AAA00022 /* TravelView.swift in Sources */, + AAA00023 /* CreditsView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacTorn/MacTorn/MacTornApp.swift b/MacTorn/MacTorn/MacTornApp.swift index 8dba5f0..4ffe9e3 100644 --- a/MacTorn/MacTorn/MacTornApp.swift +++ b/MacTorn/MacTorn/MacTornApp.swift @@ -21,15 +21,18 @@ struct MenuBarLabel: View { var body: some View { // Show airplane + flag + countdown when traveling - if let travel = appState.data?.travel, - travel.isTraveling { - let destination = travel.destination ?? "?" - let flag = flagForDestination(destination) - let time = formatShortTime(appState.travelSecondsRemaining) - Text("✈️\(flag)\(time)") - } else { - Image(systemName: menuBarIcon) + Group { + if let travel = appState.data?.travel, + travel.isTraveling { + let destination = travel.destination ?? "?" + let flag = flagForDestination(destination) + let time = formatShortTime(appState.travelSecondsRemaining) + Text("✈️\(flag)\(time)") + } else { + Image(systemName: menuBarIcon) + } } + .transaction { $0.animation = nil } } private var menuBarIcon: String { diff --git a/MacTorn/MacTorn/Views/StatusView.swift b/MacTorn/MacTorn/Views/StatusView.swift index 76af9ee..9bf7bad 100644 --- a/MacTorn/MacTorn/Views/StatusView.swift +++ b/MacTorn/MacTorn/Views/StatusView.swift @@ -136,7 +136,7 @@ struct StatusView: View { Text(travel.isTraveling ? "Traveling to \(travel.destination ?? "Unknown")" : "In \(travel.destination ?? "Unknown")") .font(.caption.bold()) } - + if travel.isTraveling { HStack { Text("Arriving in:") @@ -152,6 +152,7 @@ struct StatusView: View { .frame(maxWidth: .infinity, alignment: .leading) .background(Color.blue.opacity(0.1)) .cornerRadius(8) + .transaction { $0.animation = nil } } // MARK: - Bars diff --git a/MacTorn/MacTorn/Views/TravelView.swift b/MacTorn/MacTorn/Views/TravelView.swift index 0e68642..e254ae6 100644 --- a/MacTorn/MacTorn/Views/TravelView.swift +++ b/MacTorn/MacTorn/Views/TravelView.swift @@ -74,6 +74,7 @@ struct FlyingStatusView: View { .padding() .background(Color.blue.opacity(0.1)) .cornerRadius(12) + .transaction { $0.animation = nil } } }