Skip to content

Commit

Permalink
Issue zom#603: Show trusted/untrusted badge on single fingerprint ins…
Browse files Browse the repository at this point in the history
…tead of green/red coloured checkmark.
  • Loading branch information
tladesignz committed May 14, 2018
1 parent 400be82 commit 3dfd19d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,25 @@ class ZomFingerprintBaseViewController: UIViewController {
attributes: attributes)
}

/**
Sets the style of `self.badgeLb` - the little badge in the bottom right corner of a user's
avatar to either be read and display shield with an exclamation mark or be green and display
a shield with a check mark.

- parameter label: The badge label to change
- parameter ok: Set true if all keys aka. fingerprints are ok (none are `.untrustedNew`)
*/
static func setBadge(_ label: UILabel, ok: Bool) {
if ok {
label.backgroundColor = UIColor.zomGreen
label.text = "" // Shield with check mark
}
else {
label.backgroundColor = UIColor.zomRed
label.text = "" // Shield with exclamation mark
}
}

/**
- returns: the buddy's `displayName` or "your buddy" as a default value, if no buddy or no
`displayName`.
Expand Down Expand Up @@ -199,22 +218,4 @@ class ZomFingerprintBaseViewController: UIViewController {

return untrusted
}

/**
Sets the style of `self.badgeLb` - the little badge in the bottom right corner of a user's
avatar to either be read and display shield with an exclamation mark or be green and display
a shield with a check mark.

- parameter ok: Set true if all keys aka. fingerprints are ok (none are `.untrustedNew`)
*/
func setBadge(ok: Bool) {
if ok {
badgeLb.backgroundColor = UIColor.zomGreen
badgeLb.text = "" // Shield with check mark
}
else {
badgeLb.backgroundColor = UIColor.zomRed
badgeLb.text = "" // Shield with exclamation mark
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class ZomVerificationDetailViewController: ZomFingerprintBaseViewController, UIT
private func updateUntrustedNewFingerprintsInfo() {
let untrusted = countUntrusted()

setBadge(ok: untrusted < 1)
ZomFingerprintBaseViewController.setBadge(badgeLb, ok: untrusted < 1)

subtitleLb.text = NSLocalizedString("\(untrusted) Untrusted New Codes for \(buddyName())",
comment: "Subtitle for code verification detail scene")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ZomVerificationViewController: ZomFingerprintBaseViewController {
OTR fingerprint if no OMEMO device found.
*/
override func fingerprintsLoaded() {
setBadge(ok: countUntrusted() < 1)
ZomFingerprintBaseViewController.setBadge(badgeLb, ok: countUntrusted() < 1)

if let device = omemoDevices
.filter({ (device) -> Bool in return device.trustLevel == .untrustedNew })
Expand Down
4 changes: 2 additions & 2 deletions Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ZomFingerprintVerificationCell: UITableViewCell {
omemoDevice = device
let trusted = device.isTrusted()

trustBadge.backgroundColor = trusted ? UIColor.zomGreen : UIColor.zomRed
ZomFingerprintBaseViewController.setBadge(trustBadge, ok: trusted)

var infos: [String] = []

Expand Down Expand Up @@ -75,7 +75,7 @@ class ZomFingerprintVerificationCell: UITableViewCell {
otrFingerprint = fingerprint
let trusted = fingerprint.isTrusted()

trustBadge.backgroundColor = trusted ? UIColor.zomGreen : UIColor.zomRed
ZomFingerprintBaseViewController.setBadge(trustBadge, ok: trusted)

infoLb.text = getTrustStateString(trusted)

Expand Down
8 changes: 4 additions & 4 deletions Zom/Zom/Classes/Views/ZomFingerprintVerificationCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="MaterialIcons-Regular.ttf">
<string>MaterialIcons-Regular</string>
<array key="icomoon.ttf">
<string>icomoon</string>
</array>
</customFonts>
<objects>
Expand All @@ -25,14 +25,14 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="149.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ff4-UQ-35G">
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ff4-UQ-35G">
<rect key="frame" x="16" y="11" width="21" height="21"/>
<color key="backgroundColor" red="0.90588235294117647" green="0.15294117647058825" blue="0.3529411764705882" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="21" id="2Gk-hA-an6"/>
<constraint firstAttribute="height" constant="21" id="MEz-dZ-Lfh"/>
</constraints>
<fontDescription key="fontDescription" name="MaterialIcons-Regular" family="Material Icons" pointSize="17"/>
<fontDescription key="fontDescription" name="icomoon" family="icomoon" pointSize="17"/>
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
Expand Down

0 comments on commit 3dfd19d

Please sign in to comment.