Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 199 additions & 47 deletions CodeEdit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ extension AppPreferences {
/// The global settings for the terminal emulator
struct TerminalPreferences: Codable {

/// If true terminal will use editor theme.
var useEditorTheme: Bool = true

/// If true terminal appearance will always be `dark`. Otherwise it adapts to the system setting.
var darkAppearance: Bool = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI

// swiftlint:disable for_where
struct AccountPreferencesView: View {
@StateObject
private var prefs: AppPreferencesModel = .shared
Expand Down Expand Up @@ -40,7 +39,10 @@ struct AccountPreferencesView: View {
.padding()
}
}
}

// swiftlint:disable for_where
private extension AccountPreferencesView {
private var accountSelectionView: some View {
VStack(alignment: .leading, spacing: 1) {
PreferencesToolbar {
Expand Down Expand Up @@ -174,5 +176,4 @@ struct AccountPreferencesView: View {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ struct GeneralPreferencesView: View {
}
}

/// The extension of the view with all the preferences
private extension GeneralPreferencesView {
// MARK: - Sections

var appearanceSection: some View {
PreferencesSection("Appearance") {
Picker("Appearance", selection: $prefs.preferences.general.appAppearance) {
Expand Down Expand Up @@ -294,6 +297,18 @@ private extension GeneralPreferencesView {
}
}

var autoSaveSection: some View {
PreferencesSection("Auto Save Behavior", hideLabels: false) {
Toggle(
"Automatically save changes to disk",
isOn: $prefs.preferences.general.isAutoSaveOn
)
.toggleStyle(.checkbox)
}
}

// MARK: - Preference Views

private var lastUpdatedString: String {
if let lastUpdatedDate = updater.lastUpdateCheckDate {
return Self.formatter.string(from: lastUpdatedDate)
Expand All @@ -308,21 +323,6 @@ private extension GeneralPreferencesView {
return copy
}

private static let formatter = configure(DateFormatter()) {
$0.dateStyle = .medium
$0.timeStyle = .medium
}

var autoSaveSection: some View {
PreferencesSection("Auto Save Behavior", hideLabels: false) {
Toggle(
"Automatically save changes to disk",
isOn: $prefs.preferences.general.isAutoSaveOn
)
.toggleStyle(.checkbox)
}
}

func fallbackShellInstallation(commandPath: String, destinationPath: String) {
let cmd = [
"osascript",
Expand Down Expand Up @@ -372,4 +372,11 @@ private extension GeneralPreferencesView {
.toggleStyle(.checkbox)
}
}

// MARK: - Formatters

private static let formatter = configure(DateFormatter()) {
$0.dateStyle = .medium
$0.timeStyle = .medium
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
//
// SourceControlGeneralView.swift
// CodeEditModules/AppPreferences
//
// Created by Nanshi Li on 2022/04/01.
//

import SwiftUI

struct SourceControlPreferencesGeneralView: View {

// MARK: - View

var body: some View {
VStack {
sourceControlSection
textEditingSection
reportingSection
comparisonViewSection
sourceControlNavigator
defaultBranchNameSection
}
.frame(height: 350)
.background(EffectView(.contentBackground))
}

private let inputWidth: Double = 200

@StateObject
private var prefs: AppPreferencesModel = .shared

@State
var isChecked: Bool

@State
var branchName: String
}

private extension SourceControlPreferencesGeneralView {

// MARK: - Sections

private var sourceControlSection: some View {
PreferencesSection("Source Control", hideLabels: false) {
enableSourceControl

VStack(alignment: .leading) {
refreshLocalStatusAuto
fetchRefreshStatusAuto
addRemoveFilesAuto
selectFilesToCommitAuto
}
.padding(.leading, 20)
}
}

private var textEditingSection: some View {
PreferencesSection("Text Editing", hideLabels: false) {
showSourceControlChanges
includeUpstreamChanges
}
}

private var reportingSection: some View {
PreferencesSection("Reporting", hideLabels: false) {
openCreatedIssueInBrowser
}
}

private var comparisonViewSection: some View {
PreferencesSection("Comparison View", hideLabels: true) {
comparisonView
}
}

private var sourceControlNavigatorSection: some View {
PreferencesSection("Source Control Navigator", hideLabels: true) {
sourceControlNavigator
}
}

private var defaultBranchNameSection: some View {
PreferencesSection("Default Branch Name", hideLabels: false) {
defaultBranchName
}
}

// MARK: - Preference Views

private var enableSourceControl: some View {
Toggle(
"Enable Source Control",
isOn: $prefs.preferences.sourceControl.general.enableSourceControl
)
.toggleStyle(.checkbox)
}

private var refreshLocalStatusAuto: some View {
Toggle(
"Refresh local status automatically",
isOn: $prefs.preferences.sourceControl.general.refreshStatusLocally
)
.toggleStyle(.checkbox)
}

private var fetchRefreshStatusAuto: some View {
Toggle(
"Fetch and refresh server status automatically",
isOn: $prefs.preferences.sourceControl.general.fetchRefreshServerStatus
)
.toggleStyle(.checkbox)
}

private var addRemoveFilesAuto: some View {
Toggle(
"Add and remove files automatically",
isOn: $prefs.preferences.sourceControl.general.addRemoveAutomatically
)
.toggleStyle(.checkbox)
}

private var selectFilesToCommitAuto: some View {
Toggle(
"Select files to commit automatically",
isOn: $prefs.preferences.sourceControl.general.selectFilesToCommit
)
.toggleStyle(.checkbox)
}

private var showSourceControlChanges: some View {
Toggle(
"Show Source Control changes",
isOn: $prefs.preferences.sourceControl.general.showSourceControlChanges
)
.toggleStyle(.checkbox)
}

private var includeUpstreamChanges: some View {
Toggle(
"Include upstream changes",
isOn: $prefs.preferences.sourceControl.general.includeUpstreamChanges
)
.toggleStyle(.checkbox)
.padding(.leading, 20)
}

private var openCreatedIssueInBrowser: some View {
Toggle(
"Open created issue in the browser",
isOn: $prefs.preferences.sourceControl.general.openFeedbackInBrowser
)
.toggleStyle(.checkbox)
}

private var comparisonView: some View {
Picker(
"Comparison View",
selection: $prefs.preferences.sourceControl.general.revisionComparisonLayout
) {
Text("Local Revision on Left Side")
.tag(AppPreferences.RevisionComparisonLayout.localLeft)
Text("Local Revision on Right Side")
.tag(AppPreferences.RevisionComparisonLayout.localRight)
}
.frame(width: inputWidth)
}

private var sourceControlNavigator: some View {
Picker(
"Source Control Navigator",
selection: $prefs.preferences.sourceControl.general.controlNavigatorOrder
) {
Text("Sort by Name")
.tag(AppPreferences.ControlNavigatorOrder.sortByName)
Text("Sort by Date")
.tag(AppPreferences.ControlNavigatorOrder.sortByDate)
}
.frame(width: inputWidth)
}

@ViewBuilder
private var defaultBranchName: some View {
TextField("main", text: $branchName)
.frame(width: inputWidth)
Text("Branch names cannot contain spaces, backslashes, or other symbols")
.font(.system(size: 12))
.foregroundColor(.secondary)
}
}
Loading