Camera and editor improvements

This commit is contained in:
Ilya Laktyushin
2023-06-11 01:08:55 +04:00
parent 12dde45917
commit ec9cb0a09f
8 changed files with 173 additions and 24 deletions

View File

@@ -180,6 +180,7 @@ public final class _UpdatedChildComponent {
var _opacity: CGFloat?
var _cornerRadius: CGFloat?
var _clipsToBounds: Bool?
var _shadow: Shadow?
fileprivate var transitionAppear: Transition.Appear?
fileprivate var transitionAppearWithGuide: (Transition.AppearWithGuide, _AnyChildComponent.Id)?
@@ -260,6 +261,11 @@ public final class _UpdatedChildComponent {
self._clipsToBounds = clipsToBounds
return self
}
@discardableResult public func shadow(_ shadow: Shadow?) -> _UpdatedChildComponent {
self._shadow = shadow
return self
}
@discardableResult public func gesture(_ gesture: Gesture) -> _UpdatedChildComponent {
self.gestures.append(gesture)
@@ -706,6 +712,16 @@ public extension CombinedComponent {
updatedChild.view.alpha = updatedChild._opacity ?? 1.0
updatedChild.view.clipsToBounds = updatedChild._clipsToBounds ?? false
updatedChild.view.layer.cornerRadius = updatedChild._cornerRadius ?? 0.0
if let shadow = updatedChild._shadow {
updatedChild.view.layer.shadowColor = shadow.color.withAlphaComponent(1.0).cgColor
updatedChild.view.layer.shadowRadius = shadow.radius
updatedChild.view.layer.shadowOpacity = Float(shadow.color.alpha)
updatedChild.view.layer.shadowOffset = shadow.offset
} else {
updatedChild.view.layer.shadowColor = nil
updatedChild.view.layer.shadowRadius = 0.0
updatedChild.view.layer.shadowOpacity = 0.0
}
updatedChild.view.context(typeErasedComponent: updatedChild.component).erasedState._updated = { [weak viewContext] transition in
guard let viewContext = viewContext else {
return
@@ -834,3 +850,19 @@ public extension CombinedComponent {
return ActionSlot<Arguments>()
}
}
public struct Shadow {
public let color: UIColor
public let radius: CGFloat
public let offset: CGSize
public init(
color: UIColor,
radius: CGFloat,
offset: CGSize
) {
self.color = color
self.radius = radius
self.offset = offset
}
}