Initial Commit

This commit is contained in:
david-swift
2023-11-26 22:16:54 +01:00
commit 2a9afb060d
12 changed files with 4044 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
// The Swift Programming Language
// https://docs.swift.org/swift-book
import Adwaita
@main
struct AdwaitaTemplate: App {
let id = "io.github.AparokshaUI.AdwaitaTemplate"
var app: GTUIApp!
var scene: Scene {
Window(id: "main") { window in
Text("Hello, world!")
.padding()
.topToolbar {
ToolbarView(app: app, window: window)
}
.onAppear {
window.setDefaultSize(width: 450, height: 300)
}
}
}
}

29
Sources/ToolbarView.swift Normal file
View File

@@ -0,0 +1,29 @@
import Adwaita
struct ToolbarView: View {
var app: GTUIApp
var window: GTUIApplicationWindow
var view: Body {
HeaderBar.end {
Menu(icon: .default(icon: .openMenu), app: app, window: window) {
MenuButton("New Window", window: false) {
app.addWindow("main")
}
.keyboardShortcut("n".ctrl())
MenuButton("Close Window") {
window.close()
}
.keyboardShortcut("w".ctrl())
MenuSection {
MenuButton("Quit", window: false) {
app.quit()
}
.keyboardShortcut("q".ctrl())
}
}
}
}
}