mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-25 09:32:46 +00:00
Video avatar fixes
This commit is contained in:
parent
62ee07759e
commit
fb24e869ca
@ -35,6 +35,8 @@ typedef enum {
|
|||||||
@property (nonatomic, copy) UIView *(^beginTransitionOut)(CGRect *referenceFrame, UIView **parentView);
|
@property (nonatomic, copy) UIView *(^beginTransitionOut)(CGRect *referenceFrame, UIView **parentView);
|
||||||
@property (nonatomic, copy) void (^finishedTransitionOut)(bool saved);
|
@property (nonatomic, copy) void (^finishedTransitionOut)(bool saved);
|
||||||
|
|
||||||
|
@property (nonatomic, copy) void (^onDismiss)();
|
||||||
|
|
||||||
@property (nonatomic, copy) void (^beginCustomTransitionOut)(CGRect, UIView *, void(^)(void));
|
@property (nonatomic, copy) void (^beginCustomTransitionOut)(CGRect, UIView *, void(^)(void));
|
||||||
|
|
||||||
@property (nonatomic, copy) SSignal *(^requestThumbnailImage)(id<TGMediaEditableItem> item);
|
@property (nonatomic, copy) SSignal *(^requestThumbnailImage)(id<TGMediaEditableItem> item);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
@interface TGPhotoVideoEditor : NSObject
|
@interface TGPhotoVideoEditor : NSObject
|
||||||
|
|
||||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context parentController:(TGViewController *)parentController image:(UIImage *)image video:(NSURL *)video didFinishWithImage:(void (^)(UIImage *image))didFinishWithImage didFinishWithVideo:(void (^)(UIImage *image, NSURL *url, TGVideoEditAdjustments *adjustments))didFinishWithVideo;
|
+ (void)presentWithContext:(id<LegacyComponentsContext>)context parentController:(TGViewController *)parentController screenImage:(UIImage *)screenImage image:(UIImage *)image video:(NSURL *)video didFinishWithImage:(void (^)(UIImage *image))didFinishWithImage didFinishWithVideo:(void (^)(UIImage *image, NSURL *url, TGVideoEditAdjustments *adjustments))didFinishWithVideo dismissed:(void (^)(void))dismissed;
|
||||||
|
|
||||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName stickersContext:(id<TGPhotoPaintStickersContext>)stickersContext completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion dismissed:(void (^)())dismissed;
|
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller caption:(NSString *)caption entities:(NSArray *)entities withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName stickersContext:(id<TGPhotoPaintStickersContext>)stickersContext completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion dismissed:(void (^)())dismissed;
|
||||||
|
|
||||||
|
|||||||
@ -179,13 +179,16 @@
|
|||||||
- (void)updatePassParameters
|
- (void)updatePassParameters
|
||||||
{
|
{
|
||||||
PGBlurToolValue *value = (PGBlurToolValue *)self.displayValue;
|
PGBlurToolValue *value = (PGBlurToolValue *)self.displayValue;
|
||||||
|
|
||||||
PGPhotoBlurPass *blurPass = (PGPhotoBlurPass *)_pass;
|
PGPhotoBlurPass *blurPass = (PGPhotoBlurPass *)_pass;
|
||||||
blurPass.type = value.type;
|
if ([value isKindOfClass:[PGBlurToolValue class]]) {
|
||||||
blurPass.size = value.size;
|
blurPass.type = value.type;
|
||||||
blurPass.point = value.point;
|
blurPass.size = value.size;
|
||||||
blurPass.angle = value.angle;
|
blurPass.point = value.point;
|
||||||
blurPass.falloff = value.falloff;
|
blurPass.angle = value.angle;
|
||||||
|
blurPass.falloff = value.falloff;
|
||||||
|
} else {
|
||||||
|
blurPass.type = PGBlurToolTypeNone;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (bool)shouldBeSkipped
|
- (bool)shouldBeSkipped
|
||||||
|
|||||||
@ -523,8 +523,10 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
|||||||
// [_cropView animateTransitionIn];
|
// [_cropView animateTransitionIn];
|
||||||
[_cropView transitionInFinishedFromCamera:true];
|
[_cropView transitionInFinishedFromCamera:true];
|
||||||
|
|
||||||
self.finishedTransitionIn();
|
if (self.finishedTransitionIn) {
|
||||||
self.finishedTransitionIn = nil;
|
self.finishedTransitionIn();
|
||||||
|
self.finishedTransitionIn = nil;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)prepareForCustomTransitionOut
|
- (void)prepareForCustomTransitionOut
|
||||||
|
|||||||
@ -582,7 +582,7 @@
|
|||||||
[photoEditor processAnimated:false completion:^
|
[photoEditor processAnimated:false completion:^
|
||||||
{
|
{
|
||||||
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
||||||
if (strongSelf == nil)
|
if (strongSelf == nil)
|
||||||
return;
|
return;
|
||||||
TGDispatchOnMainThread(^
|
TGDispatchOnMainThread(^
|
||||||
{
|
{
|
||||||
@ -590,7 +590,8 @@
|
|||||||
return;
|
return;
|
||||||
[strongSelf->_previewView performTransitionInWithCompletion:^
|
[strongSelf->_previewView performTransitionInWithCompletion:^
|
||||||
{
|
{
|
||||||
[strongSelf->_previewView setSnapshotImage:next];
|
if (!strongSelf.skipInitialTransition)
|
||||||
|
[strongSelf->_previewView setSnapshotImage:next];
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
@ -1194,6 +1195,10 @@
|
|||||||
snapshotImage = _screenImage;
|
snapshotImage = _screenImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_currentTabController == nil && self.skipInitialTransition) {
|
||||||
|
[self presentAnimated:true];
|
||||||
|
}
|
||||||
|
|
||||||
_switchingTab = true;
|
_switchingTab = true;
|
||||||
|
|
||||||
if ([_currentTabController isKindOfClass:[TGPhotoAvatarPreviewController class]]) {
|
if ([_currentTabController isKindOfClass:[TGPhotoAvatarPreviewController class]]) {
|
||||||
@ -1637,6 +1642,24 @@
|
|||||||
}
|
}
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
|
- (void)presentAnimated:(bool)animated
|
||||||
|
{
|
||||||
|
if (animated)
|
||||||
|
{
|
||||||
|
const CGFloat velocity = 2000.0f;
|
||||||
|
CGFloat duration = self.view.frame.size.height / velocity;
|
||||||
|
CGRect targetFrame = self.view.frame;
|
||||||
|
self.view.frame = CGRectOffset(self.view.frame, 0, self.view.frame.size.height);
|
||||||
|
|
||||||
|
[UIView animateWithDuration:duration animations:^
|
||||||
|
{
|
||||||
|
self.view.frame = targetFrame;
|
||||||
|
} completion:^(__unused BOOL finished)
|
||||||
|
{
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dismissAnimated:(bool)animated
|
- (void)dismissAnimated:(bool)animated
|
||||||
{
|
{
|
||||||
_dismissed = true;
|
_dismissed = true;
|
||||||
@ -1662,6 +1685,8 @@
|
|||||||
[self.navigationController popViewControllerAnimated:false];
|
[self.navigationController popViewControllerAnimated:false];
|
||||||
} else {
|
} else {
|
||||||
[self dismiss];
|
[self dismiss];
|
||||||
|
if (self.onDismiss)
|
||||||
|
self.onDismiss();
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@ -1701,7 +1726,9 @@
|
|||||||
strongSelf.view.userInteractionEnabled = false;
|
strongSelf.view.userInteractionEnabled = false;
|
||||||
[strongSelf->_currentTabController prepareTransitionOutSaving:false];
|
[strongSelf->_currentTabController prepareTransitionOutSaving:false];
|
||||||
|
|
||||||
if (strongSelf.navigationController != nil && [strongSelf.navigationController.viewControllers containsObject:strongSelf])
|
if (self.skipInitialTransition) {
|
||||||
|
[strongSelf dismissAnimated:true];
|
||||||
|
} else if (strongSelf.navigationController != nil && [strongSelf.navigationController.viewControllers containsObject:strongSelf])
|
||||||
{
|
{
|
||||||
[strongSelf.navigationController popViewControllerAnimated:true];
|
[strongSelf.navigationController popViewControllerAnimated:true];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
@implementation TGPhotoVideoEditor
|
@implementation TGPhotoVideoEditor
|
||||||
|
|
||||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context parentController:(TGViewController *)parentController image:(UIImage *)image video:(NSURL *)video didFinishWithImage:(void (^)(UIImage *image))didFinishWithImage didFinishWithVideo:(void (^)(UIImage *image, NSURL *url, TGVideoEditAdjustments *adjustments))didFinishWithVideo
|
+ (void)presentWithContext:(id<LegacyComponentsContext>)context parentController:(TGViewController *)parentController screenImage:(UIImage *)screenImage image:(UIImage *)image video:(NSURL *)video didFinishWithImage:(void (^)(UIImage *image))didFinishWithImage didFinishWithVideo:(void (^)(UIImage *image, NSURL *url, TGVideoEditAdjustments *adjustments))didFinishWithVideo dismissed:(void (^)(void))dismissed
|
||||||
{
|
{
|
||||||
id<LegacyComponentsOverlayWindowManager> windowManager = [context makeOverlayWindowManager];
|
id<LegacyComponentsOverlayWindowManager> windowManager = [context makeOverlayWindowManager];
|
||||||
|
|
||||||
@ -21,8 +21,9 @@
|
|||||||
editableItem = [[TGCameraCapturedVideo alloc] initWithURL:video];
|
editableItem = [[TGCameraCapturedVideo alloc] initWithURL:video];
|
||||||
}
|
}
|
||||||
|
|
||||||
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:editableItem intent:TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:nil availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
TGPhotoEditorController *controller = [[TGPhotoEditorController alloc] initWithContext:[windowManager context] item:editableItem intent:TGPhotoEditorControllerAvatarIntent adjustments:nil caption:nil screenImage:screenImage availableTabs:[TGPhotoEditorController defaultTabsForAvatarIntent] selectedTab:TGPhotoEditorCropTab];
|
||||||
// controller.stickersContext = _stickersContext;
|
// controller.stickersContext = _stickersContext;
|
||||||
|
controller.skipInitialTransition = true;
|
||||||
controller.dontHideStatusBar = true;
|
controller.dontHideStatusBar = true;
|
||||||
controller.didFinishEditing = ^(__unused id<TGMediaEditAdjustments> adjustments, UIImage *resultImage, __unused UIImage *thumbnailImage, __unused bool hasChanges)
|
controller.didFinishEditing = ^(__unused id<TGMediaEditAdjustments> adjustments, UIImage *resultImage, __unused UIImage *thumbnailImage, __unused bool hasChanges)
|
||||||
{
|
{
|
||||||
@ -42,7 +43,6 @@
|
|||||||
{
|
{
|
||||||
return [editableItem screenImageSignal:position];
|
return [editableItem screenImageSignal:position];
|
||||||
};
|
};
|
||||||
|
|
||||||
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
||||||
{
|
{
|
||||||
if (editableItem.isVideo) {
|
if (editableItem.isVideo) {
|
||||||
@ -57,6 +57,9 @@
|
|||||||
return [editableItem originalImageSignal:position];
|
return [editableItem originalImageSignal:position];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
controller.onDismiss = ^{
|
||||||
|
dismissed();
|
||||||
|
};
|
||||||
|
|
||||||
TGOverlayControllerWindow *controllerWindow = [[TGOverlayControllerWindow alloc] initWithManager:windowManager parentController:controller contentController:controller];
|
TGOverlayControllerWindow *controllerWindow = [[TGOverlayControllerWindow alloc] initWithManager:windowManager parentController:controller contentController:controller];
|
||||||
controllerWindow.hidden = false;
|
controllerWindow.hidden = false;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import LegacyComponents
|
|||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import LegacyUI
|
import LegacyUI
|
||||||
|
|
||||||
public func presentLegacyAvatarEditor(theme: PresentationTheme, image: UIImage?, video: URL?, present: (ViewController, Any?) -> Void, imageCompletion: @escaping (UIImage) -> Void, videoCompletion: @escaping (UIImage, URL, TGVideoEditAdjustments?) -> Void) {
|
public func presentLegacyAvatarEditor(theme: PresentationTheme, screenImage: UIImage?, image: UIImage?, video: URL?, present: (ViewController, Any?) -> Void, imageCompletion: @escaping (UIImage) -> Void, videoCompletion: @escaping (UIImage, URL, TGVideoEditAdjustments?) -> Void) {
|
||||||
let legacyController = LegacyController(presentation: .custom, theme: theme)
|
let legacyController = LegacyController(presentation: .custom, theme: theme)
|
||||||
legacyController.statusBar.statusBarStyle = .Ignore
|
legacyController.statusBar.statusBarStyle = .Ignore
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ public func presentLegacyAvatarEditor(theme: PresentationTheme, image: UIImage?,
|
|||||||
|
|
||||||
present(legacyController, nil)
|
present(legacyController, nil)
|
||||||
|
|
||||||
TGPhotoVideoEditor.present(with: legacyController.context, parentController: emptyController, image: image, video: video, didFinishWithImage: { image in
|
TGPhotoVideoEditor.present(with: legacyController.context, parentController: emptyController, screenImage: screenImage, image: image, video: video, didFinishWithImage: { image in
|
||||||
if let image = image {
|
if let image = image {
|
||||||
imageCompletion(image)
|
imageCompletion(image)
|
||||||
}
|
}
|
||||||
@ -27,6 +27,8 @@ public func presentLegacyAvatarEditor(theme: PresentationTheme, image: UIImage?,
|
|||||||
if let image = image, let url = url {
|
if let image = image, let url = url {
|
||||||
videoCompletion(image, url, adjustments)
|
videoCompletion(image, url, adjustments)
|
||||||
}
|
}
|
||||||
|
}, dismissed: { [weak legacyController] in
|
||||||
|
legacyController?.dismiss()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -635,6 +635,7 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
|||||||
case let .progress(value):
|
case let .progress(value):
|
||||||
break
|
break
|
||||||
case let .data(data):
|
case let .data(data):
|
||||||
|
let screenImage: UIImage?
|
||||||
let image: UIImage?
|
let image: UIImage?
|
||||||
let video: URL?
|
let video: URL?
|
||||||
if isImage {
|
if isImage {
|
||||||
@ -643,12 +644,14 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
|||||||
} else {
|
} else {
|
||||||
image = nil
|
image = nil
|
||||||
}
|
}
|
||||||
|
screenImage = image
|
||||||
video = nil
|
video = nil
|
||||||
} else {
|
} else {
|
||||||
image = nil
|
image = nil
|
||||||
video = URL(fileURLWithPath: data.path)
|
video = URL(fileURLWithPath: data.path)
|
||||||
|
screenImage = nil
|
||||||
}
|
}
|
||||||
presentLegacyAvatarEditor(theme: strongSelf.presentationData.theme, image: image, video: video, present: { [weak self] c, a in
|
presentLegacyAvatarEditor(theme: strongSelf.presentationData.theme, screenImage: screenImage, image: image, video: video, present: { [weak self] c, a in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.present(c, in: .window(.root), with: a, blockInteraction: true)
|
strongSelf.present(c, in: .window(.root), with: a, blockInteraction: true)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user