@@ -68,32 +68,76 @@ final class AccountHeaderView: UIView {
6868private 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
0 commit comments