mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 11:23:48 +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) void (^finishedTransitionOut)(bool saved);
|
||||
|
||||
@property (nonatomic, copy) void (^onDismiss)();
|
||||
|
||||
@property (nonatomic, copy) void (^beginCustomTransitionOut)(CGRect, UIView *, void(^)(void));
|
||||
|
||||
@property (nonatomic, copy) SSignal *(^requestThumbnailImage)(id<TGMediaEditableItem> item);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
@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;
|
||||
|
||||
|
@ -179,13 +179,16 @@
|
||||
- (void)updatePassParameters
|
||||
{
|
||||
PGBlurToolValue *value = (PGBlurToolValue *)self.displayValue;
|
||||
|
||||
PGPhotoBlurPass *blurPass = (PGPhotoBlurPass *)_pass;
|
||||
blurPass.type = value.type;
|
||||
blurPass.size = value.size;
|
||||
blurPass.point = value.point;
|
||||
blurPass.angle = value.angle;
|
||||
blurPass.falloff = value.falloff;
|
||||
if ([value isKindOfClass:[PGBlurToolValue class]]) {
|
||||
blurPass.type = value.type;
|
||||
blurPass.size = value.size;
|
||||
blurPass.point = value.point;
|
||||
blurPass.angle = value.angle;
|
||||
blurPass.falloff = value.falloff;
|
||||
} else {
|
||||
blurPass.type = PGBlurToolTypeNone;
|
||||
}
|
||||
}
|
||||
|
||||
- (bool)shouldBeSkipped
|
||||
|
@ -523,8 +523,10 @@ const CGFloat TGPhotoAvatarPreviewLandscapePanelSize = TGPhotoAvatarPreviewPanel
|
||||
// [_cropView animateTransitionIn];
|
||||
[_cropView transitionInFinishedFromCamera:true];
|
||||
|
||||
self.finishedTransitionIn();
|
||||
self.finishedTransitionIn = nil;
|
||||
if (self.finishedTransitionIn) {
|
||||
self.finishedTransitionIn();
|
||||
self.finishedTransitionIn = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)prepareForCustomTransitionOut
|
||||
|
@ -582,7 +582,7 @@
|
||||
[photoEditor processAnimated:false completion:^
|
||||
{
|
||||
__strong TGPhotoEditorController *strongSelf = weakSelf;
|
||||
if (strongSelf == nil)
|
||||
if (strongSelf == nil)
|
||||
return;
|
||||
TGDispatchOnMainThread(^
|
||||
{
|
||||
@ -590,7 +590,8 @@
|
||||
return;
|
||||
[strongSelf->_previewView performTransitionInWithCompletion:^
|
||||
{
|
||||
[strongSelf->_previewView setSnapshotImage:next];
|
||||
if (!strongSelf.skipInitialTransition)
|
||||
[strongSelf->_previewView setSnapshotImage:next];
|
||||
}];
|
||||
});
|
||||
}];
|
||||
@ -1194,6 +1195,10 @@
|
||||
snapshotImage = _screenImage;
|
||||
}
|
||||
|
||||
if (_currentTabController == nil && self.skipInitialTransition) {
|
||||
[self presentAnimated:true];
|
||||
}
|
||||
|
||||
_switchingTab = true;
|
||||
|
||||
if ([_currentTabController isKindOfClass:[TGPhotoAvatarPreviewController class]]) {
|
||||
@ -1637,6 +1642,24 @@
|
||||
}
|
||||
#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
|
||||
{
|
||||
_dismissed = true;
|
||||
@ -1662,6 +1685,8 @@
|
||||
[self.navigationController popViewControllerAnimated:false];
|
||||
} else {
|
||||
[self dismiss];
|
||||
if (self.onDismiss)
|
||||
self.onDismiss();
|
||||
}
|
||||
}];
|
||||
}
|
||||
@ -1701,7 +1726,9 @@
|
||||
strongSelf.view.userInteractionEnabled = 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];
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
@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];
|
||||
|
||||
@ -21,8 +21,9 @@
|
||||
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.skipInitialTransition = true;
|
||||
controller.dontHideStatusBar = true;
|
||||
controller.didFinishEditing = ^(__unused id<TGMediaEditAdjustments> adjustments, UIImage *resultImage, __unused UIImage *thumbnailImage, __unused bool hasChanges)
|
||||
{
|
||||
@ -42,7 +43,6 @@
|
||||
{
|
||||
return [editableItem screenImageSignal:position];
|
||||
};
|
||||
|
||||
controller.requestOriginalFullSizeImage = ^(id<TGMediaEditableItem> editableItem, NSTimeInterval position)
|
||||
{
|
||||
if (editableItem.isVideo) {
|
||||
@ -57,6 +57,9 @@
|
||||
return [editableItem originalImageSignal:position];
|
||||
}
|
||||
};
|
||||
controller.onDismiss = ^{
|
||||
dismissed();
|
||||
};
|
||||
|
||||
TGOverlayControllerWindow *controllerWindow = [[TGOverlayControllerWindow alloc] initWithManager:windowManager parentController:controller contentController:controller];
|
||||
controllerWindow.hidden = false;
|
||||
|
@ -6,7 +6,7 @@ import LegacyComponents
|
||||
import TelegramPresentationData
|
||||
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)
|
||||
legacyController.statusBar.statusBarStyle = .Ignore
|
||||
|
||||
@ -19,7 +19,7 @@ public func presentLegacyAvatarEditor(theme: PresentationTheme, image: UIImage?,
|
||||
|
||||
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 {
|
||||
imageCompletion(image)
|
||||
}
|
||||
@ -27,6 +27,8 @@ public func presentLegacyAvatarEditor(theme: PresentationTheme, image: UIImage?,
|
||||
if let image = image, let url = url {
|
||||
videoCompletion(image, url, adjustments)
|
||||
}
|
||||
}, dismissed: { [weak legacyController] in
|
||||
legacyController?.dismiss()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -635,6 +635,7 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
||||
case let .progress(value):
|
||||
break
|
||||
case let .data(data):
|
||||
let screenImage: UIImage?
|
||||
let image: UIImage?
|
||||
let video: URL?
|
||||
if isImage {
|
||||
@ -643,12 +644,14 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
||||
} else {
|
||||
image = nil
|
||||
}
|
||||
screenImage = image
|
||||
video = nil
|
||||
} else {
|
||||
image = nil
|
||||
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 {
|
||||
strongSelf.present(c, in: .window(.root), with: a, blockInteraction: true)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user