Skip to content

Commit

Permalink
Merge branch 'CodeEditApp:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nanashili authored Apr 14, 2022
2 parents f7e5e83 + 03addfa commit 45ae1f1
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public extension AppPreferences {
/// Indicates whether or not we should include the upsteam
public var includeUpstreamChanges: Bool = false
/// The selected value of the comparison view
public var comparisonView: Int = 0
public var revisionComparisonLayout: RevisionComparisonLayout = .localLeft
/// The selected value of the control navigator
public var controlNavigator: Int = 0
public var controlNavigatorOrder: ControlNavigatorOrder = .sortByName
/// The name of the default branch
public var defaultBranchName: String = "main"
/// Default initializer
Expand All @@ -61,12 +61,30 @@ public extension AppPreferences {
forKey: .showSourceControlChanges) ?? true
self.includeUpstreamChanges = try container.decodeIfPresent(Bool.self,
forKey: .includeUpstreamChanges) ?? true
self.comparisonView = try container.decodeIfPresent(Int.self, forKey: .comparisonView) ?? 0
self.controlNavigator = try container.decodeIfPresent(Int.self, forKey: .controlNavigator) ?? 0
self.revisionComparisonLayout = try container.decodeIfPresent(RevisionComparisonLayout.self,
forKey: .revisionComparisonLayout) ?? .localLeft
self.controlNavigatorOrder = try container.decodeIfPresent(ControlNavigatorOrder.self,
forKey: .controlNavigatorOrder) ?? .sortByName
self.defaultBranchName = try container.decodeIfPresent(String.self, forKey: .defaultBranchName) ?? "main"
}
}

/// The style for comparison View
/// - **localLeft**: Local Revision on Left Side
/// - **localRight**: Local Revision on Right Side
enum RevisionComparisonLayout: String, Codable {
case localLeft
case localRight
}

/// The style for control Navigator
/// - **sortName**: They are sorted by Name
/// - **sortDate**: They are sorted by Date
enum ControlNavigatorOrder: String, Codable {
case sortByName
case sortByDate
}

