Skip to content

Commit 24658a2

Browse files
committed
Moved tabs below source control toggle
1 parent 464bdea commit 24658a2

File tree

3 files changed

+46
-46
lines changed

3 files changed

+46
-46
lines changed

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

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ struct SourceControlGeneralView: View {
1414
let gitConfig = GitConfigClient(shellClient: currentWorld.shellClient)
1515

1616
var body: some View {
17-
SettingsForm {
18-
Section {
19-
sourceControlIsEnabled
20-
}
17+
Group {
2118
Section("Source Control") {
2219
refreshLocalStatusAuto
2320
fetchRefreshStatusAuto
@@ -37,70 +34,47 @@ struct SourceControlGeneralView: View {
3734
}
3835

3936
private extension SourceControlGeneralView {
40-
private var sourceControlIsEnabled: some View {
41-
Toggle(
42-
isOn: $settings.sourceControlIsEnabled
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)
56-
}
57-
5837
private var refreshLocalStatusAuto: some View {
5938
Toggle(
6039
"Refresh local status automatically",
6140
isOn: $settings.refreshStatusLocally
6241
)
63-
.disabled(!settings.sourceControlIsEnabled)
6442
}
6543

6644
private var fetchRefreshStatusAuto: some View {
6745
Toggle(
6846
"Fetch and refresh server status automatically",
6947
isOn: $settings.fetchRefreshServerStatus
7048
)
71-
.disabled(!settings.sourceControlIsEnabled)
7249
}
7350

7451
private var addRemoveFilesAuto: some View {
7552
Toggle(
7653
"Add and remove files automatically",
7754
isOn: $settings.addRemoveAutomatically
7855
)
79-
.disabled(!settings.sourceControlIsEnabled)
8056
}
8157

8258
private var selectFilesToCommitAuto: some View {
8359
Toggle(
8460
"Select files to commit automatically",
8561
isOn: $settings.selectFilesToCommit
8662
)
87-
.disabled(!settings.sourceControlIsEnabled)
8863
}
8964

9065
private var showSourceControlChanges: some View {
9166
Toggle(
9267
"Show source control changes",
9368
isOn: $settings.showSourceControlChanges
9469
)
95-
.disabled(!settings.sourceControlIsEnabled)
9670
}
9771

9872
private var includeUpstreamChanges: some View {
9973
Toggle(
10074
"Include upstream changes",
10175
isOn: $settings.includeUpstreamChanges
10276
)
103-
.disabled(!settings.sourceControlIsEnabled || !settings.showSourceControlChanges)
77+
.disabled(!settings.showSourceControlChanges)
10478
}
10579

10680
private var comparisonView: some View {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct SourceControlGitView: View {
2121
@State private var resolvedGitIgnorePath: String = "~/.gitignore_global"
2222

2323
var body: some View {
24-
SettingsForm {
24+
Group {
2525
Section {
2626
gitAuthorName
2727
gitEmail

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

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,55 @@
88
import SwiftUI
99

1010
struct SourceControlSettingsView: View {
11+
@AppSettings(\.sourceControl.general)
12+
var settings
13+
1114
@State var selectedTab: String = "general"
1215

1316
var body: some View {
14-
Group {
15-
switch selectedTab {
16-
case "general":
17-
SourceControlGeneralView()
18-
case "git":
19-
SourceControlGitView()
20-
default:
21-
SourceControlGeneralView()
17+
SettingsForm {
18+
Section {
19+
sourceControlIsEnabled
20+
} footer: {
21+
if settings.sourceControlIsEnabled {
22+
Picker("", selection: $selectedTab) {
23+
Text("General").tag("general")
24+
Text("Git").tag("git")
25+
}
26+
.pickerStyle(.segmented)
27+
.labelsHidden()
28+
.padding(.top, 10)
29+
}
2230
}
23-
}
24-
.safeAreaInset(edge: .top, spacing: 0) {
25-
Picker("", selection: $selectedTab) {
26-
Text("General").tag("general")
27-
Text("Git").tag("git")
31+
if settings.sourceControlIsEnabled {
32+
switch selectedTab {
33+
case "general":
34+
SourceControlGeneralView()
35+
case "git":
36+
SourceControlGitView()
37+
default:
38+
SourceControlGeneralView()
39+
}
2840
}
29-
.pickerStyle(.segmented)
30-
.labelsHidden()
31-
.padding(.horizontal, 20)
32-
.padding(.bottom, 20)
41+
}
42+
}
3343

44+
private var sourceControlIsEnabled: some View {
45+
Toggle(
46+
isOn: $settings.sourceControlIsEnabled
47+
) {
48+
Label {
49+
Text("Source Control")
50+
Text("""
51+
Back up your files, collaborate with others, and tag your releases. \
52+
[Learn more...](https://developer.apple.com/documentation/xcode/source-control-management)
53+
""")
54+
.font(.callout)
55+
} icon: {
56+
FeatureIcon(symbol: Image(symbol: "vault"), color: Color(.systemBlue), size: 26)
57+
}
3458
}
59+
.controlSize(.large)
3560
}
61+
3662
}

0 commit comments

Comments
 (0)