├── .gitattributes ├── .gitignore ├── AdvancedToolbarApp.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── AdvancedToolbarApp ├── AdvancedToolbarApp.entitlements ├── AdvancedToolbarApp.swift ├── AdvancedToolbarWindow.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── ContentView.swift └── Preview Content │ └── Preview Assets.xcassets │ └── Contents.json ├── LICENSE ├── README.md └── preview.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /AdvancedToolbarApp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 8F19C51929C7CAF0000CF7BF /* AdvancedToolbarApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F19C51829C7CAF0000CF7BF /* AdvancedToolbarApp.swift */; }; 11 | 8F19C51B29C7CAF0000CF7BF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F19C51A29C7CAF0000CF7BF /* ContentView.swift */; }; 12 | 8F19C51D29C7CAF1000CF7BF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F19C51C29C7CAF1000CF7BF /* Assets.xcassets */; }; 13 | 8F19C52029C7CAF1000CF7BF /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8F19C51F29C7CAF1000CF7BF /* Preview Assets.xcassets */; }; 14 | 8F27129129C9FDD6007EB414 /* AdvancedToolbarWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F27129029C9FDD6007EB414 /* AdvancedToolbarWindow.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | 8F19C51529C7CAF0000CF7BF /* AdvancedToolbarApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AdvancedToolbarApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | 8F19C51829C7CAF0000CF7BF /* AdvancedToolbarApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedToolbarApp.swift; sourceTree = ""; }; 20 | 8F19C51A29C7CAF0000CF7BF /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 21 | 8F19C51C29C7CAF1000CF7BF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | 8F19C51F29C7CAF1000CF7BF /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 23 | 8F19C52129C7CAF1000CF7BF /* AdvancedToolbarApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AdvancedToolbarApp.entitlements; sourceTree = ""; }; 24 | 8F27129029C9FDD6007EB414 /* AdvancedToolbarWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedToolbarWindow.swift; sourceTree = ""; }; 25 | /* End PBXFileReference section */ 26 | 27 | /* Begin PBXFrameworksBuildPhase section */ 28 | 8F19C51229C7CAF0000CF7BF /* Frameworks */ = { 29 | isa = PBXFrameworksBuildPhase; 30 | buildActionMask = 2147483647; 31 | files = ( 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | 8F19C50C29C7CAEF000CF7BF = { 39 | isa = PBXGroup; 40 | children = ( 41 | 8F19C51729C7CAF0000CF7BF /* AdvancedToolbarApp */, 42 | 8F19C51629C7CAF0000CF7BF /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | 8F19C51629C7CAF0000CF7BF /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | 8F19C51529C7CAF0000CF7BF /* AdvancedToolbarApp.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | 8F19C51729C7CAF0000CF7BF /* AdvancedToolbarApp */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | 8F19C51829C7CAF0000CF7BF /* AdvancedToolbarApp.swift */, 58 | 8F19C51A29C7CAF0000CF7BF /* ContentView.swift */, 59 | 8F27129029C9FDD6007EB414 /* AdvancedToolbarWindow.swift */, 60 | 8F19C51C29C7CAF1000CF7BF /* Assets.xcassets */, 61 | 8F19C52129C7CAF1000CF7BF /* AdvancedToolbarApp.entitlements */, 62 | 8F19C51E29C7CAF1000CF7BF /* Preview Content */, 63 | ); 64 | path = AdvancedToolbarApp; 65 | sourceTree = ""; 66 | }; 67 | 8F19C51E29C7CAF1000CF7BF /* Preview Content */ = { 68 | isa = PBXGroup; 69 | children = ( 70 | 8F19C51F29C7CAF1000CF7BF /* Preview Assets.xcassets */, 71 | ); 72 | path = "Preview Content"; 73 | sourceTree = ""; 74 | }; 75 | /* End PBXGroup section */ 76 | 77 | /* Begin PBXNativeTarget section */ 78 | 8F19C51429C7CAF0000CF7BF /* AdvancedToolbarApp */ = { 79 | isa = PBXNativeTarget; 80 | buildConfigurationList = 8F19C52429C7CAF1000CF7BF /* Build configuration list for PBXNativeTarget "AdvancedToolbarApp" */; 81 | buildPhases = ( 82 | 8F19C51129C7CAF0000CF7BF /* Sources */, 83 | 8F19C51229C7CAF0000CF7BF /* Frameworks */, 84 | 8F19C51329C7CAF0000CF7BF /* Resources */, 85 | ); 86 | buildRules = ( 87 | ); 88 | dependencies = ( 89 | ); 90 | name = AdvancedToolbarApp; 91 | productName = AdvancedToolbarApp; 92 | productReference = 8F19C51529C7CAF0000CF7BF /* AdvancedToolbarApp.app */; 93 | productType = "com.apple.product-type.application"; 94 | }; 95 | /* End PBXNativeTarget section */ 96 | 97 | /* Begin PBXProject section */ 98 | 8F19C50D29C7CAEF000CF7BF /* Project object */ = { 99 | isa = PBXProject; 100 | attributes = { 101 | BuildIndependentTargetsInParallel = 1; 102 | LastSwiftUpdateCheck = 1420; 103 | LastUpgradeCheck = 1420; 104 | TargetAttributes = { 105 | 8F19C51429C7CAF0000CF7BF = { 106 | CreatedOnToolsVersion = 14.2; 107 | }; 108 | }; 109 | }; 110 | buildConfigurationList = 8F19C51029C7CAEF000CF7BF /* Build configuration list for PBXProject "AdvancedToolbarApp" */; 111 | compatibilityVersion = "Xcode 14.0"; 112 | developmentRegion = en; 113 | hasScannedForEncodings = 0; 114 | knownRegions = ( 115 | en, 116 | Base, 117 | ); 118 | mainGroup = 8F19C50C29C7CAEF000CF7BF; 119 | productRefGroup = 8F19C51629C7CAF0000CF7BF /* Products */; 120 | projectDirPath = ""; 121 | projectRoot = ""; 122 | targets = ( 123 | 8F19C51429C7CAF0000CF7BF /* AdvancedToolbarApp */, 124 | ); 125 | }; 126 | /* End PBXProject section */ 127 | 128 | /* Begin PBXResourcesBuildPhase section */ 129 | 8F19C51329C7CAF0000CF7BF /* Resources */ = { 130 | isa = PBXResourcesBuildPhase; 131 | buildActionMask = 2147483647; 132 | files = ( 133 | 8F19C52029C7CAF1000CF7BF /* Preview Assets.xcassets in Resources */, 134 | 8F19C51D29C7CAF1000CF7BF /* Assets.xcassets in Resources */, 135 | ); 136 | runOnlyForDeploymentPostprocessing = 0; 137 | }; 138 | /* End PBXResourcesBuildPhase section */ 139 | 140 | /* Begin PBXSourcesBuildPhase section */ 141 | 8F19C51129C7CAF0000CF7BF /* Sources */ = { 142 | isa = PBXSourcesBuildPhase; 143 | buildActionMask = 2147483647; 144 | files = ( 145 | 8F19C51B29C7CAF0000CF7BF /* ContentView.swift in Sources */, 146 | 8F19C51929C7CAF0000CF7BF /* AdvancedToolbarApp.swift in Sources */, 147 | 8F27129129C9FDD6007EB414 /* AdvancedToolbarWindow.swift in Sources */, 148 | ); 149 | runOnlyForDeploymentPostprocessing = 0; 150 | }; 151 | /* End PBXSourcesBuildPhase section */ 152 | 153 | /* Begin XCBuildConfiguration section */ 154 | 8F19C52229C7CAF1000CF7BF /* Debug */ = { 155 | isa = XCBuildConfiguration; 156 | buildSettings = { 157 | ALWAYS_SEARCH_USER_PATHS = NO; 158 | CLANG_ANALYZER_NONNULL = YES; 159 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 160 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 161 | CLANG_ENABLE_MODULES = YES; 162 | CLANG_ENABLE_OBJC_ARC = YES; 163 | CLANG_ENABLE_OBJC_WEAK = YES; 164 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 165 | CLANG_WARN_BOOL_CONVERSION = YES; 166 | CLANG_WARN_COMMA = YES; 167 | CLANG_WARN_CONSTANT_CONVERSION = YES; 168 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 169 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 170 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 171 | CLANG_WARN_EMPTY_BODY = YES; 172 | CLANG_WARN_ENUM_CONVERSION = YES; 173 | CLANG_WARN_INFINITE_RECURSION = YES; 174 | CLANG_WARN_INT_CONVERSION = YES; 175 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 176 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 177 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 178 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 179 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 180 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 181 | CLANG_WARN_STRICT_PROTOTYPES = YES; 182 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 183 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 184 | CLANG_WARN_UNREACHABLE_CODE = YES; 185 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 186 | COPY_PHASE_STRIP = NO; 187 | DEBUG_INFORMATION_FORMAT = dwarf; 188 | ENABLE_STRICT_OBJC_MSGSEND = YES; 189 | ENABLE_TESTABILITY = YES; 190 | GCC_C_LANGUAGE_STANDARD = gnu11; 191 | GCC_DYNAMIC_NO_PIC = NO; 192 | GCC_NO_COMMON_BLOCKS = YES; 193 | GCC_OPTIMIZATION_LEVEL = 0; 194 | GCC_PREPROCESSOR_DEFINITIONS = ( 195 | "DEBUG=1", 196 | "$(inherited)", 197 | ); 198 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 199 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 200 | GCC_WARN_UNDECLARED_SELECTOR = YES; 201 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 202 | GCC_WARN_UNUSED_FUNCTION = YES; 203 | GCC_WARN_UNUSED_VARIABLE = YES; 204 | MACOSX_DEPLOYMENT_TARGET = 13.1; 205 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 206 | MTL_FAST_MATH = YES; 207 | ONLY_ACTIVE_ARCH = YES; 208 | SDKROOT = macosx; 209 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 210 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 211 | }; 212 | name = Debug; 213 | }; 214 | 8F19C52329C7CAF1000CF7BF /* Release */ = { 215 | isa = XCBuildConfiguration; 216 | buildSettings = { 217 | ALWAYS_SEARCH_USER_PATHS = NO; 218 | CLANG_ANALYZER_NONNULL = YES; 219 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 220 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 221 | CLANG_ENABLE_MODULES = YES; 222 | CLANG_ENABLE_OBJC_ARC = YES; 223 | CLANG_ENABLE_OBJC_WEAK = YES; 224 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 225 | CLANG_WARN_BOOL_CONVERSION = YES; 226 | CLANG_WARN_COMMA = YES; 227 | CLANG_WARN_CONSTANT_CONVERSION = YES; 228 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 230 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 231 | CLANG_WARN_EMPTY_BODY = YES; 232 | CLANG_WARN_ENUM_CONVERSION = YES; 233 | CLANG_WARN_INFINITE_RECURSION = YES; 234 | CLANG_WARN_INT_CONVERSION = YES; 235 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 236 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 237 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 238 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 239 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 240 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 241 | CLANG_WARN_STRICT_PROTOTYPES = YES; 242 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 243 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | COPY_PHASE_STRIP = NO; 247 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 248 | ENABLE_NS_ASSERTIONS = NO; 249 | ENABLE_STRICT_OBJC_MSGSEND = YES; 250 | GCC_C_LANGUAGE_STANDARD = gnu11; 251 | GCC_NO_COMMON_BLOCKS = YES; 252 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 253 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 254 | GCC_WARN_UNDECLARED_SELECTOR = YES; 255 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 256 | GCC_WARN_UNUSED_FUNCTION = YES; 257 | GCC_WARN_UNUSED_VARIABLE = YES; 258 | MACOSX_DEPLOYMENT_TARGET = 13.1; 259 | MTL_ENABLE_DEBUG_INFO = NO; 260 | MTL_FAST_MATH = YES; 261 | SDKROOT = macosx; 262 | SWIFT_COMPILATION_MODE = wholemodule; 263 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 264 | }; 265 | name = Release; 266 | }; 267 | 8F19C52529C7CAF1000CF7BF /* Debug */ = { 268 | isa = XCBuildConfiguration; 269 | buildSettings = { 270 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 271 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 272 | CODE_SIGN_ENTITLEMENTS = AdvancedToolbarApp/AdvancedToolbarApp.entitlements; 273 | CODE_SIGN_STYLE = Automatic; 274 | COMBINE_HIDPI_IMAGES = YES; 275 | CURRENT_PROJECT_VERSION = 1; 276 | DEVELOPMENT_ASSET_PATHS = "\"AdvancedToolbarApp/Preview Content\""; 277 | DEVELOPMENT_TEAM = Q7HWV27P33; 278 | ENABLE_HARDENED_RUNTIME = YES; 279 | ENABLE_PREVIEWS = YES; 280 | GENERATE_INFOPLIST_FILE = YES; 281 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 282 | LD_RUNPATH_SEARCH_PATHS = ( 283 | "$(inherited)", 284 | "@executable_path/../Frameworks", 285 | ); 286 | MARKETING_VERSION = 1.0; 287 | PRODUCT_BUNDLE_IDENTIFIER = com.stephancasas.AdvancedToolbarApp; 288 | PRODUCT_NAME = "$(TARGET_NAME)"; 289 | SWIFT_EMIT_LOC_STRINGS = YES; 290 | SWIFT_VERSION = 5.0; 291 | }; 292 | name = Debug; 293 | }; 294 | 8F19C52629C7CAF1000CF7BF /* Release */ = { 295 | isa = XCBuildConfiguration; 296 | buildSettings = { 297 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 298 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 299 | CODE_SIGN_ENTITLEMENTS = AdvancedToolbarApp/AdvancedToolbarApp.entitlements; 300 | CODE_SIGN_STYLE = Automatic; 301 | COMBINE_HIDPI_IMAGES = YES; 302 | CURRENT_PROJECT_VERSION = 1; 303 | DEVELOPMENT_ASSET_PATHS = "\"AdvancedToolbarApp/Preview Content\""; 304 | DEVELOPMENT_TEAM = Q7HWV27P33; 305 | ENABLE_HARDENED_RUNTIME = YES; 306 | ENABLE_PREVIEWS = YES; 307 | GENERATE_INFOPLIST_FILE = YES; 308 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 309 | LD_RUNPATH_SEARCH_PATHS = ( 310 | "$(inherited)", 311 | "@executable_path/../Frameworks", 312 | ); 313 | MARKETING_VERSION = 1.0; 314 | PRODUCT_BUNDLE_IDENTIFIER = com.stephancasas.AdvancedToolbarApp; 315 | PRODUCT_NAME = "$(TARGET_NAME)"; 316 | SWIFT_EMIT_LOC_STRINGS = YES; 317 | SWIFT_VERSION = 5.0; 318 | }; 319 | name = Release; 320 | }; 321 | /* End XCBuildConfiguration section */ 322 | 323 | /* Begin XCConfigurationList section */ 324 | 8F19C51029C7CAEF000CF7BF /* Build configuration list for PBXProject "AdvancedToolbarApp" */ = { 325 | isa = XCConfigurationList; 326 | buildConfigurations = ( 327 | 8F19C52229C7CAF1000CF7BF /* Debug */, 328 | 8F19C52329C7CAF1000CF7BF /* Release */, 329 | ); 330 | defaultConfigurationIsVisible = 0; 331 | defaultConfigurationName = Release; 332 | }; 333 | 8F19C52429C7CAF1000CF7BF /* Build configuration list for PBXNativeTarget "AdvancedToolbarApp" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | 8F19C52529C7CAF1000CF7BF /* Debug */, 337 | 8F19C52629C7CAF1000CF7BF /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | /* End XCConfigurationList section */ 343 | }; 344 | rootObject = 8F19C50D29C7CAEF000CF7BF /* Project object */; 345 | } 346 | -------------------------------------------------------------------------------- /AdvancedToolbarApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AdvancedToolbarApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/AdvancedToolbarApp.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/AdvancedToolbarApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AdvancedToolbarAppApp.swift 3 | // AdvancedToolbarApp 4 | // 5 | // Created by Stephan Casas on 3/19/23. 6 | // 7 | 8 | import SwiftUI; 9 | import Combine; 10 | 11 | var MainWindow: NSWindow?; 12 | 13 | @main 14 | struct AdvancedToolbarApp: App { 15 | init() { 16 | MainWindow = AdvancedToolbarWindow( 17 | withTitle: "My Window", 18 | withToolbar: {HStack(spacing: 0){ 19 | ToolbarButton(systemIcon: "eraser") 20 | ToolbarButton(systemIcon: "pencil") 21 | ToolbarButton(systemIcon: "plus") 22 | }}, 23 | withTitleToolbar: {HStack(spacing: 0){ 24 | ToolbarButton(systemIcon: "chevron.left").forTitleToolbar() 25 | ToolbarButton(systemIcon: "chevron.right").forTitleToolbar() 26 | }}){ ContentView() } 27 | 28 | MainWindow?.makeKeyAndOrderFront(nil); 29 | MainWindow?.center(); 30 | } 31 | 32 | var body = EmptyScene(); 33 | } 34 | 35 | struct EmptyScene : Scene { 36 | var body: some Scene { 37 | MenuBarExtra(isInserted: Binding.constant(false), 38 | content: { EmptyView() }, 39 | label: {Label("", systemImage: "app")})} 40 | } 41 | 42 | struct ToolbarButton : View { 43 | private let label: () -> LabelContent; 44 | private let action: () -> Void; 45 | 46 | private var controlSize: ControlSize = .large; 47 | 48 | /// Create a toolbar button with an inferred `Image` icon from the given `systemName`. 49 | /// - Parameters: 50 | /// - systemIcon: A member in **SF Symbols** 51 | /// - action: The callback to perform when clicked. 52 | init( 53 | systemIcon: String, 54 | _ action: (() -> Void)? = nil 55 | ) where LabelContent == Image { 56 | self.init( 57 | label: { Image(systemName: systemIcon) }, 58 | action: action ?? { print("User did click button with \(systemIcon) icon.") }) 59 | } 60 | 61 | 62 | /// Create a toolbar button with a constructed label view. 63 | /// - Parameters: 64 | /// - label: The label view content to use. 65 | /// - action: The callback to perform when clicked. 66 | init(label: @escaping () -> LabelContent, action: @escaping () -> Void) { 67 | self.label = label 68 | self.action = action 69 | } 70 | 71 | var body: some View { 72 | /// Resizable items drawn as title accessories seem to struggle 73 | /// with a race condition. This may cause resizable content to 74 | /// unpredictably draw with a clipped offset. 75 | /// 76 | /// The additional horizontal padding *inside* the `HStack` 77 | /// seems to fix this issue, but is not necessary if the item 78 | /// is in its default state. 79 | HStack{ 80 | Button( 81 | action: self.action, 82 | label: self.label 83 | ) 84 | .controlSize(self.controlSize) 85 | .padding(.horizontal, self.controlSize == .regular ? 0 : 2) 86 | } 87 | } 88 | 89 | /// Use the smaller control size implemented on macOS title toolbar buttons. 90 | /// 91 | /// Main toolbar buttons implement the `.large` control size, while title toolbar 92 | /// buttons *usually* implement the `.regular` control size. 93 | /// 94 | /// Exceptions to this can be seen throughout macOS, so use what looks best. 95 | /// - Returns: A smaller version of the toolbar button. 96 | func forTitleToolbar() -> Self { 97 | var copy = self; 98 | copy.controlSize = .regular 99 | 100 | return copy; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/AdvancedToolbarWindow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AdvancedToolbarWindow.swift 3 | // 4 | // Created by Stephan Casas on 3/17/23. 5 | // 6 | 7 | import SwiftUI; 8 | import AppKit; 9 | 10 | class AdvancedToolbarWindow: NSWindow, NSToolbarDelegate { 11 | private let toolbarContent: () -> ToolbarContent; 12 | private let titleToolbarContent: () -> TitleToolbarContent; 13 | 14 | /// Create a new window styled with a unified titlebar and inset traffic signals. 15 | /// - Parameters: 16 | /// - withTitle: The window title. 17 | /// - contentRect: The window's main content size. 18 | /// - contentView: The window's main content view. 19 | convenience init( 20 | withTitle: String, 21 | contentRect: NSRect = CGRect(x:0, y: 0, width: 620, height: 400), 22 | _ contentView: () -> MainContent 23 | ) where TitleToolbarContent == EmptyView, ToolbarContent == EmptyView { 24 | self.init( withTitle: withTitle, 25 | contentRect: contentRect, 26 | withToolbar: { EmptyView() }, 27 | withTitleToolbar: { EmptyView() }, 28 | contentView); 29 | } 30 | 31 | /// Create a new window styled with a unified titlebar and inset traffic 32 | /// signals, — including a main toolbar anchored after the window title 33 | /// in the titlebar. 34 | /// - Parameters: 35 | /// - withTitle: The window title. 36 | /// - contentRect: The window's main content size. 37 | /// - withToolbar: The window's toolbar content view. 38 | /// - contentView: The window's main content view. 39 | convenience init( 40 | withTitle: String, 41 | contentRect: NSRect = CGRect(x:0, y: 0, width: 620, height: 400), 42 | withToolbar: @escaping () -> ToolbarContent, 43 | _ contentView: () -> MainContent 44 | ) where TitleToolbarContent == EmptyView { 45 | self.init( 46 | withTitle: withTitle, 47 | withToolbar: withToolbar, 48 | withTitleToolbar: { EmptyView() }, 49 | contentView); 50 | } 51 | 52 | /// Create a new window styled with a unified titlebar and inset traffic 53 | /// signals, — including a title toolbar anchored before the window title 54 | /// in the titlebar. 55 | /// - Parameters: 56 | /// - withTitle: The window title. 57 | /// - contentRect: The window's main content size. 58 | /// - withTitleToolbar: The window's toolbar content view. 59 | /// - contentView: The window's main content view. 60 | convenience init( 61 | withTitle: String, 62 | contentRect: NSRect = CGRect(x:0, y: 0, width: 620, height: 400), 63 | withTitleToolbar: @escaping () -> TitleToolbarContent, 64 | _ contentView: () -> MainContent 65 | ) where ToolbarContent == EmptyView { 66 | self.init( 67 | withTitle: withTitle, 68 | withToolbar: { EmptyView() }, 69 | withTitleToolbar: withTitleToolbar, 70 | contentView); 71 | } 72 | 73 | /// Create a new window styled with a unified titlebar and inset traffic 74 | /// signals — including a title toolbar anchored before the window title 75 | /// in the titlebar and a main toolbar anchored after the window title 76 | /// in the titlebar. 77 | /// - Parameters: 78 | /// - withTitle: The window title. 79 | /// - contentRect: The window's main content size. 80 | /// - withTitleToolbar: The window's title toolbar content view. 81 | /// - contentView: The window's main content view. 82 | init( 83 | withTitle: String, 84 | contentRect: NSRect = CGRect(x:0, y: 0, width: 620, height: 400), 85 | withToolbar: @escaping () -> ToolbarContent, 86 | withTitleToolbar: @escaping () -> TitleToolbarContent, 87 | _ contentView: () -> MainContent 88 | ) { 89 | self.toolbarContent = withToolbar; 90 | self.titleToolbarContent = withTitleToolbar; 91 | 92 | super.init( 93 | contentRect: contentRect, 94 | styleMask: [.closable, .miniaturizable, .resizable, 95 | .titled, .unifiedTitleAndToolbar, .fullSizeContentView], 96 | backing: .buffered, 97 | defer: false); 98 | self.contentView = NSHostingView(rootView: contentView().ignoresSafeArea()) 99 | 100 | /// Init empty `NSToolbar` to fill with SwiftUI later... 101 | let toolbar = NSToolbar(identifier: "\(withTitle)"); 102 | toolbar.displayMode = .iconOnly; 103 | 104 | /// Mount and style empty `NSToolbar` to offset traffic signal insets 105 | self.toolbar = toolbar; 106 | self.toolbar!.isVisible = true; 107 | self.toolbar!.displayMode = .iconOnly 108 | self.toolbarStyle = .automatic; 109 | 110 | /// Apply title and style titlebar 111 | self.title = withTitle; 112 | self.titleVisibility = .visible; 113 | self.titlebarAppearsTransparent = true; 114 | 115 | //MARK: Install Toolbar AccessoryView Controllers 116 | 117 | /// This `NSWindow` style will draw four components in the titlebar: 118 | /// 119 | /// * `NSTitlebarView` 120 | /// * `NSTitlebarContainerBlockingView` 121 | /// * `NSToolbarView` 122 | /// * `NSToolbarTitleView` 123 | /// 124 | /// We must defer installing `NSTitlebarAccessoryViewController` until 125 | /// these components mount during the next UI draw cycle. 126 | /// 127 | DispatchQueue.main.async{ 128 | /// First, install the title toolbar content, if any was given. 129 | self.installToolbarAccessory( 130 | position: .left, 131 | toolbarContent: self.titleToolbarContent); 132 | 133 | /// Next, install the main toolbar content, if any was given. 134 | self.installToolbarAccessory( 135 | position: .right, 136 | toolbarContent: self.toolbarContent); 137 | } 138 | } 139 | 140 | /// Install a toolbar or title toolbar accessory on the window. 141 | /// - Parameters: 142 | /// - position: The position in the titlebar at which to install the toolbar accessory. 143 | /// - toolbarContent: The SwiftUI toolbar content to install. 144 | internal func installToolbarAccessory( 145 | position: NSLayoutConstraint.Attribute, 146 | toolbarContent: () -> T 147 | ) { 148 | let toolbarContentView = toolbarContent(); 149 | if type(of: toolbar) == EmptyView.self { return } 150 | 151 | let accessoryView = NSHostingView(rootView: toolbarContentView); 152 | 153 | /// create the accessory at the given position -- relative to the window's title 154 | let accessory = NSTitlebarAccessoryViewController(); 155 | accessory.view = accessoryView; 156 | accessory.layoutAttribute = position; 157 | 158 | self.addTitlebarAccessoryViewController(accessory); 159 | 160 | /// `NSClipView` 161 | guard let accessoryClipView = accessoryView.superview else { return } 162 | /// `NSTitlebarView` 163 | guard let titlebarView = accessoryClipView.superview else { return } 164 | /// `NSTitlebarContainerBlockingView` 165 | guard let titlebarBlock = titlebarView.superview?.subviews.last else { return } 166 | 167 | /// `NSToolbarView` 168 | /// 169 | /// The toolbar may be at different positions depending on the window style. 170 | /// We can't use a type comparison to locate it, because `NSToolbarView` is a 171 | /// private class. Instead, we can key on each subview's accessibility role 172 | /// until we find *"toolbar"*. 173 | guard let toolbarView = titlebarView.subviews.first(where: { view in 174 | guard let role = view.accessibilityRoleDescription() else { return false } 175 | return role == "toolbar"; // FIXME: This string may need localization. 176 | }) else { return } 177 | 178 | /// `NSToolbarTitleView` 179 | /// 180 | /// We'll need this view so that we can re-assign its leading constraint to 181 | /// come *after* our newly-installed button. 182 | guard let toolbarTitleView = toolbarView.subviews.first else { return } 183 | 184 | /// Disable the auto-resizing mask constraints for **everything**. 185 | accessoryView.translatesAutoresizingMaskIntoConstraints = false; 186 | accessoryClipView.translatesAutoresizingMaskIntoConstraints = false; 187 | 188 | /// This only applies when setting the **title** toolbar. 189 | if position == .left { 190 | toolbarTitleView.translatesAutoresizingMaskIntoConstraints = false; 191 | } 192 | 193 | /// When setting the main toolbar, our view inside of `NSTitlebarAccessoryViewController` 194 | /// should appear after the window title and should hug the rightmost edge with a bit of 195 | /// padding. For the title toolbar, it should appear *before* the window title, but 196 | /// *after* the sidebar with slight padding on its leading edge. 197 | /// 198 | /// Both toolbars should also occupy the full height of the unified titlebar/toolbar 199 | /// area so that we can handle alignment in SwiftUI. 200 | /// 201 | /// For the vertical heights, we'll constrain the `NSClipView` of the accessory 202 | /// on `NSTitlebarContainerBlockingView`. 203 | /// 204 | /// We'll leave the leading edge on the main toolbar and the trailing edge on the title 205 | /// toolbar unconstrained so that they can both grow with SwiftUI-provided content. 206 | var clipViewConstraints = [ 207 | /// When setting the main toolbar, it should hug the **right** edge. 208 | /// When setting the title toolbar, it should hug the **left** edge. 209 | position == .left ? 210 | accessoryClipView.leadingAnchor.constraint( 211 | equalTo: titlebarBlock.leadingAnchor, 212 | constant: 10) 213 | :accessoryClipView.trailingAnchor.constraint( 214 | equalTo: toolbarView.trailingAnchor, 215 | constant: -10), 216 | accessoryClipView.topAnchor.constraint(equalTo: titlebarBlock.topAnchor), 217 | accessoryClipView.bottomAnchor.constraint(equalTo: titlebarBlock.bottomAnchor), 218 | ]; 219 | if position == .right { clipViewConstraints.append( 220 | accessoryClipView.leadingAnchor.constraint( 221 | equalTo: toolbarTitleView.trailingAnchor, 222 | constant: 10))} 223 | NSLayoutConstraint.activate(clipViewConstraints); 224 | 225 | /// Now, we need to constrain our `NSHostingView` to the bounds of the 226 | /// `NSClipView` in which it is contained. This will allow it to occupy 227 | /// the exact same space, and will let us handle alignment in SwiftUI. 228 | NSLayoutConstraint.activate([ 229 | accessoryView.leadingAnchor.constraint(equalTo: accessoryClipView.leadingAnchor), 230 | accessoryView.trailingAnchor.constraint(equalTo: accessoryClipView.trailingAnchor), 231 | accessoryView.topAnchor.constraint(equalTo: accessoryClipView.topAnchor), 232 | accessoryView.bottomAnchor.constraint(equalTo: accessoryClipView.bottomAnchor) 233 | ]); 234 | 235 | /// Finally, when setting the title toolbar, we must offset the window title to the 236 | /// trailing edge of our accessory -- such that it does not overlap. 237 | /// 238 | /// The `NSToolbarTitleView` already includes a leading edge inset, so 239 | /// we do not need to apply another constant here. 240 | if position == .left { 241 | NSLayoutConstraint.activate([ 242 | toolbarTitleView.leadingAnchor.constraint( 243 | equalTo: accessoryView.trailingAnchor, 244 | constant: 2 245 | )])} 246 | } 247 | 248 | override var canBecomeKey: Bool { 249 | return true; 250 | } 251 | 252 | override var canBecomeMain: Bool { 253 | return true; 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "scale" : "1x", 6 | "size" : "16x16" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "2x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "1x", 16 | "size" : "32x32" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "2x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "1x", 26 | "size" : "128x128" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "2x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "1x", 36 | "size" : "256x256" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "2x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "1x", 46 | "size" : "512x512" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "scale" : "2x", 51 | "size" : "512x512" 52 | } 53 | ], 54 | "info" : { 55 | "author" : "xcode", 56 | "version" : 1 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // AdvancedToolbarApp 4 | // 5 | // Created by Stephan Casas on 3/19/23. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | var body: some View { 12 | NavigationView{ 13 | List{ 14 | NavigationLink(destination: { 15 | Text("Pictures").onAppear{ MainWindow?.title = "Pictures" } 16 | }, label: { 17 | Label("Pictures", systemImage: "photo.on.rectangle") 18 | }) 19 | 20 | NavigationLink(destination: { 21 | Text("Videos").onAppear{ MainWindow?.title = "Videos" } 22 | }, label: { 23 | Label("Videos", systemImage: "film.stack") 24 | }) 25 | 26 | NavigationLink(destination: { 27 | Text("Documents").onAppear{ MainWindow?.title = "Documents" } 28 | }, label: { 29 | Label("Documents", systemImage: "doc") 30 | }) 31 | }.listStyle(.sidebar) 32 | } 33 | } 34 | } 35 | 36 | struct ContentView_Previews: PreviewProvider { 37 | static var previews: some View { 38 | ContentView() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /AdvancedToolbarApp/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Stephan Casas 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # swiftui-advanced-toolbar-app 2 | 3 | An example implementation of `NSWindow` with advanced toolbar capabilities in a SwiftUI-based macOS application. 4 | 5 |

6 | 7 | ## Why? 8 | 9 | Because window management for macOS apps using SwiftUI's lifecycle is goofy, and I'm not using this ridiculous workaround in my app: 10 | 11 | ```swift 12 | @main 13 | struct MyApplication: App { 14 | var body : some Scene { 15 | Window("Some Window", id: "some-window") { 16 | ContentView().background(WindowAccessor()) 17 | } 18 | } 19 | } 20 | 21 | struct WindowAccessor: NSViewRepresentable { 22 | func makeNSView(context: Context) -> NSView { 23 | let view = NSView() 24 | DispatchQueue.main.async { 25 | view.window?.titlebarAppearsTransparent = true 26 | } 27 | return view; 28 | } 29 | 30 | func updateNSView(_ nsView: NSView, context: Context) { } 31 | } 32 | ``` 33 | 34 | Until Apple starts paying some level of serious attention to SwiftUI's implementation on macOS, I'll continue to use `NSWindow`. 35 | 36 | ## License 37 | 38 | MIT 39 | -------------------------------------------------------------------------------- /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephancasas/swiftui-advanced-toolbar-app/efcac1ba06b59585595cfa25ec26efa653f017d0/preview.png --------------------------------------------------------------------------------