Skip to content

Commit 5ce4eae

Browse files
committed
feat: add menubar tray
1 parent b0a74b4 commit 5ce4eae

27 files changed

+869
-93
lines changed

Coder Desktop/.swiftlint.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
disabled_rules:
2+
- todo
3+
- trailing_comma
4+
type_name:
5+
allowed_symbols: "_"

Coder Desktop/Coder Desktop.xcodeproj/project.pbxproj

+78
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
/* Begin PBXBuildFile section */
1010
961679332CFF117300B2B6DF /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 961679322CFF117300B2B6DF /* NetworkExtension.framework */; };
1111
9616793D2CFF117300B2B6DF /* com.coder.Coder-Desktop.VPN.systemextension in Embed System Extensions */ = {isa = PBXBuildFile; fileRef = 961679302CFF117300B2B6DF /* com.coder.Coder-Desktop.VPN.systemextension */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
12+
AA8BC3392D0060A900E1ABAA /* ViewInspector in Frameworks */ = {isa = PBXBuildFile; productRef = AA8BC3382D0060A900E1ABAA /* ViewInspector */; };
13+
AA8BC33F2D0061F200E1ABAA /* FluidMenuBarExtra in Frameworks */ = {isa = PBXBuildFile; productRef = AA8BC33E2D0061F200E1ABAA /* FluidMenuBarExtra */; };
14+
AA8BC4CF2D00A4B700E1ABAA /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = AA8BC4CE2D00A4B700E1ABAA /* KeychainAccess */; };
1215
/* End PBXBuildFile section */
1316

1417
/* Begin PBXContainerItemProxy section */
@@ -98,13 +101,16 @@
98101
isa = PBXFrameworksBuildPhase;
99102
buildActionMask = 2147483647;
100103
files = (
104+
AA8BC4CF2D00A4B700E1ABAA /* KeychainAccess in Frameworks */,
105+
AA8BC33F2D0061F200E1ABAA /* FluidMenuBarExtra in Frameworks */,
101106
);
102107
runOnlyForDeploymentPostprocessing = 0;
103108
};
104109
9616790C2CFF100E00B2B6DF /* Frameworks */ = {
105110
isa = PBXFrameworksBuildPhase;
106111
buildActionMask = 2147483647;
107112
files = (
113+
AA8BC3392D0060A900E1ABAA /* ViewInspector in Frameworks */,
108114
);
109115
runOnlyForDeploymentPostprocessing = 0;
110116
};
@@ -172,13 +178,16 @@
172178
buildRules = (
173179
);
174180
dependencies = (
181+
AA8BC33C2D0060E700E1ABAA /* PBXTargetDependency */,
175182
9616793C2CFF117300B2B6DF /* PBXTargetDependency */,
176183
);
177184
fileSystemSynchronizedGroups = (
178185
961678FE2CFF100D00B2B6DF /* Coder Desktop */,
179186
);
180187
name = "Coder Desktop";
181188
packageProductDependencies = (
189+
AA8BC33E2D0061F200E1ABAA /* FluidMenuBarExtra */,
190+
AA8BC4CE2D00A4B700E1ABAA /* KeychainAccess */,
182191
);
183192
productName = "Coder Desktop";
184193
productReference = 961678FC2CFF100D00B2B6DF /* Coder Desktop.app */;
@@ -202,6 +211,7 @@
202211
);
203212
name = "Coder DesktopTests";
204213
packageProductDependencies = (
214+
AA8BC3382D0060A900E1ABAA /* ViewInspector */,
205215
);
206216
productName = "Coder DesktopTests";
207217
productReference = 9616790F2CFF100E00B2B6DF /* Coder DesktopTests.xctest */;
@@ -287,6 +297,12 @@
287297
);
288298
mainGroup = 961678F32CFF100D00B2B6DF;
289299
minimizedProjectReferenceProxies = 1;
300+
packageReferences = (
301+
AA8BC3372D00609700E1ABAA /* XCRemoteSwiftPackageReference "ViewInspector" */,
302+
AA8BC33A2D0060C500E1ABAA /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */,
303+
AA8BC33D2D0061F200E1ABAA /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */,
304+
AA8BC4CD2D00A4B700E1ABAA /* XCRemoteSwiftPackageReference "KeychainAccess" */,
305+
);
290306
preferredProjectObjectVersion = 77;
291307
productRefGroup = 961678FD2CFF100D00B2B6DF /* Products */;
292308
projectDirPath = "";
@@ -378,6 +394,10 @@
378394
target = 9616792F2CFF117300B2B6DF /* VPN */;
379395
targetProxy = 9616793B2CFF117300B2B6DF /* PBXContainerItemProxy */;
380396
};
397+
AA8BC33C2D0060E700E1ABAA /* PBXTargetDependency */ = {
398+
isa = PBXTargetDependency;
399+
productRef = AA8BC33B2D0060E700E1ABAA /* SwiftLintBuildToolPlugin */;
400+
};
381401
/* End PBXTargetDependency section */
382402

