diff --git a/Classes/Settings/Settings.storyboard b/Classes/Settings/Settings.storyboard index ef9468714..230baeea4 100644 --- a/Classes/Settings/Settings.storyboard +++ b/Classes/Settings/Settings.storyboard @@ -110,20 +110,19 @@ - + - - + + @@ -463,7 +462,7 @@ - + diff --git a/Classes/Settings/SettingsViewController.swift b/Classes/Settings/SettingsViewController.swift index a122f8fca..7bbcde09d 100644 --- a/Classes/Settings/SettingsViewController.swift +++ b/Classes/Settings/SettingsViewController.swift @@ -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! @@ -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: "") @@ -98,7 +99,7 @@ GitHubSessionListener { color = Styles.Colors.Red.medium.color } strongSelf.apiStatusView.isHidden = false - strongSelf.apiStatusView.backgroundColor = color + strongSelf.apiStatusView.image = .from(color: color) strongSelf.apiStatusLabel.text = text strongSelf.apiStatusLabel.textColor = color } diff --git a/Classes/Utility/UIImage+Color.swift b/Classes/Utility/UIImage+Color.swift new file mode 100644 index 000000000..0024a5fd2 --- /dev/null +++ b/Classes/Utility/UIImage+Color.swift @@ -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 + } +} diff --git a/Freetime.xcodeproj/project.pbxproj b/Freetime.xcodeproj/project.pbxproj index 30a1ecf15..8a7eb13af 100644 --- a/Freetime.xcodeproj/project.pbxproj +++ b/Freetime.xcodeproj/project.pbxproj @@ -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 */; }; @@ -596,6 +597,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 031E0240220B433C00A329F1 /* UIImage+Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Color.swift"; sourceTree = ""; }; 03C127B7220993300062F7C9 /* InboxZeroLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxZeroLoaderTests.swift; sourceTree = ""; }; 03E8D823221D339200EB792A /* GithubURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubURL.swift; sourceTree = ""; }; 03E8D825221D358000EB792A /* GithubURLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubURLTests.swift; sourceTree = ""; }; @@ -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; @@ -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 */,