Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 408a344

Browse files
committed
tests, views folder
1 parent a7dbb60 commit 408a344

File tree

10 files changed

+191
-35
lines changed

10 files changed

+191
-35
lines changed

Desktop.xcodeproj/project.pbxproj

+23-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Begin PBXBuildFile section */
1010
AA05870A2CFF16CA00A01A13 /* FluidMenuBarExtra in Frameworks */ = {isa = PBXBuildFile; productRef = AA0587092CFF16CA00A01A13 /* FluidMenuBarExtra */; };
11+
AA05887D2D0028F200A01A13 /* ViewInspector in Frameworks */ = {isa = PBXBuildFile; productRef = AA05887C2D0028F200A01A13 /* ViewInspector */; };
1112
/* End PBXBuildFile section */
1213

1314
/* Begin PBXContainerItemProxy section */
@@ -64,6 +65,7 @@
6465
isa = PBXFrameworksBuildPhase;
6566
buildActionMask = 2147483647;
6667
files = (
68+
AA05887D2D0028F200A01A13 /* ViewInspector in Frameworks */,
6769
);
6870
runOnlyForDeploymentPostprocessing = 0;
6971
};
@@ -142,6 +144,7 @@
142144
);
143145
name = DesktopTests;
144146
packageProductDependencies = (
147+
AA05887C2D0028F200A01A13 /* ViewInspector */,
145148
);
146149
productName = desktopTests;
147150
productReference = AA06D47F2CF59842002ECE92 /* DesktopTests.xctest */;
@@ -205,6 +208,7 @@
205208
packageReferences = (
206209
AAED56702CF7326000887B28 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */,
207210
AA0587082CFF16CA00A01A13 /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */,
211+
AA05887B2D0028F200A01A13 /* XCRemoteSwiftPackageReference "ViewInspector" */,
208212
);
209213
preferredProjectObjectVersion = 77;
210214
productRefGroup = AA06D46F2CF59841002ECE92 /* Products */;
@@ -408,11 +412,11 @@
408412
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
409413
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
410414
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
411-
CODE_SIGN_ENTITLEMENTS = desktop/desktop.entitlements;
415+
CODE_SIGN_ENTITLEMENTS = Desktop/Desktop.entitlements;
412416
CODE_SIGN_STYLE = Automatic;
413417
COMBINE_HIDPI_IMAGES = YES;
414418
CURRENT_PROJECT_VERSION = 1;
415-
DEVELOPMENT_ASSET_PATHS = "\"desktop/Preview Content\"";
419+
DEVELOPMENT_ASSET_PATHS = "\"Desktop/Preview Content\"";
416420
ENABLE_PREVIEWS = YES;
417421
GENERATE_INFOPLIST_FILE = YES;
418422
INFOPLIST_KEY_CFBundleDisplayName = "Coder Desktop";
@@ -436,11 +440,11 @@
436440
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
437441
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
438442
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
439-
CODE_SIGN_ENTITLEMENTS = desktop/desktop.entitlements;
443+
CODE_SIGN_ENTITLEMENTS = Desktop/Desktop.entitlements;
440444
CODE_SIGN_STYLE = Automatic;
441445
COMBINE_HIDPI_IMAGES = YES;
442446
CURRENT_PROJECT_VERSION = 1;
443-
DEVELOPMENT_ASSET_PATHS = "\"desktop/Preview Content\"";
447+
DEVELOPMENT_ASSET_PATHS = "\"Desktop/Preview Content\"";
444448
ENABLE_PREVIEWS = YES;
445449
GENERATE_INFOPLIST_FILE = YES;
446450
INFOPLIST_KEY_CFBundleDisplayName = "Coder Desktop";
@@ -503,7 +507,7 @@
503507
PRODUCT_NAME = "$(TARGET_NAME)";
504508
SWIFT_EMIT_LOC_STRINGS = NO;
505509
SWIFT_VERSION = 5.0;
506-
TEST_TARGET_NAME = desktop;
510+
TEST_TARGET_NAME = Desktop;
507511
};
508512
name = Debug;
509513
};
@@ -518,7 +522,7 @@
518522
PRODUCT_NAME = "$(TARGET_NAME)";
519523
SWIFT_EMIT_LOC_STRINGS = NO;
520524
SWIFT_VERSION = 5.0;
521-
TEST_TARGET_NAME = desktop;
525+
TEST_TARGET_NAME = Desktop;
522526
};
523527
name = Release;
524528
};
@@ -572,6 +576,14 @@
572576
minimumVersion = 1.1.0;
573577
};
574578
};
579+
AA05887B2D0028F200A01A13 /* XCRemoteSwiftPackageReference "ViewInspector" */ = {
580+
isa = XCRemoteSwiftPackageReference;
581+
repositoryURL = "https://github.com/nalexn/ViewInspector?tab=readme-ov-file";
582+
requirement = {
583+
kind = upToNextMajorVersion;
584+
minimumVersion = 0.10.0;
585+
};
586+
};
575587
AAED56702CF7326000887B28 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */ = {
576588
isa = XCRemoteSwiftPackageReference;
577589
repositoryURL = "https://github.com/SimplyDanny/SwiftLintPlugins";
@@ -588,6 +600,11 @@
588600
package = AA0587082CFF16CA00A01A13 /* XCRemoteSwiftPackageReference "fluid-menu-bar-extra" */;
589601
productName = FluidMenuBarExtra;
590602
};
603+
AA05887C2D0028F200A01A13 /* ViewInspector */ = {
604+
isa = XCSwiftPackageProductDependency;
605+
package = AA05887B2D0028F200A01A13 /* XCRemoteSwiftPackageReference "ViewInspector" */;
606+
productName = ViewInspector;
607+
};
591608
AAED56712CF7332C00887B28 /* SwiftLintBuildToolPlugin */ = {
592609
isa = XCSwiftPackageProductDependency;
593610
package = AAED56702CF7326000887B28 /* XCRemoteSwiftPackageReference "SwiftLintPlugins" */;

Desktop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"originHash" : "ba5cc6c48f18a191bfc7dfa34832790cdb9026b6a8f9b71b6dfe43cd35602671",
2+
"originHash" : "d39a8b95e058413544f0c950992976311c18db0f67bd754d563e7affcecf57f0",
33
"pins" : [
44
{
55
"identity" : "fluid-menu-bar-extra",
@@ -18,6 +18,15 @@
1818
"revision" : "f9731bef175c3eea3a0ca960f1be78fcc2bc7853",
1919
"version" : "0.57.1"
2020
}
21+
},
22+
{
23+
"identity" : "viewinspector?tab=readme-ov-file",
24+
"kind" : "remoteSourceControl",
25+
"location" : "https://github.com/nalexn/ViewInspector?tab=readme-ov-file",
26+
"state" : {
27+
"revision" : "5acfa0a3c095ac9ad050abe51c60d1831e8321da",
28+
"version" : "0.10.0"
29+
}
2130
}
2231
],
2332
"version" : 3

