Use solid gray color for background of the "switch camera" button.
This commit is contained in:
parent
9d13aa609f
commit
b4e7a73808
@ -617,12 +617,13 @@ class CameraOverlayButton: UIButton, UserInterfaceStyleOverride {
|
||||
}
|
||||
}
|
||||
|
||||
private let backgroundView: CircleBlurView = {
|
||||
let view = CircleBlurView(effect: UIBlurEffect(style: .regular))
|
||||
view.isUserInteractionEnabled = false
|
||||
return view
|
||||
}()
|
||||
enum BackgroundStyle {
|
||||
case solid
|
||||
case blur
|
||||
}
|
||||
|
||||
let backgroundStyle: BackgroundStyle
|
||||
let backgroundView: UIView
|
||||
private static let visibleButtonSize: CGFloat = 36 // both height and width
|
||||
private static let defaultInset: CGFloat = 4
|
||||
|
||||
@ -632,7 +633,18 @@ class CameraOverlayButton: UIButton, UserInterfaceStyleOverride {
|
||||
}
|
||||
}
|
||||
|
||||
required init(image: UIImage?, userInterfaceStyleOverride: UIUserInterfaceStyle = .unspecified) {
|
||||
required init(image: UIImage?, backgroundStyle: BackgroundStyle = .blur, userInterfaceStyleOverride: UIUserInterfaceStyle = .unspecified) {
|
||||
self.backgroundStyle = backgroundStyle
|
||||
self.backgroundView = {
|
||||
switch backgroundStyle {
|
||||
case .solid:
|
||||
return CircleView()
|
||||
|
||||
case .blur:
|
||||
return CircleBlurView(effect: UIBlurEffect(style: .regular))
|
||||
}
|
||||
}()
|
||||
|
||||
super.init(frame: CGRect(origin: .zero, size: .square(Self.visibleButtonSize + 2*Self.defaultInset)))
|
||||
|
||||
self.userInterfaceStyleOverride = userInterfaceStyleOverride
|
||||
@ -640,6 +652,7 @@ class CameraOverlayButton: UIButton, UserInterfaceStyleOverride {
|
||||
layoutMargins = contentInsets
|
||||
|
||||
addSubview(backgroundView)
|
||||
backgroundView.isUserInteractionEnabled = false
|
||||
backgroundView.autoPinEdgesToSuperviewMargins()
|
||||
|
||||
setImage(image, for: .normal)
|
||||
@ -673,8 +686,26 @@ class CameraOverlayButton: UIButton, UserInterfaceStyleOverride {
|
||||
}
|
||||
}
|
||||
|
||||
private static func backgroundColor(for userInterfaceStyle: UIUserInterfaceStyle) -> UIColor {
|
||||
switch userInterfaceStyle {
|
||||
case .dark:
|
||||
return .ows_gray80
|
||||
case .light:
|
||||
return .ows_gray20
|
||||
default:
|
||||
fatalError("It is an error to pass UIUserInterfaceStyleUnspecified.")
|
||||
}
|
||||
}
|
||||
|
||||
private func updateStyle() {
|
||||
backgroundView.effect = UIBlurEffect(style: CameraOverlayButton.blurEffectStyle(for: effectiveUserInterfaceStyle))
|
||||
switch backgroundStyle {
|
||||
case .solid:
|
||||
backgroundView.backgroundColor = CameraOverlayButton.backgroundColor(for: effectiveUserInterfaceStyle)
|
||||
case .blur:
|
||||
if let circleBlurView = backgroundView as? CircleBlurView {
|
||||
circleBlurView.effect = UIBlurEffect(style: CameraOverlayButton.blurEffectStyle(for: effectiveUserInterfaceStyle))
|
||||
}
|
||||
}
|
||||
tintColor = CameraOverlayButton.tintColor(for: effectiveUserInterfaceStyle)
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,7 +787,7 @@ private class BottomBar: UIView {
|
||||
}
|
||||
|
||||
let photoLibraryButton = MediaPickerThumbnailButton(frame: .zero)
|
||||
let switchCameraButton = CameraOverlayButton(image: ButtonImages.switchCamera, userInterfaceStyleOverride: .dark)
|
||||
let switchCameraButton = CameraOverlayButton(image: ButtonImages.switchCamera, backgroundStyle: .solid, userInterfaceStyleOverride: .dark)
|
||||
let controlButtonsLayoutGuide = UILayoutGuide() // area encompassing Photo Library and Switch Camera buttons.
|
||||
|
||||
let captureControl = CameraCaptureControl(axis: .horizontal)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user