Skip to content

Commit

Permalink
Merge branch 'codeeditapp/main'
Browse files Browse the repository at this point in the history
Conflicts:
	CodeEdit/Documents/WorkspaceCodeFileView.swift
	CodeEdit/Documents/WorkspaceDocument.swift
	CodeEdit/Info.plist
	CodeEdit/TabBar/TabBar.swift
	CodeEdit/TabBar/TabBarItem.swift
	CodeEdit/WorkspaceView.swift
	CodeEditModules/Package.swift
  • Loading branch information
pkasila committed May 1, 2022
2 parents 227c172 + 8317215 commit 0897d2e
Show file tree
Hide file tree
Showing 29 changed files with 925 additions and 261 deletions.
12 changes: 12 additions & 0 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
D7E201B227E8D50000CB86D0 /* FindNavigatorModeSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7E201B127E8D50000CB86D0 /* FindNavigatorModeSelector.swift */; };
D7E201BD27EA00E200CB86D0 /* FindNavigatorResultFileItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7E201BC27EA00E200CB86D0 /* FindNavigatorResultFileItem.swift */; };
D7F72DEB27EA3574000C3064 /* Search in Frameworks */ = {isa = PBXBuildFile; productRef = D7F72DEA27EA3574000C3064 /* Search */; };
DE513F52281B672D002260B9 /* TabBarAccessory.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE513F51281B672D002260B9 /* TabBarAccessory.swift */; };
DE513F54281DE5D0002260B9 /* TabBarXcode.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE513F53281DE5D0002260B9 /* TabBarXcode.swift */; };
DE6405A62817734700881FDF /* TabBarNative.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6405A52817734700881FDF /* TabBarNative.swift */; };
DE6F77872813625500D00A76 /* TabBarDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE6F77862813625500D00A76 /* TabBarDivider.swift */; };
FD6A3D3D2817C13B008BCF11 /* Package.resolved in Resources */ = {isa = PBXBuildFile; fileRef = FD6A3D3C2817C13B008BCF11 /* Package.resolved */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -186,6 +189,9 @@
D7E201B127E8D50000CB86D0 /* FindNavigatorModeSelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorModeSelector.swift; sourceTree = "<group>"; };
D7E201B327E9989900CB86D0 /* FindNavigatorResultList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorResultList.swift; sourceTree = "<group>"; };
D7E201BC27EA00E200CB86D0 /* FindNavigatorResultFileItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorResultFileItem.swift; sourceTree = "<group>"; };
DE513F51281B672D002260B9 /* TabBarAccessory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarAccessory.swift; sourceTree = "<group>"; };
DE513F53281DE5D0002260B9 /* TabBarXcode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarXcode.swift; sourceTree = "<group>"; };
DE6405A52817734700881FDF /* TabBarNative.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarNative.swift; sourceTree = "<group>"; };
DE6F77862813625500D00A76 /* TabBarDivider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabBarDivider.swift; sourceTree = "<group>"; };
FD6A3D3C2817C13B008BCF11 /* Package.resolved */ = {isa = PBXFileReference; lastKnownFileType = text; path = Package.resolved; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -367,6 +373,9 @@
287776E827E34BC700D46668 /* TabBar.swift */,
287776EE27E3515300D46668 /* TabBarItem.swift */,
DE6F77862813625500D00A76 /* TabBarDivider.swift */,
DE6405A52817734700881FDF /* TabBarNative.swift */,
DE513F51281B672D002260B9 /* TabBarAccessory.swift */,
DE513F53281DE5D0002260B9 /* TabBarXcode.swift */,
);
path = TabBar;
sourceTree = "<group>";
Expand Down Expand Up @@ -725,7 +734,9 @@
buildActionMask = 2147483647;
files = (
2072FA13280D74ED00C7F8D4 /* HistoryInspectorModel.swift in Sources */,
DE513F52281B672D002260B9 /* TabBarAccessory.swift in Sources */,
2813F93927ECC4C300E305E4 /* NavigatorSidebar.swift in Sources */,
DE513F54281DE5D0002260B9 /* TabBarXcode.swift in Sources */,
20EBB50D280C383700F3A5DA /* LanguageType.swift in Sources */,
2813F93827ECC4AA00E305E4 /* FindNavigatorResultList.swift in Sources */,
0483E35027FDB17700354AC0 /* ExtensionNavigator.swift in Sources */,
Expand All @@ -744,6 +755,7 @@
20EBB503280C327C00F3A5DA /* HistoryInspector.swift in Sources */,
2072FA1A280D872600C7F8D4 /* LineEndings.swift in Sources */,
20EBB507280C32D300F3A5DA /* QuickHelpInspector.swift in Sources */,
DE6405A62817734700881FDF /* TabBarNative.swift in Sources */,
04C3255C2801F86900C8DA2D /* OutlineMenu.swift in Sources */,
04540D5E27DD08C300E91B77 /* WorkspaceView.swift in Sources */,
DE6F77872813625500D00A76 /* TabBarDivider.swift in Sources */,
Expand Down
10 changes: 10 additions & 0 deletions CodeEdit.xcodeproj/xcshareddata/xcschemes/CodeEdit.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@
ReferencedContainer = "container:CodeEditModules">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CodeEditUtilsTests"
BuildableName = "CodeEditUtilsTests"
BlueprintName = "CodeEditUtilsTests"
ReferencedContainer = "container:CodeEditModules">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
55 changes: 32 additions & 23 deletions CodeEdit/Documents/WorkspaceCodeFileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,40 @@ struct WorkspaceCodeFileView: View {

@ViewBuilder
var codeView: some View {
if let item = workspace.selectionState.openFileItems.first(where: { file in
if file.tabID == workspace.selectionState.selectedId {
print("Item loaded is: ", file.url)
}
return file.tabID == workspace.selectionState.selectedId
}) {
if let codeFile = workspace.selectionState.openedCodeFiles[item] {
CodeFileView(codeFile: codeFile)
.safeAreaInset(edge: .top, spacing: 0) {
VStack(spacing: 0) {
BreadcrumbsView(file: item, tappedOpenFile: workspace.openTab(item:))
Divider()
}
ZStack {
if let item = workspace.selectionState.openFileItems.first(where: { file in
if file.tabID == workspace.selectionState.selectedId {
print("Item loaded is: ", file.url)
}
return file.tabID == workspace.selectionState.selectedId
}) {
if let codeFile = workspace.selectionState.openedCodeFiles[item] {
CodeFileView(codeFile: codeFile)
.safeAreaInset(edge: .top, spacing: 0) {
VStack(spacing: 0) {
BreadcrumbsView(file: item, tappedOpenFile: workspace.openTab(item:))
Divider()
}
} else {
Text("CodeEdit cannot open this file because its file type is not supported.")
.frame(minHeight: 0)
.clipped()
}
} else {
Text("CodeEdit cannot open this file because its file type is not supported.")
.frame(minHeight: 0)
.clipped()
} else {
Text("No Editor")
.font(.system(size: 17))
.foregroundColor(.secondary)
.frame(minHeight: 0)
.clipped()
}
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.safeAreaInset(edge: .top, spacing: 0) {
VStack(spacing: 0) {
TabBar(windowController: windowController, workspace: workspace)
TabBarBottomDivider()
}
} else {
Text("No Editor")
.font(.system(size: 17))
.foregroundColor(.secondary)
.frame(minHeight: 0)
.clipped()
}
}

Expand Down
11 changes: 8 additions & 3 deletions CodeEdit/Documents/WorkspaceDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate {

if selectionState.openedTabs.isEmpty {
selectionState.selectedId = nil
} else if idx == 0 {
selectionState.selectedId = selectionState.openedTabs.first
} else if selectionState.selectedId == closedFileItem.tabID {
// If the closed item is the selected one, then select another tab.
if idx == 0 {
selectionState.selectedId = selectionState.openedTabs.first?.tabID
} else {
selectionState.selectedId = selectionState.openedTabs[idx - 1].id
}
} else {
selectionState.selectedId = selectionState.openedTabs[idx - 1]
// If the closed item is not the selected one, then do nothing.
}
}

Expand Down
2 changes: 1 addition & 1 deletion CodeEdit/InspectorSidebar/Models/Lists/FileTypeList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation

/// A collection of file types and their associated extensions,
/// which can be selected in the inspector to override default values
public class FileTypeList {
final class FileTypeList {

var languageTypeObjCList = [LanguageType(name: "Objective-C Preprocessed Source", id: "obj_c_pre_source"),
LanguageType(name: "Objective-C Source", id: "m"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,53 @@
//

import SwiftUI
import CodeEditUI

struct FindNavigatorSearchBar: View {
@Environment(\.colorScheme)
var colorScheme

@ObservedObject
private var state: WorkspaceDocument.SearchState

@FocusState
private var isFocused: Bool

private let title: String

@Binding
private var text: String

@Environment(\.controlActiveState)
private var controlActive

@ViewBuilder
public func selectionBackground(
_ isFocused: Bool = false
) -> some View {
if self.controlActive != .inactive {
if isFocused {
if colorScheme == .light {
Color.white
} else {
Color(hex: 0x1e1e1e)
}
} else {
if colorScheme == .light {
Color.black.opacity(0.06)
} else {
Color.white.opacity(0.24)
}
}
} else {
if colorScheme == .light {
Color.clear
} else {
Color.white.opacity(0.14)
}
}
}

init(state: WorkspaceDocument.SearchState,
title: String,
text: Binding<String>) {
Expand All @@ -33,13 +70,16 @@ struct FindNavigatorSearchBar: View {
}
.padding(.horizontal, 5)
.padding(.vertical, 3)
.overlay(RoundedRectangle(cornerRadius: 4).stroke(Color.gray, lineWidth: 0.5).cornerRadius(4))
.background(selectionBackground(isFocused))
.clipShape(RoundedRectangle(cornerRadius: 6))
.overlay(RoundedRectangle(cornerRadius: 6).stroke(Color.gray, lineWidth: 0.5).cornerRadius(6))
}

private var textField: some View {
TextField(title, text: $text)
.disableAutocorrection(true)
.textFieldStyle(PlainTextFieldStyle())
.focused($isFocused)
}

private var clearButton: some View {
Expand Down
Loading

0 comments on commit 0897d2e

Please sign in to comment.