@@ -24,6 +24,7 @@ final class MergeButton: UIView {
2424 private let mergeLabel = UILabel ( )
2525 private let optionBorder = UIView ( )
2626 private let activityView = UIActivityIndicatorView ( activityIndicatorStyle: . gray)
27+ private let gradientLayer = CAGradientLayer ( )
2728
2829 override init ( frame: CGRect ) {
2930 super. init ( frame: frame)
@@ -72,18 +73,43 @@ final class MergeButton: UIView {
7273 required init ? ( coder aDecoder: NSCoder ) {
7374 fatalError ( " init(coder:) has not been implemented " )
7475 }
76+
77+ override func layoutSubviews( ) {
78+ super. layoutSubviews ( )
79+ gradientLayer. frame = bounds
80+ }
7581
7682 // MARK: Public
7783
7884 func configure( title: String , enabled: Bool , loading: Bool ) {
7985 isUserInteractionEnabled = enabled && !loading
8086
81- backgroundColor = ( enabled
82- ? Styles . Colors. Green. medium. color
83- : Styles . Colors. Gray. light. color)
84- . withAlphaComponent ( loading ? 0.2 : 1 )
85- alpha = enabled ? 1 : 0.3
86-
87+ switch ( enabled, loading) {
88+ case ( false , false ) :
89+ backgroundColor = Styles . Colors. Gray. light. color
90+ alpha = 0.3
91+
92+ case ( false , true ) :
93+ backgroundColor = Styles . Colors. Gray. light. color. withAlphaComponent ( 0.2 )
94+ alpha = 0.3
95+
96+ case ( true , true ) :
97+ backgroundColor = Styles . Colors. Green. medium. color. withAlphaComponent ( 0.2 )
98+
99+ case ( true , false ) :
100+ guard gradientLayer. superlayer == nil else { break }
101+ gradientLayer. cornerRadius = layer. cornerRadius
102+ gradientLayer. colors = [
103+ UIColor . fromHex ( " 34d058 " ) . cgColor,
104+ Styles . Colors. Green. medium. color. cgColor
105+ ]
106+ layer. addSublayer ( gradientLayer)
107+
108+ [ mergeLabel, optionIconView, optionBorder, activityView] . forEach {
109+ bringSubview ( toFront: $0)
110+ }
111+ }
112+
87113 let titleColor = enabled ? . white : Styles . Colors. Gray. dark. color
88114 mergeLabel. textColor = titleColor
89115 optionIconView. tintColor = titleColor
0 commit comments