From 599a171020467f6589191be9a5500a5a22d7eab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktoras=20Laukevi=C4=8Dius?= Date: Wed, 6 Feb 2019 18:32:12 +0200 Subject: [PATCH] Disable badge background override on API status cell highlight --- Classes/Settings/Settings.storyboard | 15 ++++++------ Classes/Settings/SettingsViewController.swift | 5 ++-- Classes/Utility/UIImage+Color.swift | 23 +++++++++++++++++++ Freetime.xcodeproj/project.pbxproj | 4 ++++ 4 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 Classes/Utility/UIImage+Color.swift diff --git a/Classes/Settings/Settings.storyboard b/Classes/Settings/Settings.storyboard index 5b7ea3cb5..ac98c551c 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 6b545a431..dee1f290e 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 */; }; 0F9440FD32236514CD7215E9 /* Pods_Freetime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ECF622FFD773FDA73297C0D0 /* Pods_Freetime.framework */; }; 15F28F992108DBA6006421B6 /* SplashView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 15F28F982108DBA6006421B6 /* SplashView.swift */; }; 290056F3210028B20046EAE5 /* UIViewController+MenuDone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 290056F2210028B20046EAE5 /* UIViewController+MenuDone.swift */; }; @@ -593,6 +594,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 031E0240220B433C00A329F1 /* UIImage+Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Color.swift"; sourceTree = ""; }; 07C7DC5A7A907BE73BCA95AC /* Pods-FreetimeTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FreetimeTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-FreetimeTests/Pods-FreetimeTests.debug.xcconfig"; sourceTree = ""; }; 0F26A46A43D11F8D04E17D4A /* Pods-FreetimeWatch Extension.testflight.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-FreetimeWatch Extension.testflight.xcconfig"; path = "Pods/Target Support Files/Pods-FreetimeWatch Extension/Pods-FreetimeWatch Extension.testflight.xcconfig"; sourceTree = ""; }; 15F28F982108DBA6006421B6 /* SplashView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplashView.swift; sourceTree = ""; }; @@ -2291,6 +2293,7 @@ C0E3CD4A21BAE49B00185B57 /* NSRegularExpression+StaticString.swift */, C0E3CD4C21BAE65000185B57 /* UIImage+StaticString.swift */, 298C7E2721D80BAF00DD2A60 /* Error+GraphQLForbidden.swift */, + 031E0240220B433C00A329F1 /* UIImage+Color.swift */, ); path = Utility; sourceTree = ""; @@ -3250,6 +3253,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 */,