[WIP] Story collage

This commit is contained in:
Ilya Laktyushin 2024-11-28 14:02:23 +04:00
parent ee5d85facd
commit 6b528aa70f
3 changed files with 36 additions and 30 deletions

View File

@ -738,7 +738,7 @@ final class CameraCollageView: UIView, UIGestureRecognizerDelegate {
self.extractedContainerView.contentView.clipsToBounds = false
self.clippingView.clipsToBounds = false
let scale = size.width / originalCameraFrame.width
let scale = self.bounds.width / originalCameraFrame.width
transition.animateScale(view: cameraContainerView, from: 1.0, to: scale)
transition.animatePosition(view: cameraContainerView, from: originalCameraFrame.center, to: cameraContainerView.center, completion: { _ in
self.extractedContainerView.contentView.clipsToBounds = true
@ -815,7 +815,7 @@ final class CameraCollageView: UIView, UIGestureRecognizerDelegate {
self.state = state
if let size = self.validLayout {
var transition: ComponentTransition = .spring(duration: 0.3)
if let previousState, previousState.innerProgress != state.innerProgress {
if let previousState, previousState.grid == state.grid && previousState.innerProgress != state.innerProgress {
transition = .immediate
}
var progressUpdated = false

View File

@ -300,7 +300,7 @@ final class CameraVideoLayer: MetalEngineSubjectLayer, MetalEngineSubject {
encoder.setFragmentTexture(blurredTexture, index: 0)
var brightness: Float = 0.75
var brightness: Float = 0.85
var saturation: Float = 1.3
var overlay: SIMD4<Float> = SIMD4<Float>()
encoder.setFragmentBytes(&brightness, length: 4, index: 0)
@ -311,32 +311,32 @@ final class CameraVideoLayer: MetalEngineSubjectLayer, MetalEngineSubject {
})
}
context.renderToLayer(spec: renderSpec, state: RenderState.self, layer: self, inputs: rgbaTexture.placeholer, commands: { encoder, placement, rgbaTexture in
guard let rgbaTexture else {
return
}
let effectiveRect = placement.effectiveRect
var rect = SIMD4<Float>(Float(effectiveRect.minX), Float(effectiveRect.minY), Float(effectiveRect.width), Float(effectiveRect.height))
encoder.setVertexBytes(&rect, length: 4 * 4, index: 0)
var mirror = SIMD2<UInt32>(
videoTextures.mirrorDirection.contains(.horizontal) ? 1 : 0,
videoTextures.mirrorDirection.contains(.vertical) ? 1 : 0
)
encoder.setVertexBytes(&mirror, length: 2 * 4, index: 1)
encoder.setFragmentTexture(rgbaTexture, index: 0)
var brightness: Float = 1.0
var saturation: Float = 1.0
var overlay: SIMD4<Float> = SIMD4<Float>()
encoder.setFragmentBytes(&brightness, length: 4, index: 0)
encoder.setFragmentBytes(&saturation, length: 4, index: 1)
encoder.setFragmentBytes(&overlay, length: 4 * 4, index: 2)
encoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 6)
})
// context.renderToLayer(spec: renderSpec, state: RenderState.self, layer: self, inputs: rgbaTexture.placeholer, commands: { encoder, placement, rgbaTexture in
// guard let rgbaTexture else {
// return
// }
//
// let effectiveRect = placement.effectiveRect
//
// var rect = SIMD4<Float>(Float(effectiveRect.minX), Float(effectiveRect.minY), Float(effectiveRect.width), Float(effectiveRect.height))
// encoder.setVertexBytes(&rect, length: 4 * 4, index: 0)
//
// var mirror = SIMD2<UInt32>(
// videoTextures.mirrorDirection.contains(.horizontal) ? 1 : 0,
// videoTextures.mirrorDirection.contains(.vertical) ? 1 : 0
// )
// encoder.setVertexBytes(&mirror, length: 2 * 4, index: 1)
//
// encoder.setFragmentTexture(rgbaTexture, index: 0)
//
// var brightness: Float = 1.0
// var saturation: Float = 1.0
// var overlay: SIMD4<Float> = SIMD4<Float>()
// encoder.setFragmentBytes(&brightness, length: 4, index: 0)
// encoder.setFragmentBytes(&saturation, length: 4, index: 1)
// encoder.setFragmentBytes(&overlay, length: 4 * 4, index: 2)
//
// encoder.drawPrimitives(type: .triangle, vertexStart: 0, vertexCount: 6)
// })
}
}

View File

@ -2349,6 +2349,12 @@ public final class WebAppController: ViewController, AttachmentContainable {
guard let controller = self.controller else {
return
}
guard !fileName.contains("/") && fileName.lengthOfBytes(using: .utf8) < 256 && url.lengthOfBytes(using: .utf8) < 32768 else {
self.webView?.sendEvent(name: "file_download_requested", data: "{status: \"cancelled\"}")
return
}
var isMedia = false
var title: String?
let photoExtensions = [".jpg", ".png", ".gif", ".tiff"]