Skip to content

Commit 464bdea

Browse files
committed
Added source control settings header. Moved feature icon into new view for reuse.
1 parent 93b0be5 commit 464bdea

File tree

5 files changed

+78
-32
lines changed

5 files changed

+78
-32
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@
571571
B6966A302C33282200259C2D /* RemoteBranchPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6966A2F2C33282200259C2D /* RemoteBranchPicker.swift */; };
572572
B6966A322C3348D300259C2D /* WorkspaceSheets.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6966A312C3348D300259C2D /* WorkspaceSheets.swift */; };
573573
B6966A342C34996B00259C2D /* SourceControlManager+GitClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6966A332C34996B00259C2D /* SourceControlManager+GitClient.swift */; };
574+
B696A7E62CFE20C40048CFE1 /* FeatureIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = B696A7E52CFE20C40048CFE1 /* FeatureIcon.swift */; };
574575
B697937A29FF5668002027EC /* AccountsSettingsAccountLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = B697937929FF5668002027EC /* AccountsSettingsAccountLink.swift */; };
575576
B69BFDC72B0686910050D9A6 /* GitClient+Initiate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69BFDC62B0686910050D9A6 /* GitClient+Initiate.swift */; };
576577
B69D3EDE2C5E85A2005CF43A /* StopTaskToolbarButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B69D3EDD2C5E85A2005CF43A /* StopTaskToolbarButton.swift */; };
@@ -1246,6 +1247,7 @@
12461247
B6966A2F2C33282200259C2D /* RemoteBranchPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteBranchPicker.swift; sourceTree = "<group>"; };
12471248
B6966A312C3348D300259C2D /* WorkspaceSheets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorkspaceSheets.swift; sourceTree = "<group>"; };
12481249
B6966A332C34996B00259C2D /* SourceControlManager+GitClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SourceControlManager+GitClient.swift"; sourceTree = "<group>"; };
1250+
B696A7E52CFE20C40048CFE1 /* FeatureIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureIcon.swift; sourceTree = "<group>"; };
12491251
B697937929FF5668002027EC /* AccountsSettingsAccountLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountsSettingsAccountLink.swift; sourceTree = "<group>"; };
12501252
B69BFDC62B0686910050D9A6 /* GitClient+Initiate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GitClient+Initiate.swift"; sourceTree = "<group>"; };
12511253
B69D3EDD2C5E85A2005CF43A /* StopTaskToolbarButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StopTaskToolbarButton.swift; sourceTree = "<group>"; };
@@ -3558,6 +3560,7 @@
35583560
B6CF632A29E5436C0085880A /* Views */ = {
35593561
isa = PBXGroup;
35603562
children = (
3563+
B696A7E52CFE20C40048CFE1 /* FeatureIcon.swift */,
35613564
B67DBB932CD5FBE2007F4F18 /* GlobPatternListItem.swift */,
35623565
B67DBB912CD5EAA4007F4F18 /* GlobPatternList.swift */,
35633566
B6041F4C29D7A4E9000F3454 /* SettingsPageView.swift */,
@@ -4032,6 +4035,7 @@
40324035
30B0880D2C0D53080063A882 /* LanguageServer+References.swift in Sources */,
40334036
77A01E2E2BB4261200F0EA38 /* CEWorkspaceSettings.swift in Sources */,
40344037
6C4104E9297C970F00F472BA /* AboutDefaultView.swift in Sources */,
4038+
B696A7E62CFE20C40048CFE1 /* FeatureIcon.swift in Sources */,
40354039
587B9E6F29301D8F00AC7927 /* GitLabProjectAccess.swift in Sources */,
40364040
587B9E6929301D8F00AC7927 /* GitLabEvent.swift in Sources */,
40374041
B63F6A7B2C561BCB003B4342 /* RegexFormatter.swift in Sources */,

CodeEdit/Features/Settings/Pages/SourceControlSettings/SourceControlGeneralView.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ struct SourceControlGeneralView: View {
1515

1616
var body: some View {
1717
SettingsForm {
18-
Section("Source Control") {
18+
Section {
1919
sourceControlIsEnabled
20+
}
21+
Section("Source Control") {
2022
refreshLocalStatusAuto
2123
fetchRefreshStatusAuto
2224
addRemoveFilesAuto
@@ -37,9 +39,20 @@ struct SourceControlGeneralView: View {
3739
private extension SourceControlGeneralView {
3840
private var sourceControlIsEnabled: some View {
3941
Toggle(
40-
"Enable source control",
4142
isOn: $settings.sourceControlIsEnabled
42-
)
43+
) {
44+
Label {
45+
Text("Source Control")
46+
Text("""
47+
Back up your files, collaborate with others, and tag your releases. \
48+
[Learn more...](https://developer.apple.com/documentation/xcode/source-control-management)
49+
""")
50+
.font(.callout)
51+
} icon: {
52+
FeatureIcon(symbol: Image(symbol: "vault"), color: Color(.systemBlue), size: 26)
53+
}
54+
}
55+
.controlSize(.large)
4356
}
4457

4558
private var refreshLocalStatusAuto: some View {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//
2+
// FeatureIcon.swift
3+
// CodeEdit
4+
//
5+
// Created by Austin Condiff on 12/2/24.
6+
//
7+
8+
import SwiftUI
9+
10+
struct FeatureIcon: View {
11+
private let symbol: Image
12+
private let color: Color
13+
private let size: CGFloat
14+
15+
init(
16+
symbol: Image?,
17+
color: Color?,
18+
size: CGFloat?
19+
) {
20+
self.symbol = symbol ?? Image(systemName: "exclamationmark.triangle")
21+
self.color = color ?? .white
22+
self.size = size ?? 20
23+
}
24+
25+
var body: some View {
26+
Group {
27+
symbol
28+
.resizable()
29+
.aspectRatio(contentMode: .fit)
30+
}
31+
.shadow(color: Color(NSColor.black).opacity(0.25), radius: size / 40, y: size / 40)
32+
.padding(size / 8)
33+
.foregroundColor(.white)
34+
.frame(width: size, height: size)
35+
.background(
36+
RoundedRectangle(
37+
cornerRadius: size / 4,
38+
style: .continuous
39+
)
40+
.fill(color.gradient)
41+
.shadow(color: Color(NSColor.black).opacity(0.25), radius: size / 40, y: size / 40)
42+
)
43+
}
44+
}

CodeEdit/Features/Settings/Views/SettingsPageView.swift

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,25 @@ struct SettingsPageView: View {
1616
self.searchText = searchText
1717
}
1818

19+
var symbol: Image? {
20+
switch page.icon {
21+
case .system(let name):
22+
Image(systemName: name)
23+
case .symbol(let name):
24+
Image(symbol: name)
25+
case .asset(let name):
26+
Image(name)
27+
case .none: nil
28+
}
29+
}
30+
1931
var body: some View {
2032
NavigationLink(value: page) {
2133
Label {
2234
page.name.rawValue.highlightOccurrences(self.searchText)
2335
.padding(.leading, 2)
2436
} icon: {
25-
Group {
26-
switch page.icon {
27-
case .system(let name):
28-
Image(systemName: name)
29-
.resizable()
30-
.aspectRatio(contentMode: .fit)
31-
case .symbol(let name):
32-
Image(symbol: name)
33-
.resizable()
34-
.aspectRatio(contentMode: .fit)
35-
case .asset(let name):
36-
Image(name)
37-
.resizable()
38-
.aspectRatio(contentMode: .fit)
39-
case .none: EmptyView()
40-
}
41-
}
42-
.shadow(color: Color(NSColor.black).opacity(0.25), radius: 0.5, y: 0.5)
43-
.padding(2.5)
44-
.foregroundColor(.white)
45-
.frame(width: 20, height: 20)
46-
.background(
47-
RoundedRectangle(
48-
cornerRadius: 5,
49-
style: .continuous
50-
)
51-
.fill((page.baseColor ?? .white).gradient)
52-
.shadow(color: Color(NSColor.black).opacity(0.25), radius: 0.5, y: 0.5)
53-
)
37+
FeatureIcon(symbol: symbol, color: page.baseColor, size: 20)
5438
}
5539
}
5640
}

CodeEdit/Features/Settings/Views/View+NavigationBarBackButtonVisible.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct NavigationBarBackButtonVisible: ViewModifier {
2121
self.presentationMode.wrappedValue.dismiss()
2222
} label: {
2323
Image(systemName: "chevron.left")
24+
.frame(width: 23)
2425
}
2526
}
2627
}

0 commit comments

Comments
 (0)