Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions Classes/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,13 @@ GitHubSessionListener {
strongSelf.apiStatusView.isHidden = true
strongSelf.apiStatusLabel.text = NSLocalizedString("error", comment: "")
case .success(let response):
let text: String
let text = response.data.status.description
let color: UIColor
switch response.data.status {
case .good:
text = NSLocalizedString("Good", comment: "")
color = Styles.Colors.Green.medium.color
case .minor:
text = NSLocalizedString("Minor", comment: "")
color = Styles.Colors.Yellow.medium.color
case .major:
text = NSLocalizedString("Major", comment: "")
color = Styles.Colors.Red.medium.color
switch response.data.status.indicator {
case .none: color = Styles.Colors.Green.medium.color
case .minor: color = Styles.Colors.Yellow.medium.color
case .major: color = Styles.Colors.Red.medium.color
case .critical: color = Styles.Colors.Red.dark.color
}
strongSelf.apiStatusView.isHidden = false
strongSelf.apiStatusView.backgroundColor = color
Expand Down Expand Up @@ -144,7 +139,7 @@ GitHubSessionListener {
}

private func onGitHubStatus() {
guard let url = URLBuilder(host: "status.github.com").add(path: "messages").url
guard let url = URLBuilder(host: "www.githubstatus.com").url
else { return }
presentSafari(url: url)
}
Expand Down
1 change: 1 addition & 0 deletions Classes/Views/Styles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ enum Styles {
static let splitViewBackground = UIColor(red: 0.556863, green: 0.556863, blue: 0.576471, alpha: 1)

enum Red {
static let dark = "75151d"
static let medium = "cb2431"
static let light = "ffeef0"
}
Expand Down
15 changes: 11 additions & 4 deletions Local Pods/GitHubAPI/GitHubAPI/GitHubAPIStatusRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,22 @@
import Foundation

public struct APIStatus: Codable {
public enum StatusType: String, Codable {
case good, minor, major
public let status: Status
}

public struct Status: Codable {
public let indicator: StatusType
public let description: String

public enum StatusType: String, Codable, CodingKey {
case none, minor, major, critical
}
public let status: StatusType
}


public struct GitHubAPIStatusRequest: HTTPRequest {
public typealias ResponseType = V3DataResponse<APIStatus>
public var url: String { return "https://status.github.com/api/status.json" }
public var url: String { return "https://www.githubstatus.com/api/v2/status.json" }
public var logoutOnAuthFailure: Bool { return false }
public var method: HTTPMethod { return .get }
public var parameters: [String : Any]? { return nil }
Expand Down