diff --git a/Session/Closed Groups/NewClosedGroupVC.swift b/Session/Closed Groups/NewClosedGroupVC.swift index 710c16ba3..4fcbcc0ab 100644 --- a/Session/Closed Groups/NewClosedGroupVC.swift +++ b/Session/Closed Groups/NewClosedGroupVC.swift @@ -74,16 +74,17 @@ final class NewClosedGroupVC: BaseVC, UITableViewDataSource, UITableViewDelegate 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.setHalfWayGradient( + gradient, + frame: .init( + x: 0, + y: 0, + width: UIScreen.main.bounds.width, + height: 150 + ) + ) 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) + result.set(.height, to: 150) return result }() @@ -168,19 +169,31 @@ 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) + fadeView.pin(.bottom, to: .bottom, of: view) view.addSubview(createGroupButton) createGroupButton.center(.horizontal, in: view) createGroupButton.pin(.bottom, to: .bottom, of: view, withInset: -Values.veryLargeSpacing) } + @objc override internal func handleAppModeChangedNotification(_ notification: Notification) { + super.handleAppModeChangedNotification(notification) + + let gradient = Gradients.newClosedGroupVCFade + fadeView.setHalfWayGradient( + gradient, + frame: .init( + x: 0, + y: 0, + width: UIScreen.main.bounds.width, + height: 150 + ) + ) // Re-do the gradient + } + // MARK: - Table View Data Source func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { diff --git a/SessionUIKit/Style Guide/Gradients.swift b/SessionUIKit/Style Guide/Gradients.swift index 0745322be..1970ecc42 100644 --- a/SessionUIKit/Style Guide/Gradients.swift +++ b/SessionUIKit/Style Guide/Gradients.swift @@ -16,9 +16,9 @@ public final class Gradient : NSObject { @objc public extension UIView { - @objc func setGradient(_ gradient: Gradient, frame: CGRect = UIScreen.main.bounds) { + @objc func setGradient(_ gradient: Gradient) { let layer = CAGradientLayer() - layer.frame = frame + layer.frame = UIScreen.main.bounds layer.colors = [ gradient.start.cgColor, gradient.end.cgColor ] if let existingSublayer = self.layer.sublayers?[0], existingSublayer is CAGradientLayer { self.layer.replaceSublayer(existingSublayer, with: layer) @@ -26,6 +26,17 @@ public final class Gradient : NSObject { self.layer.insertSublayer(layer, at: 0) } } + + func setHalfWayGradient(_ gradient: Gradient, frame: CGRect = UIScreen.main.bounds) { + let layer = CAGradientLayer() + layer.frame = frame + layer.colors = [ gradient.start.cgColor, gradient.end.cgColor, gradient.end.cgColor ] + if let existingSublayer = self.layer.sublayers?[0], existingSublayer is CAGradientLayer { + self.layer.replaceSublayer(existingSublayer, with: layer) + } else { + self.layer.insertSublayer(layer, at: 0) + } + } } @objc(LKGradients)