Skip to content

Commit

Permalink
👌 Update capture image asset to include gradient
Browse files Browse the repository at this point in the history
  • Loading branch information
iujames authored and mmaatttt committed Apr 11, 2023
1 parent d4df717 commit 60867dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
"preserves-vector-representation" : true
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,6 @@ internal protocol FloatingViewDelegate: AnyObject {
func floatingViewActivated()
}

// a helper to return a view with a blurple haze gradient background and
// a given image, tinted white and centered with a given size over the gradient
@available(iOS 13.0, *)
private class FloatingImageView: UIView {

private let image: UIImage?

private lazy var imageView: UIImageView = {
let imageView = UIImageView(image: image)
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.clipsToBounds = true
imageView.tintColor = .white
return imageView
}()

private lazy var gradient = CAGradientLayer.blurpleHazeHorizontal

init(image: UIImage?, size: CGSize) {
self.image = image
super.init(frame: .zero)
layer.addSublayer(gradient)
addSubview(imageView)
NSLayoutConstraint.activate([
imageView.centerXAnchor.constraint(equalTo: self.centerXAnchor),
imageView.centerYAnchor.constraint(equalTo: self.centerYAnchor),
imageView.widthAnchor.constraint(equalToConstant: size.width),
imageView.heightAnchor.constraint(equalToConstant: size.height)
])
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func layoutSubviews() {
super.layoutSubviews()
gradient.frame = self.bounds
}
}

@available(iOS 13.0, *)
internal class FloatingView: UIView {

Expand All @@ -62,10 +21,11 @@ internal class FloatingView: UIView {
private let mode: DebugMode

private lazy var modeIconView: UIView = {
let view = mode.imageView
view.translatesAutoresizingMaskIntoConstraints = false
view.clipsToBounds = true
return view
let imageView = UIImageView(image: UIImage(asset: mode.imageAsset))
imageView.backgroundColor = .secondarySystemBackground
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.clipsToBounds = true
return imageView
}()

init(frame: CGRect, mode: DebugMode) {
Expand Down Expand Up @@ -223,27 +183,12 @@ private extension DebugMode {
}
}

var imageView: UIView {
var imageAsset: ImageAsset {
switch self {
case .debugger:
let imageView = UIImageView(image: UIImage(asset: Asset.Image.debugIcon))
imageView.backgroundColor = .secondarySystemBackground
return imageView
return Asset.Image.debugIcon
case.screenCapture:
return FloatingImageView(image: UIImage(asset: Asset.Image.captureScreen), size: CGSize(width: 24.0, height: 24.0))
return Asset.Image.captureScreen
}
}
}

@available(iOS 13.0, *)
extension CAGradientLayer {
static var blurpleHazeHorizontal: CAGradientLayer {
let gradient = CAGradientLayer()
let startColor = CGColor(red: 92.0 / 255.0, green: 92.0 / 255.0, blue: 1.0, alpha: 1.0)
let endColor = CGColor(red: 137.0 / 255.0, green: 96.0 / 255.0, blue: 1.0, alpha: 1.0)
gradient.colors = [startColor, endColor]
gradient.startPoint = CGPoint(x: 0.0, y: 0.5)
gradient.endPoint = CGPoint(x: 1.0, y: 0.5)
return gradient
}
}

0 comments on commit 60867dc

Please sign in to comment.