Skip to content
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
8 changes: 4 additions & 4 deletions Classes/Issues/Labeled/IssueLabeledModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ final class IssueLabeledModel: ListDiffable {
) {
self.id = id
self.actor = actor
self.title = title
self.title = title.replacingGithubEmoji
self.color = color
self.date = date
self.type = type

let labelColor = color.color
let actionString: String
switch type {
case .added: actionString = NSLocalizedString(" added ", comment: "")
case .removed: actionString = NSLocalizedString(" removed ", comment: "")
}


let builder = StyledTextBuilder(styledText: StyledText(
style: Styles.Text.secondary.with(foreground: Styles.Colors.Gray.medium.color)
))
Expand All @@ -64,11 +64,11 @@ final class IssueLabeledModel: ListDiffable {
.restore()
.add(text: actionString)
.save()
.add(styledText: StyledText(text: title, style: Styles.Text.smallTitle.with(attributes: [
.add(styledText: StyledText(text: self.title, style: Styles.Text.smallTitle.with(attributes: [
.backgroundColor: labelColor,
.foregroundColor: labelColor.textOverlayColor ?? .black,
.baselineOffset: 1, // offset for better rounded background colors
MarkdownAttribute.label: LabelDetails(owner: repoOwner, repo: repoName, label: title)
MarkdownAttribute.label: LabelDetails(owner: repoOwner, repo: repoName, label: self.title)
]
)))
.restore()
Expand Down
4 changes: 2 additions & 2 deletions Classes/Models/RepositoryLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import IGListKit
final class RepositoryLabel: ListDiffable, Hashable, Equatable, ListSwiftDiffable {

let color: String
let name: String
var name: String = ""

init(color: String, name: String) {
self.color = color
self.name = name
self.name = name.replacingGithubEmoji
}

// MARK: ListDiffable
Expand Down
10 changes: 6 additions & 4 deletions Classes/Repository/RepositoryCodeBlobViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ final class RepositoryCodeBlobViewController: UIViewController, EmptyViewDelegat
branch: branch,
path: path.path
) { [weak self] (result) in
self?.feedRefresh.endRefreshing()
switch result {
case .success(let text):
self?.handle(text: text)
Expand All @@ -172,17 +171,20 @@ final class RepositoryCodeBlobViewController: UIViewController, EmptyViewDelegat
}
}

func error(cannotLoad: Bool) {
private func error(cannotLoad: Bool) {
feedRefresh.endRefreshing()
emptyView.isHidden = false
emptyView.label.text = cannotLoad
? NSLocalizedString("Cannot display file as text", comment: "")
: NSLocalizedString("Error loading file", comment: "")
}

func handle(text: String) {
private func handle(text: String) {
emptyView.isHidden = true
didFetchPayload(text)
codeView.set(code: text)
codeView.set(code: text) { [weak self] in
self?.feedRefresh.endRefreshing()
}
}

// MARK: EmptyViewDelegate
Expand Down
15 changes: 7 additions & 8 deletions Classes/Settings/Settings.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,19 @@
<color key="textColor" red="0.63921568627450975" green="0.66666666666666663" blue="0.69411764705882351" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view hidden="YES" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1mP-Dr-7rt">
<imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Wqw-0q-16V">
<rect key="frame" x="270" y="15" width="14" height="14"/>
<color key="backgroundColor" red="0.73725490196078436" green="0.73333333333333328" blue="0.75686274509803919" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="LRa-0r-Kib"/>
<constraint firstAttribute="width" constant="14" id="hum-9p-JUR"/>
<constraint firstAttribute="width" constant="14" id="ZDk-Zk-GPk"/>
<constraint firstAttribute="height" constant="14" id="w9v-uc-7PB"/>
</constraints>
</view>
</imageView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="rIC-a2-0GF" secondAttribute="trailing" id="C2A-Af-SXu"/>
<constraint firstItem="Tnv-Bx-YAk" firstAttribute="leading" secondItem="oVx-yt-y92" secondAttribute="leading" constant="16" id="VE8-RG-Yq6"/>
<constraint firstItem="1mP-Dr-7rt" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="ejb-XH-Hbe"/>
<constraint firstItem="rIC-a2-0GF" firstAttribute="leading" secondItem="1mP-Dr-7rt" secondAttribute="trailing" constant="4" id="hiY-5o-Tap"/>
<constraint firstItem="Wqw-0q-16V" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="a87-PV-1BY"/>
<constraint firstItem="rIC-a2-0GF" firstAttribute="leading" secondItem="Wqw-0q-16V" secondAttribute="trailing" constant="4" id="fB0-DK-2Oz"/>
<constraint firstItem="Tnv-Bx-YAk" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="mc6-XY-pYG"/>
<constraint firstItem="rIC-a2-0GF" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="npa-sd-pci"/>
</constraints>
Expand Down Expand Up @@ -463,7 +462,7 @@
<connections>
<outlet property="accountsCell" destination="64O-sw-wTx" id="UPX-Wa-mYM"/>
<outlet property="apiStatusLabel" destination="rIC-a2-0GF" id="ceC-Ij-CrY"/>
<outlet property="apiStatusView" destination="1mP-Dr-7rt" id="f66-HG-AkG"/>
<outlet property="apiStatusView" destination="Wqw-0q-16V" id="ir1-9k-Esu"/>
<outlet property="badgeCell" destination="pnm-5p-yC5" id="hdC-aO-QSy"/>
<outlet property="badgeSettingsButton" destination="36B-Ge-m5V" id="7Sw-oi-5Ra"/>
<outlet property="badgeSwitch" destination="FvK-93-raA" id="twy-bl-O1q"/>
Expand Down
24 changes: 10 additions & 14 deletions Classes/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ GitHubSessionListener {
@IBOutlet weak var markReadSwitch: UISwitch!
@IBOutlet weak var accountsCell: StyledTableCell!
@IBOutlet weak var apiStatusLabel: UILabel!
@IBOutlet weak var apiStatusView: UIView!
@IBOutlet weak var apiStatusView: UIImageView!
@IBOutlet weak var signatureSwitch: UISwitch!
@IBOutlet weak var defaultReactionLabel: UILabel!
@IBOutlet weak var pushSwitch: UISwitch!
Expand All @@ -54,6 +54,7 @@ GitHubSessionListener {
versionLabel.text = Bundle.main.prettyVersionString
markReadSwitch.isOn = NotificationModelController.readOnOpen
apiStatusView.layer.cornerRadius = 7
apiStatusView.image = .from(color: Styles.Colors.Gray.border.color)
signatureSwitch.isOn = Signature.enabled
openExternalLinksSwitch.isOn = UserDefaults.standard.shouldOpenExternalLinksInSafari
pushSettingsButton.accessibilityLabel = NSLocalizedString("How we send push notifications in GitHawk", comment: "")
Expand Down Expand Up @@ -84,21 +85,16 @@ 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
strongSelf.apiStatusView.image = .from(color: color)
strongSelf.apiStatusLabel.text = text
strongSelf.apiStatusLabel.textColor = color
}
Expand Down Expand Up @@ -146,7 +142,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
23 changes: 23 additions & 0 deletions Classes/Utility/UIImage+Color.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// UIImage+Color.swift
// Freetime
//
// Created by Viktoras Laukevicius on 06/02/2019.
// Copyright © 2019 Ryan Nystrom. All rights reserved.
//

import UIKit

extension UIImage {

class func from(color: UIColor) -> UIImage {
let size = CGSize(width: 1, height: 1)
UIGraphicsBeginImageContext(size)
let context = UIGraphicsGetCurrentContext()
context?.setFillColor(color.cgColor)
context?.fill(CGRect(origin: .zero, size: size))
let image = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return image
}
}
8 changes: 6 additions & 2 deletions Classes/Views/CodeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class CodeView: UITextView {
}

// MARK: Public API
func set(code: String, language: String? = nil) {
func set(code: String, language: String? = nil, completion: @escaping () -> Void) {
DispatchQueue.global().async {
let maybeHighlighted: NSAttributedString?
if let language = language {
Expand All @@ -40,9 +40,13 @@ final class CodeView: UITextView {
// Automatic language detection
maybeHighlighted = GithubHighlighting.highlight(code)
}
guard let highlighted = maybeHighlighted else { return }
guard let highlighted = maybeHighlighted else {
DispatchQueue.main.async(execute: completion)
return
}
DispatchQueue.main.async { [weak self] in
self?.set(attributedCode: highlighted)
completion()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Classes/Views/Styles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,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
4 changes: 4 additions & 0 deletions Freetime.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
031E0241220B433C00A329F1 /* UIImage+Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 031E0240220B433C00A329F1 /* UIImage+Color.swift */; };
03C127B8220993300062F7C9 /* InboxZeroLoaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03C127B7220993300062F7C9 /* InboxZeroLoaderTests.swift */; };
03E8D824221D339200EB792A /* GithubURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E8D823221D339200EB792A /* GithubURL.swift */; };
03E8D826221D358000EB792A /* GithubURLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E8D825221D358000EB792A /* GithubURLTests.swift */; };
Expand Down Expand Up @@ -596,6 +597,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
031E0240220B433C00A329F1 /* UIImage+Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Color.swift"; sourceTree = "<group>"; };
03C127B7220993300062F7C9 /* InboxZeroLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxZeroLoaderTests.swift; sourceTree = "<group>"; };
03E8D823221D339200EB792A /* GithubURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubURL.swift; sourceTree = "<group>"; };
03E8D825221D358000EB792A /* GithubURLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubURLTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2299,6 +2301,7 @@
C0E3CD4A21BAE49B00185B57 /* NSRegularExpression+StaticString.swift */,
C0E3CD4C21BAE65000185B57 /* UIImage+StaticString.swift */,
298C7E2721D80BAF00DD2A60 /* Error+GraphQLForbidden.swift */,
031E0240220B433C00A329F1 /* UIImage+Color.swift */,
03E8D823221D339200EB792A /* GithubURL.swift */,
);
path = Utility;
Expand Down Expand Up @@ -3260,6 +3263,7 @@
29DAA7AB20202A1A0029277A /* PullRequestReviewReplySectionController.swift in Sources */,
29792B1D1FFB2FC6007A0C57 /* IssueManagingNavSectionController.swift in Sources */,
2905AFAB1F7357B40015AE32 /* RepositoryOverviewViewController.swift in Sources */,
031E0241220B433C00A329F1 /* UIImage+Color.swift in Sources */,
29999734203135E100995FFD /* IssueMergeContextCell.swift in Sources */,
29EDFE821F661562005BCCEB /* RepositoryReadmeModel.swift in Sources */,
29EDFE841F661776005BCCEB /* RepositoryReadmeSectionController.swift in Sources */,
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