End-Of-Session: Created keyboard grid array
This commit is contained in:
parent
f081cfa6f2
commit
eeb19cb929
@ -12,7 +12,7 @@
|
|||||||
<key>awkbd.xcscheme_^#shared#^_</key>
|
<key>awkbd.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>1</integer>
|
<integer>0</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -8,14 +8,6 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
//struct Database {
|
|
||||||
// var groups: [String]
|
|
||||||
// var phrases: [Phrase]
|
|
||||||
// var phrasesByGroup(group: String): [Phrase] = {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
// TODO: if empty, save+return default phrases
|
// TODO: if empty, save+return default phrases
|
||||||
var phrases: [Phrase] {
|
var phrases: [Phrase] {
|
||||||
|
@ -7,26 +7,54 @@
|
|||||||
//
|
//
|
||||||
// TODO:
|
// TODO:
|
||||||
// - if touch up outside view, close Kbd
|
// - if touch up outside view, close Kbd
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct KeyboardView: View {
|
struct KeyboardView: View {
|
||||||
@State var db = Database()
|
@State var db = Database()
|
||||||
@State var cfg = Config()
|
@State var cfg = Config()
|
||||||
|
@State var size: CGSize = .zero
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
VStack {
|
||||||
VStack {
|
HStack {
|
||||||
ForEach(db.groups) { group in
|
ForEach(1...4, id: \.self) { z in
|
||||||
Text(group.name)
|
VStack {
|
||||||
.foregroundColor(cfg.highlightColor)
|
ForEach(1...2, id: \.self) { y in
|
||||||
HStack {
|
quarterButton(label: "\(z) \(y)")
|
||||||
ForEach(group.phrases) { phrase in
|
|
||||||
Text(phrase.string)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button("Clear") { db.groups[1].name = NSUUID().uuidString}
|
}
|
||||||
|
HStack {
|
||||||
|
ForEach(1...3, id: \.self) { z in
|
||||||
|
VStack {
|
||||||
|
ForEach(1...2, id: \.self) { y in
|
||||||
|
quarterButton(label: "\(z) \(y)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VStack {
|
||||||
|
quarterButton(label: "RET")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GeometryReader { proxy in
|
||||||
|
HStack {} // just an empty container to triggers the onAppear
|
||||||
|
.onAppear {
|
||||||
|
size = proxy.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func quarterButton(label: any StringProtocol) -> some View {
|
||||||
|
Button (label) {
|
||||||
|
|
||||||
|
}
|
||||||
|
.border(cfg.highlightColor)
|
||||||
|
.frame(
|
||||||
|
width: round(size.width/4),
|
||||||
|
height: round(size.height/4)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,9 @@ class KeyboardViewController: UIInputViewController {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
let hostController = UIHostingController(rootView: KeyboardView())
|
let hostController = UIHostingController(rootView: KeyboardView())
|
||||||
hostController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
hostController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||||
|
hostController.sizingOptions = [.intrinsicContentSize]
|
||||||
self.view.addSubview(hostController.view)
|
self.view.addSubview(hostController.view)
|
||||||
addChild(hostController)
|
addChild(hostController)
|
||||||
|
|
||||||
@ -64,5 +64,9 @@ class KeyboardViewController: UIInputViewController {
|
|||||||
}
|
}
|
||||||
self.nextKeyboardButton.setTitleColor(textColor, for: [])
|
self.nextKeyboardButton.setTitleColor(textColor, for: [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendText(text: String) {
|
||||||
|
textDocumentProxy.insertText(text)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user