Skip to content

Commit

Permalink
Added dock icon visibility toggle to demo project
Browse files Browse the repository at this point in the history
  • Loading branch information
orchetect committed Nov 30, 2024
1 parent 0395b83 commit f5cb1b3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
E212FC1B295167E4007E27BB /* MenuBarExtraAccessDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = E212FC1A295167E4007E27BB /* MenuBarExtraAccessDemoApp.swift */; };
E212FC1F295167E5007E27BB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E212FC1E295167E5007E27BB /* Assets.xcassets */; };
E214EC0D2CAFA71200B91076 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E214EC0C2CAFA71200B91076 /* ContentView.swift */; };
E2B6A8A42CFBBFDA00A4B22E /* Dock.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2B6A8A32CFBBFD600A4B22E /* Dock.swift */; };
E2C1790B2CF45CCD00BE21A1 /* MenuBarExtraAccess in Frameworks */ = {isa = PBXBuildFile; productRef = E2C1790A2CF45CCD00BE21A1 /* MenuBarExtraAccess */; };
E2ED15CD2CAFA6B100972C1A /* MenuBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2ED15CC2CAFA6B100972C1A /* MenuBarView.swift */; };
/* End PBXBuildFile section */
Expand All @@ -20,6 +21,7 @@
E212FC1E295167E5007E27BB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
E212FC23295167E5007E27BB /* MenuBarExtraAccessDemoApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MenuBarExtraAccessDemoApp.entitlements; sourceTree = "<group>"; };
E214EC0C2CAFA71200B91076 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
E2B6A8A32CFBBFD600A4B22E /* Dock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dock.swift; sourceTree = "<group>"; };
E2ED15CC2CAFA6B100972C1A /* MenuBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -57,6 +59,7 @@
E212FC1A295167E4007E27BB /* MenuBarExtraAccessDemoApp.swift */,
E2ED15CC2CAFA6B100972C1A /* MenuBarView.swift */,
E214EC0C2CAFA71200B91076 /* ContentView.swift */,
E2B6A8A32CFBBFD600A4B22E /* Dock.swift */,
E212FC1E295167E5007E27BB /* Assets.xcassets */,
E212FC23295167E5007E27BB /* MenuBarExtraAccessDemoApp.entitlements */,
);
Expand Down Expand Up @@ -140,6 +143,7 @@
files = (
E212FC1B295167E4007E27BB /* MenuBarExtraAccessDemoApp.swift in Sources */,
E2ED15CD2CAFA6B100972C1A /* MenuBarView.swift in Sources */,
E2B6A8A42CFBBFDA00A4B22E /* Dock.swift in Sources */,
E214EC0D2CAFA71200B91076 /* ContentView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -197,7 +201,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -252,7 +256,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand Down
5 changes: 5 additions & 0 deletions Demo/Demo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ struct ContentView: View {
@Binding var isMenu3Presented: Bool
@Binding var isMenu4Presented: Bool

@State private var dock = Dock()

var body: some View {
VStack(spacing: 40) {
HStack(spacing: 20) {
Expand All @@ -23,6 +25,8 @@ struct ContentView: View {
MenuStateView(num: 0, isMenuPresented: $isMenu0Presented)
}

Toggle("Dock Icon Visible", isOn: $dock.isVisible)

Text(
"""
Try opening and closing the menus in the status bar. The toggles will update in response because the state binding is being updated. Clicking on the toggles will also open or close the menus by setting the binding value.")
Expand All @@ -33,6 +37,7 @@ struct ContentView: View {
}
.padding()
.frame(minWidth: 400, minHeight: 350)
.toggleStyle(.switch)
}

struct MenuStateView: View {
Expand Down
15 changes: 15 additions & 0 deletions Demo/Demo/Dock.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Dock.swift
// MenuBarExtraAccess • https://github.com/orchetect/MenuBarExtraAccess
// © 2023 Steffan Andrews • Licensed under MIT License
//

import Foundation
import SwiftUI

@Observable @MainActor final class Dock {
var isVisible: Bool {
get { NSApplication.shared.activationPolicy() == .regular }
set { NSApplication.shared.setActivationPolicy(newValue ? .regular : .accessory) }
}
}

0 comments on commit f5cb1b3

Please sign in to comment.