mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
Video editor fixes
This commit is contained in:
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
@property (nonatomic, copy) void (^tabsChanged)(void);
|
@property (nonatomic, copy) void (^tabsChanged)(void);
|
||||||
|
|
||||||
|
@property (nonatomic, copy) void (^controlVideoPlayback)(bool);
|
||||||
|
|
||||||
@property (nonatomic, assign) TGPhotoEditorTab availableTabs;
|
@property (nonatomic, assign) TGPhotoEditorTab availableTabs;
|
||||||
|
|
||||||
@property (nonatomic, assign) TGPhotoEditorTab switchingToTab;
|
@property (nonatomic, assign) TGPhotoEditorTab switchingToTab;
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
|
|
||||||
@protocol TGPhotoPaintStickersScreen <NSObject>
|
@protocol TGPhotoPaintStickersScreen <NSObject>
|
||||||
|
|
||||||
|
@property (nonatomic, copy) void(^screenDidAppear)(void);
|
||||||
|
@property (nonatomic, copy) void(^screenWillDisappear)(void);
|
||||||
|
|
||||||
- (void)restore;
|
- (void)restore;
|
||||||
- (void)invalidate;
|
- (void)invalidate;
|
||||||
|
|
||||||
|
|||||||
@@ -913,8 +913,14 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||||||
|
|
||||||
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
||||||
{
|
{
|
||||||
if (editableItem.isVideo && [editableItem isKindOfClass:[TGMediaAsset class]]) {
|
if (editableItem.isVideo) {
|
||||||
|
if ([editableItem isKindOfClass:[TGMediaAsset class]]) {
|
||||||
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
||||||
|
} else if ([editableItem isKindOfClass:[TGCameraCapturedVideo class]]) {
|
||||||
|
return [SSignal single:((TGCameraCapturedVideo *)editableItem).avAsset];
|
||||||
|
} else {
|
||||||
|
return [editableItem originalImageSignal:position];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return [editableItem originalImageSignal:position];
|
return [editableItem originalImageSignal:position];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1761,7 +1761,17 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||||||
|
|
||||||
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
||||||
{
|
{
|
||||||
|
if (editableItem.isVideo) {
|
||||||
|
if ([editableItem isKindOfClass:[TGMediaAsset class]]) {
|
||||||
|
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
||||||
|
} else if ([editableItem isKindOfClass:[TGCameraCapturedVideo class]]) {
|
||||||
|
return [SSignal single:((TGCameraCapturedVideo *)editableItem).avAsset];
|
||||||
|
} else {
|
||||||
return [editableItem originalImageSignal:position];
|
return [editableItem originalImageSignal:position];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return [editableItem originalImageSignal:position];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
overlayController = (TGOverlayController *)controller;
|
overlayController = (TGOverlayController *)controller;
|
||||||
|
|||||||
@@ -1022,7 +1022,17 @@
|
|||||||
|
|
||||||
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
||||||
{
|
{
|
||||||
|
if (editableItem.isVideo) {
|
||||||
|
if ([editableItem isKindOfClass:[TGMediaAsset class]]) {
|
||||||
|
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
||||||
|
} else if ([editableItem isKindOfClass:[TGCameraCapturedVideo class]]) {
|
||||||
|
return [SSignal single:((TGCameraCapturedVideo *)editableItem).avAsset];
|
||||||
|
} else {
|
||||||
return [editableItem originalImageSignal:position];
|
return [editableItem originalImageSignal:position];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return [editableItem originalImageSignal:position];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
[self addChildViewController:controller];
|
[self addChildViewController:controller];
|
||||||
|
|||||||
@@ -430,8 +430,14 @@
|
|||||||
|
|
||||||
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
||||||
{
|
{
|
||||||
if (editableItem.isVideo && [editableItem isKindOfClass:[TGMediaAsset class]]) {
|
if (editableItem.isVideo) {
|
||||||
|
if ([editableItem isKindOfClass:[TGMediaAsset class]]) {
|
||||||
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
||||||
|
} else if ([editableItem isKindOfClass:[TGCameraCapturedVideo class]]) {
|
||||||
|
return [SSignal single:((TGCameraCapturedVideo *)editableItem).avAsset];
|
||||||
|
} else {
|
||||||
|
return [editableItem originalImageSignal:position];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return [editableItem originalImageSignal:position];
|
return [editableItem originalImageSignal:position];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -911,12 +911,12 @@
|
|||||||
|
|
||||||
- (bool)shouldDisplayTooltip
|
- (bool)shouldDisplayTooltip
|
||||||
{
|
{
|
||||||
return ![[[NSUserDefaults standardUserDefaults] objectForKey:@"TG_displayedMediaTimerTooltip_v1"] boolValue];
|
return ![[[NSUserDefaults standardUserDefaults] objectForKey:@"TG_displayedMediaTimerTooltip_v2"] boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setupTooltip:(CGRect)rect
|
- (void)setupTooltip:(CGRect)rect
|
||||||
{
|
{
|
||||||
if (_tooltipContainerView != nil)
|
if (_tooltipContainerView != nil || !_hasTimer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_tooltipTimer = [TGTimerTarget scheduledMainThreadTimerWithTarget:self action:@selector(tooltipTimerTick) interval:2.5 repeat:false];
|
_tooltipTimer = [TGTimerTarget scheduledMainThreadTimerWithTarget:self action:@selector(tooltipTimerTick) interval:2.5 repeat:false];
|
||||||
@@ -934,7 +934,7 @@
|
|||||||
|
|
||||||
[_tooltipContainerView showMenuFromRect:rect animated:false];
|
[_tooltipContainerView showMenuFromRect:rect animated:false];
|
||||||
|
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:@true forKey:@"TG_displayedMediaTimerTooltip_v1"];
|
[[NSUserDefaults standardUserDefaults] setObject:@true forKey:@"TG_displayedMediaTimerTooltip_v2"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tooltipTimerTick
|
- (void)tooltipTimerTick
|
||||||
|
|||||||
@@ -560,8 +560,14 @@
|
|||||||
|
|
||||||
controller.requestOriginalFullSizeImage = ^SSignal *(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
controller.requestOriginalFullSizeImage = ^SSignal *(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
||||||
{
|
{
|
||||||
if (editableItem.isVideo && [editableItem isKindOfClass:[TGMediaAsset class]]) {
|
if (editableItem.isVideo) {
|
||||||
|
if ([editableItem isKindOfClass:[TGMediaAsset class]]) {
|
||||||
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
return [TGMediaAssetImageSignals avAssetForVideoAsset:(TGMediaAsset *)editableItem];
|
||||||
|
} else if ([editableItem isKindOfClass:[TGCameraCapturedVideo class]]) {
|
||||||
|
return [SSignal single:((TGCameraCapturedVideo *)editableItem).avAsset];
|
||||||
|
} else {
|
||||||
|
return [editableItem originalImageSignal:position];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return [editableItem originalImageSignal:position];
|
return [editableItem originalImageSignal:position];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -922,7 +922,16 @@
|
|||||||
TGPhotoPaintController *paintController = [[TGPhotoPaintController alloc] initWithContext:_context photoEditor:_photoEditor previewView:_previewView];
|
TGPhotoPaintController *paintController = [[TGPhotoPaintController alloc] initWithContext:_context photoEditor:_photoEditor previewView:_previewView];
|
||||||
paintController.stickersContext = _stickersContext;
|
paintController.stickersContext = _stickersContext;
|
||||||
paintController.toolbarLandscapeSize = TGPhotoEditorToolbarSize;
|
paintController.toolbarLandscapeSize = TGPhotoEditorToolbarSize;
|
||||||
|
paintController.controlVideoPlayback = ^(bool play) {
|
||||||
|
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
||||||
|
if (strongSelf == nil)
|
||||||
|
return;
|
||||||
|
if (play) {
|
||||||
|
[strongSelf->_player play];
|
||||||
|
} else {
|
||||||
|
[strongSelf->_player pause];
|
||||||
|
}
|
||||||
|
};
|
||||||
paintController.beginTransitionIn = ^UIView *(CGRect *referenceFrame, UIView **parentView, bool *noTransitionView)
|
paintController.beginTransitionIn = ^UIView *(CGRect *referenceFrame, UIView **parentView, bool *noTransitionView)
|
||||||
{
|
{
|
||||||
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
||||||
|
|||||||
@@ -1012,10 +1012,21 @@ const CGFloat TGPhotoPaintStickerKeyboardSize = 260.0f;
|
|||||||
_stickersScreen = _stickersContext.presentStickersController(^(id document, bool animated, UIView *view, CGRect rect) {
|
_stickersScreen = _stickersContext.presentStickersController(^(id document, bool animated, UIView *view, CGRect rect) {
|
||||||
__strong TGPhotoPaintController *strongSelf = weakSelf;
|
__strong TGPhotoPaintController *strongSelf = weakSelf;
|
||||||
if (strongSelf != nil) {
|
if (strongSelf != nil) {
|
||||||
// UIView *snapshot = [view snapshotViewAfterScreenUpdates:false];
|
|
||||||
[strongSelf createNewStickerWithDocument:document animated:animated transitionPoint:CGPointZero snapshotView:nil];
|
[strongSelf createNewStickerWithDocument:document animated:animated transitionPoint:CGPointZero snapshotView:nil];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_stickersScreen.screenDidAppear = ^{
|
||||||
|
__strong TGPhotoPaintController *strongSelf = weakSelf;
|
||||||
|
if (strongSelf != nil) {
|
||||||
|
strongSelf.controlVideoPlayback(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
_stickersScreen.screenWillDisappear = ^{
|
||||||
|
__strong TGPhotoPaintController *strongSelf = weakSelf;
|
||||||
|
if (strongSelf != nil) {
|
||||||
|
strongSelf.controlVideoPlayback(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)createNewStickerWithDocument:(id)document animated:(bool)animated transitionPoint:(CGPoint)transitionPoint snapshotView:(UIView *)snapshotView
|
- (void)createNewStickerWithDocument:(id)document animated:(bool)animated transitionPoint:(CGPoint)transitionPoint snapshotView:(UIView *)snapshotView
|
||||||
|
|||||||
@@ -1265,6 +1265,9 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileprivate var didAppear: (() -> Void)?
|
||||||
|
fileprivate var willDisappear: (() -> Void)?
|
||||||
|
|
||||||
func animateIn() {
|
func animateIn() {
|
||||||
self.isUserInteractionEnabled = true
|
self.isUserInteractionEnabled = true
|
||||||
self.isHidden = false
|
self.isHidden = false
|
||||||
@@ -1273,10 +1276,16 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
|
|||||||
self.insertSubnode(hiddenPane, belowSubnode: self.collectionListContainer)
|
self.insertSubnode(hiddenPane, belowSubnode: self.collectionListContainer)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.layer.animatePosition(from: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), to: self.layer.position, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
|
self.layer.animatePosition(from: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), to: self.layer.position, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, completion: { [weak self] _ in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.didAppear?()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func animateOut() {
|
func animateOut() {
|
||||||
|
self.willDisappear?()
|
||||||
|
|
||||||
self.isUserInteractionEnabled = false
|
self.isUserInteractionEnabled = false
|
||||||
self.layer.animatePosition(from: self.layer.position, to: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { [weak self] _ in
|
self.layer.animatePosition(from: self.layer.position, to: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { [weak self] _ in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
@@ -1299,6 +1308,9 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class DrawingStickersScreen: ViewController, TGPhotoPaintStickersScreen {
|
final class DrawingStickersScreen: ViewController, TGPhotoPaintStickersScreen {
|
||||||
|
public var screenDidAppear: (() -> Void)?
|
||||||
|
public var screenWillDisappear: (() -> Void)?
|
||||||
|
|
||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
var selectSticker: ((FileMediaReference, ASDisplayNode, CGRect) -> Bool)?
|
var selectSticker: ((FileMediaReference, ASDisplayNode, CGRect) -> Bool)?
|
||||||
|
|
||||||
@@ -1368,6 +1380,12 @@ final class DrawingStickersScreen: ViewController, TGPhotoPaintStickersScreen {
|
|||||||
(self.displayNode as! DrawingStickersScreenNode).dismiss = { [weak self] in
|
(self.displayNode as! DrawingStickersScreenNode).dismiss = { [weak self] in
|
||||||
self?.dismiss()
|
self?.dismiss()
|
||||||
}
|
}
|
||||||
|
(self.displayNode as! DrawingStickersScreenNode).didAppear = { [weak self] in
|
||||||
|
self?.screenDidAppear?()
|
||||||
|
}
|
||||||
|
(self.displayNode as! DrawingStickersScreenNode).willDisappear = { [weak self] in
|
||||||
|
self?.screenWillDisappear?()
|
||||||
|
}
|
||||||
self._ready.set(self.controllerNode.ready.get())
|
self._ready.set(self.controllerNode.ready.get())
|
||||||
|
|
||||||
super.displayNodeDidLoad()
|
super.displayNodeDidLoad()
|
||||||
|
|||||||
Reference in New Issue
Block a user