mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
+ WIP
This commit is contained in:
@@ -52,6 +52,9 @@
|
|||||||
[self extractUsableAttachments];
|
[self extractUsableAttachments];
|
||||||
[self setupScrollView];
|
[self setupScrollView];
|
||||||
|
|
||||||
|
self.view.frame = UIScreen.mainScreen.applicationFrame;
|
||||||
|
// self.view.frame.origin = CGPointZero;
|
||||||
|
|
||||||
[self layoutViews];
|
[self layoutViews];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +83,7 @@
|
|||||||
for (int i = 0; i<3; i++){
|
for (int i = 0; i<3; i++){
|
||||||
UIImageView *newImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
UIImageView *newImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
||||||
[imageviews addObject:newImageView];
|
[imageviews addObject:newImageView];
|
||||||
newImageView.contentMode = UIViewContentModeScaleAspectFit;
|
newImageView.contentMode = UIViewContentModeScaleAspectFit|UIViewContentModeBottom;
|
||||||
[self.scrollView addSubview:newImageView];
|
[self.scrollView addSubview:newImageView];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,11 +116,7 @@
|
|||||||
NSInteger newIndex = self.scrollView.contentOffset.x / self.scrollView.frame.size.width;
|
NSInteger newIndex = self.scrollView.contentOffset.x / self.scrollView.frame.size.width;
|
||||||
if (newIndex!=self.currentIndex){
|
if (newIndex!=self.currentIndex){
|
||||||
self.currentIndex = newIndex;
|
self.currentIndex = newIndex;
|
||||||
// requeue elements.
|
|
||||||
NSInteger baseIndex = MAX(0,self.currentIndex-1);
|
|
||||||
[self layoutViews];
|
[self layoutViews];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +124,10 @@
|
|||||||
|
|
||||||
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.contentInset = UIEdgeInsetsZero;
|
||||||
|
|
||||||
|
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;
|
||||||
@@ -163,10 +166,11 @@
|
|||||||
[[UIApplication sharedApplication] setStatusBarHidden:YES];
|
[[UIApplication sharedApplication] setStatusBarHidden:YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
[self layoutViews];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)frameForItemAtIndex:(NSInteger)index {
|
- (CGRect)frameForItemAtIndex:(NSInteger)index {
|
||||||
return CGRectMake(index * CGRectGetWidth(self.scrollView.frame), 0, CGRectGetWidth(self.scrollView.frame), CGRectGetHeight(self.scrollView.frame));
|
return CGRectMake(index * CGRectGetWidth(self.scrollView.frame), 0, CGRectGetWidth(self.scrollView.frame), CGRectGetHeight(self.view.bounds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -184,8 +184,7 @@
|
|||||||
self.textAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44)];
|
self.textAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44)];
|
||||||
self.textAccessoryView.backgroundColor = [UIColor colorWithRed:0.9f green:0.9f blue:0.9f alpha:1.0f];
|
self.textAccessoryView.backgroundColor = [UIColor colorWithRed:0.9f green:0.9f blue:0.9f alpha:1.0f];
|
||||||
UIButton *addPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
UIButton *addPhotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
[addPhotoButton setTitle:@"+ Add Photo" forState:UIControlStateNormal];
|
[addPhotoButton setTitle:@"+ Add Photo" forState:UIControlStateNormal]; [addPhotoButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
|
||||||
[addPhotoButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
|
|
||||||
addPhotoButton.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44);
|
addPhotoButton.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 44);
|
||||||
[addPhotoButton addTarget:self action:@selector(addPhotoAction:) forControlEvents:UIControlEventTouchUpInside];
|
[addPhotoButton addTarget:self action:@selector(addPhotoAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
|
|
||||||
- (UIImage *)imageRepresentation {
|
- (UIImage *)imageRepresentation {
|
||||||
if ([self.contentType rangeOfString:@"image"].location != NSNotFound){
|
if ([self.contentType rangeOfString:@"image"].location != NSNotFound){
|
||||||
return [UIImage imageWithData:self.data];
|
return [UIImage imageWithData:self.data scale:[UIScreen mainScreen].scale];
|
||||||
} else {
|
} else {
|
||||||
return bit_imageNamed(@"feedbackActiviy.png", BITHOCKEYSDK_BUNDLE); // TODO add another placeholder.
|
return bit_imageNamed(@"feedbackActiviy.png", BITHOCKEYSDK_BUNDLE); // TODO add another placeholder.
|
||||||
}
|
}
|
||||||
@@ -118,9 +118,16 @@
|
|||||||
|
|
||||||
if (!self.thumbnailRepresentations[cacheKey]){
|
if (!self.thumbnailRepresentations[cacheKey]){
|
||||||
UIImage *image = self.imageRepresentation;
|
UIImage *image = self.imageRepresentation;
|
||||||
UIImage *thumbnail = bit_imageToFitSize(image, size, NO);
|
// consider the scale.
|
||||||
|
|
||||||
|
CGFloat scale = [UIScreen mainScreen].scale;
|
||||||
|
|
||||||
|
CGSize scaledSize = CGSizeApplyAffineTransform(size, CGAffineTransformMakeScale(scale, scale));
|
||||||
|
UIImage *thumbnail = bit_imageToFitSize(image, scaledSize, NO) ;
|
||||||
|
|
||||||
|
UIImage *scaledTumbnail = [UIImage imageWithCGImage:thumbnail.CGImage scale:scale orientation:thumbnail.imageOrientation];
|
||||||
if (thumbnail){
|
if (thumbnail){
|
||||||
[self.thumbnailRepresentations setObject:thumbnail forKey:cacheKey];
|
[self.thumbnailRepresentations setObject:scaledTumbnail forKey:cacheKey];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user