struct SourceControlGit: Codable {
/// The author name
public var authorName: String = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import SwiftUI
/// A view that implements the `General` preference section
public struct GeneralPreferencesView: View {

private let inputWidth: Double = 160

@StateObject
private var prefs: AppPreferencesModel = .shared

Expand All @@ -30,6 +32,7 @@ public struct GeneralPreferencesView: View {
.onChange(of: prefs.preferences.general.appAppearance) { tag in
tag.applyAppearance()
}
.frame(width: inputWidth)
}
PreferencesSection("File Icon Style") {
Picker("File Icon Style:", selection: $prefs.preferences.general.fileIconStyle) {
Expand All @@ -50,6 +53,7 @@ public struct GeneralPreferencesView: View {
Text("New Document")
.tag(AppPreferences.ReopenBehavior.newDocument)
}
.frame(width: inputWidth)
}
PreferencesSection("Project Navigator Size") {
Picker("Project Navigator Size", selection: $prefs.preferences.general.projectNavigatorSize) {
Expand All @@ -60,6 +64,7 @@ public struct GeneralPreferencesView: View {
Text("Large")
.tag(AppPreferences.ProjectNavigatorSize.large)
}
.frame(width: inputWidth)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import CodeEditUI

struct SourceControlGeneralView: View {

private let inputWidth: Double = 200

@State var isChecked: Bool
@State var branchName: String

Expand Down Expand Up @@ -41,7 +43,7 @@ struct SourceControlGeneralView: View {
}

PreferencesSection("Text Editing", hideLabels: false) {
Toggle("Show Source Control chnages",
Toggle("Show Source Control changes",
isOn: $prefs.preferences.sourceControl.general.showSourceControlChanges)
.toggleStyle(.checkbox)

Expand All @@ -51,27 +53,31 @@ struct SourceControlGeneralView: View {
.padding(.leading, 20)
}

PreferencesSection("Comparison View", hideLabels: false) {
Menu {
Button("Comparison") {}
} label: {
PreferencesSection("Comparison View", hideLabels: true) {
Picker("Comparison View",
selection: $prefs.preferences.sourceControl.general.revisionComparisonLayout) {
Text("Local Revision on Left Side")
.font(.system(size: 11))
.tag(AppPreferences.RevisionComparisonLayout.localLeft)
Text("Local Revision on Right Side")
.tag(AppPreferences.RevisionComparisonLayout.localRight)
}
.frame(width: inputWidth)
}

PreferencesSection("Source Control Navigator", hideLabels: false) {
Menu {
Button("Control Navigator") {}
} label: {
PreferencesSection("Source Control Navigator", hideLabels: true) {
Picker("Source Control Navigator",
selection: $prefs.preferences.sourceControl.general.controlNavigatorOrder) {
Text("Sort by Name")
.font(.system(size: 11))
.tag(AppPreferences.ControlNavigatorOrder.sortByName)
Text("Sort by Date")
.tag(AppPreferences.ControlNavigatorOrder.sortByDate)
}
.frame(width: inputWidth)
}

PreferencesSection("Default Branch Name", hideLabels: false) {
TextField("Text", text: $branchName)
.frame(width: 170)
TextField("main", text: $branchName)
.frame(width: inputWidth)
Text("Branch names cannot contain spaces, backslashes, or other symbols")
.font(.system(size: 12))
.foregroundColor(.secondary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import CodeEditUI

struct SourceControlGitView: View {

private let inputWidth: Double = 280

@State var ignoredFileSelection: IgnoredFiles.ID?

@StateObject
Expand All @@ -19,12 +21,12 @@ struct SourceControlGitView: View {
VStack {
PreferencesSection("Author Name", hideLabels: false) {
TextField("Git Author Name", text: $prefs.preferences.sourceControl.git.authorName)
.frame(width: 280)
.frame(width: inputWidth)
}

PreferencesSection("Author Email", hideLabels: false) {
TextField("Git Email", text: $prefs.preferences.sourceControl.git.authorEmail)
.frame(width: 280)
.frame(width: inputWidth)
}

PreferencesSection("Ignored Files", hideLabels: false, align: .top) {
Expand All @@ -37,14 +39,15 @@ struct SourceControlGitView: View {
if prefs.preferences.sourceControl.git.ignoredFiles.isEmpty {
Text("No Ignored Files")
.foregroundColor(.secondary)
.font(.system(size: 11))
}
})
.frame(height: 150)
PreferencesToolbar(height: 22) {
bottomToolbar
}
}
.frame(width: 280)
.frame(width: inputWidth)
.padding(1)
.background(Rectangle().foregroundColor(Color(NSColor.separatorColor)))
}
Expand All @@ -53,11 +56,11 @@ struct SourceControlGitView: View {
Toggle("Prefer to rebase when pulling",
isOn: $prefs.preferences.sourceControl.git.preferRebaseWhenPulling)
.toggleStyle(.checkbox)
.frame(width: 280, alignment: .leading)
.frame(width: inputWidth, alignment: .leading)
Toggle("Show merge commits in per-file log",
isOn: $prefs.preferences.sourceControl.git.showMergeCommitsPerFileLog)
.toggleStyle(.checkbox)
.frame(width: 280, alignment: .leading)
.frame(width: inputWidth, alignment: .leading)
}
}
.frame(height: 350)
Expand All @@ -68,6 +71,7 @@ struct SourceControlGitView: View {
HStack(spacing: 12) {
Button {} label: {
Image(systemName: "plus")
.foregroundColor(Color.secondary)
}
.buttonStyle(.plain)
Button {} label: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import CodeEditUI
/// A view that implements the `Terminal` preference section
public struct TerminalPreferencesView: View {

private let inputWidth: Double = 150

@StateObject
private var prefs: AppPreferencesModel = .shared

Expand Down Expand Up @@ -39,6 +41,7 @@ public struct TerminalPreferencesView: View {
Text("Bash")
.tag(AppPreferences.TerminalShell.bash)
}
.frame(width: inputWidth)
}

private var optionAsMetaToggle: some View {
Expand All @@ -56,6 +59,7 @@ public struct TerminalPreferencesView: View {
Text("Custom")
.tag(true)
}
.frame(width: inputWidth)
if prefs.preferences.terminal.font.customFont {
FontPicker(
"\(prefs.preferences.terminal.font.name) \(prefs.preferences.terminal.font.size)",
Expand Down

0 comments on commit 45ae1f1

Please sign in to comment.