Desktop/CoderVPN.swift

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ enum CoderVPNState: Equatable {
1717
}
1818

1919
enum CoderVPNError: Error {
20+
// TODO:
2021
case exampleError
2122

2223
var description: String {

Desktop/AgentRow.swift renamed to Desktop/Views/AgentRow.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct AgentRowView: View {
3131
var body: some View {
3232
HStack(spacing: 0) {
3333
Link(destination: wsURL) {
34-
HStack(spacing: 10) {
34+
HStack(spacing: Theme.Size.trayPadding) {
3535
ZStack {
3636
Circle()
3737
.fill(workspace.status.opacity(0.4))
@@ -42,12 +42,12 @@ struct AgentRowView: View {
4242
}
4343
Text(fmtWsName).lineLimit(1).truncationMode(.tail)
4444
Spacer()
45-
}.padding(.horizontal, 10)
45+
}.padding(.horizontal, Theme.Size.trayPadding)
4646
.frame(minHeight: 22)
4747
.frame(maxWidth: .infinity, alignment: .leading)
4848
.foregroundStyle(nameIsSelected ? Color.white : .primary)
4949
.background(nameIsSelected ? Color.accentColor.opacity(0.8) : .clear)
50-
.clipShape(.rect(cornerRadius: 4))
50+
.clipShape(.rect(cornerRadius: Theme.Size.rectCornerRadius))
5151
.onHover { hovering in nameIsSelected = hovering }
5252
Spacer()
5353
}.buttonStyle(.plain)
@@ -61,10 +61,10 @@ struct AgentRowView: View {
6161
}.foregroundStyle(copyIsSelected ? Color.white : .primary)
6262
.imageScale(.small)
6363
.background(copyIsSelected ? Color.accentColor.opacity(0.8) : .clear)
64-
.clipShape(.rect(cornerRadius: 4))
64+
.clipShape(.rect(cornerRadius: Theme.Size.rectCornerRadius))
6565
.onHover { hovering in copyIsSelected = hovering }
6666
.buttonStyle(.plain)
67-
.padding(.trailing, 5)
67+
.padding(.trailing, Theme.Size.trayMargin)
6868
}
6969
}
7070
}

Desktop/ButtonRow.swift renamed to Desktop/Views/ButtonRow.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ struct ButtonRowView<Label: View>: View {
99
label()
1010
Spacer()
1111
}
12-
.padding(.horizontal, 10)
12+
.padding(.horizontal, Theme.Size.trayPadding)
1313
.frame(minHeight: 22)
1414
.frame(maxWidth: .infinity, alignment: .leading)
1515
.foregroundStyle(isSelected ? Color.white : .primary)
1616
.background(isSelected ? Color.accentColor.opacity(0.8) : .clear)
17-
.clipShape(.rect(cornerRadius: 4))
17+
.clipShape(.rect(cornerRadius: Theme.Size.rectCornerRadius))
1818
.onHover { hovering in isSelected = hovering }
1919
}
2020
}

Desktop/Views/Theme.swift

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Foundation
2+
3+
enum Theme {
4+
enum Size {
5+
static let trayMargin: CGFloat = 5
6+
static let trayPadding: CGFloat = 10
7+
static let trayInset: CGFloat = trayMargin + trayPadding
8+
9+
static let rectCornerRadius: CGFloat = 4
10+
}
11+
}

Desktop/Views/TrayDivider.swift

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import SwiftUI
2+
3+
struct TrayDivider: View {
4+
var body: some View {
5+
Divider()
6+
.padding(.horizontal, Theme.Size.trayPadding)
7+
.padding(.vertical, 4)
8+
}
9+
}

Desktop/VPNMenu.swift renamed to Desktop/Views/VPNMenu.swift

+16-17
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ struct VPNMenu<VPN: CoderVPN>: View {
88

99
var body: some View {
1010
// Main stack
11-
VStack(alignment: .leading) {
11+
VStackLayout(alignment: .leading) {
1212
// CoderVPN Stack
13-
VStack(alignment: .leading, spacing: 10) {
13+
VStack(alignment: .leading, spacing: Theme.Size.trayPadding) {
1414
HStack {
1515
Toggle(isOn: Binding(
1616
get: { self.vpnService.state == .connected || self.vpnService.state == .connecting },
@@ -23,6 +23,7 @@ struct VPNMenu<VPN: CoderVPN>: View {
2323
.frame(maxWidth: .infinity, alignment: .leading)
2424
}.toggleStyle(.switch)
2525
.disabled(self.vpnService.state == .connecting || self.vpnService.state == .disconnecting)
26+
.accessibilityIdentifier("coderVPNToggle")
2627
}
2728
Divider()
2829
Text("Workspace Agents")
@@ -47,58 +48,56 @@ struct VPNMenu<VPN: CoderVPN>: View {
4748
.foregroundColor(.red)
4849
.multilineTextAlignment(.center)
4950
.fixedSize(horizontal: false, vertical: true)
50-
.padding(.horizontal, 15)
51-
.padding(.top, 5)
51+
.padding(.horizontal, Theme.Size.trayInset)
52+
.padding(.vertical, Theme.Size.trayPadding)
5253
.frame(maxWidth: .infinity)
5354
default:
5455
EmptyView()
5556
}
56-
}.padding([.horizontal, .top], 15)
57+
}.padding([.horizontal, .top], Theme.Size.trayInset)
5758
// Workspaces List
5859
if self.vpnService.state == .connected {
5960
let visibleData = viewAll ? vpnService.agents : Array(vpnService.agents.prefix(defaultVisibleRows))
6061
ForEach(visibleData, id: \.id) { workspace in
6162
AgentRowView(workspace: workspace, baseAccessURL: vpnService.baseAccessURL)
62-
.padding(.horizontal, 5)
63+
.padding(.horizontal, Theme.Size.trayMargin)
6364
}
6465
if vpnService.agents.count > defaultVisibleRows {
65-
Button(action: {
66-
viewAll.toggle()
67-
}, label: {
66+
Toggle(isOn: $viewAll) {
6867
Text(viewAll ? "Show Less" : "Show All")
6968
.font(.headline)
7069
.foregroundColor(.gray)
71-
.padding(.horizontal, 15)
72-
.padding(.top, 5)
73-
}).buttonStyle(.plain)
70+
.padding(.horizontal, Theme.Size.trayInset)
71+
.padding(.top, 2)
72+
}.toggleStyle(.button).buttonStyle(.plain)
7473
}
7574
}
7675
// Trailing stack
7776
VStack(alignment: .leading, spacing: 3) {
78-
Divider().padding([.horizontal], 10).padding(.vertical, 4)
77+
TrayDivider()
7978
Link(destination: vpnService.baseAccessURL.appending(path: "templates")) {
8079
ButtonRowView {
8180
Text("Create workspace")
8281
EmptyView()
8382
}
8483
}
85-
Divider().padding([.horizontal], 10).padding(.vertical, 4)
84+
TrayDivider()
8685
ButtonRowView {
8786
Text("About")
8887
}
8988
ButtonRowView {
9089
Text("Preferences")
9190
}
92-
Divider().padding([.horizontal], 10).padding(.vertical, 4)
91+
TrayDivider()
9392
Button {
9493
NSApp.terminate(nil)
9594
} label: {
9695
ButtonRowView {
9796
Text("Quit")
9897
}
9998
}.buttonStyle(.plain)
100-
}.padding([.horizontal, .bottom], 5)
101-
}.padding(.bottom, 5)
99+
}.padding([.horizontal, .bottom], Theme.Size.trayMargin)
100+
}.padding(.bottom, Theme.Size.trayMargin)
102101
}
103102
}
104103

0 commit comments

Comments
 (0)