mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-24 21:11:22 +00:00
Merge commit '9e2e55e46c28c945eafc4d4db7974c649ef0adf5'
This commit is contained in:
@@ -48,6 +48,8 @@
|
||||
09AB58151F6C401B0087449F /* TGLocationWavesView.m in Sources */ = {isa = PBXBuildFile; fileRef = 09AB58131F6C401B0087449F /* TGLocationWavesView.m */; };
|
||||
09B51E001F6AF476000EE471 /* TGLocationMapViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 09B51DFE1F6AF476000EE471 /* TGLocationMapViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
09B51E011F6AF476000EE471 /* TGLocationMapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 09B51DFF1F6AF476000EE471 /* TGLocationMapViewController.m */; };
|
||||
09BD14EB20BD928100D95932 /* TGPhotoVideoEditor.h in Headers */ = {isa = PBXBuildFile; fileRef = 09BD14E920BD928100D95932 /* TGPhotoVideoEditor.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
09BD14EC20BD928100D95932 /* TGPhotoVideoEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = 09BD14EA20BD928100D95932 /* TGPhotoVideoEditor.m */; };
|
||||
09C0BEE02069FDD400380399 /* TGPassportAttachMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 09C0BEDE2069FDD300380399 /* TGPassportAttachMenu.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
09C0BEE12069FDD400380399 /* TGPassportAttachMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 09C0BEDF2069FDD300380399 /* TGPassportAttachMenu.m */; };
|
||||
09E97B571F97C11700526020 /* TGTooltipView.h in Headers */ = {isa = PBXBuildFile; fileRef = 09E97B551F97C11600526020 /* TGTooltipView.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@@ -1236,6 +1238,8 @@
|
||||
09AB58131F6C401B0087449F /* TGLocationWavesView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGLocationWavesView.m; sourceTree = "<group>"; };
|
||||
09B51DFE1F6AF476000EE471 /* TGLocationMapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGLocationMapViewController.h; sourceTree = "<group>"; };
|
||||
09B51DFF1F6AF476000EE471 /* TGLocationMapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGLocationMapViewController.m; sourceTree = "<group>"; };
|
||||
09BD14E920BD928100D95932 /* TGPhotoVideoEditor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TGPhotoVideoEditor.h; sourceTree = "<group>"; };
|
||||
09BD14EA20BD928100D95932 /* TGPhotoVideoEditor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TGPhotoVideoEditor.m; sourceTree = "<group>"; };
|
||||
09C0BEDE2069FDD300380399 /* TGPassportAttachMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGPassportAttachMenu.h; sourceTree = "<group>"; };
|
||||
09C0BEDF2069FDD300380399 /* TGPassportAttachMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TGPassportAttachMenu.m; sourceTree = "<group>"; };
|
||||
09E97B551F97C11600526020 /* TGTooltipView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TGTooltipView.h; sourceTree = "<group>"; };
|
||||
@@ -3229,6 +3233,8 @@
|
||||
D07BC9B91F2A705D00ED97AA /* TGPhotoFilterCell.m */,
|
||||
D07BC9BC1F2A722400ED97AA /* TGHistogramView.h */,
|
||||
D07BC9BD1F2A722400ED97AA /* TGHistogramView.m */,
|
||||
09BD14E920BD928100D95932 /* TGPhotoVideoEditor.h */,
|
||||
09BD14EA20BD928100D95932 /* TGPhotoVideoEditor.m */,
|
||||
);
|
||||
name = "Photo Editor";
|
||||
sourceTree = "<group>";
|
||||
@@ -3964,6 +3970,7 @@
|
||||
D01778191F1F961D0044446D /* TGMessageEntityHashtag.h in Headers */,
|
||||
D07BCA341F2A9B0400ED97AA /* TGModernGalleryEditableItemView.h in Headers */,
|
||||
D0177A911F221BB10044446D /* TGModernGalleryTransitionView.h in Headers */,
|
||||
09BD14EB20BD928100D95932 /* TGPhotoVideoEditor.h in Headers */,
|
||||
0916FEAC20A1EBFA0084A755 /* TGPassportMRZ.h in Headers */,
|
||||
D01778E51F20CAE60044446D /* TGNavigationController.h in Headers */,
|
||||
D01777721F1F92420044446D /* TGPhoneUtils.h in Headers */,
|
||||
@@ -5030,6 +5037,7 @@
|
||||
D07BC77B1F2A2B3700ED97AA /* TGPhotoEditorInterfaceAssets.m in Sources */,
|
||||
D07BC9B71F2A700900ED97AA /* TGPhotoMaskPosition.m in Sources */,
|
||||
D07BC91A1F2A380D00ED97AA /* TGPaintRadialBrush.m in Sources */,
|
||||
09BD14EC20BD928100D95932 /* TGPhotoVideoEditor.m in Sources */,
|
||||
D07BC7891F2A2B3700ED97AA /* TGPhotoEditorTintSwatchView.m in Sources */,
|
||||
D07BC8C01F2A37EC00ED97AA /* TGPhotoPaintActionsView.m in Sources */,
|
||||
D07BCB161F2B646A00ED97AA /* TGPasswordEntryView.m in Sources */,
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0830"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D01777261F1F8F100044446D"
|
||||
BuildableName = "LegacyComponents.framework"
|
||||
BlueprintName = "LegacyComponents"
|
||||
ReferencedContainer = "container:LegacyComponents.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D01777261F1F8F100044446D"
|
||||
BuildableName = "LegacyComponents.framework"
|
||||
BlueprintName = "LegacyComponents"
|
||||
ReferencedContainer = "container:LegacyComponents.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "D01777261F1F8F100044446D"
|
||||
BuildableName = "LegacyComponents.framework"
|
||||
BlueprintName = "LegacyComponents"
|
||||
ReferencedContainer = "container:LegacyComponents.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>LegacyComponents.xcscheme</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>12</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict>
|
||||
<key>D01777261F1F8F100044446D</key>
|
||||
<dict>
|
||||
<key>primary</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -270,6 +270,7 @@ FOUNDATION_EXPORT const unsigned char LegacyComponentsVersionString[];
|
||||
#import <LegacyComponents/TGCameraController.h>
|
||||
#import <LegacyComponents/TGCameraCapturedPhoto.h>
|
||||
#import <LegacyComponents/TGCameraCapturedVideo.h>
|
||||
#import <LegacyComponents/TGPhotoVideoEditor.h>
|
||||
|
||||
#import <LegacyComponents/TGModernConversationTitleActivityIndicator.h>
|
||||
#import <LegacyComponents/TGEmbedPIPButton.h>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
if (self != nil)
|
||||
{
|
||||
_identifier = [NSString stringWithFormat:@"%ld", lrand48()];
|
||||
_dimensions = image.size;
|
||||
_dimensions = CGSizeMake(image.size.width * image.scale, image.size.height * image.scale);
|
||||
_metadata = metadata;
|
||||
_thumbnail = [[SVariable alloc] init];
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ typedef enum {
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context saveEditedPhotos:(bool)saveEditedPhotos saveCapturedMedia:(bool)saveCapturedMedia intent:(TGCameraControllerIntent)intent;
|
||||
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context saveEditedPhotos:(bool)saveEditedPhotos saveCapturedMedia:(bool)saveCapturedMedia camera:(PGCamera *)camera previewView:(TGCameraPreviewView *)previewView intent:(TGCameraControllerIntent)intent;
|
||||
|
||||
+ (NSArray *)resultSignalsForSelectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext currentItem:(id<TGMediaSelectableItem>)currentItem storeAssets:(bool)storeAssets saveEditedPhotos:(bool)saveEditedPhotos descriptionGenerator:(id (^)(id, NSString *, NSArray *, NSString *))descriptionGenerator;
|
||||
+ (NSArray *)resultSignalsForSelectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext currentItem:(id<TGMediaSelectableItem>)currentItem storeAssets:(bool)storeAssets saveEditedPhotos:(bool)saveEditedPhotos descriptionGenerator:(id (^)(id, NSString *, NSArray *, NSString *))descriptionGenerator;
|
||||
|
||||
- (void)beginTransitionInFromRect:(CGRect)rect;
|
||||
- (void)_dismissTransitionForResultController:(TGOverlayController *)resultController;
|
||||
|
||||
@@ -2190,7 +2190,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
||||
+ (NSArray *)resultSignalsForSelectionContext:(TGMediaSelectionContext *)selectionContext editingContext:(TGMediaEditingContext *)editingContext currentItem:(id<TGMediaSelectableItem>)currentItem storeAssets:(bool)storeAssets saveEditedPhotos:(bool)saveEditedPhotos descriptionGenerator:(id (^)(id, NSString *, NSArray *, NSString *))descriptionGenerator
|
||||
{
|
||||
NSMutableArray *signals = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *selectedItems = [selectionContext.selectedItems mutableCopy];
|
||||
NSMutableArray *selectedItems = selectionContext.selectedItems != nil ? [selectionContext.selectedItems mutableCopy] : [[NSMutableArray alloc] init];
|
||||
if (selectedItems.count == 0 && currentItem != nil)
|
||||
[selectedItems addObject:currentItem];
|
||||
|
||||
|
||||
@@ -235,6 +235,7 @@ NSString *TGImageViewOptionSynchronous = @"TGImageViewOptionSynchronous";
|
||||
_transitionOverlayView = [[UIImageView alloc] init];
|
||||
|
||||
_transitionOverlayView.frame = _extendedInsetsImageView == nil ? self.bounds : _extendedInsetsImageView.frame;
|
||||
_transitionOverlayView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
[self insertSubview:_transitionOverlayView atIndex:0];
|
||||
|
||||
_transitionOverlayView.image = _extendedInsetsImageView == nil ? self.image : _extendedInsetsImageView.image;
|
||||
|
||||
@@ -492,42 +492,50 @@
|
||||
return;
|
||||
|
||||
__weak TGMediaPickerGalleryVideoItemView *weakSelf = self;
|
||||
[_videoDurationDisposable setDisposable:[[_videoDurationVar.signal deliverOn:[SQueue mainQueue]] startWithNext:^(NSNumber *next)
|
||||
void (^block)(void) = ^
|
||||
{
|
||||
__strong TGMediaPickerGalleryVideoItemView *strongSelf = weakSelf;
|
||||
if (strongSelf == nil || next == nil)
|
||||
return;
|
||||
|
||||
TGMediaPickerGalleryVideoItem *item = strongSelf.item;
|
||||
NSTimeInterval videoDuration = next.doubleValue;
|
||||
strongSelf->_videoDuration = videoDuration;
|
||||
|
||||
strongSelf->_scrubberView.allowsTrimming = (!item.asFile && ((item.asset != nil && ![strongSelf itemIsHighFramerateVideo])) && videoDuration >= TGVideoEditMinimumTrimmableDuration);
|
||||
|
||||
TGVideoEditAdjustments *adjustments = (TGVideoEditAdjustments *)[item.editingContext adjustmentsForItem:item.editableMediaItem];
|
||||
if (adjustments != nil && fabs(adjustments.trimEndValue - adjustments.trimStartValue) > DBL_EPSILON)
|
||||
[_videoDurationDisposable setDisposable:[[_videoDurationVar.signal deliverOn:[SQueue mainQueue]] startWithNext:^(NSNumber *next)
|
||||
{
|
||||
strongSelf->_scrubberView.trimStartValue = adjustments.trimStartValue;
|
||||
strongSelf->_scrubberView.trimEndValue = adjustments.trimEndValue;
|
||||
strongSelf->_scrubberView.value = adjustments.trimStartValue;
|
||||
[strongSelf->_scrubberView setTrimApplied:(adjustments.trimStartValue > 0 || adjustments.trimEndValue < videoDuration)];
|
||||
strongSelf->_shouldResetScrubber = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
strongSelf->_scrubberView.trimStartValue = 0;
|
||||
strongSelf->_scrubberView.trimEndValue = videoDuration;
|
||||
[strongSelf->_scrubberView setTrimApplied:false];
|
||||
strongSelf->_shouldResetScrubber = true;
|
||||
}
|
||||
|
||||
[strongSelf->_scrubberView reloadData];
|
||||
if (!strongSelf->_appeared)
|
||||
{
|
||||
[strongSelf->_scrubberView resetToStart];
|
||||
strongSelf->_appeared = true;
|
||||
}
|
||||
}]];
|
||||
__strong TGMediaPickerGalleryVideoItemView *strongSelf = weakSelf;
|
||||
if (strongSelf == nil || next == nil)
|
||||
return;
|
||||
|
||||
TGMediaPickerGalleryVideoItem *item = strongSelf.item;
|
||||
NSTimeInterval videoDuration = next.doubleValue;
|
||||
strongSelf->_videoDuration = videoDuration;
|
||||
|
||||
strongSelf->_scrubberView.allowsTrimming = (!item.asFile && ((item.asset != nil && ![strongSelf itemIsHighFramerateVideo])) && videoDuration >= TGVideoEditMinimumTrimmableDuration);
|
||||
|
||||
TGVideoEditAdjustments *adjustments = (TGVideoEditAdjustments *)[item.editingContext adjustmentsForItem:item.editableMediaItem];
|
||||
if (adjustments != nil && fabs(adjustments.trimEndValue - adjustments.trimStartValue) > DBL_EPSILON)
|
||||
{
|
||||
strongSelf->_scrubberView.trimStartValue = adjustments.trimStartValue;
|
||||
strongSelf->_scrubberView.trimEndValue = adjustments.trimEndValue;
|
||||
strongSelf->_scrubberView.value = adjustments.trimStartValue;
|
||||
[strongSelf->_scrubberView setTrimApplied:(adjustments.trimStartValue > 0 || adjustments.trimEndValue < videoDuration)];
|
||||
strongSelf->_shouldResetScrubber = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
strongSelf->_scrubberView.trimStartValue = 0;
|
||||
strongSelf->_scrubberView.trimEndValue = videoDuration;
|
||||
[strongSelf->_scrubberView setTrimApplied:false];
|
||||
strongSelf->_shouldResetScrubber = true;
|
||||
}
|
||||
|
||||
[strongSelf->_scrubberView reloadData];
|
||||
if (!strongSelf->_appeared)
|
||||
{
|
||||
[strongSelf->_scrubberView resetToStart];
|
||||
strongSelf->_appeared = true;
|
||||
}
|
||||
}]];
|
||||
};
|
||||
|
||||
if (_scrubberView.frame.size.width < FLT_EPSILON)
|
||||
TGDispatchAfter(0.01, dispatch_get_main_queue(), block);
|
||||
else
|
||||
block();
|
||||
}
|
||||
|
||||
- (void)presentScrubbingPanelAfterReload:(bool)afterReload
|
||||
|
||||
@@ -133,6 +133,7 @@ const CGFloat TGMediaPickerToolbarHeight = 44.0f;
|
||||
{
|
||||
button.alpha = 0.0f;
|
||||
[button setTitle:title forState:UIControlStateNormal];
|
||||
[button sizeToFit];
|
||||
|
||||
[UIView animateWithDuration:0.15f animations:^
|
||||
{
|
||||
@@ -153,6 +154,7 @@ const CGFloat TGMediaPickerToolbarHeight = 44.0f;
|
||||
else
|
||||
{
|
||||
[button setTitle:title forState:UIControlStateNormal];
|
||||
[button sizeToFit];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
7
LegacyComponents/TGPhotoVideoEditor.h
Normal file
7
LegacyComponents/TGPhotoVideoEditor.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#import <LegacyComponents/LegacyComponents.h>
|
||||
|
||||
@interface TGPhotoVideoEditor : NSObject
|
||||
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName completion:(void (^)(id, TGMediaEditingContext *))completion;
|
||||
|
||||
@end
|
||||
148
LegacyComponents/TGPhotoVideoEditor.m
Normal file
148
LegacyComponents/TGPhotoVideoEditor.m
Normal file
@@ -0,0 +1,148 @@
|
||||
#import "TGPhotoVideoEditor.h"
|
||||
|
||||
#import "TGMediaEditingContext.h"b
|
||||
|
||||
#import "TGMediaPickerGalleryModel.h"
|
||||
#import "TGMediaPickerGalleryPhotoItem.h"
|
||||
#import "TGMediaPickerGalleryVideoItem.h"
|
||||
|
||||
#import "TGMediaPickerGalleryVideoItemView.h"
|
||||
|
||||
@implementation TGPhotoVideoEditor
|
||||
|
||||
+ (void)presentWithContext:(id<LegacyComponentsContext>)context controller:(TGViewController *)controller withItem:(id<TGMediaEditableItem, TGMediaSelectableItem>)item recipientName:(NSString *)recipientName completion:(void (^)(id<TGMediaEditableItem>, TGMediaEditingContext *))completion
|
||||
{
|
||||
id<LegacyComponentsOverlayWindowManager> windowManager = [context makeOverlayWindowManager];
|
||||
id<LegacyComponentsContext> windowContext = [windowManager context];
|
||||
|
||||
TGMediaEditingContext *editingContext = [[TGMediaEditingContext alloc] init];
|
||||
|
||||
TGModernGalleryController *galleryController = [[TGModernGalleryController alloc] initWithContext:windowContext];
|
||||
galleryController.adjustsStatusBarVisibility = true;
|
||||
//galleryController.hasFadeOutTransition = true;
|
||||
|
||||
id<TGModernGalleryEditableItem> galleryItem = nil;
|
||||
if (item.isVideo)
|
||||
galleryItem = [[TGMediaPickerGalleryVideoItem alloc] initWithAsset:item];
|
||||
else
|
||||
galleryItem = [[TGMediaPickerGalleryPhotoItem alloc] initWithAsset:item];
|
||||
galleryItem.editingContext = editingContext;
|
||||
|
||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:@[galleryItem] focusItem:galleryItem selectionContext:nil editingContext:editingContext hasCaptions:false allowCaptionEntities:false hasTimer:false onlyCrop:false inhibitDocumentCaptions:false hasSelectionPanel:false hasCamera:false recipientName:recipientName];
|
||||
model.controller = galleryController;
|
||||
//model.suggestionContext = self.suggestionContext;
|
||||
|
||||
model.willFinishEditingItem = ^(id<TGMediaEditableItem> editableItem, id<TGMediaEditAdjustments> adjustments, id representation, bool hasChanges)
|
||||
{
|
||||
if (hasChanges)
|
||||
{
|
||||
[editingContext setAdjustments:adjustments forItem:editableItem];
|
||||
[editingContext setTemporaryRep:representation forItem:editableItem];
|
||||
}
|
||||
};
|
||||
|
||||
model.didFinishEditingItem = ^(id<TGMediaEditableItem> editableItem, __unused id<TGMediaEditAdjustments> adjustments, UIImage *resultImage, UIImage *thumbnailImage)
|
||||
{
|
||||
[editingContext setImage:resultImage thumbnailImage:thumbnailImage forItem:editableItem synchronous:false];
|
||||
};
|
||||
|
||||
model.saveItemCaption = ^(id<TGMediaEditableItem> editableItem, NSString *caption, NSArray *entities)
|
||||
{
|
||||
[editingContext setCaption:caption entities:entities forItem:editableItem];
|
||||
};
|
||||
|
||||
model.interfaceView.hasSwipeGesture = false;
|
||||
galleryController.model = model;
|
||||
|
||||
__weak TGModernGalleryController *weakGalleryController = galleryController;
|
||||
__weak TGMediaPickerGalleryModel *weakModel = model;
|
||||
|
||||
[model.interfaceView updateSelectionInterface:1 counterVisible:false animated:false];
|
||||
model.interfaceView.thumbnailSignalForItem = ^SSignal *(id item)
|
||||
{
|
||||
return nil;
|
||||
};
|
||||
model.interfaceView.donePressed = ^(TGMediaPickerGalleryItem *item)
|
||||
{
|
||||
__strong TGModernGalleryController *strongController = weakGalleryController;
|
||||
if (strongController == nil)
|
||||
return;
|
||||
|
||||
if ([item isKindOfClass:[TGMediaPickerGalleryVideoItem class]])
|
||||
{
|
||||
TGMediaPickerGalleryVideoItemView *itemView = (TGMediaPickerGalleryVideoItemView *)[strongController itemViewForItem:item];
|
||||
[itemView stop];
|
||||
[itemView setPlayButtonHidden:true animated:true];
|
||||
}
|
||||
|
||||
if (completion != nil)
|
||||
completion(item.asset, editingContext);
|
||||
|
||||
[UIView animateWithDuration:0.3f delay:0.0f options:(7 << 16) animations:^
|
||||
{
|
||||
strongController.view.frame = CGRectOffset(strongController.view.frame, 0, strongController.view.frame.size.height);
|
||||
} completion:^(__unused BOOL finished)
|
||||
{
|
||||
[strongController dismiss];
|
||||
}];
|
||||
};
|
||||
|
||||
// CGSize snapshotSize = TGScaleToFill(CGSizeMake(480, 640), CGSizeMake(self.view.frame.size.width, self.view.frame.size.width));
|
||||
// UIView *snapshotView = [_previewView snapshotViewAfterScreenUpdates:false];
|
||||
// snapshotView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
// snapshotView.frame = CGRectMake(_previewView.center.x - snapshotSize.width / 2, _previewView.center.y - snapshotSize.height / 2, snapshotSize.width, snapshotSize.height);
|
||||
// snapshotView.hidden = true;
|
||||
// [_previewView.superview insertSubview:snapshotView aboveSubview:_previewView];
|
||||
|
||||
galleryController.beginTransitionIn = ^UIView *(__unused TGMediaPickerGalleryItem *item, __unused TGModernGalleryItemView *itemView)
|
||||
{
|
||||
TGModernGalleryController *strongGalleryController = weakGalleryController;
|
||||
strongGalleryController.view.alpha = 0.0f;
|
||||
[UIView animateWithDuration:0.3f animations:^
|
||||
{
|
||||
strongGalleryController.view.alpha = 1.0f;
|
||||
}];
|
||||
//return snapshotView;
|
||||
return nil;
|
||||
};
|
||||
|
||||
galleryController.beginTransitionOut = ^UIView *(__unused TGMediaPickerGalleryItem *item, __unused TGModernGalleryItemView *itemView)
|
||||
{
|
||||
// __strong TGCameraController *strongSelf = weakSelf;
|
||||
// if (strongSelf != nil)
|
||||
// {
|
||||
TGMediaPickerGalleryModel *strongModel = weakModel;
|
||||
if (strongModel == nil)
|
||||
return nil;
|
||||
|
||||
// [UIView animateWithDuration:0.3f delay:0.1f options:UIViewAnimationOptionCurveLinear animations:^
|
||||
// {
|
||||
// strongSelf->_interfaceView.alpha = 1.0f;
|
||||
// } completion:nil];
|
||||
|
||||
// return snapshotView;
|
||||
// }
|
||||
return nil;
|
||||
};
|
||||
|
||||
galleryController.completedTransitionOut = ^
|
||||
{
|
||||
//[snapshotView removeFromSuperview];
|
||||
|
||||
TGModernGalleryController *strongGalleryController = weakGalleryController;
|
||||
if (strongGalleryController != nil && strongGalleryController.overlayWindow == nil)
|
||||
{
|
||||
TGNavigationController *navigationController = (TGNavigationController *)strongGalleryController.navigationController;
|
||||
TGOverlayControllerWindow *window = (TGOverlayControllerWindow *)navigationController.view.window;
|
||||
if ([window isKindOfClass:[TGOverlayControllerWindow class]])
|
||||
[window dismiss];
|
||||
}
|
||||
};
|
||||
|
||||
TGOverlayControllerWindow *controllerWindow = [[TGOverlayControllerWindow alloc] initWithManager:windowManager parentController:controller contentController:galleryController];
|
||||
controllerWindow.hidden = false;
|
||||
//controllerWindow.windowLevel = self.view.window.windowLevel + 0.0001f;
|
||||
galleryController.view.clipsToBounds = true;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user