diff --git a/MacTorn/MacTorn/Models/TornModels.swift b/MacTorn/MacTorn/Models/TornModels.swift index 6a2e6dc..0cebaba 100644 --- a/MacTorn/MacTorn/Models/TornModels.swift +++ b/MacTorn/MacTorn/Models/TornModels.swift @@ -2,23 +2,44 @@ import Foundation // MARK: - Root Response struct TornResponse: Codable { - let bars: Bars? + let energy: Bar? + let nerve: Bar? + let life: Bar? + let happy: Bar? let cooldowns: Cooldowns? let travel: Travel? let error: TornError? + + // Convenience computed property + var bars: Bars? { + guard let energy = energy, + let nerve = nerve, + let life = life, + let happy = happy else { return nil } + return Bars(energy: energy, nerve: nerve, life: life, happy: happy) + } } -// MARK: - Bars +// MARK: - Bars (for internal use) struct Bar: Codable, Equatable { let current: Int let maximum: Int - let increment: Double - let interval: Int - let ticktime: Int - let fulltime: Int + let increment: Double? + let interval: Int? + let ticktime: Int? + let fulltime: Int? + + init(current: Int, maximum: Int, increment: Double? = nil, interval: Int? = nil, ticktime: Int? = nil, fulltime: Int? = nil) { + self.current = current + self.maximum = maximum + self.increment = increment + self.interval = interval + self.ticktime = ticktime + self.fulltime = fulltime + } } -struct Bars: Codable, Equatable { +struct Bars: Equatable { let energy: Bar let nerve: Bar let life: Bar diff --git a/MacTorn/MacTorn/Views/SettingsView.swift b/MacTorn/MacTorn/Views/SettingsView.swift index 3f987f8..b5a3ef7 100644 --- a/MacTorn/MacTorn/Views/SettingsView.swift +++ b/MacTorn/MacTorn/Views/SettingsView.swift @@ -3,7 +3,6 @@ import SwiftUI struct SettingsView: View { @EnvironmentObject var appState: AppState @State private var inputKey: String = "" - @State private var showShortcutsEditor = false var body: some View { VStack(spacing: 16) { @@ -53,20 +52,6 @@ struct SettingsView: View { } .toggleStyle(.switch) .padding(.horizontal) - - // Shortcuts Editor - Button { - showShortcutsEditor.toggle() - } label: { - Label("Edit Shortcuts", systemImage: "keyboard") - } - .buttonStyle(.plain) - .foregroundColor(.accentColor) - - if showShortcutsEditor { - ShortcutsEditorView() - .environmentObject(appState) - } } .padding() .onAppear { @@ -74,106 +59,3 @@ struct SettingsView: View { } } } - -// MARK: - Shortcuts Editor -struct ShortcutsEditorView: View { - @EnvironmentObject var appState: AppState - @State private var editingShortcut: KeyboardShortcut? - - var body: some View { - VStack(alignment: .leading, spacing: 8) { - HStack { - Text("Quick Links") - .font(.caption.bold()) - - Spacer() - - Button("Reset") { - appState.shortcutsManager.resetToDefaults() - } - .font(.caption2) - .buttonStyle(.plain) - .foregroundColor(.red) - } - - ForEach(appState.shortcutsManager.shortcuts) { shortcut in - ShortcutRowView(shortcut: shortcut) { updated in - appState.shortcutsManager.updateShortcut(updated) - } - } - } - .padding() - .background(Color.gray.opacity(0.1)) - .cornerRadius(8) - } -} - -struct ShortcutRowView: View { - let shortcut: KeyboardShortcut - let onUpdate: (KeyboardShortcut) -> Void - - @State private var isEditing = false - @State private var editedName: String = "" - @State private var editedURL: String = "" - @State private var editedKey: String = "" - - var body: some View { - VStack(spacing: 4) { - HStack { - if isEditing { - TextField("Name", text: $editedName) - .textFieldStyle(.roundedBorder) - .font(.caption) - .frame(width: 60) - - TextField("URL", text: $editedURL) - .textFieldStyle(.roundedBorder) - .font(.caption2) - - TextField("Key", text: $editedKey) - .textFieldStyle(.roundedBorder) - .font(.caption) - .frame(width: 30) - - Button("Save") { - var updated = shortcut - updated.name = editedName - updated.url = editedURL - updated.keyEquivalent = editedKey - onUpdate(updated) - isEditing = false - } - .font(.caption2) - .buttonStyle(.borderedProminent) - } else { - Text(shortcut.name) - .font(.caption) - .frame(width: 60, alignment: .leading) - - Text(shortcut.url) - .font(.caption2) - .foregroundColor(.secondary) - .lineLimit(1) - .truncationMode(.middle) - - Spacer() - - Text("⌘⇧\(shortcut.keyEquivalent.uppercased())") - .font(.caption2.monospaced()) - .foregroundColor(.secondary) - - Button { - editedName = shortcut.name - editedURL = shortcut.url - editedKey = shortcut.keyEquivalent - isEditing = true - } label: { - Image(systemName: "pencil") - .font(.caption2) - } - .buttonStyle(.plain) - } - } - } - } -} diff --git a/MacTorn/MacTorn/Views/StatusView.swift b/MacTorn/MacTorn/Views/StatusView.swift index 12a348f..bc96e6b 100644 --- a/MacTorn/MacTorn/Views/StatusView.swift +++ b/MacTorn/MacTorn/Views/StatusView.swift @@ -34,7 +34,7 @@ struct StatusView: View { } .padding() } - .frame(maxHeight: 400) + .fixedSize(horizontal: false, vertical: true) } // MARK: - Header