Add CMath library + ensure it builds, links, and runs
This commit is contained in:
21
Sources/PMCalc/Localized.yml
Normal file
21
Sources/PMCalc/Localized.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
default: en
|
||||
|
||||
helloWorld:
|
||||
en: Hello, world!
|
||||
de: Hallo, Welt!
|
||||
|
||||
newWindow:
|
||||
en: New Window
|
||||
de: Neues Fenster
|
||||
|
||||
closeWindow:
|
||||
en: Close Window
|
||||
de: Fenster schliessen
|
||||
|
||||
about:
|
||||
en: About AdwaitaTemplate
|
||||
de: Info zu AdwaitaTemplate
|
||||
|
||||
mainMenu:
|
||||
en: Main Menu
|
||||
de: Hauptmenü
|
102
Sources/PMCalc/PMCalc.swift
Normal file
102
Sources/PMCalc/PMCalc.swift
Normal file
@@ -0,0 +1,102 @@
|
||||
// The Swift Programming Language
|
||||
// https://docs.swift.org/swift-book
|
||||
|
||||
import Adwaita
|
||||
import CMath
|
||||
|
||||
@main
|
||||
struct PMCalc: App {
|
||||
let app = AdwaitaApp(id: "me.thealgorithm476.PMCalc.PMCalc")
|
||||
|
||||
var scene: Scene {
|
||||
Window(id: "main") { window in
|
||||
VStack(spacing: 8) {
|
||||
Text("Calculations here...")
|
||||
.selectable(false)
|
||||
VStack(spacing: 8) {
|
||||
HStack(spacing: 8) {
|
||||
Button("AC") {}
|
||||
.keyboardShortcut("c", app: app)
|
||||
.hexpand()
|
||||
.destructive()
|
||||
Button("") {}
|
||||
.hexpand()
|
||||
.flat()
|
||||
Button("%") {}
|
||||
.keyboardShortcut("percent", app: app)
|
||||
.hexpand()
|
||||
Button("/") {}
|
||||
.keyboardShortcut("slash", app: app)
|
||||
.hexpand()
|
||||
}
|
||||
.vexpand()
|
||||
HStack(spacing: 8) {
|
||||
Button("7") {}
|
||||
.keyboardShortcut("7", app: app)
|
||||
.hexpand()
|
||||
Button("8") {}
|
||||
.keyboardShortcut("8", app: app)
|
||||
.hexpand()
|
||||
Button("9") {}
|
||||
.keyboardShortcut("9", app: app)
|
||||
.hexpand()
|
||||
Button("*") {}
|
||||
.keyboardShortcut("asterisk", app: app)
|
||||
.hexpand()
|
||||
}
|
||||
.vexpand()
|
||||
HStack(spacing: 8) {
|
||||
Button("4") {}
|
||||
.keyboardShortcut("4", app: app)
|
||||
.hexpand()
|
||||
Button("5") {}
|
||||
.keyboardShortcut("5", app: app)
|
||||
.hexpand()
|
||||
Button("6") {}
|
||||
.keyboardShortcut("6", app: app)
|
||||
.hexpand()
|
||||
Button("-") {}
|
||||
.keyboardShortcut("minus", app: app)
|
||||
.hexpand()
|
||||
}
|
||||
.vexpand()
|
||||
HStack(spacing: 8) {
|
||||
Button("1") {}
|
||||
.keyboardShortcut("1", app: app)
|
||||
.hexpand()
|
||||
Button("2") {}
|
||||
.keyboardShortcut("2", app: app)
|
||||
.hexpand()
|
||||
Button("3") {}
|
||||
.keyboardShortcut("3", app: app)
|
||||
.hexpand()
|
||||
Button("+") {}
|
||||
.keyboardShortcut("plus", app: app)
|
||||
.hexpand()
|
||||
}
|
||||
.vexpand()
|
||||
HStack(spacing: 8) {
|
||||
Button("0") {}
|
||||
.keyboardShortcut("0", app: app)
|
||||
.hexpand()
|
||||
Button("") {}
|
||||
.hexpand()
|
||||
.flat()
|
||||
Button(",") {}
|
||||
.keyboardShortcut("comma", app: app)
|
||||
.hexpand()
|
||||
Button("=") {}
|
||||
.keyboardShortcut("equal", app: app)
|
||||
.hexpand()
|
||||
}
|
||||
.vexpand()
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.topToolbar {
|
||||
ToolbarView(app: app, window: window)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
39
Sources/PMCalc/ToolbarView.swift
Normal file
39
Sources/PMCalc/ToolbarView.swift
Normal file
@@ -0,0 +1,39 @@
|
||||
import Adwaita
|
||||
|
||||
struct ToolbarView: View {
|
||||
|
||||
@State private var about = false
|
||||
var app: AdwaitaApp
|
||||
var window: AdwaitaWindow
|
||||
|
||||
var view: Body {
|
||||
HeaderBar.end {
|
||||
Menu(icon: .default(icon: .openMenu)) {
|
||||
MenuButton(Loc.newWindow, window: false) {
|
||||
app.addWindow("main")
|
||||
}
|
||||
.keyboardShortcut("n".ctrl())
|
||||
MenuButton(Loc.closeWindow) {
|
||||
window.close()
|
||||
}
|
||||
.keyboardShortcut("w".ctrl())
|
||||
MenuSection {
|
||||
MenuButton(Loc.about, window: false) {
|
||||
about = true
|
||||
}
|
||||
}
|
||||
}
|
||||
.primary()
|
||||
.tooltip(Loc.mainMenu)
|
||||
.aboutDialog(
|
||||
visible: $about,
|
||||
app: "PMCalc",
|
||||
developer: "TheAlgorithm476",
|
||||
version: "1.0",
|
||||
icon: .custom(name: "me.thealgorithm476.PMCalc.PMCalc"),
|
||||
website: .init(string: "https://repo.thealgorithm476.me/Bachelorproef/bap-poc-phase-4")!
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user