Skip to content

Commit d6c2e0f

Browse files
WelcomeWindow Package Implementation (#2059)
### Description - Removed old welcome window code and implemented WelcomeWindow package. - Refactored related code in RecentProjectsMenu and CodeEditDocumentController. - Recreated views that go inside the welcome window in Features/Welcome ### Related Issues None. ### Checklist - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots WelcomeWindow UI updates from PR#2040 <img width="801" alt="Screenshot 2025-06-08 at 20 15 27" src="https://github.com/user-attachments/assets/a1c31dea-5d99-44b6-bb35-47721fd642a5" />
1 parent 9079813 commit d6c2e0f

File tree

20 files changed

+453
-755
lines changed

20 files changed

+453
-755
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
58F2EB03292FB2B0004A9BDE /* Documentation.docc in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EACE292FB2B0004A9BDE /* Documentation.docc */; };
1818
58F2EB1E292FB954004A9BDE /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 58F2EB1D292FB954004A9BDE /* Sparkle */; };
1919
5E4485612DF600D9008BBE69 /* AboutWindow in Frameworks */ = {isa = PBXBuildFile; productRef = 5E4485602DF600D9008BBE69 /* AboutWindow */; };
20+
5EACE6222DF4BF08005E08B8 /* WelcomeWindow in Frameworks */ = {isa = PBXBuildFile; productRef = 5EACE6212DF4BF08005E08B8 /* WelcomeWindow */; };
2021
6C0617D62BDB4432008C9C42 /* LogStream in Frameworks */ = {isa = PBXBuildFile; productRef = 6C0617D52BDB4432008C9C42 /* LogStream */; };
2122
6C0824A12C5C0C9700A0751E /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = 6C0824A02C5C0C9700A0751E /* SwiftTerm */; };
2223
6C147C4529A329350089B630 /* OrderedCollections in Frameworks */ = {isa = PBXBuildFile; productRef = 6C147C4429A329350089B630 /* OrderedCollections */; };
@@ -182,6 +183,7 @@
182183
6C73A6D32D4F1E550012D95C /* CodeEditSourceEditor in Frameworks */,
183184
2816F594280CF50500DD548B /* CodeEditSymbols in Frameworks */,
184185
30CB64942C16CA9100CC8A9E /* LanguageClient in Frameworks */,
186+
5EACE6222DF4BF08005E08B8 /* WelcomeWindow in Frameworks */,
185187
6C6BD6F829CD14D100235D17 /* CodeEditKit in Frameworks */,
186188
6C0824A12C5C0C9700A0751E /* SwiftTerm in Frameworks */,
187189
6C81916B29B41DD300B75C92 /* DequeModule in Frameworks */,
@@ -319,6 +321,7 @@
319321
6CB94D022CA1205100E8651C /* AsyncAlgorithms */,
320322
6CC00A8A2CBEF150004E8134 /* CodeEditSourceEditor */,
321323
6C73A6D22D4F1E550012D95C /* CodeEditSourceEditor */,
324+
5EACE6212DF4BF08005E08B8 /* WelcomeWindow */,
322325
5E4485602DF600D9008BBE69 /* AboutWindow */,
323326
);
324327
productName = CodeEdit;
@@ -423,6 +426,7 @@
423426
6C4E37FA2C73E00700AEE7B5 /* XCRemoteSwiftPackageReference "SwiftTerm" */,
424427
6CB94D012CA1205100E8651C /* XCRemoteSwiftPackageReference "swift-async-algorithms" */,
425428
6CF368562DBBD274006A77FD /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */,
429+
5EACE6202DF4BF08005E08B8 /* XCRemoteSwiftPackageReference "WelcomeWindow" */,
426430
5E44855F2DF600D9008BBE69 /* XCRemoteSwiftPackageReference "AboutWindow" */,
427431
);
428432
preferredProjectObjectVersion = 55;
@@ -1699,8 +1703,16 @@
16991703
isa = XCRemoteSwiftPackageReference;
17001704
repositoryURL = "https://github.com/CodeEditApp/AboutWindow";
17011705
requirement = {
1702-
branch = main;
1703-
kind = branch;
1706+
kind = upToNextMajorVersion;
1707+
minimumVersion = 1.0.0;
1708+
};
1709+
};
1710+
5EACE6202DF4BF08005E08B8 /* XCRemoteSwiftPackageReference "WelcomeWindow" */ = {
1711+
isa = XCRemoteSwiftPackageReference;
1712+
repositoryURL = "https://github.com/CodeEditApp/WelcomeWindow";
1713+
requirement = {
1714+
kind = upToNextMajorVersion;
1715+
minimumVersion = 1.0.0;
17041716
};
17051717
};
17061718
6C0617D42BDB4432008C9C42 /* XCRemoteSwiftPackageReference "LogStream" */ = {
@@ -1808,6 +1820,11 @@
18081820
package = 5E44855F2DF600D9008BBE69 /* XCRemoteSwiftPackageReference "AboutWindow" */;
18091821
productName = AboutWindow;
18101822
};
1823+
5EACE6212DF4BF08005E08B8 /* WelcomeWindow */ = {
1824+
isa = XCSwiftPackageProductDependency;
1825+
package = 5EACE6202DF4BF08005E08B8 /* XCRemoteSwiftPackageReference "WelcomeWindow" */;
1826+
productName = WelcomeWindow;
1827+
};
18111828
6C0617D52BDB4432008C9C42 /* LogStream */ = {
18121829
isa = XCSwiftPackageProductDependency;
18131830
package = 6C0617D42BDB4432008C9C42 /* XCRemoteSwiftPackageReference "LogStream" */;

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeEdit.xcodeproj/xcshareddata/xcschemes/OpenWithCodeEdit.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1640"
3+
LastUpgradeVersion = "1620"
44
wasCreatedForAppExtension = "YES"
55
version = "2.0">
66
<BuildAction

CodeEdit/CodeEditApp.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77

88
import SwiftUI
9+
import WelcomeWindow
910
import AboutWindow
1011

1112
@main
@@ -28,7 +29,17 @@ struct CodeEditApp: App {
2829

2930
var body: some Scene {
3031
Group {
31-
WelcomeWindow()
32+
WelcomeWindow(
33+
subtitleView: { WelcomeSubtitleView() },
34+
actions: { dismissWindow in
35+
NewFileButton(dismissWindow: dismissWindow)
36+
GitCloneButton(dismissWindow: dismissWindow)
37+
OpenFileOrFolderButton(dismissWindow: dismissWindow)
38+
},
39+
onDrop: { url, dismissWindow in
40+
Task { CodeEditDocumentController.shared.openDocument(at: url, onCompletion: { dismissWindow() }) }
41+
}
42+
)
3243

3344
ExtensionManagerWindow()
3445

CodeEdit/Features/Documents/Controllers/CodeEditDocumentController.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import Cocoa
99
import SwiftUI
10+
import WelcomeWindow
1011

1112
final class CodeEditDocumentController: NSDocumentController {
1213
@Environment(\.openWindow)
@@ -16,6 +17,26 @@ final class CodeEditDocumentController: NSDocumentController {
1617

1718
private let fileManager = FileManager.default
1819

20+
@MainActor
21+
func createAndOpenNewDocument(onCompletion: @escaping () -> Void) {
22+
guard let newDocumentUrl = self.newDocumentUrl else { return }
23+
24+
let createdFile = self.fileManager.createFile(
25+
atPath: newDocumentUrl.path,
26+
contents: nil,
27+
attributes: [FileAttributeKey.creationDate: Date()]
28+
)
29+
30+
guard createdFile else {
31+
print("Failed to create new document")
32+
return
33+
}
34+
35+
self.openDocument(withContentsOf: newDocumentUrl, display: true) { _, _, _ in
36+
onCompletion()
37+
}
38+
}
39+
1940
override func newDocument(_ sender: Any?) {
2041
guard let newDocumentUrl = self.newDocumentUrl else { return }
2142

@@ -71,7 +92,7 @@ final class CodeEditDocumentController: NSDocumentController {
7192
print("Unable to open document '\(url)': \(errorMessage)")
7293
}
7394

74-
RecentProjectsStore.shared.documentOpened(at: url)
95+
RecentsStore.documentOpened(at: url)
7596
completionHandler(document, documentWasAlreadyOpen, error)
7697
}
7798
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// GitCloneButton.swift
3+
// CodeEdit
4+
//
5+
// Created by Giorgi Tchelidze on 07.06.25.
6+
//
7+
8+
import SwiftUI
9+
import WelcomeWindow
10+
11+
struct GitCloneButton: View {
12+
13+
@State private var showGitClone = false
14+
@State private var showCheckoutBranchItem: URL?
15+
16+
var dismissWindow: () -> Void
17+
18+
var body: some View {
19+
WelcomeButton(
20+
iconName: "square.and.arrow.down.on.square",
21+
title: "Clone Git Repository...",
22+
action: {
23+
showGitClone = true
24+
}
25+
)
26+
.sheet(isPresented: $showGitClone) {
27+
GitCloneView(
28+
openBranchView: { url in
29+
showCheckoutBranchItem = url
30+
},
31+
openDocument: { url in
32+
CodeEditDocumentController.shared.openDocument(at: url, onCompletion: { dismissWindow() })
33+
}
34+
)
35+
}
36+
.sheet(item: $showCheckoutBranchItem) { url in
37+
GitCheckoutBranchView(
38+
repoLocalPath: url,
39+
openDocument: { url in
40+
CodeEditDocumentController.shared.openDocument(at: url, onCompletion: { dismissWindow() })
41+
}
42+
)
43+
}
44+
}
45+
}

CodeEdit/Features/Welcome/Model/RecentProjectsStore.swift

Lines changed: 0 additions & 133 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// NewFileButton.swift
3+
// CodeEdit
4+
//
5+
// Created by Giorgi Tchelidze on 07.06.25.
6+
//
7+
8+
import SwiftUI
9+
import WelcomeWindow
10+
11+
struct NewFileButton: View {
12+
13+
var dismissWindow: () -> Void
14+
15+
var body: some View {
16+
WelcomeButton(
17+
iconName: "plus.square",
18+
title: "Create New File...",
19+
action: {
20+
let documentController = CodeEditDocumentController()
21+
documentController.createAndOpenNewDocument(onCompletion: { dismissWindow() })
22+
}
23+
)
24+
}
25+
}

0 commit comments

Comments
 (0)