WIP: Gradient background for closed group create button

pull/689/head
ryanzhao 3 years ago
parent 11071c3dbc
commit ac008fbd35

@ -68,7 +68,22 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate
result.setTitle(NSLocalizedString("CREATE_GROUP_BUTTON_TITLE", comment: ""), for: .normal)
result.addTarget(self, action: #selector(createClosedGroup), for: .touchUpInside)
result.set(.width, to: 160)
result.backgroundColor = Colors.navigationBarBackground
return result
}()
private lazy var fadeView: UIView = {
let result = UIView()
let gradient = Gradients.newClosedGroupVCFade
result.setGradient(gradient, frame: .init(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 40))
result.isUserInteractionEnabled = false
result.set(.height, to: 40)
return result
}()
private lazy var buttonBackgroundView: UIView = {
let result = UIView()
result.backgroundColor = Colors.cellBackground
result.set(.height, to: 60)
return result
}()
@ -153,6 +168,14 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate
scrollView.set(.width, to: UIScreen.main.bounds.width)
scrollView.pin(to: view)
view.addSubview(buttonBackgroundView)
buttonBackgroundView.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.bottom ], to: view)
view.addSubview(fadeView)
fadeView.pin(.leading, to: .leading, of: view)
fadeView.pin(.trailing, to: .trailing, of: view)
fadeView.pin(.bottom, to: .top, of: buttonBackgroundView)
view.addSubview(createGroupButton)
createGroupButton.center(.horizontal, in: view)
createGroupButton.pin(.bottom, to: .bottom, of: view, withInset: -Values.veryLargeSpacing)

@ -16,9 +16,9 @@ public final class Gradient : NSObject {
@objc public extension UIView {
@objc func setGradient(_ gradient: Gradient) {
@objc func setGradient(_ gradient: Gradient, frame: CGRect = UIScreen.main.bounds) {
let layer = CAGradientLayer()
layer.frame = UIScreen.main.bounds
layer.frame = frame
layer.colors = [ gradient.start.cgColor, gradient.end.cgColor ]
if let existingSublayer = self.layer.sublayers?[0], existingSublayer is CAGradientLayer {
self.layer.replaceSublayer(existingSublayer, with: layer)
@ -44,4 +44,11 @@ final public class Gradients : NSObject {
case .dark: return Gradient(start: UIColor(hex: 0x000000).withAlphaComponent(0), end: UIColor(hex: 0x000000))
}
}
@objc public static var newClosedGroupVCFade: Gradient {
switch AppModeManager.shared.currentAppMode {
case .light: return Gradient(start: UIColor(hex: 0xF9F9F9).withAlphaComponent(0), end: UIColor(hex: 0xF9F9F9))
case .dark: return Gradient(start: UIColor(hex: 0x1B1B1B).withAlphaComponent(0), end: UIColor(hex: 0x1B1B1B))
}
}
}

Loading…
Cancel
Save