Skip to content

Commit 521fb14

Browse files
committed
[trello.com/c/vawidi4o] Setting secret wallet icon and its badge displaying.
1 parent e7fb916 commit 521fb14

File tree

3 files changed

+53
-15
lines changed

3 files changed

+53
-15
lines changed

Adamant/Modules/Account/AccountHeader.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
5555
</view>
5656
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="secret_wallets_regular" translatesAutoresizingMaskIntoConstraints="NO" id="Man-rA-gFA">
57-
<rect key="frame" x="306.5" y="45" width="35" height="35"/>
57+
<rect key="frame" x="271.5" y="45" width="35" height="35"/>
5858
<constraints>
5959
<constraint firstAttribute="width" constant="35" id="45y-Er-QMf"/>
6060
<constraint firstAttribute="height" constant="35" id="YhE-0q-neO"/>
@@ -64,11 +64,11 @@
6464
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6565
<constraints>
6666
<constraint firstItem="LHk-7R-5oq" firstAttribute="top" secondItem="6hF-gW-1fF" secondAttribute="bottom" constant="28" id="0d9-Ro-csQ"/>
67-
<constraint firstItem="Man-rA-gFA" firstAttribute="leading" secondItem="IVQ-4p-zci" secondAttribute="trailing" constant="80" id="2eO-z5-9Ha"/>
6867
<constraint firstItem="Man-rA-gFA" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="45" id="4Gw-op-P7G"/>
6968
<constraint firstAttribute="bottom" secondItem="LHk-7R-5oq" secondAttribute="bottom" id="5u8-dI-fD1"/>
7069
<constraint firstItem="6hF-gW-1fF" firstAttribute="top" secondItem="IVQ-4p-zci" secondAttribute="bottom" constant="13" id="EN0-a5-cHs"/>
7170
<constraint firstAttribute="trailing" secondItem="LHk-7R-5oq" secondAttribute="trailing" id="FJv-73-Ayr"/>
71+
<constraint firstItem="Man-rA-gFA" firstAttribute="leading" secondItem="IVQ-4p-zci" secondAttribute="trailing" constant="45" id="Uol-2s-20a"/>
7272
<constraint firstItem="IVQ-4p-zci" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="25" id="Z7D-Q0-s2x"/>
7373
<constraint firstItem="LHk-7R-5oq" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="eip-WC-PKw"/>
7474
<constraint firstItem="6hF-gW-1fF" firstAttribute="centerX" secondItem="IVQ-4p-zci" secondAttribute="centerX" id="gMH-Q7-bMw"/>

Adamant/Modules/Account/AccountHeaderView.swift

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,32 +68,76 @@ final class AccountHeaderView: UIView {
6868
private extension AccountHeaderView {
6969
func setupGestureRecognizers() {
7070
secretWalletsImageView.isUserInteractionEnabled = true
71-
7271
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(walletsButtonTapped))
7372
secretWalletsImageView.addGestureRecognizer(tapGesture)
73+
74+
guard self.circularBackgroundView != nil else { return }
75+
circularBackgroundView!.isUserInteractionEnabled = true
76+
let bgTapGesture = UITapGestureRecognizer(target: self, action: #selector(walletsButtonTapped))
77+
circularBackgroundView!.addGestureRecognizer(bgTapGesture)
7478
}
7579

7680
func updateWalletBadge(count: Int) {
77-
secretWalletsImageView.viewWithTag(99)?.removeFromSuperview()
81+
guard let bgView = circularBackgroundView else { return }
82+
83+
bgView.viewWithTag(99)?.removeFromSuperview()
7884

7985
guard count > 0 else { return }
8086

87+
let badgeLabel = UILabel()
88+
badgeLabel.tag = 99
89+
badgeLabel.text = "\(count)"
90+
badgeLabel.font = .systemFont(ofSize: 14, weight: .medium)
91+
badgeLabel.textAlignment = .center
92+
badgeLabel.textColor = UIColor { traitCollection in
93+
return traitCollection.userInterfaceStyle == .light ? .white : .black
94+
}
95+
badgeLabel.backgroundColor = .adamant.secondary
96+
97+
let badgeSize: CGFloat = 24
98+
badgeLabel.layer.cornerRadius = badgeSize / 2
99+
badgeLabel.layer.masksToBounds = true
100+
101+
badgeLabel.translatesAutoresizingMaskIntoConstraints = false
102+
bgView.addSubview(badgeLabel)
103+
104+
NSLayoutConstraint.activate([
105+
badgeLabel.widthAnchor.constraint(equalToConstant: badgeSize),
106+
badgeLabel.heightAnchor.constraint(equalToConstant: badgeSize),
107+
badgeLabel.trailingAnchor.constraint(equalTo: bgView.trailingAnchor, constant: 0),
108+
badgeLabel.bottomAnchor.constraint(equalTo: bgView.bottomAnchor, constant: 0)
109+
])
81110
}
82-
111+
83112
private func addPersistentOutline() {
84113
let bgView = UIView()
85114
bgView.backgroundColor = UIColor { traitCollection in
86-
return traitCollection.userInterfaceStyle == .dark
87-
? .adamant.secondary
88-
: UIColor.black
115+
return traitCollection.userInterfaceStyle == .light
116+
? .adamant.secondBackgroundColor
117+
: .adamant.background
89118
}
90119

91120
secretWalletsImageView.superview?.insertSubview(bgView, belowSubview: secretWalletsImageView)
92121
self.circularBackgroundView = bgView
93122
}
94123

95124
private func animateOutline() {
125+
guard let bgView = circularBackgroundView else { return }
126+
127+
let originalColor = bgView.backgroundColor
128+
let highlightColor = UIColor.systemGray5
96129

130+
UIView.animate(withDuration: 0.1, animations: {
131+
bgView.backgroundColor = highlightColor
132+
bgView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
133+
self.secretWalletsImageView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
134+
}, completion: { _ in
135+
UIView.animate(withDuration: 0.1, animations: {
136+
bgView.backgroundColor = originalColor
137+
bgView.transform = .identity
138+
self.secretWalletsImageView.transform = .identity
139+
})
140+
})
97141
}
98142
}
99143

CommonKit/Sources/CommonKit/Helpers/UIHelpers/UIColor+adamant.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,6 @@ extension UIColor {
271271

272272
// Outcome transfer icon background, light red
273273
public static let transferOutcomeIconBackground = #colorLiteral(red: 0.9411764706, green: 0.5215686275, blue: 0.5294117647, alpha: 1) //#F08587
274-
275-
// MARK: Secret Wallets
276-
public static var secretWalletButtonBackground: UIColor {
277-
let colorWhiteTheme = #colorLiteral(red: 0.9450980392, green: 0.9450980392, blue: 0.9647058824, alpha: 1) //#F1F1F6
278-
let colorDarkTheme = UIColor.white.withAlphaComponent(0.3)
279-
return returnColorByTheme(colorWhiteTheme: colorWhiteTheme, colorDarkTheme: colorDarkTheme)
280-
}
274+
281275
}
282276
}

0 commit comments

Comments
 (0)