mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-26 09:37:40 +00:00
81 lines
2.2 KiB
Swift
81 lines
2.2 KiB
Swift
/*
|
|
* Keyman is copyright (C) SIL Global. MIT License.
|
|
*
|
|
* Created by Shawn Schantz on 2026-02-26
|
|
*
|
|
* Main view used for configuring Keyman
|
|
*/
|
|
|
|
import SwiftUI
|
|
import KeymanSettings
|
|
|
|
struct ConfigView: View {
|
|
@EnvironmentObject var settings: SettingsContainer
|
|
@State private var isShowingSheet = false
|
|
|
|
var body: some View {
|
|
VStack {
|
|
HStack {
|
|
Image(systemName: "keyboard")
|
|
.imageScale(.large)
|
|
.foregroundColor(.accentColor)
|
|
Text("keyboard count = \(settings.installedPackages.count)")
|
|
Button("debug") {
|
|
settings.debug()
|
|
}
|
|
Button("log defaults") {
|
|
settings.logUserDefaults()
|
|
}
|
|
Button("clear defaults") {
|
|
settings.clearUserDefaults()
|
|
}
|
|
Button("install keyboard") {
|
|
isShowingSheet = true
|
|
}
|
|
Spacer()
|
|
}
|
|
.padding()
|
|
.frame(width: 700, height: 100)
|
|
// Binds the visibility state to the sheet builder
|
|
.sheet(isPresented: $isShowingSheet) {
|
|
InstallKeyboardView()
|
|
.presentationDetents([.medium, .large])
|
|
.frame(width: 700, height: 500)
|
|
}
|
|
|
|
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
ForEach(Array(settings.installedPackages.enumerated()), id: \.offset) { index, package in
|
|
VStack {
|
|
HStack(alignment: .center, spacing: 10) {
|
|
Text(package.packageName)
|
|
.font(.headline)
|
|
Text(package.packageVersion)
|
|
.font(.subheadline)
|
|
// Example of Icon-Only Button
|
|
Spacer()
|
|
Button(action: {
|
|
settings.removePackage(at: index)
|
|
}) {
|
|
Label("remove", systemImage: "trash.fill")
|
|
}
|
|
.labelStyle(.iconOnly)
|
|
.buttonStyle(.borderless)
|
|
}
|
|
KeyboardListView(packageId: package.id, keyboards: package.keyboards)
|
|
}
|
|
}
|
|
}
|
|
.padding(.trailing, 25) // allow space for scroll bar
|
|
}
|
|
}
|
|
.padding()
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
let settings = SettingsContainer()
|
|
ConfigView()
|
|
.environmentObject(settings)
|
|
}
|