mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-27 10:32:37 +00:00
+ Preselecting an attachment works.
This commit is contained in:
parent
d891af1929
commit
1df69d131a
@ -8,8 +8,12 @@
|
|||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
|
@class BITFeedbackMessageAttachment;
|
||||||
|
|
||||||
@interface BITAttachmentGalleryViewController : UIViewController
|
@interface BITAttachmentGalleryViewController : UIViewController
|
||||||
|
|
||||||
@property (nonatomic, strong) NSArray *messages;
|
@property (nonatomic, strong) NSArray *messages;
|
||||||
|
|
||||||
|
@property (nonatomic, strong) BITFeedbackMessageAttachment *preselectedAttachment;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -54,8 +54,9 @@
|
|||||||
[self setupScrollView];
|
[self setupScrollView];
|
||||||
|
|
||||||
self.view.frame = UIScreen.mainScreen.applicationFrame;
|
self.view.frame = UIScreen.mainScreen.applicationFrame;
|
||||||
// self.view.frame.origin = CGPointZero;
|
|
||||||
|
|
||||||
|
self.tapognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
|
||||||
|
[self.view addGestureRecognizer:self.tapognizer];
|
||||||
}
|
}
|
||||||
-(void)viewWillAppear:(BOOL)animated {
|
-(void)viewWillAppear:(BOOL)animated {
|
||||||
[super viewWillAppear:animated];
|
[super viewWillAppear:animated];
|
||||||
@ -64,6 +65,15 @@
|
|||||||
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
[self.navigationController setNavigationBarHidden:YES animated:NO];
|
||||||
[[UIApplication sharedApplication] setStatusBarHidden:YES];
|
[[UIApplication sharedApplication] setStatusBarHidden:YES];
|
||||||
|
|
||||||
|
if (self.preselectedAttachment){
|
||||||
|
NSInteger indexOfSelectedAttachment = [self.extractedAttachments indexOfObject:self.preselectedAttachment];
|
||||||
|
if (indexOfSelectedAttachment != NSNotFound){
|
||||||
|
self.currentIndex = indexOfSelectedAttachment;
|
||||||
|
self.scrollView.contentOffset = CGPointMake(self.scrollView.frame.size.width * self.currentIndex, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[self layoutViews];
|
[self layoutViews];
|
||||||
|
|
||||||
|
|
||||||
@ -72,8 +82,7 @@
|
|||||||
- (void)viewDidAppear:(BOOL)animated {
|
- (void)viewDidAppear:(BOOL)animated {
|
||||||
[super viewDidAppear:animated];
|
[super viewDidAppear:animated];
|
||||||
|
|
||||||
self.tapognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
|
|
||||||
[self.view addGestureRecognizer:self.tapognizer];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
- (void)setupScrollView {
|
- (void)setupScrollView {
|
||||||
@ -129,14 +138,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)layoutViews {
|
- (void)layoutViews {
|
||||||
|
CGPoint savedOffset = self.scrollView.contentOffset;
|
||||||
|
|
||||||
|
self.scrollView.delegate = nil;
|
||||||
self.scrollView.frame = self.view.bounds;
|
self.scrollView.frame = self.view.bounds;
|
||||||
self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.view.bounds) * self.extractedAttachments.count, CGRectGetHeight(self.view.bounds));
|
self.scrollView.contentSize = CGSizeMake(CGRectGetWidth(self.view.bounds) * self.extractedAttachments.count, CGRectGetHeight(self.view.bounds));
|
||||||
|
self.scrollView.delegate = self;
|
||||||
self.scrollView.contentInset = UIEdgeInsetsZero;
|
self.scrollView.contentInset = UIEdgeInsetsZero;
|
||||||
self.scrollView.autoresizesSubviews = NO;
|
self.scrollView.autoresizesSubviews = NO;
|
||||||
|
self.scrollView.contentOffset = savedOffset;
|
||||||
|
|
||||||
self.scrollView.contentOffset = CGPointMake(self.scrollView.contentOffset.x, 0);
|
|
||||||
|
|
||||||
NSInteger baseIndex = MAX(0,self.currentIndex-1);
|
NSInteger baseIndex = MAX(0,self.currentIndex-1);
|
||||||
NSInteger z = baseIndex;
|
NSInteger z = baseIndex;
|
||||||
|
|||||||
@ -773,14 +773,16 @@
|
|||||||
|
|
||||||
- (void)listCell:(id)cell didSelectAttachment:(BITFeedbackMessageAttachment *)attachment {
|
- (void)listCell:(id)cell didSelectAttachment:(BITFeedbackMessageAttachment *)attachment {
|
||||||
BITAttachmentGalleryViewController *galleryController = [BITAttachmentGalleryViewController new];
|
BITAttachmentGalleryViewController *galleryController = [BITAttachmentGalleryViewController new];
|
||||||
|
|
||||||
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:galleryController];
|
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:galleryController];
|
||||||
|
|
||||||
NSMutableArray *collectedMessages = [NSMutableArray new];
|
NSMutableArray *collectedMessages = [NSMutableArray new];
|
||||||
|
|
||||||
for (int i = 0; i<self.manager.numberOfMessages;i++){
|
for (int i = 0; i<self.manager.numberOfMessages;i++){
|
||||||
[collectedMessages addObject:[self.manager messageAtIndex:i]];
|
[collectedMessages addObject:[self.manager messageAtIndex:i]];
|
||||||
}
|
}
|
||||||
[galleryController setMessages:collectedMessages];
|
|
||||||
|
|
||||||
|
[galleryController setMessages:collectedMessages];
|
||||||
|
[galleryController setPreselectedAttachment:attachment];
|
||||||
[self presentViewController:navController animated:YES completion:nil];
|
[self presentViewController:navController animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user