Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit fe77f98

Browse files
viktoraslBasThomas
authored andcommitted
Disable badge background override on API status cell highlight (#2631)
1 parent c527846 commit fe77f98

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

Classes/Settings/Settings.storyboard

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,19 @@
110110
<color key="textColor" red="0.63921568627450975" green="0.66666666666666663" blue="0.69411764705882351" alpha="1" colorSpace="calibratedRGB"/>
111111
<nil key="highlightedColor"/>
112112
</label>
113-
<view hidden="YES" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1mP-Dr-7rt">
113+
<imageView hidden="YES" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Wqw-0q-16V">
114114
<rect key="frame" x="270" y="15" width="14" height="14"/>
115-
<color key="backgroundColor" red="0.73725490196078436" green="0.73333333333333328" blue="0.75686274509803919" alpha="1" colorSpace="calibratedRGB"/>
116115
<constraints>
117-
<constraint firstAttribute="height" constant="14" id="LRa-0r-Kib"/>
118-
<constraint firstAttribute="width" constant="14" id="hum-9p-JUR"/>
116+
<constraint firstAttribute="width" constant="14" id="ZDk-Zk-GPk"/>
117+
<constraint firstAttribute="height" constant="14" id="w9v-uc-7PB"/>
119118
</constraints>
120-
</view>
119+
</imageView>
121120
</subviews>
122121
<constraints>
123122
<constraint firstAttribute="trailing" secondItem="rIC-a2-0GF" secondAttribute="trailing" id="C2A-Af-SXu"/>
124123
<constraint firstItem="Tnv-Bx-YAk" firstAttribute="leading" secondItem="oVx-yt-y92" secondAttribute="leading" constant="16" id="VE8-RG-Yq6"/>
125-
<constraint firstItem="1mP-Dr-7rt" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="ejb-XH-Hbe"/>
126-
<constraint firstItem="rIC-a2-0GF" firstAttribute="leading" secondItem="1mP-Dr-7rt" secondAttribute="trailing" constant="4" id="hiY-5o-Tap"/>
124+
<constraint firstItem="Wqw-0q-16V" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="a87-PV-1BY"/>
125+
<constraint firstItem="rIC-a2-0GF" firstAttribute="leading" secondItem="Wqw-0q-16V" secondAttribute="trailing" constant="4" id="fB0-DK-2Oz"/>
127126
<constraint firstItem="Tnv-Bx-YAk" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="mc6-XY-pYG"/>
128127
<constraint firstItem="rIC-a2-0GF" firstAttribute="centerY" secondItem="oVx-yt-y92" secondAttribute="centerY" id="npa-sd-pci"/>
129128
</constraints>
@@ -463,7 +462,7 @@
463462
<connections>
464463
<outlet property="accountsCell" destination="64O-sw-wTx" id="UPX-Wa-mYM"/>
465464
<outlet property="apiStatusLabel" destination="rIC-a2-0GF" id="ceC-Ij-CrY"/>
466-
<outlet property="apiStatusView" destination="1mP-Dr-7rt" id="f66-HG-AkG"/>
465+
<outlet property="apiStatusView" destination="Wqw-0q-16V" id="ir1-9k-Esu"/>
467466
<outlet property="badgeCell" destination="pnm-5p-yC5" id="hdC-aO-QSy"/>
468467
<outlet property="badgeSettingsButton" destination="36B-Ge-m5V" id="7Sw-oi-5Ra"/>
469468
<outlet property="badgeSwitch" destination="FvK-93-raA" id="twy-bl-O1q"/>

Classes/Settings/SettingsViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ GitHubSessionListener {
4040
@IBOutlet weak var markReadSwitch: UISwitch!
4141
@IBOutlet weak var accountsCell: StyledTableCell!
4242
@IBOutlet weak var apiStatusLabel: UILabel!
43-
@IBOutlet weak var apiStatusView: UIView!
43+
@IBOutlet weak var apiStatusView: UIImageView!
4444
@IBOutlet weak var signatureSwitch: UISwitch!
4545
@IBOutlet weak var defaultReactionLabel: UILabel!
4646
@IBOutlet weak var pushSwitch: UISwitch!
@@ -54,6 +54,7 @@ GitHubSessionListener {
5454
versionLabel.text = Bundle.main.prettyVersionString
5555
markReadSwitch.isOn = NotificationModelController.readOnOpen
5656
apiStatusView.layer.cornerRadius = 7
57+
apiStatusView.image = .from(color: Styles.Colors.Gray.border.color)
5758
signatureSwitch.isOn = Signature.enabled
5859
openExternalLinksSwitch.isOn = UserDefaults.standard.shouldOpenExternalLinksInSafari
5960
pushSettingsButton.accessibilityLabel = NSLocalizedString("How we send push notifications in GitHawk", comment: "")
@@ -93,7 +94,7 @@ GitHubSessionListener {
9394
case .critical: color = Styles.Colors.Red.dark.color
9495
}
9596
strongSelf.apiStatusView.isHidden = false
96-
strongSelf.apiStatusView.backgroundColor = color
97+
strongSelf.apiStatusView.image = .from(color: color)
9798
strongSelf.apiStatusLabel.text = text
9899
strongSelf.apiStatusLabel.textColor = color
99100
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// UIImage+Color.swift
3+
// Freetime
4+
//
5+
// Created by Viktoras Laukevicius on 06/02/2019.
6+
// Copyright © 2019 Ryan Nystrom. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
extension UIImage {
12+
13+
class func from(color: UIColor) -> UIImage {
14+
let size = CGSize(width: 1, height: 1)
15+
UIGraphicsBeginImageContext(size)
16+
let context = UIGraphicsGetCurrentContext()
17+
context?.setFillColor(color.cgColor)
18+
context?.fill(CGRect(origin: .zero, size: size))
19+
let image = UIGraphicsGetImageFromCurrentImageContext()!
20+
UIGraphicsEndImageContext()
21+
return image
22+
}
23+
}

Freetime.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

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

598599
/* Begin PBXFileReference section */
600+
031E0240220B433C00A329F1 /* UIImage+Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Color.swift"; sourceTree = "<group>"; };
599601
03C127B7220993300062F7C9 /* InboxZeroLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxZeroLoaderTests.swift; sourceTree = "<group>"; };
600602
03E8D823221D339200EB792A /* GithubURL.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubURL.swift; sourceTree = "<group>"; };
601603
03E8D825221D358000EB792A /* GithubURLTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GithubURLTests.swift; sourceTree = "<group>"; };
@@ -2299,6 +2301,7 @@
22992301
C0E3CD4A21BAE49B00185B57 /* NSRegularExpression+StaticString.swift */,
23002302
C0E3CD4C21BAE65000185B57 /* UIImage+StaticString.swift */,
23012303
298C7E2721D80BAF00DD2A60 /* Error+GraphQLForbidden.swift */,
2304+
031E0240220B433C00A329F1 /* UIImage+Color.swift */,
23022305
03E8D823221D339200EB792A /* GithubURL.swift */,
23032306
);
23042307
path = Utility;
@@ -3260,6 +3263,7 @@
32603263
29DAA7AB20202A1A0029277A /* PullRequestReviewReplySectionController.swift in Sources */,
32613264
29792B1D1FFB2FC6007A0C57 /* IssueManagingNavSectionController.swift in Sources */,
32623265
2905AFAB1F7357B40015AE32 /* RepositoryOverviewViewController.swift in Sources */,
3266+
031E0241220B433C00A329F1 /* UIImage+Color.swift in Sources */,
32633267
29999734203135E100995FFD /* IssueMergeContextCell.swift in Sources */,
32643268
29EDFE821F661562005BCCEB /* RepositoryReadmeModel.swift in Sources */,
32653269
29EDFE841F661776005BCCEB /* RepositoryReadmeSectionController.swift in Sources */,

0 commit comments

Comments
 (0)