mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-04 03:40:45 +00:00
no message
This commit is contained in:
parent
ea6ab4d669
commit
f5e09253e2
@ -66,6 +66,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||||||
SMetaDisposable *_assetsDisposable;
|
SMetaDisposable *_assetsDisposable;
|
||||||
TGMediaAssetFetchResult *_fetchResult;
|
TGMediaAssetFetchResult *_fetchResult;
|
||||||
|
|
||||||
|
bool _document;
|
||||||
bool _forProfilePhoto;
|
bool _forProfilePhoto;
|
||||||
|
|
||||||
SMetaDisposable *_selectionChangedDisposable;
|
SMetaDisposable *_selectionChangedDisposable;
|
||||||
@ -133,12 +134,13 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
__weak TGAttachmentCarouselItemView *weakSelf = self;
|
__weak TGAttachmentCarouselItemView *weakSelf = self;
|
||||||
|
_document = document;
|
||||||
_forProfilePhoto = forProfilePhoto;
|
_forProfilePhoto = forProfilePhoto;
|
||||||
|
|
||||||
_assetsLibrary = [TGMediaAssetsLibrary libraryForAssetType:assetType];
|
_assetsLibrary = [TGMediaAssetsLibrary libraryForAssetType:assetType];
|
||||||
_assetsDisposable = [[SMetaDisposable alloc] init];
|
_assetsDisposable = [[SMetaDisposable alloc] init];
|
||||||
|
|
||||||
if (!forProfilePhoto && !document)
|
if (!forProfilePhoto && !selfPortrait)
|
||||||
{
|
{
|
||||||
_selectionContext = [[TGMediaSelectionContext alloc] initWithGroupingAllowed:allowGrouping];
|
_selectionContext = [[TGMediaSelectionContext alloc] initWithGroupingAllowed:allowGrouping];
|
||||||
if (allowGrouping)
|
if (allowGrouping)
|
||||||
@ -257,15 +259,18 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||||||
[_sendMediaItemView setHidden:true animated:false];
|
[_sendMediaItemView setHidden:true animated:false];
|
||||||
[self addSubview:_sendMediaItemView];
|
[self addSubview:_sendMediaItemView];
|
||||||
|
|
||||||
_sendFileItemView = [[TGMenuSheetButtonItemView alloc] initWithTitle:nil type:TGMenuSheetButtonTypeDefault action:^
|
if (!_document)
|
||||||
{
|
{
|
||||||
__strong TGAttachmentCarouselItemView *strongSelf = weakSelf;
|
_sendFileItemView = [[TGMenuSheetButtonItemView alloc] initWithTitle:nil type:TGMenuSheetButtonTypeDefault action:^
|
||||||
if (strongSelf != nil && strongSelf.sendPressed != nil)
|
{
|
||||||
strongSelf.sendPressed(nil, true);
|
__strong TGAttachmentCarouselItemView *strongSelf = weakSelf;
|
||||||
}];
|
if (strongSelf != nil && strongSelf.sendPressed != nil)
|
||||||
_sendFileItemView.requiresDivider = false;
|
strongSelf.sendPressed(nil, true);
|
||||||
[_sendFileItemView setHidden:true animated:false];
|
}];
|
||||||
[self addSubview:_sendFileItemView];
|
_sendFileItemView.requiresDivider = false;
|
||||||
|
[_sendFileItemView setHidden:true animated:false];
|
||||||
|
[self addSubview:_sendFileItemView];
|
||||||
|
}
|
||||||
|
|
||||||
[self setSignal:[[TGMediaAssetsLibrary authorizationStatusSignal] mapToSignal:^SSignal *(NSNumber *statusValue)
|
[self setSignal:[[TGMediaAssetsLibrary authorizationStatusSignal] mapToSignal:^SSignal *(NSNumber *statusValue)
|
||||||
{
|
{
|
||||||
@ -553,6 +558,12 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||||||
else
|
else
|
||||||
[self setSelectedMode:activated animated:true];
|
[self setSelectedMode:activated animated:true];
|
||||||
|
|
||||||
|
if (_document)
|
||||||
|
{
|
||||||
|
_sendMediaItemView.title = TGLocalized(@"Common.Done");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (totalCount == 0)
|
if (totalCount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -628,7 +639,7 @@ const NSUInteger TGAttachmentDisplayedAssetLimit = 500;
|
|||||||
{
|
{
|
||||||
progress = zoomedIn ? progress : 1.0f - progress;
|
progress = zoomedIn ? progress : 1.0f - progress;
|
||||||
|
|
||||||
CGFloat correction = self.remainingHeight - 2 * TGMenuSheetButtonItemViewHeight;
|
CGFloat correction = self.remainingHeight - (_document ? 1 : 2) * TGMenuSheetButtonItemViewHeight;
|
||||||
return -(correction * progress);
|
return -(correction * progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,7 +1226,7 @@ static CGPoint TGCameraControllerClampPointToScreenSize(__unused id self, __unus
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
bool hasCamera = _intent == TGCameraControllerGenericIntent && !_shortcut;
|
bool hasCamera = (_intent == TGCameraControllerGenericIntent && !_shortcut) || (_intent == TGCameraControllerPassportIntent || _intent == TGCameraControllerPassportIdIntent);
|
||||||
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:galleryItems focusItem:focusItem selectionContext:_items.count > 1 ? selectionContext : nil editingContext:editingContext hasCaptions:self.allowCaptions allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:_intent == TGCameraControllerPassportIntent || _intent == TGCameraControllerPassportIdIntent inhibitDocumentCaptions:self.inhibitDocumentCaptions hasSelectionPanel:true hasCamera:hasCamera recipientName:self.recipientName];
|
TGMediaPickerGalleryModel *model = [[TGMediaPickerGalleryModel alloc] initWithContext:windowContext items:galleryItems focusItem:focusItem selectionContext:_items.count > 1 ? selectionContext : nil editingContext:editingContext hasCaptions:self.allowCaptions allowCaptionEntities:self.allowCaptionEntities hasTimer:self.hasTimer onlyCrop:_intent == TGCameraControllerPassportIntent || _intent == TGCameraControllerPassportIdIntent inhibitDocumentCaptions:self.inhibitDocumentCaptions hasSelectionPanel:true hasCamera:hasCamera recipientName:self.recipientName];
|
||||||
model.controller = galleryController;
|
model.controller = galleryController;
|
||||||
model.suggestionContext = self.suggestionContext;
|
model.suggestionContext = self.suggestionContext;
|
||||||
|
@ -13,6 +13,18 @@
|
|||||||
#import <LegacyComponents/TGCameraController.h>
|
#import <LegacyComponents/TGCameraController.h>
|
||||||
#import <LegacyComponents/TGLegacyCameraController.h>
|
#import <LegacyComponents/TGLegacyCameraController.h>
|
||||||
|
|
||||||
|
@interface TGPassportDocumentPickerDelegate : NSObject <UIDocumentPickerDelegate>
|
||||||
|
{
|
||||||
|
TGPassportDocumentPickerDelegate *_self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@property (nonatomic, copy, readonly) void (^completionBlock)(TGPassportDocumentPickerDelegate *, NSArray *);
|
||||||
|
|
||||||
|
- (instancetype)initWithCompletionBlock:(void (^)(TGPassportDocumentPickerDelegate *, NSArray *))completionBlock;
|
||||||
|
- (void)cleanup;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation TGPassportAttachMenu
|
@implementation TGPassportAttachMenu
|
||||||
|
|
||||||
+ (TGMenuSheetController *)presentWithContext:(id<LegacyComponentsContext>)context parentController:(TGViewController *)parentController menuController:(TGMenuSheetController *)menuController title:(NSString *)title identity:(bool)identity selfie:(bool)selfie uploadAction:(void (^)(SSignal *, void (^)(void)))uploadAction sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect barButtonItem:(UIBarButtonItem *)barButtonItem
|
+ (TGMenuSheetController *)presentWithContext:(id<LegacyComponentsContext>)context parentController:(TGViewController *)parentController menuController:(TGMenuSheetController *)menuController title:(NSString *)title identity:(bool)identity selfie:(bool)selfie uploadAction:(void (^)(SSignal *, void (^)(void)))uploadAction sourceView:(UIView *)sourceView sourceRect:(CGRect (^)(void))sourceRect barButtonItem:(UIBarButtonItem *)barButtonItem
|
||||||
@ -87,6 +99,31 @@
|
|||||||
}];
|
}];
|
||||||
[itemViews addObject:galleryItem];
|
[itemViews addObject:galleryItem];
|
||||||
|
|
||||||
|
if (iosMajorVersion() >= 8 && !selfie)
|
||||||
|
{
|
||||||
|
TGMenuSheetButtonItemView *icloudItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Conversation.FileICloudDrive") type:TGMenuSheetButtonTypeDefault action:^
|
||||||
|
{
|
||||||
|
__strong TGMenuSheetController *strongController = weakController;
|
||||||
|
if (strongController == nil)
|
||||||
|
return;
|
||||||
|
|
||||||
|
__strong TGViewController *strongParentController = weakParentController;
|
||||||
|
if (strongParentController == nil)
|
||||||
|
return;
|
||||||
|
|
||||||
|
[strongController dismissAnimated:true];
|
||||||
|
[TGPassportAttachMenu _presentICloudPickerWithParentController:strongParentController uploadAction:uploadAction];
|
||||||
|
}];
|
||||||
|
[itemViews addObject:icloudItem];
|
||||||
|
|
||||||
|
carouselItem.underlyingViews = @[ galleryItem, icloudItem ];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
carouselItem.underlyingViews = @[ galleryItem ];
|
||||||
|
}
|
||||||
|
carouselItem.remainingHeight = TGMenuSheetButtonItemViewHeight * (itemViews.count - 1);
|
||||||
|
|
||||||
TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^
|
TGMenuSheetButtonItemView *cancelItem = [[TGMenuSheetButtonItemView alloc] initWithTitle:TGLocalized(@"Common.Cancel") type:TGMenuSheetButtonTypeCancel action:^
|
||||||
{
|
{
|
||||||
__strong TGMenuSheetController *strongController = weakController;
|
__strong TGMenuSheetController *strongController = weakController;
|
||||||
@ -186,6 +223,7 @@
|
|||||||
__weak TGMediaAssetsController *weakController = controller;
|
__weak TGMediaAssetsController *weakController = controller;
|
||||||
controller.singleCompletionBlock = ^(id<TGMediaEditableItem> currentItem, TGMediaEditingContext *editingContext)
|
controller.singleCompletionBlock = ^(id<TGMediaEditableItem> currentItem, TGMediaEditingContext *editingContext)
|
||||||
{
|
{
|
||||||
|
exit(1);
|
||||||
uploadAction([TGPassportAttachMenu resultSignalForEditingContext:editingContext currentItem:(id<TGMediaEditableItem>)currentItem],
|
uploadAction([TGPassportAttachMenu resultSignalForEditingContext:editingContext currentItem:(id<TGMediaEditableItem>)currentItem],
|
||||||
^{
|
^{
|
||||||
__strong TGMediaAssetsController *strongController = weakController;
|
__strong TGMediaAssetsController *strongController = weakController;
|
||||||
@ -327,6 +365,28 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (void)_presentICloudPickerWithParentController:(TGViewController *)parentController uploadAction:(void (^)(SSignal *, void (^)(void)))uploadAction
|
||||||
|
{
|
||||||
|
TGPassportDocumentPickerDelegate *delegate = [[TGPassportDocumentPickerDelegate alloc] initWithCompletionBlock:^(TGPassportDocumentPickerDelegate *delegate, NSArray *urls)
|
||||||
|
{
|
||||||
|
if (urls.count > 0)
|
||||||
|
{
|
||||||
|
NSURL *url = urls.firstObject;
|
||||||
|
uploadAction([SSignal single:url], ^{});
|
||||||
|
}
|
||||||
|
|
||||||
|
[delegate cleanup];
|
||||||
|
}];
|
||||||
|
|
||||||
|
UIDocumentPickerViewController *controller = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeOpen];
|
||||||
|
controller.view.backgroundColor = [UIColor whiteColor];
|
||||||
|
controller.delegate = delegate;
|
||||||
|
|
||||||
|
if (TGIsPad())
|
||||||
|
controller.modalPresentationStyle = UIModalPresentationFormSheet;
|
||||||
|
|
||||||
|
[parentController presentViewController:controller animated:true completion:nil];
|
||||||
|
}
|
||||||
|
|
||||||
+ (SSignal *)resultSignalForEditingContext:(TGMediaEditingContext *)editingContext currentItem:(id<TGMediaEditableItem>)currentItem
|
+ (SSignal *)resultSignalForEditingContext:(TGMediaEditingContext *)editingContext currentItem:(id<TGMediaEditableItem>)currentItem
|
||||||
{
|
{
|
||||||
@ -382,3 +442,42 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation TGPassportDocumentPickerDelegate
|
||||||
|
|
||||||
|
- (instancetype)initWithCompletionBlock:(void (^)(TGPassportDocumentPickerDelegate *, NSArray *))completionBlock
|
||||||
|
{
|
||||||
|
self = [super init];
|
||||||
|
if (self != nil)
|
||||||
|
{
|
||||||
|
_self = self;
|
||||||
|
_completionBlock = [completionBlock copy];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentAtURL:(NSURL *)url
|
||||||
|
{
|
||||||
|
if (self.completionBlock != nil)
|
||||||
|
self.completionBlock(self, @[url]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls
|
||||||
|
{
|
||||||
|
if (self.completionBlock != nil)
|
||||||
|
self.completionBlock(self, urls);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)documentPickerWasCancelled:(UIDocumentPickerViewController *)controller
|
||||||
|
{
|
||||||
|
if (self.completionBlock != nil)
|
||||||
|
self.completionBlock(self, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cleanup
|
||||||
|
{
|
||||||
|
_self = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user