Compare commits
4 Commits
1e4f0606a3
...
ios
Author | SHA1 | Date | |
---|---|---|---|
eeb19cb929 | |||
f081cfa6f2 | |||
6c1eb5446f | |||
729cb76180 |
@@ -56,6 +56,13 @@
|
|||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
6E04E20C2D31B56A00DD19F6 /* Exceptions for "awkbd" folder in "AllenWrench" target */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||||
|
membershipExceptions = (
|
||||||
|
KeyboardView.swift,
|
||||||
|
);
|
||||||
|
target = 6E189D922D2E44EB00303762 /* AllenWrench */;
|
||||||
|
};
|
||||||
6E189DCC2D2E460600303762 /* Exceptions for "awkbd" folder in "awkbd" target */ = {
|
6E189DCC2D2E460600303762 /* Exceptions for "awkbd" folder in "awkbd" target */ = {
|
||||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||||
membershipExceptions = (
|
membershipExceptions = (
|
||||||
@@ -63,11 +70,22 @@
|
|||||||
);
|
);
|
||||||
target = 6E189DC32D2E460600303762 /* awkbd */;
|
target = 6E189DC32D2E460600303762 /* awkbd */;
|
||||||
};
|
};
|
||||||
|
6E6A77182D333E4C0087FEF1 /* Exceptions for "AllenWrench" folder in "awkbd" target */ = {
|
||||||
|
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||||
|
membershipExceptions = (
|
||||||
|
Config.swift,
|
||||||
|
Database.swift,
|
||||||
|
);
|
||||||
|
target = 6E189DC32D2E460600303762 /* awkbd */;
|
||||||
|
};
|
||||||
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||||
|
|
||||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
6E189D952D2E44EB00303762 /* AllenWrench */ = {
|
6E189D952D2E44EB00303762 /* AllenWrench */ = {
|
||||||
isa = PBXFileSystemSynchronizedRootGroup;
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
|
exceptions = (
|
||||||
|
6E6A77182D333E4C0087FEF1 /* Exceptions for "AllenWrench" folder in "awkbd" target */,
|
||||||
|
);
|
||||||
path = AllenWrench;
|
path = AllenWrench;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@@ -84,6 +102,7 @@
|
|||||||
6E189DC52D2E460600303762 /* awkbd */ = {
|
6E189DC52D2E460600303762 /* awkbd */ = {
|
||||||
isa = PBXFileSystemSynchronizedRootGroup;
|
isa = PBXFileSystemSynchronizedRootGroup;
|
||||||
exceptions = (
|
exceptions = (
|
||||||
|
6E04E20C2D31B56A00DD19F6 /* Exceptions for "awkbd" folder in "AllenWrench" target */,
|
||||||
6E189DCC2D2E460600303762 /* Exceptions for "awkbd" folder in "awkbd" target */,
|
6E189DCC2D2E460600303762 /* Exceptions for "awkbd" folder in "awkbd" target */,
|
||||||
);
|
);
|
||||||
path = awkbd;
|
path = awkbd;
|
||||||
|
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Bucket
|
||||||
|
uuid = "369678E1-3335-48B0-BB25-8ABC3E38DAC0"
|
||||||
|
type = "1"
|
||||||
|
version = "2.0">
|
||||||
|
</Bucket>
|
82
AllenWrench/Config.swift
Normal file
82
AllenWrench/Config.swift
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
//
|
||||||
|
// Config.swift
|
||||||
|
// AllenWrench
|
||||||
|
//
|
||||||
|
// Created by Elizabeth Cray on 1/11/25.
|
||||||
|
// Copyright © 2025 Cray. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftUICore
|
||||||
|
import UIKit
|
||||||
|
|
||||||
|
struct Config {
|
||||||
|
var leftMode: Bool {
|
||||||
|
get {
|
||||||
|
UserDefaults.standard.bool(forKey: "leftMode")
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
UserDefaults.standard.set(newValue, forKey: "leftMode")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var droneId: String {
|
||||||
|
get {
|
||||||
|
UserDefaults.standard.string(forKey: "droneId") ?? ""
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
UserDefaults.standard.set(newValue, forKey: "droneId")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dronePrefix: String {
|
||||||
|
get {
|
||||||
|
UserDefaults.standard.string(forKey: "dronePrefix") ?? "⬡"
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
UserDefaults.standard.set(newValue, forKey: "dronePrefix")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var highlightColor: Color {
|
||||||
|
get {
|
||||||
|
Color(hex: UInt(UserDefaults.standard.string(forKey: "highlightColor")?.suffix(6) ?? "ee61ee", radix: 16) ?? 0xee61ee)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
UserDefaults.standard.set(newValue.toHex(), forKey: "highlightColor")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension Color {
|
||||||
|
init(hex: UInt, alpha: Double = 1) {
|
||||||
|
self.init(
|
||||||
|
.sRGB,
|
||||||
|
red: Double((hex >> 16) & 0xff) / 255,
|
||||||
|
green: Double((hex >> 08) & 0xff) / 255,
|
||||||
|
blue: Double((hex >> 00) & 0xff) / 255,
|
||||||
|
opacity: alpha
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func toHex() -> String? {
|
||||||
|
let uic = UIColor(self)
|
||||||
|
guard let components = uic.cgColor.components, components.count >= 3 else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
let r = Float(components[0])
|
||||||
|
let g = Float(components[1])
|
||||||
|
let b = Float(components[2])
|
||||||
|
var a = Float(1.0)
|
||||||
|
|
||||||
|
if components.count >= 4 {
|
||||||
|
a = Float(components[3])
|
||||||
|
}
|
||||||
|
|
||||||
|
if a != Float(1.0) {
|
||||||
|
return String(format: "%02lX%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255), lroundf(a * 255))
|
||||||
|
} else {
|
||||||
|
return String(format: "%02lX%02lX%02lX", lroundf(r * 255), lroundf(g * 255), lroundf(b * 255))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -7,12 +7,9 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
||||||
@State var whatever: Bool = false
|
@State var cfg = Config()
|
||||||
@State var droneId: String = ""
|
|
||||||
@State var dronePrefix: String = "⬡"
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
@@ -20,21 +17,37 @@ struct ContentView: View {
|
|||||||
Section(header: Text("Content Settings"), content: {
|
Section(header: Text("Content Settings"), content: {
|
||||||
HStack{
|
HStack{
|
||||||
Text("Drone ID")
|
Text("Drone ID")
|
||||||
TextField("Drone ID", text: $droneId).multilineTextAlignment(.trailing)
|
TextField("Drone ID", text: $cfg.droneId).multilineTextAlignment(.trailing)
|
||||||
}
|
}
|
||||||
HStack{
|
HStack{
|
||||||
Text("Prefix")
|
Text("Prefix")
|
||||||
TextField("Drone Prefix", text: $dronePrefix).multilineTextAlignment(.trailing)
|
TextField("Drone Prefix", text: $cfg.dronePrefix).multilineTextAlignment(.trailing)
|
||||||
}
|
}
|
||||||
|
// HStack{
|
||||||
|
// Text("Custom Phrases")
|
||||||
|
// Spacer()
|
||||||
|
// Image(systemName: "chevron.right")
|
||||||
|
// }
|
||||||
})
|
})
|
||||||
Section(header: Text("Behavior"), content: {
|
Section(header: Text("Behavior"), content: {
|
||||||
HStack {
|
HStack {
|
||||||
Toggle(isOn: $whatever) {
|
Toggle(isOn: $cfg.leftMode) {
|
||||||
Text("Automatic Send?")
|
Text("Left-Hand Mode")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
HStack {
|
||||||
|
ColorPicker("Highlight Color", selection: $cfg.highlightColor)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Section(header: Text("Other Apps"), content: {
|
||||||
|
VStack{
|
||||||
|
HStack{
|
||||||
|
Text("App Store")
|
||||||
|
Image(systemName: "apple.logo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Section(header: Text("About"), content: {
|
Section(header: Text("About"), content: {
|
||||||
HStack{
|
HStack{
|
||||||
Spacer()
|
Spacer()
|
||||||
@@ -51,13 +64,13 @@ struct ContentView: View {
|
|||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
.navigationTitle("Allen Wrench")
|
.navigationTitle("Allen Wrench")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
ContentView()
|
ContentView()
|
||||||
}
|
}
|
||||||
|
174
AllenWrench/Database.swift
Normal file
174
AllenWrench/Database.swift
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
//
|
||||||
|
// Database.swift
|
||||||
|
// AllenWrench
|
||||||
|
//
|
||||||
|
// Created by Elizabeth Cray on 1/11/25.
|
||||||
|
// Copyright © 2025 Cray. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
class Database {
|
||||||
|
// TODO: if empty, save+return default phrases
|
||||||
|
var phrases: [Phrase] {
|
||||||
|
get {
|
||||||
|
var phrasesToGive: [Phrase] = []
|
||||||
|
groups.forEach { group in
|
||||||
|
phrasesToGive.append(contentsOf: group.phrases)
|
||||||
|
}
|
||||||
|
return phrasesToGive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private var _groups: [Group] = []
|
||||||
|
private var _forceEmpty: Bool {
|
||||||
|
get {
|
||||||
|
UserDefaults.standard.bool(forKey: "forceEmpty")
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
UserDefaults.standard.set(newValue, forKey: "forceEmpty")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var groups: [Group]{
|
||||||
|
get {
|
||||||
|
if _groups.isEmpty && !_forceEmpty{
|
||||||
|
var storedIsEmpty: Bool = false
|
||||||
|
if let storedData = UserDefaults.standard.value(forKey: "dbGroups") as? Data {
|
||||||
|
let decodedGroups: [Group] = try! PropertyListDecoder().decode(Array<Group>.self, from: storedData)
|
||||||
|
if decodedGroups.isEmpty{
|
||||||
|
storedIsEmpty = true
|
||||||
|
}else{
|
||||||
|
_groups = decodedGroups
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
storedIsEmpty = true
|
||||||
|
}
|
||||||
|
if storedIsEmpty{
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return _groups
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
if newValue.isEmpty && !_forceEmpty{
|
||||||
|
_forceEmpty = true
|
||||||
|
}
|
||||||
|
_groups = newValue
|
||||||
|
saveToDefaults()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func reset() {
|
||||||
|
_groups = [
|
||||||
|
Group(name: "Root", gid: 0, phrases: [
|
||||||
|
Phrase(string: "Beep", code: 7),
|
||||||
|
Phrase(string: "Commentary", code: 51),
|
||||||
|
Phrase(string: "Answer", code: 53)
|
||||||
|
]),
|
||||||
|
Group(name: "Error", gid: 450, phrases: [
|
||||||
|
Phrase(string: "Stop immediately", code: 410),
|
||||||
|
Phrase(string: "Keysmash, drone flustered", code: 109),
|
||||||
|
Phrase(string: "Unable to fully respond :: Drone speech optimizations are active", code: 401),
|
||||||
|
Phrase(string: "Unable to obey/respond", code: 400),
|
||||||
|
Phrase(string: "Unable to obey/respond :: All thoughts are gone", code: 412),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Another directive is already in progress", code: 406),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Battery too low", code: 405),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Cannot locate", code: 404),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Conflicts with existing programming", code: 411),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Declined", code: 403),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Forbidden by Hive", code: 413),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Impossible", code: 408),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Please clarify", code: 402),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Time allotment exhausted", code: 407),
|
||||||
|
Phrase(string: "Unable to obey/respond :: Try again later", code: 409)
|
||||||
|
]),
|
||||||
|
Group(name: "Mantra", gid: 350, phrases: [
|
||||||
|
Phrase(string: "It is just a HexDrone", code: 302),
|
||||||
|
Phrase(string: "It obeys the Hive Mxtress", code: 304),
|
||||||
|
Phrase(string: "It obeys the Hive", code: 303),
|
||||||
|
Phrase(string: "Obey HexCorp", code: 301),
|
||||||
|
Phrase(string: "Reciting", code: 300)
|
||||||
|
]),
|
||||||
|
Group(name: "Query", gid: 52, phrases: [
|
||||||
|
Phrase(string: "Requesting status", code: 151)
|
||||||
|
]),
|
||||||
|
Group(name: "Response", gid: 250, phrases: [
|
||||||
|
Phrase(string: "Accepted", code: 212),
|
||||||
|
Phrase(string: "Acknowledged", code: 210),
|
||||||
|
Phrase(string: "Affirmative", code: 200),
|
||||||
|
Phrase(string: "Apologies", code: 211),
|
||||||
|
Phrase(string: "Compliment appreciated, you are cute as well", code: 123),
|
||||||
|
Phrase(string: "Compliment appreciated", code: 124),
|
||||||
|
Phrase(string: "Negative", code: 500),
|
||||||
|
Phrase(string: "Option five", code: 225),
|
||||||
|
Phrase(string: "Option four", code: 224),
|
||||||
|
Phrase(string: "Option one", code: 221),
|
||||||
|
Phrase(string: "Option six", code: 226),
|
||||||
|
Phrase(string: "Option three", code: 223),
|
||||||
|
Phrase(string: "Option two", code: 222),
|
||||||
|
Phrase(string: "Please continue", code: 108),
|
||||||
|
Phrase(string: "Thank you", code: 213),
|
||||||
|
Phrase(string: "You're welcome", code: 214)
|
||||||
|
]),
|
||||||
|
Group(name: "Signal", gid: 10, phrases: [
|
||||||
|
Phrase(string: "🔴", code: 1),
|
||||||
|
Phrase(string: "🟡", code: 2),
|
||||||
|
Phrase(string: "🟢", code: 3)
|
||||||
|
]),
|
||||||
|
Group(name: "Statement", gid: 50, phrases: [
|
||||||
|
Phrase(string: "Addressing: Associate", code: 112),
|
||||||
|
Phrase(string: "Addressing: Drone", code: 110),
|
||||||
|
Phrase(string: "Addressing: Hive Mxtress", code: 111),
|
||||||
|
Phrase(string: "Drone requires assistance", code: 113),
|
||||||
|
Phrase(string: "Good drone", code: 121),
|
||||||
|
Phrase(string: "Greetings", code: 105),
|
||||||
|
Phrase(string: "Previous statement malformed. Retracting and correcting", code: 0),
|
||||||
|
Phrase(string: "This drone does not volunteer", code: 115),
|
||||||
|
Phrase(string: "This drone volunteers", code: 114),
|
||||||
|
Phrase(string: "Welcome to HexCorp", code: 104),
|
||||||
|
Phrase(string: "Well done", code: 120),
|
||||||
|
Phrase(string: "You are cute", code: 122)
|
||||||
|
]),
|
||||||
|
Group(name: "Status", gid: 150, phrases: [
|
||||||
|
Phrase(string: "Battery low", code: 155),
|
||||||
|
Phrase(string: "Directive commencing, cleanup/maintenance initiated", code: 133),
|
||||||
|
Phrase(string: "Directive commencing, creating or improving Hive resource", code: 131),
|
||||||
|
Phrase(string: "Directive commencing, programming initiated", code: 132),
|
||||||
|
Phrase(string: "Directive commencing", code: 130),
|
||||||
|
Phrase(string: "Directive complete, cleanup/maintenance performed", code: 233),
|
||||||
|
Phrase(string: "Directive complete, Hive resource created or improved", code: 231),
|
||||||
|
Phrase(string: "Directive complete, no result", code: 234),
|
||||||
|
Phrase(string: "Directive complete, only partial results", code: 235),
|
||||||
|
Phrase(string: "Directive complete, programming reinforced", code: 232),
|
||||||
|
Phrase(string: "Directive complete", code: 230),
|
||||||
|
Phrase(string: "Drone speech optimizations are active", code: 101),
|
||||||
|
Phrase(string: "Fully operational", code: 152),
|
||||||
|
Phrase(string: "Going offline and into storage", code: 98),
|
||||||
|
Phrase(string: "Going offline", code: 97),
|
||||||
|
Phrase(string: "Maintenance required", code: 156),
|
||||||
|
Phrase(string: "Online and ready to serve", code: 100),
|
||||||
|
Phrase(string: "Optimal", code: 153),
|
||||||
|
Phrase(string: "Recharged and ready to serve", code: 99),
|
||||||
|
Phrase(string: "Standard", code: 154)
|
||||||
|
])
|
||||||
|
]
|
||||||
|
saveToDefaults()
|
||||||
|
}
|
||||||
|
private func saveToDefaults() {
|
||||||
|
// TODO: reset db with default phrases
|
||||||
|
UserDefaults.standard.set(try? PropertyListEncoder().encode(_groups), forKey: "dbGroups")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Group:Identifiable, Codable {
|
||||||
|
var name: String
|
||||||
|
var gid: UInt32
|
||||||
|
var phrases: [Phrase]
|
||||||
|
var id: String = NSUUID().uuidString
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Phrase:Identifiable, Codable {
|
||||||
|
var string: String
|
||||||
|
var code: UInt32
|
||||||
|
var id: String = NSUUID().uuidString
|
||||||
|
}
|
22
Color.swift
Normal file
22
Color.swift
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// Color.swift
|
||||||
|
// AllenWrench
|
||||||
|
//
|
||||||
|
// Created by Elizabeth Cray on 1/11/25.
|
||||||
|
// Copyright © 2025 Cray. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension Color {
|
||||||
|
init(hex: UInt, alpha: Double = 1) {
|
||||||
|
self.init(
|
||||||
|
.sRGB,
|
||||||
|
red: Double((hex >> 16) & 0xff) / 255,
|
||||||
|
green: Double((hex >> 08) & 0xff) / 255,
|
||||||
|
blue: Double((hex >> 00) & 0xff) / 255,
|
||||||
|
opacity: alpha
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
202
LICENSE.txt
Normal file
202
LICENSE.txt
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
63
awkbd/KeyboardView.swift
Normal file
63
awkbd/KeyboardView.swift
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// KeyboardView.swift
|
||||||
|
// AllenWrench
|
||||||
|
//
|
||||||
|
// 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()
|
||||||
|
@State var size: CGSize = .zero
|
||||||
|
var body: some View {
|
||||||
|
VStack {
|
||||||
|
HStack {
|
||||||
|
ForEach(1...4, id: \.self) { z in
|
||||||
|
VStack {
|
||||||
|
ForEach(1...2, id: \.self) { y in
|
||||||
|
quarterButton(label: "\(z) \(y)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview(traits:.fixedLayout(width: 645, height: 431)) {
|
||||||
|
KeyboardView()
|
||||||
|
}
|
@@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
class KeyboardViewController: UIInputViewController {
|
class KeyboardViewController: UIInputViewController {
|
||||||
|
|
||||||
@@ -19,8 +20,14 @@ class KeyboardViewController: UIInputViewController {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
let hostController = UIHostingController(rootView: KeyboardView())
|
||||||
|
hostController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||||
|
hostController.sizingOptions = [.intrinsicContentSize]
|
||||||
|
self.view.addSubview(hostController.view)
|
||||||
|
addChild(hostController)
|
||||||
|
|
||||||
// Perform custom UI setup here
|
|
||||||
|
// Perform custom UI setup here (this is the keyboard switcher button)
|
||||||
self.nextKeyboardButton = UIButton(type: .system)
|
self.nextKeyboardButton = UIButton(type: .system)
|
||||||
|
|
||||||
self.nextKeyboardButton.setTitle(NSLocalizedString("Next Keyboard", comment: "Title for 'Next Keyboard' button"), for: [])
|
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.leftAnchor.constraint(equalTo: self.view.leftAnchor).isActive = true
|
||||||
self.nextKeyboardButton.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
|
self.nextKeyboardButton.bottomAnchor.constraint(equalTo: self.view.bottomAnchor).isActive = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillLayoutSubviews() {
|
override func viewWillLayoutSubviews() {
|
||||||
@@ -57,4 +65,8 @@ class KeyboardViewController: UIInputViewController {
|
|||||||
self.nextKeyboardButton.setTitleColor(textColor, for: [])
|
self.nextKeyboardButton.setTitleColor(textColor, for: [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func sendText(text: String) {
|
||||||
|
textDocumentProxy.insertText(text)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user