383403
/* Begin XCBuildConfiguration section */
@@ -724,6 +744,64 @@
724744
defaultConfigurationName = Release;
725745
};
726746
/* End XCConfigurationList section */
747+
748+
/* Begin XCRemoteSwiftPackageReference section */
749+
AA8BC3372D00609700E1ABAA /* XCRemoteSwiftPackageReference "ViewInspector" */ = {
750+
isa = XCRemoteSwiftPackageReference;
751+
repositoryURL = "https://github.com/nalexn/ViewInspector";
752+
requirement = {
753+
kind = upToNextMajorVersion;
754+
minimumVersion = 0.10.0;
755+
};
756+
};
757+
AA8BC33A2D0060C500E1ABAA /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = {
758+
isa = XCRemoteSwiftPackageReference;
759+
repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins";
760+
requirement = {
761+
kind = upToNextMajorVersion;
762+
minimumVersion = 0.57.1;
763+
};
764+
};
765+
AA8BC33D2D0061F200E1ABAA /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */ = {
766+
isa = XCRemoteSwiftPackageReference;
767+
repositoryURL = "https://github.com/lfroms/fluid-menu-bar-extra";
768+
requirement = {
769+
kind = upToNextMajorVersion;
770+
minimumVersion = 1.1.0;
771+
};
772+
};
773+
AA8BC4CD2D00A4B700E1ABAA /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
774+
isa = XCRemoteSwiftPackageReference;
775+
repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess";
776+
requirement = {
777+
branch = e0c7eebc5a4465a3c4680764f26b7a61f567cdaf;
778+
kind = branch;
779+
};
780+
};
781+
/* End XCRemoteSwiftPackageReference section */
782+
783+
/* Begin XCSwiftPackageProductDependency section */
784+
AA8BC3382D0060A900E1ABAA /* ViewInspector */ = {
785+
isa = XCSwiftPackageProductDependency;
786+
package = AA8BC3372D00609700E1ABAA /* XCRemoteSwiftPackageReference "ViewInspector" */;
787+
productName = ViewInspector;
788+
};
789+
AA8BC33B2D0060E700E1ABAA /* SwiftLintBuildToolPlugin */ = {
790+
isa = XCSwiftPackageProductDependency;
791+
package = AA8BC33A2D0060C500E1ABAA /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */;
792+
productName = "plugin:SwiftLintBuildToolPlugin";
793+
};
794+
AA8BC33E2D0061F200E1ABAA /* FluidMenuBarExtra */ = {
795+
isa = XCSwiftPackageProductDependency;
796+
package = AA8BC33D2D0061F200E1ABAA /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */;
797+
productName = FluidMenuBarExtra;
798+
};
799+
AA8BC4CE2D00A4B700E1ABAA /* KeychainAccess */ = {
800+
isa = XCSwiftPackageProductDependency;
801+
package = AA8BC4CD2D00A4B700E1ABAA /* XCRemoteSwiftPackageReference "KeychainAccess" */;
802+
productName = KeychainAccess;
803+
};
804+
/* End XCSwiftPackageProductDependency section */
727805
};
728806
rootObject = 961678F42CFF100D00B2B6DF /* Project object */;
729807
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"originHash" : "726475d6c2c0355de7a4de72708853eaf53eb295e791efe2cc4b8eb5ce4e9ae8",
3+
"pins" : [
4+
{
5+
"identity" : "fluid-menu-bar-extra",
6+
"kind" : "remoteSourceControl",
7+
"location" : "https://github.com/lfroms/fluid-menu-bar-extra",
8+
"state" : {
9+
"revision" : "e152a3a1a25aca24906217f8d4d63afbb08d7f97",
10+
"version" : "1.1.0"
11+
}
12+
},
13+
{
14+
"identity" : "keychainaccess",
15+
"kind" : "remoteSourceControl",
16+
"location" : "https://github.com/kishikawakatsumi/KeychainAccess",
17+
"state" : {
18+
"revision" : "e0c7eebc5a4465a3c4680764f26b7a61f567cdaf"
19+
}
20+
},
21+
{
22+
"identity" : "swiftlintplugins",
23+
"kind" : "remoteSourceControl",
24+
"location" : "https://github.com/SimplyDanny/SwiftLintPlugins",
25+
"state" : {
26+
"revision" : "f9731bef175c3eea3a0ca960f1be78fcc2bc7853",
27+
"version" : "0.57.1"
28+
}
29+
},
30+
{
31+
"identity" : "viewinspector",
32+
"kind" : "remoteSourceControl",
33+
"location" : "https://github.com/nalexn/ViewInspector",
34+
"state" : {
35+
"revision" : "5acfa0a3c095ac9ad050abe51c60d1831e8321da",
36+
"version" : "0.10.0"
37+
}
38+
}
39+
],
40+
"version" : 3
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "coder_icon_16.png",
5+
"idiom" : "mac",
6+
"scale" : "1x"
7+
},
8+
{
9+
"filename" : "coder_icon_32.png",
10+
"idiom" : "mac",
11+
"scale" : "2x"
12+
}
13+
],
14+
"info" : {
15+
"author" : "xcode",
16+
"version" : 1
17+
}
18+
}
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
import SwiftUI
2-
import SwiftData
2+
import FluidMenuBarExtra
33

