Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensions Base #1274

Merged
merged 29 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c5591db
Merge branch 'main' into extensions-v2
Wouter01 Mar 23, 2023
94b7415
Add local CodeEditKit package
Wouter01 Mar 23, 2023
950010f
moved foldermonitor and created extensions window
Wouter01 Mar 23, 2023
903c05c
Readded various extension structs
Wouter01 Mar 24, 2023
cb9229e
Fixed inspector extensions
Wouter01 Mar 25, 2023
72cf7ab
Merge branch 'main' into extensions-v2
Wouter01 Mar 26, 2023
72f24ff
fixed regression
Wouter01 Mar 26, 2023
2744550
update packages
Wouter01 Mar 30, 2023
b46111a
added processidentifier to extension
Wouter01 May 22, 2023
725e435
Merge branch 'main' into extensions-v2
Wouter01 May 22, 2023
cc14468
fixed inspector
Wouter01 May 22, 2023
d20a227
added logs to codeedit console
Wouter01 May 22, 2023
d8fbf5f
added separate tabs for each extension
Wouter01 May 22, 2023
39adc06
small fixes
Wouter01 May 22, 2023
12cd073
add hot reloading
Wouter01 May 23, 2023
c3daa1e
Fixed navigator extensions
Wouter01 May 23, 2023
924a0e0
fir warnings
Wouter01 May 23, 2023
84ce9e9
add CodeEditKit as remote package
Wouter01 May 23, 2023
dd8ccc6
fix build issue
Wouter01 May 23, 2023
dfe7d35
config fixes
Wouter01 May 23, 2023
795208c
fix swiftlint
Wouter01 May 23, 2023
dbccf12
warning fixes
Wouter01 May 23, 2023
af72bc8
swiftlint fix
Wouter01 May 23, 2023
b8e3847
test fix
Wouter01 May 23, 2023
36e0587
remove swiftlint:disable in Commands+ForEach
Wouter01 May 26, 2023
0847bf5
improvements for other comments
Wouter01 May 26, 2023
756798e
resolve comments
Wouter01 May 29, 2023
d1df6dd
Merge branch 'main' into extensions-v2
Wouter01 May 29, 2023
9886043
swiftlint fix
Wouter01 May 29, 2023
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
216 changes: 185 additions & 31 deletions CodeEdit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
{
"pins" : [
{
"identity" : "anycodable",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Flight-School/AnyCodable",
"state" : {
"revision" : "862808b2070cd908cb04f9aafe7de83d35f81b05",
"version" : "0.6.7"
}
},
{
"identity" : "codeeditkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/CodeEditApp/CodeEditKit",
"state" : {
"branch" : "dev/foundation",
"revision" : "b0e0c5be9ff5d2cff56bb0cda3df5c0d9c4e029b"
}
},
{
"identity" : "codeeditlanguages",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -27,6 +45,105 @@
"version" : "0.6.3"
}
},
{
"identity" : "collectionconcurrencykit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/johnsundell/collectionconcurrencykit",
"state" : {
"revision" : "b4f23e24b5a1bff301efc5e70871083ca029ff95",
"version" : "0.2.0"
}
},
{
"identity" : "concurrencyplus",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/ConcurrencyPlus",
"state" : {
"branch" : "main",
"revision" : "8dc56499412a373d617d50d059116bccf44b9874"
}
},
{
"identity" : "fseventswrapper",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Frizlab/FSEventsWrapper",
"state" : {
"revision" : "e0c59a2ce2775e5f6642da6d19207445f10112d0",
"version" : "1.0.2"
}
},
{
"identity" : "glob",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Bouke/Glob",
"state" : {
"revision" : "deda6e163d2ff2a8d7e138e2c3326dbd71157faf",
"version" : "1.0.5"
}
},
{
"identity" : "grdb.swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/groue/GRDB.swift.git",
"state" : {
"revision" : "dd7e7f39e8e4d7a22d258d9809a882f914690b01",
"version" : "5.26.1"
}
},
{
"identity" : "jsonrpc",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/JSONRPC",
"state" : {
"revision" : "afc20d00e38674774f84edc325424a32ae3b9e01",
"version" : "0.7.0"
}
},
{
"identity" : "languageclient",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/LanguageClient",
"state" : {
"revision" : "92beeecd0bb783da52227839ba6c55e43fc866ec",
"version" : "0.5.1"
}
},
{
"identity" : "languageserverprotocol",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/LanguageServerProtocol",
"state" : {
"revision" : "192bcfdcf7a013da49c6fa1b95de66254ce7c614",
"version" : "0.9.1"
}
},
{
"identity" : "logstream",
"kind" : "remoteSourceControl",
"location" : "https://github.com/CodeEditApp/LogStream",
"state" : {
"revision" : "afd2422c65c12822f26606408b4e39b9549c5e1a",
"version" : "1.2.1"
}
},
{
"identity" : "processenv",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/ProcessEnv",
"state" : {
"revision" : "29487b6581bb785c372c611c943541ef4309d051",
"version" : "0.3.1"
}
},
{
"identity" : "processservice",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/ProcessService",
"state" : {
"revision" : "369fb0379983d3b43c7d7ad62c4e91ee020e347c",
"version" : "0.2.6"
}
},
{
"identity" : "rearrange",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -77,8 +194,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/lukepistrol/SwiftLintPlugin",
"state" : {
"revision" : "f3586ed424d7bf5d94628332fbd0edebf1f5147f",
"version" : "0.2.3"
"revision" : "d3ec7fb242ebe1d8e23bf17e58a1e27d43125994",
"version" : "0.2.6"
}
},
{
Expand All @@ -104,8 +221,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : {
"revision" : "c18951c747ab62af7c15e17a81bd37d4fd5a9979",
"version" : "0.2.3"
"revision" : "5b3f3996c7a2a84d5f4ba0e03cd7d584154778f2",
"version" : "0.3.1"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 4 additions & 0 deletions CodeEdit/CodeEditApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ struct CodeEditApp: App {

var body: some Scene {
WelcomeWindow()
.keyboardShortcut("1", modifiers: [.command, .shift])

ExtensionManagerWindow()
.keyboardShortcut("2", modifiers: [.command, .shift])

AboutWindow()

Expand Down
142 changes: 142 additions & 0 deletions CodeEdit/Features/CodeEditUI/Views/SegmentedControlImproved.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
//
// SegmentedControlImproved.swift
// CodeEdit
//
// Created by Wouter Hennen on 22/05/2023.
//

import SwiftUI

extension ButtonStyle where Self == XcodeButtonStyle {
static func xcodeButton(
isActive: Bool,
prominent: Bool,
isHovering: Bool,
namespace: Namespace.ID = Namespace().wrappedValue
) -> XcodeButtonStyle {
XcodeButtonStyle(isActive: isActive, prominent: prominent, isHovering: isHovering, namespace: namespace)
}
}

struct XcodeButtonStyle: ButtonStyle {
var isActive: Bool
var prominent: Bool
var isHovering: Bool
var namespace: Namespace.ID

@Environment(\.controlSize) var controlSize

@Environment(\.colorScheme) var colorScheme

@Environment(\.controlActiveState) private var activeState

func makeBody(configuration: Configuration) -> some View {
configuration.label
.padding(.horizontal, controlSizePadding.horizontal)
.padding(.vertical, controlSizePadding.vertical)
.font(fontSize)
.foregroundColor(isActive ? .white : .primary)
.opacity(textOpacity)
.background {
if isActive {
RoundedRectangle(cornerRadius: 5)
.foregroundColor(.accentColor)
.opacity(configuration.isPressed ? (prominent ? 0.75 : 0.5) : (prominent ? 1 : 0.75))
.matchedGeometryEffect(id: "xcodebuttonbackground", in: namespace)

} else if isHovering {
RoundedRectangle(cornerRadius: 5)
.foregroundColor(.gray)
.opacity(0.2)
.transition(.opacity)
.animation(.easeInOut, value: isHovering)
}
}
.opacity(activeState == .inactive ? 0.6 : 1)
.animation(.interpolatingSpring(stiffness: 600, damping: 50), value: isActive)
}

var fontSize: Font {
switch controlSize {
case .mini:
return .footnote
case .small, .regular:
return .subheadline
default:
return .callout
}
}

var controlSizePadding: (vertical: CGFloat, horizontal: CGFloat) {
switch controlSize {
case .mini:
return (1, 2)
case .small:
return (2, 4)
case .regular:
return (3, 8)
case .large:
return (6, 12)
@unknown default:
return (4, 8)
}
}

private var textOpacity: Double {
if prominent {
return activeState != .inactive ? 1 : isActive ? 1 : 0.3
} else {
return activeState != .inactive ? 1 : isActive ? 0.5 : 0.3
}
}
}

private struct MyTag: _ViewTraitKey {
static var defaultValue: AnyHashable? = Optional<Int>.none
}

extension View {
func segmentedTag<Value: Hashable>(_ value: Value) -> some View {
_trait(MyTag.self, value)
}
}

struct SegmentedControlV2<Selection: Hashable, Content: View>: View {
@Binding var selection: Selection
var prominent: Bool
@ViewBuilder var content: Content

@State private var hoveringOver: Selection?

@Namespace var namespace

var body: some View {
content.variadic { children in
HStack(spacing: 8) {
ForEach(children, id: \.id) { option in
let tag: Selection? = option[MyTag.self].flatMap { $0 as? Selection }
Button {
hoveringOver = nil
if let tag {
selection = tag
}
} label: {
option
}
.buttonStyle(
.xcodeButton(
isActive: tag == selection,
prominent: prominent,
isHovering: tag == hoveringOver,
namespace: namespace
)
)
.onHover { hover in
hoveringOver = hover ? tag : nil
}
.animation(.interpolatingSpring(stiffness: 600, damping: 50), value: selection)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ final class CodeEditDocumentController: NSDocumentController {

override func clearRecentDocuments(_ sender: Any?) {
super.clearRecentDocuments(sender)
UserDefaults.standard.set([], forKey: "recentProjectPaths")
UserDefaults.standard.set([Any](), forKey: "recentProjectPaths")
}
}

Expand Down
Loading