Update documentation to latest changes

This commit is contained in:
david-swift 2024-10-15 15:31:09 +02:00
parent f1643efd76
commit 04b705b1de
79 changed files with 268 additions and 238 deletions

View File

@ -19,7 +19,7 @@ struct CustomText: Widget {
} }
``` ```
This widget can be called in a view body using `CustomText(text: "Hello, world!")`. This widget can be called in a view body using `CustomText(text: "Hello, world!")`.
Now, add the two functions required by the protocol: Now, add the function required by the protocol:
```swift ```swift
import CAdw import CAdw
@ -27,37 +27,36 @@ struct CustomText: Widget {
var text: String var text: String
public func container(modifiers: [(View) -> View]) -> ViewStorage { } func initializeWidget() -> Any {
public func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) { } gtk_label_new(text)?.opaque()
}
```
Import CAdw which exposes the whole C Libadwaita and Gtk API to Swift.
## The `container(modifiers:)` function
This function initializes the widget when the widget appears for the first time.
It expects a ``ViewStorage`` as the return type.
In our case, this function is very simple:
```swift
func container(modifiers: [(View) -> View]) -> ViewStorage {
.init(gtk_label_new(text)?.opaque())
}
```
## The `update(_:modifiers:updateProperties:)` function
Whenever a state of the app changes, the ``Widget/update(_:modifiers:updateProperties:)`` function of the widget gets called.
You get the view storage that you have previously initialized as a parameter.
Update the storage to reflect the current state of the widget:
```swift
func update(_ storage: ViewStorage, modifiers: [(View) -> View], updateProperties: Bool) {
if updateProperties {
gtk_label_set_label(storage.pointer, text)
} }
} }
``` ```
## Containers ## Updates
Some widgets act as containers that accept other widgets as children. The widget will be rendered as expected, but updates do not work currently.
In that case, use the ``ViewStorage``'s `content` property for storing their view storages. To mark properties as a widget property, use the ``Property`` property wrapper.
In the ``Widget/update(_:modifiers:updateProperties:)`` function, update the children's storages.
Take a look at the code of the container widgets in this library as a reference. ```swift
import CAdw
struct CustomText: Widget {
@Property(
set: { gtk_label_set_label($0, text) },
pointer: OpaquePointer.self
)
var text: String
func initializeWidget() -> Any {
gtk_label_new(text)?.opaque()
}
}
```
## More Complex Widgets
If a property should allow two-way traffic (able to modify inside of the widget, e.g. the `isOn` property of a checkbox which can be updated when the user clicks the checkbox), use ``BindingProperty``. For views, use ``ViewProperty``.
More help is available [here](https://meta.aparoksha.dev/documentation/meta/createbackend).

View File

@ -12,13 +12,13 @@ Find detailed information in the [Flatpak documentation](https://docs.flatpak.or
This is the only code that should be submitted to Flathub. This is the only code that should be submitted to Flathub.
There will be a new repository created under `flathub/app-id` that hosts the manifest. There will be a new repository created under `flathub/app-id` that hosts the manifest.
### SDK Extension for Swift 5 ### SDK Extension for Swift 6
I recommend using the SDK Extension for building the app. I recommend using the SDK Extension for building the app.
Add the following snippet. Add the following snippet.
```json ```json
"sdk-extensions": [ "sdk-extensions": [
"org.freedesktop.Sdk.Extension.swift5" "org.freedesktop.Sdk.Extension.swift6"
] ]
``` ```

View File

@ -85,7 +85,7 @@ Find more information in the [template repository](https://github.com/AparokshaU
### Basics ### Basics
- <doc:CreatingViews> - <doc:CreatingViews>
- <doc:Windows> - <doc:WindowsDoc>
- <doc:KeyboardShortcuts> - <doc:KeyboardShortcuts>
### Advanced ### Advanced

View File

@ -11,15 +11,16 @@ import Adwaita
@main @main
struct HelloWorld: App { struct HelloWorld: App {
let id = "io.github.david_swift.HelloWorld" let app: AdwaitaApp = .init(id: "io.github.david_swift.HelloWorld")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "content") { _ in Window(id: "content") { _ in
// These are the views: // These are the views:
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
} }
@ -38,9 +39,11 @@ Create custom views by declaring types that conform to the ``View`` protocol:
struct ContentView: View { struct ContentView: View {
var view: Body { var view: Body {
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
} }

View File

@ -26,14 +26,15 @@ import Adwaita
@main @main
struct HelloWorld: App { struct HelloWorld: App {
let id = "io.github.david_swift.HelloWorld" let app = AdwaitaApp(id: "io.github.david_swift.HelloWorld")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "content") { _ in Window(id: "content") { _ in
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
// Add the shortcut "Ctrl + W" for closing the window // Add the shortcut "Ctrl + W" for closing the window
.keyboardShortcut("w".ctrl()) { window in .keyboardShortcut("w".ctrl()) { window in
@ -52,14 +53,15 @@ import Adwaita
@main @main
struct HelloWorld: App { struct HelloWorld: App {
let id = "io.github.david_swift.HelloWorld" let app = AdwaitaApp(id: "io.github.david_swift.HelloWorld")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "content") { _ in Window(id: "content") { _ in
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
// Add the shortcut "Ctrl + Q" for terminating the app // Add the shortcut "Ctrl + Q" for terminating the app
.appKeyboardShortcut("q".ctrl()) { app in .appKeyboardShortcut("q".ctrl()) { app in
@ -76,7 +78,7 @@ Here is an example using a menu button:
```swift ```swift
struct TestView: View { struct TestView: View {
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
Menu(icon: .default(icon: .openMenu), app: app) { Menu(icon: .default(icon: .openMenu), app: app) {

View File

@ -11,20 +11,23 @@ Whenever the last one disappears, the app terminates.
@main @main
struct HelloWorld: App { struct HelloWorld: App {
let id = "io.github.david_swift.HelloWorld" let app: AdwaitaApp = .init(id: "io.github.david_swift.HelloWorld")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "content") { _ in Window(id: "content") { _ in
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
// Add a second window: // Add a second window:
Window(id: "window-2") { _ in Window(id: "window-2") { _ in
HeaderBar.empty()
Text("Window 2") Text("Window 2")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
} }
@ -39,22 +42,25 @@ Another use case is showing a window:
@main @main
struct HelloWorld: App { struct HelloWorld: App {
let id = "io.github.david_swift.HelloWorld" let app: AdwaitaApp = .init(id: "io.github.david_swift.HelloWorld")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "content") { _ in Window(id: "content") { _ in
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
Window(id: "control") { _ in Window(id: "control") { _ in
HeaderBar.empty()
Button("Show Window") { Button("Show Window") {
// Show the window with the identifier "content": // Show the window with the identifier "content":
app.showWindow("content") app.showWindow("content")
} }
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
} }
@ -66,70 +72,64 @@ It should be used for opening windows that cannot be presented more than once
and for moving a window that is already open into the foreground. and for moving a window that is already open into the foreground.
## Adding windows ## Adding windows
You can call the ``GTUIApp/addWindow(_:parent:)`` function instead of ``GTUIApp/showWindow(_:)`` You can call the ``AdwaitaApp/addWindow(_:)`` function instead of ``AdwaitaApp/showWindow(_:)``
if you want to add and focus another instance of a window type: if you want to add and focus another instance of a window type:
```swift ```swift
@main @main
struct HelloWorld: App { struct HelloWorld: App {
let id = "io.github.david_swift.HelloWorld" let app: AdwaitaApp = .init(id: "io.github.david_swift.HelloWorld")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "content") { _ in Window(id: "content") { _ in
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
Window(id: "control") { _ in Window(id: "control") { _ in
HeaderBar.empty()
Button("Add Window") { Button("Add Window") {
// Add a new instance of the "content" window type // Add a new instance of the "content" window type
app.addWindow("content") app.addWindow("content")
} }
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
} }
} }
``` ```
It can be used to add an overlay window to a certain instance of a window type
by specifying the `parent` parameter, e.g. in the example above:
```swift
Window(id: "control") { window in
HeaderBar.empty()
Button("Add Child Window") {
// Add the new instance as a child window of this window
app.addWindow("content", parent: window)
}
.padding()
}
```
## Customizing the initial number of windows ## Customizing the initial number of windows
By default, every window type of the app's scene appears once when the app starts. By default, every window type of the app's scene appears once when the app starts.
It's possible to customize how many windows are being presented at the app's startup: It's possible to customize how many windows are being presented at the app's startup:
```swift ```swift
@main @main
struct HelloWorld: App { struct HelloWorld: App {
let id = "io.github.david_swift.HelloWorld" let app: AdwaitaApp = .init(id: "io.github.david_swift.HelloWorld")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
// Open no window of the "content" type // Open no window of the "content" type
Window(id: "content", open: 0) { _ in Window(id: "content", open: 0) { _ in
HeaderBar.empty()
Text("Hello, world!") Text("Hello, world!")
.padding() .padding()
.topToolbar {
HeaderBar.empty()
}
} }
// Open two windows of the "control" type // Open two windows of the "control" type
Window(id: "control", open: 2) { _ in Window(id: "control", open: 2) { _ in
HeaderBar.empty()
Button("Show Window") { Button("Show Window") {
app.addWindow("content") app.addWindow("content")
} }
.padding() .topToolbar {
HeaderBar.empty()
}
} }
} }

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -6,8 +6,7 @@ import Adwaita
@main @main
struct AdwaitaTemplate: App { struct AdwaitaTemplate: App {
let id = "io.github.AparokshaUI.AdwaitaTemplate" let app = AdwaitaApp(id: "io.github.AparokshaUI.AdwaitaTemplate")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in

View File

@ -0,0 +1,42 @@
{
"originHash" : "af6fb6b129be2ee0c0916fac48a05560178b7f22f7940f6ab37ceda75820b4e4",
"pins" : [
{
"identity" : "adwaita",
"kind" : "remoteSourceControl",
"location" : "https://github.com/AparokshaUI/Adwaita",
"state" : {
"revision" : "c82957e2398a766458ff22129db26b46de75248b",
"version" : "0.2.6"
}
},
{
"identity" : "levenshteintransformations",
"kind" : "remoteSourceControl",
"location" : "https://github.com/david-swift/LevenshteinTransformations",
"state" : {
"revision" : "002c3ae5c48f30d61c96045fd3ceb9928aa778d2",
"version" : "0.1.3"
}
},
{
"identity" : "localized",
"kind" : "remoteSourceControl",
"location" : "https://github.com/AparokshaUI/Localized",
"state" : {
"revision" : "8135771fc0852cdea4361674d964d1c2e048db05",
"version" : "0.3.0"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams",
"state" : {
"revision" : "3036ba9d69cf1fd04d433527bc339dc0dc75433d",
"version" : "5.1.3"
}
}
],
"version" : 3
}

View File

@ -1,4 +1,4 @@
// swift-tools-version: 5.8 // swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package. // The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription
@ -9,15 +9,15 @@ let package = Package(
.macOS(.v13) .macOS(.v13)
], ],
dependencies: [ dependencies: [
.package(url: "https://github.com/AparokshaUI/Adwaita", from: "0.2.0"), .package(url: "https://git.aparoksha.dev/aparoksha/adwaita-swift", from: "0.1.0"),
.package(url: "https://github.com/AparokshaUI/Localized", from: "0.2.0") .package(url: "https://git.aparoksha.dev/aparoksha/localized", from: "0.1.0")
], ],
targets: [ targets: [
.executableTarget( .executableTarget(
name: "AdwaitaTemplate", name: "AdwaitaTemplate",
dependencies: [ dependencies: [
.product(name: "Adwaita", package: "Adwaita"), .product(name: "Adwaita", package: "adwaita-swift"),
.product(name: "Localized", package: "Localized") .product(name: "Localized", package: "localized")
], ],
path: "Sources", path: "Sources",
resources: [ resources: [

View File

@ -1,10 +1,10 @@
{ {
"app-id": "io.github.AparokshaUI.AdwaitaTemplate", "app-id": "io.github.AparokshaUI.AdwaitaTemplate",
"runtime": "org.gnome.Platform", "runtime": "org.gnome.Platform",
"runtime-version": "46", "runtime-version": "47",
"sdk": "org.gnome.Sdk", "sdk": "org.gnome.Sdk",
"sdk-extensions": [ "sdk-extensions": [
"org.freedesktop.Sdk.Extension.swift5" "org.freedesktop.Sdk.Extension.swift6"
], ],
"command": "AdwaitaTemplate", "command": "AdwaitaTemplate",
"finish-args": [ "finish-args": [
@ -14,8 +14,8 @@
"--socket=wayland" "--socket=wayland"
], ],
"build-options": { "build-options": {
"append-path": "/usr/lib/sdk/swift5/bin", "append-path": "/usr/lib/sdk/swift6/bin",
"prepend-ld-library-path": "/usr/lib/sdk/swift5/lib" "prepend-ld-library-path": "/usr/lib/sdk/swift6/lib"
}, },
"cleanup": [ "cleanup": [
"/include", "/include",
@ -40,7 +40,7 @@
} }
], ],
"build-commands": [ "build-commands": [
"swift build -c release --static-swift-stdlib", "swift build -c debug --static-swift-stdlib",
"install -Dm755 .build/release/AdwaitaTemplate /app/bin/AdwaitaTemplate", "install -Dm755 .build/release/AdwaitaTemplate /app/bin/AdwaitaTemplate",
"install -Dm644 data/io.github.AparokshaUI.AdwaitaTemplate.metainfo.xml $DESTDIR/app/share/metainfo/io.github.AparokshaUI.AdwaitaTemplate.metainfo.xml", "install -Dm644 data/io.github.AparokshaUI.AdwaitaTemplate.metainfo.xml $DESTDIR/app/share/metainfo/io.github.AparokshaUI.AdwaitaTemplate.metainfo.xml",
"install -Dm644 data/io.github.AparokshaUI.AdwaitaTemplate.desktop $DESTDIR/app/share/applications/io.github.AparokshaUI.AdwaitaTemplate.desktop", "install -Dm644 data/io.github.AparokshaUI.AdwaitaTemplate.desktop $DESTDIR/app/share/applications/io.github.AparokshaUI.AdwaitaTemplate.desktop",

View File

@ -7,7 +7,7 @@ import Adwaita
struct ContentView: View { struct ContentView: View {
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
Text("Hello, world!") Text("Hello, world!")

View File

@ -8,7 +8,7 @@ import Adwaita
struct ContentView: View { struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
Text("Hello, world!") Text("Hello, world!")

View File

@ -9,7 +9,7 @@ struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Task> = .init() @State private var destination: NavigationStack<Task> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -9,7 +9,7 @@ struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Task> = .init() @State private var destination: NavigationStack<Task> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -9,7 +9,7 @@ struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Task> = .init() @State private var destination: NavigationStack<Task> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -9,7 +9,7 @@ struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Binding<Task>> = .init() @State private var destination: NavigationStack<Binding<Task>> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -9,7 +9,7 @@ struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Binding<Task>> = .init() @State private var destination: NavigationStack<Binding<Task>> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -9,7 +9,7 @@ struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Binding<Task>> = .init() @State private var destination: NavigationStack<Binding<Task>> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -9,7 +9,7 @@ struct ContentView: View {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Binding<Task>> = .init() @State private var destination: NavigationStack<Binding<Task>> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -8,8 +8,7 @@ import Adwaita
@main @main
struct Subtasks: App { struct Subtasks: App {
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { _ in Window(id: "main") { _ in

View File

@ -12,7 +12,7 @@ struct TaskList: View {
@State private var showAddDialog = false @State private var showAddDialog = false
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {
@ -33,7 +33,7 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
@ -43,7 +43,7 @@ struct TaskList: View {
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
var dialog: View { var dialog: AnyView {
Form { Form {
EntryRow(Loc.label, text: $addDialogText) EntryRow(Loc.label, text: $addDialogText)
.entryActivated { .entryActivated {
@ -69,7 +69,7 @@ struct TaskList: View {
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {

View File

@ -12,7 +12,7 @@ struct TaskList: View {
@State private var showAddDialog = false @State private var showAddDialog = false
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {

View File

@ -12,7 +12,7 @@ struct TaskList: View {
@State private var showAddDialog = false @State private var showAddDialog = false
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {

View File

@ -13,7 +13,7 @@ struct TaskList: View {
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {

View File

@ -13,7 +13,7 @@ struct TaskList: View {
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {

View File

@ -13,7 +13,7 @@ struct TaskList: View {
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
var app: GTUIApp var app: AdwaitaApp
var deleteTask: (() -> Void)? var deleteTask: (() -> Void)?
var view: Body { var view: Body {

View File

@ -13,7 +13,7 @@ struct TaskList: View {
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
var app: GTUIApp var app: AdwaitaApp
var deleteTask: (() -> Void)? var deleteTask: (() -> Void)?
var view: Body { var view: Body {

View File

@ -13,7 +13,7 @@ struct TaskList: View {
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
var app: GTUIApp var app: AdwaitaApp
var deleteTask: (() -> Void)? var deleteTask: (() -> Void)?
var view: Body { var view: Body {

View File

@ -13,7 +13,7 @@ struct TaskList: View {
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
var app: GTUIApp var app: AdwaitaApp
var deleteTask: (() -> Void)? var deleteTask: (() -> Void)?
var view: Body { var view: Body {

View File

@ -9,7 +9,7 @@ struct ContentView: WindowView {
@State("tasks") private var tasks: [Task] = [] @State("tasks") private var tasks: [Task] = []
@State private var destination: NavigationStack<Binding<Task>> = .init() @State private var destination: NavigationStack<Binding<Task>> = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -12,7 +12,7 @@ struct ContentView: WindowView {
@State("width") private var width = 500 @State("width") private var width = 500
@State("height") private var height = 400 @State("height") private var height = 400
@State("maximized") private var maximized = false @State("maximized") private var maximized = false
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -12,7 +12,7 @@ struct ContentView: WindowView {
@State("width") private var width = 500 @State("width") private var width = 500
@State("height") private var height = 450 @State("height") private var height = 450
@State("maximized") private var maximized = false @State("maximized") private var maximized = false
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -12,7 +12,7 @@ struct ContentView: WindowView {
@State("width") private var width = 500 @State("width") private var width = 500
@State("height") private var height = 450 @State("height") private var height = 450
@State("maximized") private var maximized = false @State("maximized") private var maximized = false
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
NavigationView($destination, "Subtasks") { task in NavigationView($destination, "Subtasks") { task in

View File

@ -8,8 +8,7 @@ import Adwaita
@main @main
struct Subtasks: App { struct Subtasks: App {
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { _ in Window(id: "main") { _ in

View File

@ -8,8 +8,7 @@ import Adwaita
@main @main
struct Subtasks: App { struct Subtasks: App {
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { _ in Window(id: "main") { _ in

View File

@ -13,7 +13,7 @@ struct TaskList: View {
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
var app: GTUIApp var app: AdwaitaApp
var deleteTask: (() -> Void)? var deleteTask: (() -> Void)?
var view: Body { var view: Body {

View File

@ -14,7 +14,7 @@ struct TaskList: View {
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
@State private var showAboutDialog = false @State private var showAboutDialog = false
var app: GTUIApp var app: AdwaitaApp
var deleteTask: (() -> Void)? var deleteTask: (() -> Void)?
var view: Body { var view: Body {

View File

@ -14,7 +14,7 @@ struct TaskList: View {
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
@State private var showDeleteDialog = false @State private var showDeleteDialog = false
@State private var showAboutDialog = false @State private var showAboutDialog = false
var app: GTUIApp var app: AdwaitaApp
var deleteTask: (() -> Void)? var deleteTask: (() -> Void)?
var view: Body { var view: Body {

View File

@ -6,8 +6,7 @@ import Adwaita
@main @main
struct Subtasks: App { struct Subtasks: App {
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in

View File

@ -8,8 +8,7 @@ import Adwaita
@main @main
struct Subtasks: App { struct Subtasks: App {
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in

View File

@ -13,8 +13,7 @@ struct Subtasks: App {
.init(label: "World"), .init(label: "World"),
.init(label: "Complete", done: true) .init(label: "Complete", done: true)
] ]
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in

View File

@ -13,8 +13,7 @@ struct Subtasks: App {
.init(label: "World"), .init(label: "World"),
.init(label: "Complete", done: true) .init(label: "Complete", done: true)
] ]
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in

View File

@ -13,8 +13,7 @@ struct Subtasks: App {
.init(label: "World"), .init(label: "World"),
.init(label: "Complete", done: true) .init(label: "Complete", done: true)
] ]
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { _ in Window(id: "main") { _ in

View File

@ -13,8 +13,7 @@ struct Subtasks: App {
.init(label: "World"), .init(label: "World"),
.init(label: "Complete", done: true) .init(label: "Complete", done: true)
] ]
let id = "io.github.david_swift.Subtasks" let app: AdwaitaApp = .init(id: "io.github.david_swift.Subtasks")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { _ in Window(id: "main") { _ in

View File

@ -17,13 +17,13 @@ struct TaskList: View {
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
} }

View File

@ -17,7 +17,7 @@ struct TaskList: View {
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {
@ -25,6 +25,7 @@ struct TaskList: View {
.iconName(Icon.default(icon: .goNext).string) .iconName(Icon.default(icon: .goNext).string)
} }
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list") .style("boxed-list")

View File

@ -17,7 +17,7 @@ struct TaskList: View {
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {
@ -25,9 +25,9 @@ struct TaskList: View {
.iconName(Icon.default(icon: .goNext).string) .iconName(Icon.default(icon: .goNext).string)
} }
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
.topToolbar { .topToolbar {

View File

@ -18,14 +18,14 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {
@ -33,9 +33,9 @@ struct TaskList: View {
.iconName(Icon.default(icon: .goNext).string) .iconName(Icon.default(icon: .goNext).string)
} }
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }

View File

@ -18,23 +18,23 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -23,23 +23,23 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -26,13 +26,13 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
@ -44,13 +44,13 @@ struct TaskList: View {
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -27,17 +27,17 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
var dialog: View { var dialog: AnyView {
Form { Form {
EntryRow("Label", text: $addDialogText) EntryRow("Label", text: $addDialogText)
.frame(minWidth: 250) .frame(minWidth: 250)
@ -49,13 +49,13 @@ struct TaskList: View {
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -29,17 +29,17 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
var dialog: View { var dialog: AnyView {
Form { Form {
EntryRow("Label", text: $addDialogText) EntryRow("Label", text: $addDialogText)
.frame(minWidth: 250) .frame(minWidth: 250)
@ -57,19 +57,19 @@ struct TaskList: View {
tasks.append(.init(label: addDialogText)) tasks.append(.init(label: addDialogText))
cancel() cancel()
} }
.style("suggested-action") .suggested()
} }
.showEndTitleButtons(false) .showEndTitleButtons(false)
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -29,17 +29,17 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
var dialog: View { var dialog: AnyView {
Form { Form {
EntryRow("Label", text: $addDialogText) EntryRow("Label", text: $addDialogText)
.entryActivated { .entryActivated {
@ -59,19 +59,19 @@ struct TaskList: View {
Button("Add") { Button("Add") {
add() add()
} }
.style("suggested-action") .suggested()
} }
.showEndTitleButtons(false) .showEndTitleButtons(false)
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -11,7 +11,7 @@ struct TaskList: View {
@State private var showAddDialog = false @State private var showAddDialog = false
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {
@ -31,17 +31,17 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
var dialog: View { var dialog: AnyView {
Form { Form {
EntryRow("Label", text: $addDialogText) EntryRow("Label", text: $addDialogText)
.entryActivated { .entryActivated {
@ -61,19 +61,19 @@ struct TaskList: View {
Button("Add") { Button("Add") {
add() add()
} }
.style("suggested-action") .suggested()
} }
.showEndTitleButtons(false) .showEndTitleButtons(false)
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -11,7 +11,7 @@ struct TaskList: View {
@State private var showAddDialog = false @State private var showAddDialog = false
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {
@ -31,17 +31,17 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
var dialog: View { var dialog: AnyView {
Form { Form {
EntryRow("Label", text: $addDialogText) EntryRow("Label", text: $addDialogText)
.entryActivated { .entryActivated {
@ -61,19 +61,19 @@ struct TaskList: View {
Button("Add") { Button("Add") {
add() add()
} }
.style("suggested-action") .suggested()
} }
.showEndTitleButtons(false) .showEndTitleButtons(false)
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -11,7 +11,7 @@ struct TaskList: View {
@State private var showAddDialog = false @State private var showAddDialog = false
@State private var addDialogText = "" @State private var addDialogText = ""
@State private var focusEntry: Signal = .init() @State private var focusEntry: Signal = .init()
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
ScrollView { ScrollView {
@ -32,17 +32,17 @@ struct TaskList: View {
} }
} }
var list: View { var list: AnyView {
List(tasks, selection: nil) { task in List(tasks, selection: nil) { task in
taskRow(task: task) taskRow(task: task)
} }
.boxedList()
.valign(.start) .valign(.start)
.padding(20) .padding(20)
.style("boxed-list")
.frame(maxWidth: 500) .frame(maxWidth: 500)
} }
var dialog: View { var dialog: AnyView {
Form { Form {
EntryRow(Loc.label, text: $addDialogText) EntryRow(Loc.label, text: $addDialogText)
.entryActivated { .entryActivated {
@ -62,19 +62,19 @@ struct TaskList: View {
Button(Loc.add) { Button(Loc.add) {
add() add()
} }
.style("suggested-action") .suggested()
} }
.showEndTitleButtons(false) .showEndTitleButtons(false)
} }
} }
func taskRow(task: Task) -> View { func taskRow(task: Task) -> AnyView {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
.suffix { .suffix {

View File

@ -15,8 +15,8 @@ struct TaskList: View {
ActionRow() ActionRow()
.title(task.label) .title(task.label)
} }
.boxedList()
.padding() .padding()
.style("boxed-list")
} }
} }

View File

@ -16,8 +16,8 @@ struct TaskList: View {
.title(task.label) .title(task.label)
} }
.valign(.start) .valign(.start)
.boxedList()
.padding() .padding()
.style("boxed-list")
} }
} }

View File

@ -17,13 +17,13 @@ struct TaskList: View {
.prefix { .prefix {
CheckButton() CheckButton()
.active($tasks[id: task.id, default: .init(label: "")].done) .active($tasks[id: task.id, default: .init(label: "")].done)
.style("selection-mode") .selectionMode()
.valign(.center) .valign(.center)
} }
} }
.boxedList()
.valign(.start) .valign(.start)
.padding() .padding()
.style("boxed-list")
} }
} }

View File

@ -6,8 +6,7 @@ import Adwaita
@main @main
struct AdwaitaTemplate: App { struct AdwaitaTemplate: App {
let id = "io.github.AparokshaUI.AdwaitaTemplate" let app = AdwaitaApp(id: "io.github.AparokshaUI.AdwaitaTemplate")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in

View File

@ -6,8 +6,7 @@ import Adwaita
@main @main
struct AdwaitaTemplate: App { struct AdwaitaTemplate: App {
let id = "io.github.AparokshaUI.AdwaitaTemplate" let app = AdwaitaApp(id: "io.github.AparokshaUI.AdwaitaTemplate")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in
@ -20,8 +19,8 @@ struct AdwaitaTemplate: App {
struct Content: View { struct Content: View {
var app: GTUIApp var app: AdwaitaApp
var window: GTUIApplicationWindow var window: AdwaitaApplicationWindow
var view: Body { var view: Body {
Text(Loc.helloWorld) Text(Loc.helloWorld)

View File

@ -6,8 +6,7 @@ import Adwaita
@main @main
struct AdwaitaTemplate: App { struct AdwaitaTemplate: App {
let id = "io.github.AparokshaUI.AdwaitaTemplate" let app = AdwaitaApp(id: "io.github.AparokshaUI.AdwaitaTemplate")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in
@ -20,8 +19,8 @@ struct AdwaitaTemplate: App {
struct Content: View { struct Content: View {
var app: GTUIApp var app: AdwaitaApp
var window: GTUIApplicationWindow var window: AdwaitaApplicationWindow
var view: Body { var view: Body {
Button(Loc.helloWorld) { Button(Loc.helloWorld) {

View File

@ -6,8 +6,7 @@ import Adwaita
@main @main
struct AdwaitaTemplate: App { struct AdwaitaTemplate: App {
let id = "io.github.AparokshaUI.AdwaitaTemplate" let app = AdwaitaApp(id: "io.github.AparokshaUI.AdwaitaTemplate")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in
@ -21,8 +20,8 @@ struct AdwaitaTemplate: App {
struct Content: View { struct Content: View {
@State private var startAlign = false @State private var startAlign = false
var app: GTUIApp var app: AdwaitaApp
var window: GTUIApplicationWindow var window: AdwaitaApplicationWindow
var view: Body { var view: Body {
Button("Toggle Start Alignment") { Button("Toggle Start Alignment") {

View File

@ -6,8 +6,7 @@ import Adwaita
@main @main
struct AdwaitaTemplate: App { struct AdwaitaTemplate: App {
let id = "io.github.AparokshaUI.AdwaitaTemplate" let app = AdwaitaApp(id: "io.github.AparokshaUI.AdwaitaTemplate")
var app: GTUIApp!
var scene: Scene { var scene: Scene {
Window(id: "main") { window in Window(id: "main") { window in
@ -21,8 +20,8 @@ struct AdwaitaTemplate: App {
struct Content: View { struct Content: View {
@State private var startAlign = false @State private var startAlign = false
var app: GTUIApp var app: AdwaitaApp
var window: GTUIApplicationWindow var window: AdwaitaApplicationWindow
var view: Body { var view: Body {
ButtonView(startAlign: $startAlign) ButtonView(startAlign: $startAlign)

View File

@ -16,7 +16,7 @@
@Image(source: "ChangeDirectory.png", alt: "The GNOME Console app.") @Image(source: "ChangeDirectory.png", alt: "The GNOME Console app.")
} }
@Step { @Step {
Clone the template repository into the `Subtasks` directory using `git clone https://github.com/AparokshaUI/AdwaitaTemplate Subtasks`. Clone the template repository into the `Subtasks` directory using `git clone https://git.aparoksha.dev/aparoksha/adwaita-template Subtasks`.
@Image(source: "CloneTemplateSubtasks.png", alt: "The GNOME Console app.") @Image(source: "CloneTemplateSubtasks.png", alt: "The GNOME Console app.")
} }
@Step { @Step {

View File

@ -1,9 +0,0 @@
@Article {
@Intro(title: "About Flatpak") {
In the previous tutorial, you have named various files required for distributing apps via Flatpak.
}
@
}

View File

@ -34,7 +34,7 @@
@Image(source: "ChangeDirectory.png", alt: "The GNOME Console app.") @Image(source: "ChangeDirectory.png", alt: "The GNOME Console app.")
} }
@Step { @Step {
Clone the template repository into the `HelloWorld` directory using `git clone https://github.com/AparokshaUI/AdwaitaTemplate HelloWorld`. Clone the template repository into the `HelloWorld` directory using `git clone https://git.aparoksha.dev/aparoksha/adwaita-template HelloWorld`.
This creates a directory `HelloWorld` containing the content of the [Adwaita Template](https://github.com/AparokshaUI/AdwaitaTemplate). This creates a directory `HelloWorld` containing the content of the [Adwaita Template](https://github.com/AparokshaUI/AdwaitaTemplate).
@Image(source: "GitClone.png", alt: "The GNOME Console app.") @Image(source: "GitClone.png", alt: "The GNOME Console app.")

View File

@ -22,7 +22,7 @@
A window contains _views_. A window contains _views_.
You can call other views inside of views (such as the ``Text`` or `ToolbarView` in this example). You can call other views inside of views (such as the ``Text`` or `ToolbarView` in this example).
Methods like ``View/padding(_:_:)`` and ``View/topToolbar(visible:_:)`` often used to tweak views or wrap views into other views (you'll get more familiar with them soon). Methods like ``AnyView/padding(_:_:)`` and ``AnyView/topToolbar(visible:_:)`` are often used to tweak views or wrap views into other views (you'll get more familiar with them soon).
@Code(name: "AdwaitaTemplate.swift", file: "AdwaitaTemplate1.swift") @Code(name: "AdwaitaTemplate.swift", file: "AdwaitaTemplate1.swift")
} }
@Step { @Step {
@ -73,7 +73,7 @@
@Binding var section: String @Binding var section: String
@State private var title = "Title" @State private var title = "Title"
var app: GTUIApp var app: AdwaitaApp
var view: Body { var view: Body {
... ...

View File

@ -1,14 +1,14 @@
@Article { @Article {
@Intro(title: "The GNOME project") { @Intro(title: "The GNOME Project") {
Learn about the GNOME project and how you can get involved. Learn about the GNOME Project and how you can get involved.
} }
@ContentAndMedia { @ContentAndMedia {
# GNOME shell # GNOME shell
The GNOME shell is a popular open-source desktop environment for Linux. The GNOME shell is a popular open source desktop environment for Linux.
There is a vast app ecosystem built using its modern Adwaita design language, enabling a unique consistency across the platform. There is a vast app ecosystem built using its modern Adwaita design language, enabling a unique consistency across the platform.
GNOME apps follow strictly the philosophy "do one thing and do it well", and using them requires little technical knowledge. GNOME apps strictly follow the philosophy "do one thing and do it well", and using them requires little technical knowledge.
You can find more information in the [GNOME Human Interface Guidelines](https://developer.gnome.org/hig/index.html). You can find more information in the [GNOME Human Interface Guidelines](https://developer.gnome.org/hig/index.html).
![The GNOME desktop environment showing some apps.](Screenshot.png) ![The GNOME desktop environment showing some apps.](Screenshot.png)
@ -17,7 +17,7 @@
@ContentAndMedia { @ContentAndMedia {
# Adwaita # Adwaita
Adwaita is not only a design language, but a [C API](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/) providing user interface elements, so called _widgets_, for native GNOME apps, built on top of the powerful [GTK widget toolkit](https://docs.gtk.org/gtk4/). Adwaita is not only a design language, but a [C API](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/) providing user interface elements, so called _widgets_, for native GNOME apps, built on top of the powerful [GTK widget toolkit](https://docs.gtk.org/gtk4/).
It offers various UI elements that support pointer, touch, and keyboard out of the box, and allows the creation of accessible apps without further configuration. It offers various UI elements that support pointer, touch, and keyboard input out of the box, and allows the creation of accessible apps without further configuration.
There are modern controls, containers, navigation design patterns and elements for visual feedback, working great on different types of screens, including phones. There are modern controls, containers, navigation design patterns and elements for visual feedback, working great on different types of screens, including phones.
} }

View File

@ -11,7 +11,7 @@
@Steps { @Steps {
@Step { @Step {
Install [Asahi Linux](https://asahilinux.org/) by running the following command into a macOS terminal: **`curl https://alx.sh | sh`** Install [Asahi Linux](https://asahilinux.org/) by running the following command in a macOS terminal: **`curl https://alx.sh | sh`**
Follow the instructions until you get to the OS selection. Follow the instructions until you get to the OS selection.
@Image(source: "Asahi.svg", alt: "A laptop showing the Asahi logo.") @Image(source: "Asahi.svg", alt: "A laptop showing the Asahi logo.")

View File

@ -12,18 +12,18 @@
@Steps { @Steps {
@Step { @Step {
You can see how creating an array in Swift with the content `[5, 10, 2, 3]` is done. You can see how creating an array in Swift with the content `[5, 10, 2, 3]` is done.
@Code(name: "main.swift", file: "Array1.swift") @Code(name: "main.swift", file: "Array1D.swift")
} }
@Step { @Step {
Let's assume Swift wouldn't offer this convenient syntax - how would you create the same array starting from an empty array? Let's assume Swift wouldn't offer this convenient syntax - how would you create the same array starting from an empty array?
@Code(name: "main.swift", file: "Array2.swift") @Code(name: "main.swift", file: "Array2D.swift")
} }
@Step { @Step {
The `append(_:)` function could be used for example. The `append(_:)` function could be used for example.
In this code, it gets clearer _how_ the result of having the array in the memory is accomplished, but one would have to mentally follow the commands to construct the _what_. In this code, it gets clearer _how_ the result of having the array in the memory is accomplished, but one would have to mentally follow the commands to construct the _what_.
Therefore, this code is more on the imperative side compared to the initial code example being rather on the declarative side. Therefore, this code is more on the imperative side compared to the initial code example being rather on the declarative side.
@Code(name: "main.swift", file: "Array3.swift") @Code(name: "main.swift", file: "Array3D.swift")
} }
} }
} }

View File

@ -117,7 +117,7 @@
} }
} }
@Step { @Step {
Then, add the ``View/aboutDialog(visible:app:developer:version:icon:website:issues:)`` modifier. Then, add the ``AnyView/aboutDialog(visible:app:developer:version:icon:website:issues:)`` modifier.
@Code(name: "TaskList.swift", file: "TaskList34.swift", previousFile: "TaskList33.swift") { @Code(name: "TaskList.swift", file: "TaskList34.swift", previousFile: "TaskList33.swift") {
@Image(source: "Localized7.png", alt: "The window.") @Image(source: "Localized7.png", alt: "The window.")
} }

View File

@ -30,7 +30,7 @@
@Step { @Step {
Add the ``NavigationView``. Add the ``NavigationView``.
`destination` is of the type ``NavigationStack``, which means that it stores the navigation path. `destination` is of the type ``NavigationView/NavigationStack``, which means that it stores the navigation path.
If the path is empty, the `initialView` will be presented, otherwise, line 16 will be visible for the last element in the path which is of the type `Task`. If the path is empty, the `initialView` will be presented, otherwise, line 16 will be visible for the last element in the path which is of the type `Task`.
@Code(name: "ContentView.swift", file: "ContentView3.swift") { @Code(name: "ContentView.swift", file: "ContentView3.swift") {
@Image(source: "TaskList15.png", alt: "The window.") @Image(source: "TaskList15.png", alt: "The window.")
@ -52,7 +52,7 @@
@Step { @Step {
In the task list view, add the destination binding parameter and implement the navigation. In the task list view, add the destination binding parameter and implement the navigation.
You can navigate using ``NavigationStack/push(_:)`` and ``NavigationStack/pop()``. You can navigate using ``NavigationView/NavigationStack/push(_:)`` and ``NavigationView/NavigationStack/pop()``.
@Code(name: "TaskList.swift", file: "TaskList23.swift", previousFile: "TaskList22.swift") { @Code(name: "TaskList.swift", file: "TaskList23.swift", previousFile: "TaskList22.swift") {
@Image(source: "TaskList15.png", alt: "The window.") @Image(source: "TaskList15.png", alt: "The window.")
} }