44
@main
5-
struct Coder_DesktopApp: App {
6-
var sharedModelContainer: ModelContainer = {
7-
let schema = Schema([
8-
Item.self,
9-
])
10-
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
5+
struct DesktopApp: App {
6+
@NSApplicationDelegateAdaptor private var appDelegate: AppDelegate
7+
@State private var hidden: Bool = false
118

12-
do {
13-
return try ModelContainer(for: schema, configurations: [modelConfiguration])
14-
} catch {
15-
fatalError("Could not create ModelContainer: \(error)")
9+
var body: some Scene {
10+
MenuBarExtra("", isInserted: $hidden) {
11+
EmptyView()
1612
}
17-
}()
13+
}
14+
}
1815

19-
var body: some Scene {
20-
WindowGroup {
21-
ContentView()
16+
class AppDelegate: NSObject, NSApplicationDelegate {
17+
private var menuBarExtra: FluidMenuBarExtra?
18+
// TODO: Replace with real implementations
19+
private var vpn = PreviewVPN()
20+
private var session = PreviewSession()
21+
22+
func applicationDidFinishLaunching(_ notification: Notification) {
23+
self.menuBarExtra = FluidMenuBarExtra(title: "Coder Desktop", image: "MenuBarIcon") {
24+
VPNMenu(
25+
vpn: self.vpn,
26+
session: self.session
27+
).frame(width: 256)
2228
}
23-
.modelContainer(sharedModelContainer)
2429
}
2530
}

Coder Desktop/Coder Desktop/ContentView.swift

-52
This file was deleted.

Coder Desktop/Coder Desktop/Item.swift

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import SwiftUI
2+
3+
class PreviewSession: Session {
4+
@Published var hasSession: Bool
5+
@Published var sessionToken: String?
6+
@Published var baseAccessURL: URL?
7+
8+
init() {
9+
hasSession = false
10+
sessionToken = nil
11+
baseAccessURL = nil
12+
}
13+
14+
func login(baseAccessURL: URL, sessionToken: String) {
15+
hasSession = true
16+
self.baseAccessURL = baseAccessURL
17+
self.sessionToken = sessionToken
18+
}
19+
20+
func logout() {
21+
hasSession = false
22+
self.baseAccessURL = nil
23+
self.sessionToken = nil
24+
}
25+
}

0 commit comments

Comments
 (0)