mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Improve smaller text rendering
This commit is contained in:
parent
a196a1684b
commit
8eaee14c41
@ -35,6 +35,16 @@ public struct LayoutMetrics: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extension LayoutMetrics {
|
||||||
|
var isTablet: Bool {
|
||||||
|
if case .regular = self.widthClass {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public enum LayoutOrientation {
|
public enum LayoutOrientation {
|
||||||
case portrait
|
case portrait
|
||||||
case landscape
|
case landscape
|
||||||
|
@ -693,7 +693,7 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
|
|||||||
|
|
||||||
func getRenderImage() -> UIImage? {
|
func getRenderImage() -> UIImage? {
|
||||||
let rect = self.bounds
|
let rect = self.bounds
|
||||||
UIGraphicsBeginImageContextWithOptions(rect.size, false, 2.0)
|
UIGraphicsBeginImageContextWithOptions(rect.size, false, 3.0)
|
||||||
self.textView.drawHierarchy(in: rect, afterScreenUpdates: true)
|
self.textView.drawHierarchy(in: rect, afterScreenUpdates: true)
|
||||||
let image = UIGraphicsGetImageFromCurrentImageContext()
|
let image = UIGraphicsGetImageFromCurrentImageContext()
|
||||||
UIGraphicsEndImageContext()
|
UIGraphicsEndImageContext()
|
||||||
|
@ -21,7 +21,7 @@ typedef struct {
|
|||||||
float grain;
|
float grain;
|
||||||
float vignette;
|
float vignette;
|
||||||
float hasCurves;
|
float hasCurves;
|
||||||
float2 empty;
|
float2 empty;
|
||||||
} MediaEditorAdjustments;
|
} MediaEditorAdjustments;
|
||||||
|
|
||||||
half3 fade(half3 color, float fadeAmount) {
|
half3 fade(half3 color, float fadeAmount) {
|
||||||
|
@ -805,154 +805,3 @@ public final class MediaEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class MediaEditorRenderChain {
|
|
||||||
fileprivate let enhancePass = EnhanceRenderPass()
|
|
||||||
fileprivate let sharpenPass = SharpenRenderPass()
|
|
||||||
fileprivate let blurPass = BlurRenderPass()
|
|
||||||
fileprivate let adjustmentsPass = AdjustmentsRenderPass()
|
|
||||||
|
|
||||||
var renderPasses: [RenderPass] {
|
|
||||||
return [
|
|
||||||
self.enhancePass,
|
|
||||||
self.sharpenPass,
|
|
||||||
self.blurPass,
|
|
||||||
self.adjustmentsPass
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
func update(values: MediaEditorValues) {
|
|
||||||
for key in EditorToolKey.allCases {
|
|
||||||
let value = values.toolValues[key]
|
|
||||||
switch key {
|
|
||||||
case .enhance:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.enhancePass.value = abs(value)
|
|
||||||
} else {
|
|
||||||
self.enhancePass.value = 0.0
|
|
||||||
}
|
|
||||||
case .brightness:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.exposure = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.exposure = 0.0
|
|
||||||
}
|
|
||||||
case .contrast:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.contrast = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.contrast = 0.0
|
|
||||||
}
|
|
||||||
case .saturation:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.saturation = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.saturation = 0.0
|
|
||||||
}
|
|
||||||
case .warmth:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.warmth = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.warmth = 0.0
|
|
||||||
}
|
|
||||||
case .fade:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.fade = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.fade = 0.0
|
|
||||||
}
|
|
||||||
case .highlights:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.highlights = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.highlights = 0.0
|
|
||||||
}
|
|
||||||
case .shadows:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.shadows = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.shadows = 0.0
|
|
||||||
}
|
|
||||||
case .vignette:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.vignette = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.vignette = 0.0
|
|
||||||
}
|
|
||||||
case .grain:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.adjustmentsPass.adjustments.grain = value
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.grain = 0.0
|
|
||||||
}
|
|
||||||
case .sharpen:
|
|
||||||
if let value = value as? Float {
|
|
||||||
self.sharpenPass.value = value
|
|
||||||
} else {
|
|
||||||
self.sharpenPass.value = 0.0
|
|
||||||
}
|
|
||||||
case .shadowsTint:
|
|
||||||
if let value = value as? TintValue {
|
|
||||||
if value.color != .clear {
|
|
||||||
let (red, green, blue, _) = value.color.components
|
|
||||||
self.adjustmentsPass.adjustments.shadowsTintColor = simd_float3(Float(red), Float(green), Float(blue))
|
|
||||||
self.adjustmentsPass.adjustments.shadowsTintIntensity = value.intensity
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.shadowsTintIntensity = 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case .highlightsTint:
|
|
||||||
if let value = value as? TintValue {
|
|
||||||
if value.color != .clear {
|
|
||||||
let (red, green, blue, _) = value.color.components
|
|
||||||
self.adjustmentsPass.adjustments.shadowsTintColor = simd_float3(Float(red), Float(green), Float(blue))
|
|
||||||
self.adjustmentsPass.adjustments.highlightsTintIntensity = value.intensity
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.highlightsTintIntensity = 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case .blur:
|
|
||||||
if let value = value as? BlurValue {
|
|
||||||
switch value.mode {
|
|
||||||
case .off:
|
|
||||||
self.blurPass.mode = .off
|
|
||||||
case .linear:
|
|
||||||
self.blurPass.mode = .linear
|
|
||||||
case .radial:
|
|
||||||
self.blurPass.mode = .radial
|
|
||||||
case .portrait:
|
|
||||||
self.blurPass.mode = .portrait
|
|
||||||
}
|
|
||||||
self.blurPass.intensity = value.intensity
|
|
||||||
self.blurPass.value.size = Float(value.size)
|
|
||||||
self.blurPass.value.position = simd_float2(Float(value.position.x), Float(value.position.y))
|
|
||||||
self.blurPass.value.falloff = Float(value.falloff)
|
|
||||||
self.blurPass.value.rotation = Float(value.rotation)
|
|
||||||
}
|
|
||||||
case .curves:
|
|
||||||
if var value = value as? CurvesValue {
|
|
||||||
let allDataPoints = value.all.dataPoints
|
|
||||||
let redDataPoints = value.red.dataPoints
|
|
||||||
let greenDataPoints = value.green.dataPoints
|
|
||||||
let blueDataPoints = value.blue.dataPoints
|
|
||||||
|
|
||||||
self.adjustmentsPass.adjustments.hasCurves = 1.0
|
|
||||||
self.adjustmentsPass.allCurve = allDataPoints
|
|
||||||
self.adjustmentsPass.redCurve = redDataPoints
|
|
||||||
self.adjustmentsPass.greenCurve = greenDataPoints
|
|
||||||
self.adjustmentsPass.blueCurve = blueDataPoints
|
|
||||||
} else {
|
|
||||||
self.adjustmentsPass.adjustments.hasCurves = 0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public func debugSaveImage(_ image: UIImage, name: String) {
|
|
||||||
let path = NSTemporaryDirectory() + "debug_\(name)_\(Int64.random(in: .min ... .max)).png"
|
|
||||||
print(path)
|
|
||||||
if let data = image.pngData() {
|
|
||||||
try? data.write(to: URL(fileURLWithPath: path))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -115,7 +115,6 @@ final class MediaEditorComposer {
|
|||||||
var pixelBuffer: CVPixelBuffer?
|
var pixelBuffer: CVPixelBuffer?
|
||||||
CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pool, &pixelBuffer)
|
CVPixelBufferPoolCreatePixelBuffer(kCFAllocatorDefault, pool, &pixelBuffer)
|
||||||
|
|
||||||
|
|
||||||
if let pixelBuffer {
|
if let pixelBuffer {
|
||||||
processImage(inputImage: ciImage, time: time, completion: { compositedImage in
|
processImage(inputImage: ciImage, time: time, completion: { compositedImage in
|
||||||
if var compositedImage {
|
if var compositedImage {
|
||||||
|
@ -41,9 +41,9 @@ private func prerenderTextTransformations(entity: DrawingTextEntity, image: UIIm
|
|||||||
if let cgImage = image.cgImage {
|
if let cgImage = image.cgImage {
|
||||||
context.draw(cgImage, in: drawRect)
|
context.draw(cgImage, in: drawRect)
|
||||||
}
|
}
|
||||||
})!
|
}, scale: 1.0)!
|
||||||
|
|
||||||
return MediaEditorComposerStaticEntity(image: CIImage(image: newImage, options: [.colorSpace: colorSpace])!, position: entity.position, scale: 1.0, rotation: 0.0, baseSize: nil, baseScale: 0.333, mirrored: false)
|
return MediaEditorComposerStaticEntity(image: CIImage(image: newImage, options: [.colorSpace: colorSpace])!, position: entity.position, scale: 1.0, rotation: 0.0, baseSize: nil, baseScale: 1.0, mirrored: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func composerEntitiesForDrawingEntity(account: Account, entity: DrawingEntity, colorSpace: CGColorSpace, tintColor: UIColor? = nil) -> [MediaEditorComposerEntity] {
|
func composerEntitiesForDrawingEntity(account: Account, entity: DrawingEntity, colorSpace: CGColorSpace, tintColor: UIColor? = nil) -> [MediaEditorComposerEntity] {
|
||||||
@ -69,9 +69,9 @@ func composerEntitiesForDrawingEntity(account: Account, entity: DrawingEntity, c
|
|||||||
return [MediaEditorComposerStaticEntity(image: image, position: CGPoint(x: entity.drawingSize.width * 0.5, y: entity.drawingSize.height * 0.5), scale: 1.0, rotation: 0.0, baseSize: entity.drawingSize, baseScale: nil, mirrored: false)]
|
return [MediaEditorComposerStaticEntity(image: image, position: CGPoint(x: entity.drawingSize.width * 0.5, y: entity.drawingSize.height * 0.5), scale: 1.0, rotation: 0.0, baseSize: entity.drawingSize, baseScale: nil, mirrored: false)]
|
||||||
} else if let entity = entity as? DrawingTextEntity {
|
} else if let entity = entity as? DrawingTextEntity {
|
||||||
var entities: [MediaEditorComposerEntity] = []
|
var entities: [MediaEditorComposerEntity] = []
|
||||||
// entities.append(prerenderTextTransformations(entity: entity, image: renderImage, colorSpace: colorSpace))
|
entities.append(prerenderTextTransformations(entity: entity, image: renderImage, colorSpace: colorSpace))
|
||||||
|
|
||||||
entities.append(MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: entity.scale, rotation: entity.rotation, baseSize: nil, baseScale: 0.5, mirrored: false))
|
// entities.append(MediaEditorComposerStaticEntity(image: image, position: entity.position, scale: entity.scale, rotation: entity.rotation, baseSize: nil, baseScale: 0.5, mirrored: false))
|
||||||
if let renderSubEntities = entity.renderSubEntities {
|
if let renderSubEntities = entity.renderSubEntities {
|
||||||
for subEntity in renderSubEntities {
|
for subEntity in renderSubEntities {
|
||||||
entities.append(contentsOf: composerEntitiesForDrawingEntity(account: account, entity: subEntity, colorSpace: colorSpace, tintColor: entity.color.toUIColor()))
|
entities.append(contentsOf: composerEntitiesForDrawingEntity(account: account, entity: subEntity, colorSpace: colorSpace, tintColor: entity.color.toUIColor()))
|
||||||
|
@ -0,0 +1,145 @@
|
|||||||
|
import Foundation
|
||||||
|
import simd
|
||||||
|
|
||||||
|
final class MediaEditorRenderChain {
|
||||||
|
let enhancePass = EnhanceRenderPass()
|
||||||
|
let sharpenPass = SharpenRenderPass()
|
||||||
|
let blurPass = BlurRenderPass()
|
||||||
|
let adjustmentsPass = AdjustmentsRenderPass()
|
||||||
|
|
||||||
|
var renderPasses: [RenderPass] {
|
||||||
|
return [
|
||||||
|
self.enhancePass,
|
||||||
|
self.sharpenPass,
|
||||||
|
self.blurPass,
|
||||||
|
self.adjustmentsPass
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
func update(values: MediaEditorValues) {
|
||||||
|
for key in EditorToolKey.allCases {
|
||||||
|
let value = values.toolValues[key]
|
||||||
|
switch key {
|
||||||
|
case .enhance:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.enhancePass.value = abs(value)
|
||||||
|
} else {
|
||||||
|
self.enhancePass.value = 0.0
|
||||||
|
}
|
||||||
|
case .brightness:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.exposure = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.exposure = 0.0
|
||||||
|
}
|
||||||
|
case .contrast:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.contrast = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.contrast = 0.0
|
||||||
|
}
|
||||||
|
case .saturation:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.saturation = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.saturation = 0.0
|
||||||
|
}
|
||||||
|
case .warmth:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.warmth = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.warmth = 0.0
|
||||||
|
}
|
||||||
|
case .fade:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.fade = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.fade = 0.0
|
||||||
|
}
|
||||||
|
case .highlights:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.highlights = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.highlights = 0.0
|
||||||
|
}
|
||||||
|
case .shadows:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.shadows = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.shadows = 0.0
|
||||||
|
}
|
||||||
|
case .vignette:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.vignette = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.vignette = 0.0
|
||||||
|
}
|
||||||
|
case .grain:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.adjustmentsPass.adjustments.grain = value
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.grain = 0.0
|
||||||
|
}
|
||||||
|
case .sharpen:
|
||||||
|
if let value = value as? Float {
|
||||||
|
self.sharpenPass.value = value
|
||||||
|
} else {
|
||||||
|
self.sharpenPass.value = 0.0
|
||||||
|
}
|
||||||
|
case .shadowsTint:
|
||||||
|
if let value = value as? TintValue {
|
||||||
|
if value.color != .clear {
|
||||||
|
let (red, green, blue, _) = value.color.components
|
||||||
|
self.adjustmentsPass.adjustments.shadowsTintColor = simd_float3(Float(red), Float(green), Float(blue))
|
||||||
|
self.adjustmentsPass.adjustments.shadowsTintIntensity = value.intensity
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.shadowsTintIntensity = 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case .highlightsTint:
|
||||||
|
if let value = value as? TintValue {
|
||||||
|
if value.color != .clear {
|
||||||
|
let (red, green, blue, _) = value.color.components
|
||||||
|
self.adjustmentsPass.adjustments.shadowsTintColor = simd_float3(Float(red), Float(green), Float(blue))
|
||||||
|
self.adjustmentsPass.adjustments.highlightsTintIntensity = value.intensity
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.highlightsTintIntensity = 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case .blur:
|
||||||
|
if let value = value as? BlurValue {
|
||||||
|
switch value.mode {
|
||||||
|
case .off:
|
||||||
|
self.blurPass.mode = .off
|
||||||
|
case .linear:
|
||||||
|
self.blurPass.mode = .linear
|
||||||
|
case .radial:
|
||||||
|
self.blurPass.mode = .radial
|
||||||
|
case .portrait:
|
||||||
|
self.blurPass.mode = .portrait
|
||||||
|
}
|
||||||
|
self.blurPass.intensity = value.intensity
|
||||||
|
self.blurPass.value.size = Float(value.size)
|
||||||
|
self.blurPass.value.position = simd_float2(Float(value.position.x), Float(value.position.y))
|
||||||
|
self.blurPass.value.falloff = Float(value.falloff)
|
||||||
|
self.blurPass.value.rotation = Float(value.rotation)
|
||||||
|
}
|
||||||
|
case .curves:
|
||||||
|
if var value = value as? CurvesValue {
|
||||||
|
let allDataPoints = value.all.dataPoints
|
||||||
|
let redDataPoints = value.red.dataPoints
|
||||||
|
let greenDataPoints = value.green.dataPoints
|
||||||
|
let blueDataPoints = value.blue.dataPoints
|
||||||
|
|
||||||
|
self.adjustmentsPass.adjustments.hasCurves = 1.0
|
||||||
|
self.adjustmentsPass.allCurve = allDataPoints
|
||||||
|
self.adjustmentsPass.redCurve = redDataPoints
|
||||||
|
self.adjustmentsPass.greenCurve = greenDataPoints
|
||||||
|
self.adjustmentsPass.blueCurve = blueDataPoints
|
||||||
|
} else {
|
||||||
|
self.adjustmentsPass.adjustments.hasCurves = 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -35,8 +35,8 @@ swift_library(
|
|||||||
"//submodules/TelegramUI/Components/TextFieldComponent",
|
"//submodules/TelegramUI/Components/TextFieldComponent",
|
||||||
"//submodules/TelegramUI/Components/ChatInputNode",
|
"//submodules/TelegramUI/Components/ChatInputNode",
|
||||||
"//submodules/TelegramUI/Components/ChatEntityKeyboardInputNode",
|
"//submodules/TelegramUI/Components/ChatEntityKeyboardInputNode",
|
||||||
|
"//submodules/TelegramUI/Components/PlainButtonComponent",
|
||||||
"//submodules/TooltipUI",
|
"//submodules/TooltipUI",
|
||||||
"//submodules/Components/BlurredBackgroundComponent",
|
|
||||||
"//submodules/AvatarNode",
|
"//submodules/AvatarNode",
|
||||||
"//submodules/TelegramUI/Components/ShareWithPeersScreen",
|
"//submodules/TelegramUI/Components/ShareWithPeersScreen",
|
||||||
"//submodules/TelegramUI/Components/CameraButtonComponent",
|
"//submodules/TelegramUI/Components/CameraButtonComponent",
|
||||||
|
@ -19,7 +19,7 @@ import MessageInputPanelComponent
|
|||||||
import TextFieldComponent
|
import TextFieldComponent
|
||||||
import EntityKeyboard
|
import EntityKeyboard
|
||||||
import TooltipUI
|
import TooltipUI
|
||||||
import BlurredBackgroundComponent
|
import PlainButtonComponent
|
||||||
import AvatarNode
|
import AvatarNode
|
||||||
import ShareWithPeersScreen
|
import ShareWithPeersScreen
|
||||||
import PresentationDataUtils
|
import PresentationDataUtils
|
||||||
@ -38,7 +38,6 @@ enum DrawingScreenType {
|
|||||||
case sticker
|
case sticker
|
||||||
}
|
}
|
||||||
|
|
||||||
private let privacyButtonTag = GenericComponentViewTag()
|
|
||||||
private let muteButtonTag = GenericComponentViewTag()
|
private let muteButtonTag = GenericComponentViewTag()
|
||||||
private let saveButtonTag = GenericComponentViewTag()
|
private let saveButtonTag = GenericComponentViewTag()
|
||||||
|
|
||||||
@ -237,11 +236,9 @@ final class MediaEditorScreenComponent: Component {
|
|||||||
|
|
||||||
private let scrubber = ComponentView<Empty>()
|
private let scrubber = ComponentView<Empty>()
|
||||||
|
|
||||||
private let privacyButton = ComponentView<Empty>()
|
|
||||||
private let flipStickerButton = ComponentView<Empty>()
|
private let flipStickerButton = ComponentView<Empty>()
|
||||||
private let muteButton = ComponentView<Empty>()
|
private let muteButton = ComponentView<Empty>()
|
||||||
private let saveButton = ComponentView<Empty>()
|
private let saveButton = ComponentView<Empty>()
|
||||||
private let settingsButton = ComponentView<Empty>()
|
|
||||||
|
|
||||||
private let textCancelButton = ComponentView<Empty>()
|
private let textCancelButton = ComponentView<Empty>()
|
||||||
private let textDoneButton = ComponentView<Empty>()
|
private let textDoneButton = ComponentView<Empty>()
|
||||||
@ -469,16 +466,6 @@ final class MediaEditorScreenComponent: Component {
|
|||||||
view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2)
|
view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let view = self.settingsButton.view {
|
|
||||||
view.layer.animateAlpha(from: 0.0, to: view.alpha, duration: 0.2)
|
|
||||||
view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let view = self.privacyButton.view {
|
|
||||||
view.layer.animateAlpha(from: 0.0, to: view.alpha, duration: 0.2)
|
|
||||||
view.layer.animateScale(from: 0.1, to: 1.0, duration: 0.2)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let view = self.inputPanel.view {
|
if let view = self.inputPanel.view {
|
||||||
view.layer.animatePosition(from: CGPoint(x: 0.0, y: 44.0), to: .zero, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, additive: true)
|
view.layer.animatePosition(from: CGPoint(x: 0.0, y: 44.0), to: .zero, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, additive: true)
|
||||||
view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||||
@ -546,16 +533,6 @@ final class MediaEditorScreenComponent: Component {
|
|||||||
transition.setScale(view: view, scale: 0.1)
|
transition.setScale(view: view, scale: 0.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let view = self.settingsButton.view {
|
|
||||||
transition.setAlpha(view: view, alpha: 0.0)
|
|
||||||
transition.setScale(view: view, scale: 0.1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let view = self.privacyButton.view {
|
|
||||||
transition.setAlpha(view: view, alpha: 0.0)
|
|
||||||
transition.setScale(view: view, scale: 0.1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let view = self.scrubber.view {
|
if let view = self.scrubber.view {
|
||||||
view.layer.animatePosition(from: .zero, to: CGPoint(x: 0.0, y: 44.0), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, additive: true)
|
view.layer.animatePosition(from: .zero, to: CGPoint(x: 0.0, y: 44.0), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, additive: true)
|
||||||
view.layer.animateAlpha(from: view.alpha, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
view.layer.animateAlpha(from: view.alpha, to: 0.0, duration: 0.2, removeOnCompletion: false)
|
||||||
@ -673,12 +650,7 @@ final class MediaEditorScreenComponent: Component {
|
|||||||
|
|
||||||
self.setupIfNeeded()
|
self.setupIfNeeded()
|
||||||
|
|
||||||
let isTablet: Bool
|
let isTablet = environment.metrics.isTablet
|
||||||
if case .regular = environment.metrics.widthClass {
|
|
||||||
isTablet = true
|
|
||||||
} else {
|
|
||||||
isTablet = false
|
|
||||||
}
|
|
||||||
|
|
||||||
let openDrawing = component.openDrawing
|
let openDrawing = component.openDrawing
|
||||||
let openTools = component.openTools
|
let openTools = component.openTools
|
||||||
@ -745,11 +717,12 @@ final class MediaEditorScreenComponent: Component {
|
|||||||
|
|
||||||
let doneButtonSize = self.doneButton.update(
|
let doneButtonSize = self.doneButton.update(
|
||||||
transition: transition,
|
transition: transition,
|
||||||
component: AnyComponent(Button(
|
component: AnyComponent(PlainButtonComponent(
|
||||||
content: AnyComponent(DoneButtonComponent(
|
content: AnyComponent(DoneButtonContentComponent(
|
||||||
backgroundColor: UIColor(rgb: 0x007aff),
|
backgroundColor: UIColor(rgb: 0x007aff),
|
||||||
icon: UIImage(bundleImageName: "Media Editor/Next")!,
|
icon: UIImage(bundleImageName: "Media Editor/Next")!,
|
||||||
title: doneButtonTitle.uppercased())),
|
title: doneButtonTitle.uppercased())),
|
||||||
|
effectAlignment: .center,
|
||||||
action: {
|
action: {
|
||||||
guard let controller = environment.controller() as? MediaEditorScreen else {
|
guard let controller = environment.controller() as? MediaEditorScreen else {
|
||||||
return
|
return
|
||||||
@ -1282,70 +1255,9 @@ final class MediaEditorScreenComponent: Component {
|
|||||||
transition.setAlpha(view: inputPanelView, alpha: isEditingTextEntity || component.isDisplayingTool || component.isDismissing || component.isInteractingWithEntities ? 0.0 : 1.0)
|
transition.setAlpha(view: inputPanelView, alpha: isEditingTextEntity || component.isDisplayingTool || component.isDismissing || component.isInteractingWithEntities ? 0.0 : 1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
let additionalPeersCount = component.privacy.privacy.additionallyIncludePeers.count
|
|
||||||
var privacyText: String
|
|
||||||
switch component.privacy.privacy.base {
|
|
||||||
case .everyone:
|
|
||||||
privacyText = environment.strings.Story_ContextPrivacy_LabelEveryone
|
|
||||||
case .closeFriends:
|
|
||||||
privacyText = environment.strings.Story_ContextPrivacy_LabelCloseFriends
|
|
||||||
case .contacts:
|
|
||||||
if additionalPeersCount > 0 {
|
|
||||||
privacyText = environment.strings.Story_ContextPrivacy_LabelContactsExcept("\(additionalPeersCount)").string
|
|
||||||
} else {
|
|
||||||
privacyText = environment.strings.Story_ContextPrivacy_LabelContacts
|
|
||||||
}
|
|
||||||
case .nobody:
|
|
||||||
if additionalPeersCount > 0 {
|
|
||||||
privacyText = environment.strings.Story_ContextPrivacy_LabelOnlySelected(Int32(additionalPeersCount))
|
|
||||||
} else {
|
|
||||||
privacyText = environment.strings.Story_ContextPrivacy_LabelOnlyMe
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let displayTopButtons = !(self.inputPanelExternalState.isEditing || isEditingTextEntity || component.isDisplayingTool)
|
let displayTopButtons = !(self.inputPanelExternalState.isEditing || isEditingTextEntity || component.isDisplayingTool)
|
||||||
|
|
||||||
let privacyButtonSize = self.privacyButton.update(
|
|
||||||
transition: transition,
|
|
||||||
component: AnyComponent(Button(
|
|
||||||
content: AnyComponent(
|
|
||||||
PrivacyButtonComponent(
|
|
||||||
backgroundColor: isTablet ? UIColor(rgb: 0x303030, alpha: 0.5) : UIColor(white: 0.0, alpha: 0.5),
|
|
||||||
icon: UIImage(bundleImageName: "Media Editor/Recipient")!,
|
|
||||||
text: privacyText
|
|
||||||
)
|
|
||||||
),
|
|
||||||
action: {
|
|
||||||
if let controller = environment.controller() as? MediaEditorScreen {
|
|
||||||
controller.openPrivacySettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).tagged(privacyButtonTag)),
|
|
||||||
environment: {},
|
|
||||||
containerSize: CGSize(width: 44.0, height: 44.0)
|
|
||||||
)
|
|
||||||
let privacyButtonFrame: CGRect
|
|
||||||
if isTablet {
|
|
||||||
privacyButtonFrame = CGRect(
|
|
||||||
origin: CGPoint(x: availableSize.width - buttonSideInset - doneButtonSize.width - privacyButtonSize.width - 24.0, y: availableSize.height - environment.safeInsets.bottom + buttonBottomInset + 1.0),
|
|
||||||
size: privacyButtonSize
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
privacyButtonFrame = CGRect(
|
|
||||||
origin: CGPoint(x: 16.0, y: environment.safeInsets.top + 20.0),
|
|
||||||
size: privacyButtonSize
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if let privacyButtonView = self.privacyButton.view {
|
|
||||||
if privacyButtonView.superview == nil {
|
|
||||||
//self.addSubview(privacyButtonView)
|
|
||||||
}
|
|
||||||
transition.setPosition(view: privacyButtonView, position: privacyButtonFrame.center)
|
|
||||||
transition.setBounds(view: privacyButtonView, bounds: CGRect(origin: .zero, size: privacyButtonFrame.size))
|
|
||||||
transition.setScale(view: privacyButtonView, scale: displayTopButtons ? 1.0 : 0.01)
|
|
||||||
transition.setAlpha(view: privacyButtonView, alpha: displayTopButtons && !component.isDismissing && !component.isInteractingWithEntities ? 1.0 : 0.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
let saveContentComponent: AnyComponentWithIdentity<Empty>
|
let saveContentComponent: AnyComponentWithIdentity<Empty>
|
||||||
if component.hasAppeared {
|
if component.hasAppeared {
|
||||||
saveContentComponent = AnyComponentWithIdentity(
|
saveContentComponent = AnyComponentWithIdentity(
|
||||||
@ -2747,10 +2659,8 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
|||||||
|
|
||||||
if let context = context {
|
if let context = context {
|
||||||
let path = UIBezierPath(roundedRect: rect, cornerRadius: cornerRadius)
|
let path = UIBezierPath(roundedRect: rect, cornerRadius: cornerRadius)
|
||||||
|
|
||||||
context.addPath(path.cgPath)
|
context.addPath(path.cgPath)
|
||||||
context.clip()
|
context.clip()
|
||||||
|
|
||||||
image.draw(in: rect)
|
image.draw(in: rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3813,9 +3723,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
|||||||
} else {
|
} else {
|
||||||
duration = durationValue
|
duration = durationValue
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = additionalPath
|
|
||||||
|
|
||||||
firstFrame = Signal<(UIImage?, UIImage?), NoError> { subscriber in
|
firstFrame = Signal<(UIImage?, UIImage?), NoError> { subscriber in
|
||||||
let avAsset = AVURLAsset(url: URL(fileURLWithPath: path))
|
let avAsset = AVURLAsset(url: URL(fileURLWithPath: path))
|
||||||
let avAssetGenerator = AVAssetImageGenerator(asset: avAsset)
|
let avAssetGenerator = AVAssetImageGenerator(asset: avAsset)
|
||||||
@ -4135,10 +4043,6 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestSettings() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fileprivate func cancelVideoExport() {
|
fileprivate func cancelVideoExport() {
|
||||||
if let videoExport = self.videoExport {
|
if let videoExport = self.videoExport {
|
||||||
self.previousSavedValues = nil
|
self.previousSavedValues = nil
|
||||||
@ -4213,80 +4117,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class PrivacyButtonComponent: CombinedComponent {
|
final class DoneButtonContentComponent: CombinedComponent {
|
||||||
let backgroundColor: UIColor
|
|
||||||
let icon: UIImage
|
|
||||||
let text: String
|
|
||||||
|
|
||||||
init(
|
|
||||||
backgroundColor: UIColor,
|
|
||||||
icon: UIImage,
|
|
||||||
text: String
|
|
||||||
) {
|
|
||||||
self.backgroundColor = backgroundColor
|
|
||||||
self.icon = icon
|
|
||||||
self.text = text
|
|
||||||
}
|
|
||||||
|
|
||||||
static func ==(lhs: PrivacyButtonComponent, rhs: PrivacyButtonComponent) -> Bool {
|
|
||||||
if lhs.backgroundColor != rhs.backgroundColor {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if lhs.text != rhs.text {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
static var body: Body {
|
|
||||||
let background = Child(BlurredBackgroundComponent.self)
|
|
||||||
let icon = Child(Image.self)
|
|
||||||
let text = Child(Text.self)
|
|
||||||
|
|
||||||
return { context in
|
|
||||||
let icon = icon.update(
|
|
||||||
component: Image(image: context.component.icon, size: CGSize(width: 9.0, height: 11.0)),
|
|
||||||
availableSize: CGSize(width: 180.0, height: 100.0),
|
|
||||||
transition: .immediate
|
|
||||||
)
|
|
||||||
|
|
||||||
let text = text.update(
|
|
||||||
component: Text(
|
|
||||||
text: context.component.text,
|
|
||||||
font: Font.medium(14.0),
|
|
||||||
color: .white
|
|
||||||
),
|
|
||||||
availableSize: CGSize(width: 180.0, height: 100.0),
|
|
||||||
transition: .immediate
|
|
||||||
)
|
|
||||||
|
|
||||||
let backgroundSize = CGSize(width: text.size.width + 38.0, height: 30.0)
|
|
||||||
let background = background.update(
|
|
||||||
component: BlurredBackgroundComponent(color: context.component.backgroundColor),
|
|
||||||
availableSize: backgroundSize,
|
|
||||||
transition: .immediate
|
|
||||||
)
|
|
||||||
|
|
||||||
context.add(background
|
|
||||||
.position(CGPoint(x: backgroundSize.width / 2.0, y: backgroundSize.height / 2.0))
|
|
||||||
.cornerRadius(min(backgroundSize.width, backgroundSize.height) / 2.0)
|
|
||||||
.clipsToBounds(true)
|
|
||||||
)
|
|
||||||
|
|
||||||
context.add(icon
|
|
||||||
.position(CGPoint(x: 16.0, y: backgroundSize.height / 2.0))
|
|
||||||
)
|
|
||||||
|
|
||||||
context.add(text
|
|
||||||
.position(CGPoint(x: backgroundSize.width / 2.0 + 7.0, y: backgroundSize.height / 2.0))
|
|
||||||
)
|
|
||||||
|
|
||||||
return backgroundSize
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final class DoneButtonComponent: CombinedComponent {
|
|
||||||
let backgroundColor: UIColor
|
let backgroundColor: UIColor
|
||||||
let icon: UIImage
|
let icon: UIImage
|
||||||
let title: String?
|
let title: String?
|
||||||
@ -4301,7 +4132,7 @@ final class DoneButtonComponent: CombinedComponent {
|
|||||||
self.title = title
|
self.title = title
|
||||||
}
|
}
|
||||||
|
|
||||||
static func ==(lhs: DoneButtonComponent, rhs: DoneButtonComponent) -> Bool {
|
static func ==(lhs: DoneButtonContentComponent, rhs: DoneButtonContentComponent) -> Bool {
|
||||||
if lhs.backgroundColor != rhs.backgroundColor {
|
if lhs.backgroundColor != rhs.backgroundColor {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -383,8 +383,6 @@ public final class SaveProgressScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private let storyDimensions = CGSize(width: 1080.0, height: 1920.0)
|
|
||||||
|
|
||||||
public final class SaveProgressScreen: ViewController {
|
public final class SaveProgressScreen: ViewController {
|
||||||
fileprivate final class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
|
fileprivate final class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
|
||||||
private weak var controller: SaveProgressScreen?
|
private weak var controller: SaveProgressScreen?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user