Skip to content

Commit 1c90f5a

Browse files
committed
[trello.com/c/vawidi4o] Setting secret wallet icon displaying.
1 parent ef9602b commit 1c90f5a

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

Adamant.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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="271.5" y="45" width="35" height="35"/>
57+
<rect key="frame" x="306.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"/>
6768
<constraint firstItem="Man-rA-gFA" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="45" id="4Gw-op-P7G"/>
6869
<constraint firstAttribute="bottom" secondItem="LHk-7R-5oq" secondAttribute="bottom" id="5u8-dI-fD1"/>
6970
<constraint firstItem="6hF-gW-1fF" firstAttribute="top" secondItem="IVQ-4p-zci" secondAttribute="bottom" constant="13" id="EN0-a5-cHs"/>
7071
<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="YDE-9H-P5x"/>
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: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ final class AccountHeaderView: UIView {
2121
@IBOutlet weak var addressButton: UIButton!
2222
@IBOutlet weak var walletViewContainer: UIView!
2323
@IBOutlet weak var secretWalletsImageView: UIImageView!
24-
private var outlineLayer: CAShapeLayer?
24+
25+
private var circularBackgroundView: UIView?
2526

2627
weak var delegate: AccountHeaderViewDelegate?
2728

@@ -34,6 +35,20 @@ final class AccountHeaderView: UIView {
3435
setupGestureRecognizers()
3536
}
3637

38+
override func layoutSubviews() {
39+
super.layoutSubviews()
40+
guard let bgView = circularBackgroundView else { return }
41+
42+
let iconFrame = secretWalletsImageView.frame
43+
let bgWidth = iconFrame.width * 2
44+
let bgHeight = iconFrame.height * 2
45+
bgView.frame = CGRect(x: iconFrame.midX - bgWidth / 2,
46+
y: iconFrame.midY - bgHeight / 2,
47+
width: bgWidth,
48+
height: bgHeight)
49+
bgView.layer.cornerRadius = bgWidth / 2
50+
}
51+
3752
func setWalletIcon(_ icon: WalletIcon, badgeCount: Int) {
3853
secretWalletsImageView.tintColor = .adamant.secondary
3954
secretWalletsImageView.image = .asset(named: icon.rawValue)?.withRenderingMode(.alwaysTemplate) ?? .init()
@@ -48,19 +63,6 @@ final class AccountHeaderView: UIView {
4863
animateOutline()
4964
delegate?.walletsButtonTapped(from: secretWalletsImageView)
5065
}
51-
52-
override func layoutSubviews() {
53-
super.layoutSubviews()
54-
55-
guard let outlineLayer = outlineLayer else { return }
56-
guard !secretWalletsImageView.frame.isEmpty else { return }
57-
58-
let imageView = secretWalletsImageView!
59-
let center = imageView.center
60-
let radius = imageView.bounds.width
61-
let path = UIBezierPath(arcCenter: center, radius: radius, startAngle: 0, endAngle: .pi * 2, clockwise: true)
62-
outlineLayer.path = path.cgPath
63-
}
6466
}
6567

6668
private extension AccountHeaderView {
@@ -79,16 +81,24 @@ private extension AccountHeaderView {
7981
}
8082

8183
private func addPersistentOutline() {
84+
let bgView = UIView()
85+
bgView.backgroundColor = UIColor { traitCollection in
86+
return traitCollection.userInterfaceStyle == .dark
87+
? .adamant.secondary
88+
: UIColor.black
89+
}
8290

91+
secretWalletsImageView.superview?.insertSubview(bgView, belowSubview: secretWalletsImageView)
92+
self.circularBackgroundView = bgView
8393
}
8494

8595
private func animateOutline() {
8696

8797
}
8898
}
8999

90-
extension AccountHeaderView{
91-
enum WalletIcon: String{
100+
extension AccountHeaderView {
101+
enum WalletIcon: String {
92102
case regular = "secret_wallets_regular"
93103
case secret = "secret_wallets_active"
94104

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,5 +271,12 @@ 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+
}
274281
}
275282
}

0 commit comments

Comments
 (0)