mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
fix gradient background
This commit is contained in:
parent
47d41ea64d
commit
bd1e1b266b
|
@ -46,12 +46,12 @@ final class FakeChatView : UIView {
|
||||||
stackView.axis = .vertical
|
stackView.axis = .vertical
|
||||||
stackView.spacing = spacing
|
stackView.spacing = spacing
|
||||||
stackView.alignment = .fill
|
stackView.alignment = .fill
|
||||||
stackView.set(.width, to: UIScreen.main.bounds.width)
|
|
||||||
let vInset = Values.smallSpacing
|
let vInset = Values.smallSpacing
|
||||||
stackView.layoutMargins = UIEdgeInsets(top: vInset, leading: Values.veryLargeSpacing, bottom: vInset, trailing: Values.veryLargeSpacing)
|
stackView.layoutMargins = UIEdgeInsets(top: vInset, leading: Values.veryLargeSpacing, bottom: vInset, trailing: Values.veryLargeSpacing)
|
||||||
stackView.isLayoutMarginsRelativeArrangement = true
|
stackView.isLayoutMarginsRelativeArrangement = true
|
||||||
scrollView.addSubview(stackView)
|
scrollView.addSubview(stackView)
|
||||||
stackView.pin(to: scrollView)
|
stackView.pin(to: scrollView)
|
||||||
|
stackView.set(.width, to: .width, of: scrollView)
|
||||||
addSubview(scrollView)
|
addSubview(scrollView)
|
||||||
scrollView.pin(to: self)
|
scrollView.pin(to: self)
|
||||||
let height = chatBubbles.reduce(0) { $0 + $1.systemLayoutSizeFitting(UIView.layoutFittingExpandedSize).height } + CGFloat(chatBubbles.count - 1) * spacing + 2 * vInset
|
let height = chatBubbles.reduce(0) { $0 + $1.systemLayoutSizeFitting(UIView.layoutFittingExpandedSize).height } + CGFloat(chatBubbles.count - 1) * spacing + 2 * vInset
|
||||||
|
|
|
@ -28,6 +28,13 @@ class BaseVC : UIViewController {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: .OWSApplicationDidBecomeActive, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive(_:)), name: .OWSApplicationDidBecomeActive, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||||
|
if hasGradient {
|
||||||
|
let frame = CGRect(x: 0, y: 0, width: size.width, height: size.height)
|
||||||
|
setUpGradientBackground(frame: frame)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal func ensureWindowBackground() {
|
internal func ensureWindowBackground() {
|
||||||
let appMode = AppModeManager.shared.currentAppMode
|
let appMode = AppModeManager.shared.currentAppMode
|
||||||
switch appMode {
|
switch appMode {
|
||||||
|
@ -38,11 +45,11 @@ class BaseVC : UIViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func setUpGradientBackground() {
|
internal func setUpGradientBackground(frame: CGRect = UIScreen.main.bounds) {
|
||||||
hasGradient = true
|
hasGradient = true
|
||||||
view.backgroundColor = .clear
|
view.backgroundColor = .clear
|
||||||
let gradient = Gradients.defaultBackground
|
let gradient = Gradients.defaultBackground
|
||||||
view.setGradient(gradient)
|
view.setGradient(gradient, frame: frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func setUpNavBarStyle() {
|
internal func setUpNavBarStyle() {
|
||||||
|
|
|
@ -16,9 +16,9 @@ public final class Gradient : NSObject {
|
||||||
|
|
||||||
@objc public extension UIView {
|
@objc public extension UIView {
|
||||||
|
|
||||||
@objc func setGradient(_ gradient: Gradient) {
|
@objc func setGradient(_ gradient: Gradient, frame: CGRect = UIScreen.main.bounds) {
|
||||||
let layer = CAGradientLayer()
|
let layer = CAGradientLayer()
|
||||||
layer.frame = UIScreen.main.bounds
|
layer.frame = frame
|
||||||
layer.colors = [ gradient.start.cgColor, gradient.end.cgColor ]
|
layer.colors = [ gradient.start.cgColor, gradient.end.cgColor ]
|
||||||
if let existingSublayer = self.layer.sublayers?[0], existingSublayer is CAGradientLayer {
|
if let existingSublayer = self.layer.sublayers?[0], existingSublayer is CAGradientLayer {
|
||||||
self.layer.replaceSublayer(existingSublayer, with: layer)
|
self.layer.replaceSublayer(existingSublayer, with: layer)
|
||||||
|
|
Loading…
Reference in a new issue