Skip to content

Commit bc40ff7

Browse files
committed
Add Documentation Homepage
1 parent 5168cf1 commit bc40ff7

File tree

2 files changed

+116
-28
lines changed

2 files changed

+116
-28
lines changed

README.md

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,59 @@ This package is fully documented [here](https://codeeditapp.github.io/WelcomeWin
3131

3232
## Usage
3333

34-
To use `WelcomeWindow`, simply add it to your app.
34+
To use welcome window, simply import the package
3535

3636
```swift
37-
WelcomeWindow(
38-
actions: { dismiss in
39-
WelcomeActionView(
40-
iconName: "circle.fill",
41-
title: "New Text Document",
42-
action: {
43-
NSDocumentController.shared.createFileDocumentWithDialog(
44-
configuration: .init(title: "Create new text document"),
45-
onCompletion: { dismiss() }
37+
import WelcomeWindow
38+
```
39+
40+
And add it as a window in your SwiftUI App.
41+
42+
```swift
43+
@main
44+
struct CodeEditApp: App {
45+
@Environment(\.dismiss) private var dismiss
46+
47+
var body: some Scene {
48+
WelcomeWindow(
49+
// Add two action buttons below your icon
50+
actions: { dismiss in
51+
WelcomeButton(
52+
iconName: "circle.fill",
53+
title: "New Text Document",
54+
action: {
55+
NSDocumentController.shared.createFileDocumentWithDialog(
56+
configuration: .init(title: "Create new text document"),
57+
onCompletion: { dismiss() }
58+
)
59+
}
4660
)
47-
}
48-
)
49-
WelcomeActionView(
50-
iconName: "triangle.fill",
51-
title: "Open Text Document or Folder",
52-
action: {
53-
NSDocumentController.shared.openDocumentWithDialog(
54-
configuration: .init(canChooseDirectories: true),
55-
onDialogPresented: { dismiss() },
56-
onCancel: { openWindow(id: "welcome") }
61+
WelcomeButton(
62+
iconName: "triangle.fill",
63+
title: "Open Text Document or Folder",
64+
action: {
65+
NSDocumentController.shared.openDocumentWithDialog(
66+
configuration: .init(canChooseDirectories: true),
67+
onDialogPresented: { dismiss() },
68+
onCancel: { openWindow(id: "welcome") }
69+
)
70+
}
5771
)
72+
},
73+
// Receive files via drag and drop
74+
onDrop: { url, dismiss in
75+
print("File dropped at: \(url.path)")
76+
77+
Task {
78+
NSDocumentController.shared.openDocument(at: url, onCompletion: { dismiss() })
79+
}
5880
}
5981
)
60-
},
61-
onDrop: { url, dismiss in
62-
print("File dropped at: \(url.path)")
63-
64-
Task {
65-
NSDocumentController.shared.openDocument(at: url, onCompletion: { dismiss() })
66-
}
6782
}
68-
)
83+
}
6984
```
7085

7186
## License
7287

7388
Licensed under the [MIT license](https://github.com/CodeEditApp/WelcomeWindow/blob/main/LICENSE.md)
89+
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# ``WelcomeWindow``
2+
3+
A highly customizable welcome window built for macOS applications. This package supports NSDocument-based apps and offers the ability to override the recent list for other use cases. It's designed to provide a native and elegant welcome experience for your app at launch, with support for new/open document actions, drag-and-drop functionality, and dynamic layouts.
4+
5+
## Overview
6+
7+
To use welcome window, simply import the package
8+
9+
```swift
10+
import WelcomeWindow
11+
```
12+
13+
And add it as a window in your SwiftUI App.
14+
15+
```swift
16+
@main
17+
struct CodeEditApp: App {
18+
@Environment(\.dismiss) private var dismiss
19+
20+
var body: some Scene {
21+
WelcomeWindow(
22+
// Add two action buttons below your icon
23+
actions: { dismiss in
24+
WelcomeButton(
25+
iconName: "circle.fill",
26+
title: "New Text Document",
27+
action: {
28+
NSDocumentController.shared.createFileDocumentWithDialog(
29+
configuration: .init(title: "Create new text document"),
30+
onCompletion: { dismiss() }
31+
)
32+
}
33+
)
34+
WelcomeButton(
35+
iconName: "triangle.fill",
36+
title: "Open Text Document or Folder",
37+
action: {
38+
NSDocumentController.shared.openDocumentWithDialog(
39+
configuration: .init(canChooseDirectories: true),
40+
onDialogPresented: { dismiss() },
41+
onCancel: { openWindow(id: "welcome") }
42+
)
43+
}
44+
)
45+
},
46+
// Receive files via drag and drop
47+
onDrop: { url, dismiss in
48+
print("File dropped at: \(url.path)")
49+
50+
Task {
51+
NSDocumentController.shared.openDocument(at: url, onCompletion: { dismiss() })
52+
}
53+
}
54+
)
55+
}
56+
}
57+
```
58+
59+
## Topics
60+
61+
### Example App
62+
63+
A great way to get started is by checking out the example app in the `Example` folder.
64+
65+
### Window Configuration
66+
67+
- ``WelcomeWindow`` This window creates the styled window that is the core of WelcomeWindow.
68+
- ``WelcomeButton`` Use welcome buttons to create pre-designed buttons to go in your welcome window. These are common actions users may take to start a project, open an old project, or navigate somewhere useful in your app.
69+
70+
### Recent Projects List
71+
72+
- ``RecentsStore`` stores a list of bookmarked files or folders that your users can open from the welcome window. Call ``RecentsStore/documentOpened(at:)`` to tell the recents store about an opened document. The store will trim items to 100 history automatically, so don't worry about space or memory usage and call it often.

0 commit comments

Comments
 (0)