@@ -68,32 +68,76 @@ final class AccountHeaderView: UIView {
68
68
private extension AccountHeaderView {
69
69
func setupGestureRecognizers( ) {
70
70
secretWalletsImageView. isUserInteractionEnabled = true
71
-
72
71
let tapGesture = UITapGestureRecognizer ( target: self , action: #selector( walletsButtonTapped) )
73
72
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)
74
78
}
75
79
76
80
func updateWalletBadge( count: Int ) {
77
- secretWalletsImageView. viewWithTag ( 99 ) ? . removeFromSuperview ( )
81
+ guard let bgView = circularBackgroundView else { return }
82
+
83
+ bgView. viewWithTag ( 99 ) ? . removeFromSuperview ( )
78
84
79
85
guard count > 0 else { return }
80
86
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
+ ] )
81
110
}
82
-
111
+
83
112
private func addPersistentOutline( ) {
84
113
let bgView = UIView ( )
85
114
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
89
118
}
90
119
91
120
secretWalletsImageView. superview? . insertSubview ( bgView, belowSubview: secretWalletsImageView)
92
121
self . circularBackgroundView = bgView
93
122
}
94
123
95
124
private func animateOutline( ) {
125
+ guard let bgView = circularBackgroundView else { return }
126
+
127
+ let originalColor = bgView. backgroundColor
128
+ let highlightColor = UIColor . systemGray5
96
129
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
+ } )
97
141
}
98
142
}
99
143
0 commit comments