From 358e70b885ce1d96e187ff8694bdc7c20eaba7f7 Mon Sep 17 00:00:00 2001 From: Levin Li Date: Thu, 29 Apr 2021 19:36:00 +0800 Subject: [PATCH] Optimize Catalyst build for Mac --- MobileCelestia.xcodeproj/project.pbxproj | 18 ++++++++---------- MobileCelestia/AppDelegate.swift | 13 ++++++++++--- .../Event/EventFinderInputViewController.swift | 2 +- MobileCelestia/Info/BodyActionCell.swift | 2 ++ .../Resource/Views/ProgressButton.swift | 1 + MobileCelestia/Settings/SettingTextCell.swift | 4 +++- MobileCelestia/Settings/SettngSliderCell.swift | 3 --- .../Tutorial/TutorialActionCell.swift | 4 +++- 8 files changed, 28 insertions(+), 19 deletions(-) diff --git a/MobileCelestia.xcodeproj/project.pbxproj b/MobileCelestia.xcodeproj/project.pbxproj index 0c58ab6a..17122137 100644 --- a/MobileCelestia.xcodeproj/project.pbxproj +++ b/MobileCelestia.xcodeproj/project.pbxproj @@ -994,11 +994,13 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 11.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.0; + MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; - SHARED_BUILD_NUMBER = 103; + SHARED_BUILD_NUMBER = 106; SHARED_BUILD_VERSION = 1.3.1; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -1052,10 +1054,12 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 11.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.0; + MACOSX_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = iphoneos; - SHARED_BUILD_NUMBER = 103; + SHARED_BUILD_NUMBER = 106; SHARED_BUILD_VERSION = 1.3.1; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; @@ -1077,7 +1081,6 @@ "$(PROJECT_DIR)/AppCenter", ); INFOPLIST_FILE = MobileCelestia/Info.plist; - "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1090,7 +1093,7 @@ SWIFT_OBJC_BRIDGING_HEADER = "MobileCelestia/Utils/MobileCelestia-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; VALID_ARCHS = "arm64 arm64e x86_64"; }; name = Debug; @@ -1109,7 +1112,6 @@ "$(PROJECT_DIR)/AppCenter", ); INFOPLIST_FILE = MobileCelestia/Info.plist; - "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1121,7 +1123,7 @@ SUPPORTS_MACCATALYST = YES; SWIFT_OBJC_BRIDGING_HEADER = "MobileCelestia/Utils/MobileCelestia-Bridging-Header.h"; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; VALID_ARCHS = "arm64 arm64e x86_64"; }; name = Release; @@ -1134,7 +1136,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 22NR5428TD; INFOPLIST_FILE = MobileCelestiaTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1156,7 +1157,6 @@ CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 22NR5428TD; INFOPLIST_FILE = MobileCelestiaTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 13.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1180,7 +1180,6 @@ DEVELOPMENT_TEAM = 22NR5428TD; INFOPLIST_FILE = CelestiaMacBridge/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; - MACOSX_DEPLOYMENT_TARGET = 10.15; MARKETING_VERSION = "$(SHARED_BUILD_VERSION)"; PRODUCT_BUNDLE_IDENTIFIER = space.celestia.CelestiaMacBridge; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1200,7 +1199,6 @@ DEVELOPMENT_TEAM = 22NR5428TD; INFOPLIST_FILE = CelestiaMacBridge/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles"; - MACOSX_DEPLOYMENT_TARGET = 10.15; MARKETING_VERSION = "$(SHARED_BUILD_VERSION)"; PRODUCT_BUNDLE_IDENTIFIER = space.celestia.CelestiaMacBridge; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/MobileCelestia/AppDelegate.swift b/MobileCelestia/AppDelegate.swift index f099273e..e2151dfc 100644 --- a/MobileCelestia/AppDelegate.swift +++ b/MobileCelestia/AppDelegate.swift @@ -51,6 +51,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { try? FileManager.default.removeItem(atPath: savedStatePath) } } + #else + UISlider.appearance().minimumTrackTintColor = .darkSliderMinimumTrackTintColor + UIBarButtonItem.appearance().tintColor = .themeLabel + UIButton.appearance().tintColor = .themeLabel + UITabBar.appearance().tintColor = .themeLabel + UISearchBar.appearance().tintColor = .themeLabel + UISegmentedControl.appearance().tintColor = .themeLabel #endif #if !DEBUG @@ -163,13 +170,13 @@ extension AppDelegate { builder.remove(menu: .newScene) + let identifierPrefix = Bundle.app.bundleIdentifier! + "." + let preferencesCommand = UIKeyCommand(title: CelestiaString("Preferences…", comment: ""), action: #selector(showPreferences), input: ",", modifierFlags: .command) - builder.insertSibling(UIMenu(identifier: .preferences, options: .displayInline, children: [ + builder.insertSibling(UIMenu(identifier: UIMenu.Identifier(identifierPrefix + "preferences"), options: .displayInline, children: [ preferencesCommand ]), afterMenu: .about) - let identifierPrefix = Bundle.app.bundleIdentifier! + "." - builder.insertChild(UIMenu(title: "", image: nil, identifier: UIMenu.Identifier(identifierPrefix + "open"), options: .displayInline, children: [ UIKeyCommand(title: CelestiaString("Run Script…", comment: ""), image: nil, action: #selector(openScriptFile), input: "O", modifierFlags: .command) ]), atStartOfMenu: .file) diff --git a/MobileCelestia/Event/EventFinderInputViewController.swift b/MobileCelestia/Event/EventFinderInputViewController.swift index 10acb329..a688ceea 100644 --- a/MobileCelestia/Event/EventFinderInputViewController.swift +++ b/MobileCelestia/Event/EventFinderInputViewController.swift @@ -43,7 +43,7 @@ class EventFinderInputViewController: BaseTableViewController { private let defaultSearchingInterval: TimeInterval = 365 * 24 * 60 * 60 private lazy var startTime = endTime.addingTimeInterval(-defaultSearchingInterval) private lazy var endTime = Date() - private var objectName = "Earth" + private var objectName = LocalizedString("Earth", "celestia") private let core = CelestiaAppCore.shared diff --git a/MobileCelestia/Info/BodyActionCell.swift b/MobileCelestia/Info/BodyActionCell.swift index ac537554..3aa75d54 100644 --- a/MobileCelestia/Info/BodyActionCell.swift +++ b/MobileCelestia/Info/BodyActionCell.swift @@ -40,6 +40,8 @@ final class BodyActionCell: UICollectionViewCell { } } } else { + button.titleLabel?.lineBreakMode = .byWordWrapping + button.titleLabel?.textAlignment = .center button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 0, bottom: 12, right: 0) button.layer.cornerRadius = 4 #if targetEnvironment(macCatalyst) diff --git a/MobileCelestia/Resource/Views/ProgressButton.swift b/MobileCelestia/Resource/Views/ProgressButton.swift index 57264cc3..b2cbd76d 100644 --- a/MobileCelestia/Resource/Views/ProgressButton.swift +++ b/MobileCelestia/Resource/Views/ProgressButton.swift @@ -23,6 +23,7 @@ public class ProgressButton: UIButton { layer.cornerRadius = cornerRadius layer.masksToBounds = true + titleLabel?.lineBreakMode = .byWordWrapping titleLabel?.textAlignment = .center titleLabel?.textColor = .white titleLabel?.font = UIFont.boldSystemFont(ofSize: 0) diff --git a/MobileCelestia/Settings/SettingTextCell.swift b/MobileCelestia/Settings/SettingTextCell.swift index cceaf3b2..3c4ef4fe 100644 --- a/MobileCelestia/Settings/SettingTextCell.swift +++ b/MobileCelestia/Settings/SettingTextCell.swift @@ -98,7 +98,9 @@ private extension SettingTextCell { detailLabel.textColor = .darkTertiaryLabel detailLabel.font = UIFont.preferredFont(forTextStyle: .body) - detailLabel.numberOfLines = 0 + detailLabel.numberOfLines = 1 + detailLabel.adjustsFontSizeToFitWidth = true + detailLabel.minimumScaleFactor = 0.4 NSLayoutConstraint.activate([ detailLabel.leadingAnchor.constraint(greaterThanOrEqualTo: label.trailingAnchor, constant: 16), diff --git a/MobileCelestia/Settings/SettngSliderCell.swift b/MobileCelestia/Settings/SettngSliderCell.swift index 8358b81e..026b4973 100644 --- a/MobileCelestia/Settings/SettngSliderCell.swift +++ b/MobileCelestia/Settings/SettngSliderCell.swift @@ -70,9 +70,6 @@ private extension SettingSliderCell { label.topAnchor.constraint(equalTo: topContainer.topAnchor, constant: 12), ]) - #if !targetEnvironment(macCatalyst) - slider.minimumTrackTintColor = .darkSliderMinimumTrackTintColor - #endif slider.minimumValue = 0 slider.maximumValue = 100 slider.translatesAutoresizingMaskIntoConstraints = false diff --git a/MobileCelestia/Tutorial/TutorialActionCell.swift b/MobileCelestia/Tutorial/TutorialActionCell.swift index b4d33bb7..9cf9d51d 100644 --- a/MobileCelestia/Tutorial/TutorialActionCell.swift +++ b/MobileCelestia/Tutorial/TutorialActionCell.swift @@ -15,7 +15,7 @@ class TutorialActionCell: UITableViewCell { var title: String? { didSet { button.setTitle(title, for: .normal) } } var actionHandler: (() -> Void)? - private lazy var button = UIButton(type: .system) + private lazy var button = StandardButton(type: .system) override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) @@ -46,6 +46,8 @@ private extension TutorialActionCell { } } } else { + button.titleLabel?.lineBreakMode = .byWordWrapping + button.titleLabel?.textAlignment = .center button.contentEdgeInsets = UIEdgeInsets(top: 12, left: 0, bottom: 12, right: 0) button.layer.cornerRadius = 4 #if targetEnvironment(macCatalyst)