mirror of
https://github.com/pawelorzech/MacTorn.git
synced 2026-01-29 19:54:27 +00:00
feat: Add API usage disclosure to settings and update 'Life' progress bar color to blue.
This commit is contained in:
parent
8d4645c2a2
commit
61235e78af
3 changed files with 55 additions and 5 deletions
|
|
@ -71,7 +71,7 @@ struct ProgressBarView: View {
|
|||
ProgressBarView(label: "Energy", current: 75, maximum: 100, color: .green, icon: "bolt.fill")
|
||||
ProgressBarView(label: "Nerve", current: 50, maximum: 50, color: .red, icon: "flame.fill")
|
||||
ProgressBarView(label: "Happy", current: 500, maximum: 1000, color: .yellow, icon: "face.smiling.fill")
|
||||
ProgressBarView(label: "Life", current: 0, maximum: 100, color: .pink, icon: "heart.fill")
|
||||
ProgressBarView(label: "Life", current: 0, maximum: 100, color: .blue, icon: "heart.fill")
|
||||
}
|
||||
.padding()
|
||||
.frame(width: 280)
|
||||
|
|
|
|||
|
|
@ -27,20 +27,23 @@ struct SettingsView: View {
|
|||
VStack(spacing: 8) {
|
||||
SecureField("Torn API Key", text: $inputKey)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
|
||||
|
||||
Button("Save & Connect") {
|
||||
appState.apiKey = inputKey.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
appState.refreshNow()
|
||||
}
|
||||
.buttonStyle(.borderedProminent)
|
||||
.disabled(inputKey.isEmpty)
|
||||
|
||||
|
||||
Link("Get API Key from Torn",
|
||||
destination: URL(string: "https://www.torn.com/preferences.php#tab=api")!)
|
||||
.font(.caption)
|
||||
}
|
||||
.padding(.horizontal)
|
||||
|
||||
|
||||
// API ToS Compliance
|
||||
apiUsageDisclosure
|
||||
|
||||
Divider()
|
||||
|
||||
// Settings
|
||||
|
|
@ -164,6 +167,53 @@ struct SettingsView: View {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: - API Usage Disclosure
|
||||
private var apiUsageDisclosure: some View {
|
||||
DisclosureGroup {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
ForEach(apiSelections, id: \.selection) { item in
|
||||
HStack(alignment: .top) {
|
||||
Text(item.selection)
|
||||
.font(.caption.monospaced())
|
||||
.frame(width: 60, alignment: .leading)
|
||||
.foregroundColor(.accentColor)
|
||||
Text(item.purpose)
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
|
||||
Divider()
|
||||
|
||||
Link("View Torn API Terms of Service",
|
||||
destination: URL(string: "https://www.torn.com/api.html")!)
|
||||
.font(.caption)
|
||||
}
|
||||
.padding(.top, 4)
|
||||
} label: {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "doc.text")
|
||||
.foregroundColor(.secondary)
|
||||
Text("API Data Usage")
|
||||
.font(.caption.bold())
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
private var apiSelections: [(selection: String, purpose: String)] {
|
||||
[
|
||||
("basic", "Player name, ID, basic info"),
|
||||
("bars", "Energy, Nerve, Happy, Life bars"),
|
||||
("cooldowns", "Drug, Medical, Booster cooldowns"),
|
||||
("travel", "Travel status and destination"),
|
||||
("profile", "Battle stats, faction info"),
|
||||
("events", "Recent events feed"),
|
||||
("messages", "Unread message count"),
|
||||
("market", "Item watchlist prices")
|
||||
]
|
||||
}
|
||||
|
||||
private func openTornProfile() {
|
||||
let url = "https://www.torn.com/profiles.php?XID=\(developerID)"
|
||||
if let url = URL(string: url) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ struct StatusView: View {
|
|||
label: "Life",
|
||||
current: bars.life.current,
|
||||
maximum: bars.life.maximum,
|
||||
color: .pink,
|
||||
color: .blue,
|
||||
icon: "heart.fill"
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue