178 lines
4.7 KiB
Plaintext
178 lines
4.7 KiB
Plaintext
import SwiftUI
|
|
|
|
@main
|
|
struct WorkbenchReplacementApp: App {
|
|
@StateObject private var model = DatabaseModel()
|
|
|
|
var body: some Scene {
|
|
WindowGroup("Workbench Replacement") {
|
|
MainView()
|
|
.environmentObject(model)
|
|
.frame(minWidth: 1000, minHeight: 650)
|
|
}
|
|
.commands {
|
|
CommandGroup(replacing: .newItem) {}
|
|
}
|
|
|
|
|
|
Settings {
|
|
WorkbenchSettingsView()
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - Application Preferences
|
|
|
|
@MainActor
|
|
final class WorkbenchPreferences: ObservableObject {
|
|
static let shared = WorkbenchPreferences()
|
|
|
|
@AppStorage("preferences.editorFontSize")
|
|
var editorFontSize = 13.0
|
|
|
|
@AppStorage("preferences.uppercaseKeywords")
|
|
var uppercaseKeywords = true
|
|
|
|
@AppStorage("preferences.showLineNumbers")
|
|
var showLineNumbers = true
|
|
|
|
@AppStorage("preferences.tabWidth")
|
|
var tabWidth = 4
|
|
|
|
@AppStorage("preferences.resultRowHeight")
|
|
var resultRowHeight = 24.0
|
|
|
|
@AppStorage("preferences.resultColumnWidth")
|
|
var resultColumnWidth = 170.0
|
|
|
|
@AppStorage("preferences.alternatingRows")
|
|
var alternatingRows = true
|
|
|
|
@AppStorage("preferences.appearance")
|
|
var appearance = "light"
|
|
|
|
@AppStorage("preferences.autoExpandTables")
|
|
var autoExpandTables = true
|
|
}
|
|
|
|
struct WorkbenchSettingsView: View {
|
|
@AppStorage("preferences.editorFontSize")
|
|
private var editorFontSize = 13.0
|
|
|
|
@AppStorage("preferences.uppercaseKeywords")
|
|
private var uppercaseKeywords = true
|
|
|
|
@AppStorage("preferences.showLineNumbers")
|
|
private var showLineNumbers = true
|
|
|
|
@AppStorage("preferences.tabWidth")
|
|
private var tabWidth = 4
|
|
|
|
@AppStorage("preferences.resultRowHeight")
|
|
private var resultRowHeight = 24.0
|
|
|
|
@AppStorage("preferences.resultColumnWidth")
|
|
private var resultColumnWidth = 170.0
|
|
|
|
@AppStorage("preferences.alternatingRows")
|
|
private var alternatingRows = true
|
|
|
|
@AppStorage("preferences.appearance")
|
|
private var appearance = "light"
|
|
|
|
@AppStorage("preferences.autoExpandTables")
|
|
private var autoExpandTables = true
|
|
|
|
var body: some View {
|
|
TabView {
|
|
Form {
|
|
HStack {
|
|
Text("Editor Font Size")
|
|
Spacer()
|
|
Stepper(
|
|
"\(Int(editorFontSize)) pt",
|
|
value: $editorFontSize,
|
|
in: 10...24,
|
|
step: 1
|
|
)
|
|
.frame(width: 130)
|
|
}
|
|
|
|
Toggle(
|
|
"Automatically uppercase SQL keywords",
|
|
isOn: $uppercaseKeywords
|
|
)
|
|
|
|
Toggle(
|
|
"Show line numbers",
|
|
isOn: $showLineNumbers
|
|
)
|
|
|
|
Picker("Tab Width", selection: $tabWidth) {
|
|
Text("2 spaces").tag(2)
|
|
Text("4 spaces").tag(4)
|
|
Text("8 spaces").tag(8)
|
|
}
|
|
}
|
|
.padding(20)
|
|
.tabItem {
|
|
Label("SQL Editor", systemImage: "chevron.left.forwardslash.chevron.right")
|
|
}
|
|
|
|
Form {
|
|
HStack {
|
|
Text("Result Row Height")
|
|
Spacer()
|
|
Stepper(
|
|
"\(Int(resultRowHeight)) px",
|
|
value: $resultRowHeight,
|
|
in: 18...40,
|
|
step: 1
|
|
)
|
|
.frame(width: 130)
|
|
}
|
|
|
|
HStack {
|
|
Text("Default Column Width")
|
|
Spacer()
|
|
Stepper(
|
|
"\(Int(resultColumnWidth)) px",
|
|
value: $resultColumnWidth,
|
|
in: 80...400,
|
|
step: 10
|
|
)
|
|
.frame(width: 140)
|
|
}
|
|
|
|
Toggle(
|
|
"Alternating row colours",
|
|
isOn: $alternatingRows
|
|
)
|
|
}
|
|
.padding(20)
|
|
.tabItem {
|
|
Label("Result Grid", systemImage: "tablecells")
|
|
}
|
|
|
|
Form {
|
|
Picker("Appearance", selection: $appearance) {
|
|
Text("Light").tag("light")
|
|
Text("Dark").tag("dark")
|
|
Text("System").tag("system")
|
|
}
|
|
|
|
Toggle(
|
|
"Automatically expand table folders",
|
|
isOn: $autoExpandTables
|
|
)
|
|
}
|
|
.padding(20)
|
|
.tabItem {
|
|
Label("General", systemImage: "gearshape")
|
|
}
|
|
}
|
|
.frame(width: 560, height: 330)
|
|
}
|
|
}
|