End-Of-Session: Added config/data storage with default phrases
This commit is contained in:
@@ -5,15 +5,31 @@
|
||||
// Created by Elizabeth Cray on 1/10/25.
|
||||
// Copyright © 2025 Cray. All rights reserved.
|
||||
//
|
||||
|
||||
// TODO:
|
||||
// - if touch up outside view, close Kbd
|
||||
import SwiftUI
|
||||
|
||||
struct KeyboardView: View {
|
||||
@State var db = Database()
|
||||
@State var cfg = Config()
|
||||
var body: some View {
|
||||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
|
||||
ScrollView {
|
||||
VStack {
|
||||
ForEach(db.groups) { group in
|
||||
Text(group.name)
|
||||
.foregroundColor(cfg.highlightColor)
|
||||
HStack {
|
||||
ForEach(group.phrases) { phrase in
|
||||
Text(phrase.string)
|
||||
}
|
||||
}
|
||||
}
|
||||
Button("Clear") { db.groups[1].name = NSUUID().uuidString}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
#Preview(traits:.fixedLayout(width: 645, height: 431)) {
|
||||
KeyboardView()
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
class KeyboardViewController: UIInputViewController {
|
||||
|
||||
@@ -20,7 +21,13 @@ class KeyboardViewController: UIInputViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
// Perform custom UI setup here
|
||||
let hostController = UIHostingController(rootView: KeyboardView())
|
||||
hostController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
self.view.addSubview(hostController.view)
|
||||
addChild(hostController)
|
||||
|
||||
|
||||
// Perform custom UI setup here (this is the keyboard switcher button)
|
||||
self.nextKeyboardButton = UIButton(type: .system)
|
||||
|
||||
self.nextKeyboardButton.setTitle(NSLocalizedString("Next Keyboard", comment: "Title for 'Next Keyboard' button"), for: [])
|
||||
@@ -33,6 +40,7 @@ class KeyboardViewController: UIInputViewController {
|
||||
|
||||
self.nextKeyboardButton.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
|
||||
self.nextKeyboardButton.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
|
||||
|
||||
}
|
||||
|
||||
override func viewWillLayoutSubviews() {
|
||||
|
Reference in New Issue
Block a user