mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 11:20:18 +00:00
Camera and editor improvements
This commit is contained in:
parent
82a59e4e60
commit
137e234310
@ -878,6 +878,7 @@ public class CameraScreen: ViewController {
|
|||||||
self.effectivePreviewView.addGestureRecognizer(pinchGestureRecognizer)
|
self.effectivePreviewView.addGestureRecognizer(pinchGestureRecognizer)
|
||||||
|
|
||||||
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.handlePan(_:)))
|
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.handlePan(_:)))
|
||||||
|
panGestureRecognizer.maximumNumberOfTouches = 1
|
||||||
self.effectivePreviewView.addGestureRecognizer(panGestureRecognizer)
|
self.effectivePreviewView.addGestureRecognizer(panGestureRecognizer)
|
||||||
|
|
||||||
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
|
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
|
||||||
|
|||||||
@ -221,7 +221,7 @@ final class MediaEditorRenderer: TextureConsumer {
|
|||||||
|
|
||||||
if let onNextRender = self.onNextRender {
|
if let onNextRender = self.onNextRender {
|
||||||
self.onNextRender = nil
|
self.onNextRender = nil
|
||||||
Queue.mainQueue().async {
|
Queue.mainQueue().after(0.1) {
|
||||||
onNextRender()
|
onNextRender()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -702,7 +702,7 @@ final class MediaEditorScreenComponent: Component {
|
|||||||
case 86400:
|
case 86400:
|
||||||
timeoutValue = "24"
|
timeoutValue = "24"
|
||||||
case 172800:
|
case 172800:
|
||||||
timeoutValue = "2d"
|
timeoutValue = "48"
|
||||||
default:
|
default:
|
||||||
timeoutValue = "24"
|
timeoutValue = "24"
|
||||||
}
|
}
|
||||||
@ -1640,8 +1640,10 @@ public final class MediaEditorScreen: ViewController {
|
|||||||
|
|
||||||
self.mediaEditor?.onFirstDisplay = { [weak self] in
|
self.mediaEditor?.onFirstDisplay = { [weak self] in
|
||||||
if let self, let transitionInView = self.transitionInView {
|
if let self, let transitionInView = self.transitionInView {
|
||||||
transitionInView.removeFromSuperview()
|
|
||||||
self.transitionInView = nil
|
self.transitionInView = nil
|
||||||
|
transitionInView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak transitionInView] _ in
|
||||||
|
transitionInView?.removeFromSuperview()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2502,7 +2504,7 @@ public final class MediaEditorScreen: ViewController {
|
|||||||
|
|
||||||
updateTimeout(86400, false)
|
updateTimeout(86400, false)
|
||||||
})))
|
})))
|
||||||
items.append(.action(ContextMenuActionItem(text: "2 Days", icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: "48 Hours", icon: { theme in
|
||||||
return currentValue == 86400 * 2 ? generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor) : nil
|
return currentValue == 86400 * 2 ? generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.contextMenu.primaryColor) : nil
|
||||||
}, action: { _, a in
|
}, action: { _, a in
|
||||||
a(.default)
|
a(.default)
|
||||||
|
|||||||
@ -132,7 +132,7 @@ final class VideoScrubberComponent: Component {
|
|||||||
private var isPanningPositionHandle = false
|
private var isPanningPositionHandle = false
|
||||||
|
|
||||||
private var displayLink: SharedDisplayLinkDriver.Link?
|
private var displayLink: SharedDisplayLinkDriver.Link?
|
||||||
private var positionAnimation: (start: Double, from: Double, to: Double)?
|
private var positionAnimation: (start: Double, from: Double, to: Double, ended: Bool)?
|
||||||
|
|
||||||
override init(frame: CGRect) {
|
override init(frame: CGRect) {
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
@ -343,12 +343,12 @@ final class VideoScrubberComponent: Component {
|
|||||||
let timestamp = CACurrentMediaTime()
|
let timestamp = CACurrentMediaTime()
|
||||||
|
|
||||||
let updatedPosition: Double
|
let updatedPosition: Double
|
||||||
if let (start, from, to) = self.positionAnimation {
|
if let (start, from, to, _) = self.positionAnimation {
|
||||||
let duration = to - from
|
let duration = to - from
|
||||||
let fraction = duration > 0.0 ? (timestamp - start) / duration : 0.0
|
let fraction = duration > 0.0 ? (timestamp - start) / duration : 0.0
|
||||||
updatedPosition = max(component.startPosition, min(component.endPosition, from + (to - from) * fraction))
|
updatedPosition = max(component.startPosition, min(component.endPosition, from + (to - from) * fraction))
|
||||||
if fraction >= 1.0 {
|
if fraction >= 1.0 {
|
||||||
self.positionAnimation = (timestamp, component.startPosition, component.endPosition)
|
self.positionAnimation = (start, from, to, true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let advance = component.isPlaying ? timestamp - component.generationTimestamp : 0.0
|
let advance = component.isPlaying ? timestamp - component.generationTimestamp : 0.0
|
||||||
@ -419,8 +419,12 @@ final class VideoScrubberComponent: Component {
|
|||||||
self.displayLink?.isPaused = true
|
self.displayLink?.isPaused = true
|
||||||
transition.setFrame(view: self.cursorView, frame: cursorFrame(size: scrubberSize, position: component.position, duration: component.duration))
|
transition.setFrame(view: self.cursorView, frame: cursorFrame(size: scrubberSize, position: component.position, duration: component.duration))
|
||||||
} else {
|
} else {
|
||||||
if self.positionAnimation == nil {
|
if let (_, _, end, ended) = self.positionAnimation {
|
||||||
self.positionAnimation = (CACurrentMediaTime(), component.position, component.endPosition)
|
if ended, component.position >= component.startPosition && component.position < end - 1.0 {
|
||||||
|
self.positionAnimation = (CACurrentMediaTime(), component.position, component.endPosition, false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.positionAnimation = (CACurrentMediaTime(), component.position, component.endPosition, false)
|
||||||
}
|
}
|
||||||
self.displayLink?.isPaused = false
|
self.displayLink?.isPaused = false
|
||||||
self.updateCursorPosition()
|
self.updateCursorPosition()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user