diff --git a/MacTorn/MacTorn/Models/TornModels.swift b/MacTorn/MacTorn/Models/TornModels.swift index 0cebaba..5dc1b54 100644 --- a/MacTorn/MacTorn/Models/TornModels.swift +++ b/MacTorn/MacTorn/Models/TornModels.swift @@ -2,6 +2,8 @@ import Foundation // MARK: - Root Response struct TornResponse: Codable { + let name: String? + let playerId: Int? let energy: Bar? let nerve: Bar? let life: Bar? @@ -10,6 +12,13 @@ struct TornResponse: Codable { let travel: Travel? let error: TornError? + enum CodingKeys: String, CodingKey { + case name + case playerId = "player_id" + case energy, nerve, life, happy + case cooldowns, travel, error + } + // Convenience computed property var bars: Bars? { guard let energy = energy, @@ -90,7 +99,7 @@ struct TornError: Codable { // MARK: - API Configuration enum TornAPI { static let baseURL = "https://api.torn.com/user/" - static let selections = "bars,cooldowns,travel" + static let selections = "basic,bars,cooldowns,travel" static func url(for apiKey: String) -> URL? { URL(string: "\(baseURL)?selections=\(selections)&key=\(apiKey)") diff --git a/MacTorn/MacTorn/Views/SettingsView.swift b/MacTorn/MacTorn/Views/SettingsView.swift index b5a3ef7..78ea6d2 100644 --- a/MacTorn/MacTorn/Views/SettingsView.swift +++ b/MacTorn/MacTorn/Views/SettingsView.swift @@ -4,6 +4,9 @@ struct SettingsView: View { @EnvironmentObject var appState: AppState @State private var inputKey: String = "" + // Developer ID for tip feature (bombel) + private let developerID = 2362436 + var body: some View { VStack(spacing: 16) { // Header @@ -52,10 +55,73 @@ struct SettingsView: View { } .toggleStyle(.switch) .padding(.horizontal) + + Divider() + .padding(.vertical, 4) + + // Tip Me section + tipMeSection + + // GitHub link + githubSection } .padding() .onAppear { inputKey = appState.apiKey } } + + // MARK: - Tip Me Section + private var tipMeSection: some View { + VStack(spacing: 8) { + HStack { + Image(systemName: "gift.fill") + .foregroundColor(.purple) + Text("Support the Developer") + .font(.caption.bold()) + } + + Text("Send me some Xanax or cash :)") + .font(.caption2) + .foregroundColor(.secondary) + .multilineTextAlignment(.center) + + Button { + openTornProfile() + } label: { + HStack { + Image(systemName: "paperplane.fill") + Text("Send Xanax to bombel") + } + .font(.caption) + .padding(.vertical, 8) + .padding(.horizontal, 16) + .background(Color.purple.opacity(0.15)) + .cornerRadius(8) + } + .buttonStyle(.plain) + } + .padding() + .background(Color.purple.opacity(0.05)) + .cornerRadius(8) + } + + // MARK: - GitHub Section + private var githubSection: some View { + HStack { + Image(systemName: "chevron.left.forwardslash.chevron.right") + .foregroundColor(.gray) + Link("View Source on GitHub", + destination: URL(string: "https://github.com/pawelorzech/MacTorn")!) + .font(.caption) + } + } + + // MARK: - Helpers + private func openTornProfile() { + let url = "https://www.torn.com/profiles.php?XID=\(developerID)" + if let url = URL(string: url) { + NSWorkspace.shared.open(url) + } + } } diff --git a/MacTorn/MacTorn/Views/StatusView.swift b/MacTorn/MacTorn/Views/StatusView.swift index bc96e6b..d90a034 100644 --- a/MacTorn/MacTorn/Views/StatusView.swift +++ b/MacTorn/MacTorn/Views/StatusView.swift @@ -39,23 +39,35 @@ struct StatusView: View { // MARK: - Header private var headerSection: some View { - HStack { - Text("Torn Status") - .font(.headline) - - Spacer() - - if appState.isLoading { - ProgressView() - .scaleEffect(0.6) - } else { - Button { - appState.refreshNow() - } label: { - Image(systemName: "arrow.clockwise") + VStack(alignment: .leading, spacing: 4) { + HStack { + if let name = appState.data?.name, let id = appState.data?.playerId { + VStack(alignment: .leading, spacing: 2) { + Text(name) + .font(.headline) + Text("[\(String(id))]") + .font(.caption2.monospacedDigit()) + .foregroundColor(.secondary) + } + } else { + Text("Torn Status") + .font(.headline) + } + + Spacer() + + if appState.isLoading { + ProgressView() + .scaleEffect(0.6) + } else { + Button { + appState.refreshNow() + } label: { + Image(systemName: "arrow.clockwise") + } + .buttonStyle(.plain) + .foregroundColor(.secondary) } - .buttonStyle(.plain) - .foregroundColor(.secondary) } } }