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.spacing = spacing
|
||||
stackView.alignment = .fill
|
||||
stackView.set(.width, to: UIScreen.main.bounds.width)
|
||||
let vInset = Values.smallSpacing
|
||||
stackView.layoutMargins = UIEdgeInsets(top: vInset, leading: Values.veryLargeSpacing, bottom: vInset, trailing: Values.veryLargeSpacing)
|
||||
stackView.isLayoutMarginsRelativeArrangement = true
|
||||
scrollView.addSubview(stackView)
|
||||
stackView.pin(to: scrollView)
|
||||
stackView.set(.width, to: .width, of: scrollView)
|
||||
addSubview(scrollView)
|
||||
scrollView.pin(to: self)
|
||||
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)
|
||||
}
|
||||
|
||||
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() {
|
||||
let appMode = AppModeManager.shared.currentAppMode
|
||||
switch appMode {
|
||||
|
@ -38,11 +45,11 @@ class BaseVC : UIViewController {
|
|||
}
|
||||
}
|
||||
|
||||
internal func setUpGradientBackground() {
|
||||
internal func setUpGradientBackground(frame: CGRect = UIScreen.main.bounds) {
|
||||
hasGradient = true
|
||||
view.backgroundColor = .clear
|
||||
let gradient = Gradients.defaultBackground
|
||||
view.setGradient(gradient)
|
||||
view.setGradient(gradient, frame: frame)
|
||||
}
|
||||
|
||||
internal func setUpNavBarStyle() {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue