no message

This commit is contained in:
Ilya Laktyushin
2017-08-15 11:21:05 +03:00
parent 0dc27a249d
commit ba45f84217
11 changed files with 149 additions and 37 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -175,7 +175,7 @@
[_galleryController setPreviewMode:false];
TGOverlayControllerWindow *controllerWindow = [[TGOverlayControllerWindow alloc] initWithParentController:_parentController contentController:_galleryController];
TGOverlayControllerWindow *controllerWindow = [[TGOverlayControllerWindow alloc] initWithManager:[_context makeOverlayWindowManager] parentController:_parentController contentController:_galleryController];
controllerWindow.hidden = false;
_galleryController.view.clipsToBounds = true;

View File

@@ -340,7 +340,7 @@
{
__strong TGClipboardGalleryModel *strongSelf = weakSelf;
if (strongSelf == nil) {
TGLog(@"controller.didFinishEditing strongSelf == nil");
TGLegacyLog(@"controller.didFinishEditing strongSelf == nil");
}
#ifdef DEBUG

View File

@@ -165,14 +165,21 @@ static UIImage *pagerLeftButtonHighlightedImage() {
if (title.length == 0)
title = [self titleForState:UIControlStateNormal];
if (self.isMultiline)
if (title.length > 0)
{
CGSize size = [title sizeWithFont:self.titleLabel.font constrainedToSize:CGSizeMake(self.maxWidth - 18.0f, FLT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, ceil(size.width) + 18, MAX(41.0f, ceil(size.height) + 20.0f));
if (self.isMultiline)
{
CGSize size = [title sizeWithFont:self.titleLabel.font constrainedToSize:CGSizeMake(self.maxWidth - 18.0f, FLT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, ceil(size.width) + 18, MAX(41.0f, ceil(size.height) + 20.0f));
}
else
{
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, [title sizeWithFont:self.titleLabel.font].width + 34, 41);
}
}
else
{
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, [title sizeWithFont:self.titleLabel.font].width + 34, 41);
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.imageView.frame.size.width + 24.0f, 41);
}
}
@@ -304,6 +311,8 @@ static UIImage *pagerLeftButtonHighlightedImage() {
else if ([titleValue isKindOfClass:[NSAttributedString class]])
attributedTitle = titleValue;
id imageValue = [dict objectForKey:@"image"];
TGMenuButtonView *buttonView = nil;
if (index < (int)_buttonViews.count)
@@ -335,6 +344,13 @@ static UIImage *pagerLeftButtonHighlightedImage() {
[buttonView setTitle:title forState:UIControlStateNormal];
else if (attributedTitle)
[buttonView setAttributedTitle:attributedTitle forState:UIControlStateNormal];
if ([imageValue isKindOfClass:[UIImage class]])
{
[buttonView setImage:imageValue forState:UIControlStateNormal];
//buttonView.imageEdgeInsets = UIEdgeInsetsMake(0.0f, 10.0f, 0.0f, 10.0f);
}
buttonView.selected = false;
}

View File

@@ -403,7 +403,7 @@ typedef enum {
[_collectionView reloadData];
[_tabPanel setStickerPacks:_section == TGPhotoStickersViewSectionMasks ? _maskStickerPacks : _genericStickerPacks showRecent:_section == TGPhotoStickersViewSectionMasks ? (_recentStickers.count != 0) : (_recentMasks.count != 0) showGifs:false showTrendingFirst:false showTrendingLast:false];
[_tabPanel setStickerPacks:_section == TGPhotoStickersViewSectionMasks ? _maskStickerPacks : _genericStickerPacks showRecent:_section == TGPhotoStickersViewSectionMasks ? (_recentStickers.count != 0) : (_recentMasks.count != 0) showFavorite:false showGroup:false showGifs:false showTrendingFirst:false showTrendingLast:false];
}
- (void)updateRecentDocuments
@@ -880,7 +880,7 @@ typedef enum {
if (section != _section) {
_section = section;
[_tabPanel setStickerPacks:_section == TGPhotoStickersViewSectionMasks ? _maskStickerPacks : _genericStickerPacks showRecent:_section == TGPhotoStickersViewSectionMasks ? (_recentMasks.count != 0) : (_recentStickers.count != 0) showGifs:false showTrendingFirst:false showTrendingLast:false];
[_tabPanel setStickerPacks:_section == TGPhotoStickersViewSectionMasks ? _maskStickerPacks : _genericStickerPacks showRecent:_section == TGPhotoStickersViewSectionMasks ? (_recentMasks.count != 0) : (_recentStickers.count != 0) showFavorite:false showGroup:false showGifs:false showTrendingFirst:false showTrendingLast:false];
[_collectionView reloadData];
[self updateCurrentSection];

View File

@@ -22,9 +22,9 @@ static const CGFloat TGStickersTopMargin = 140.0f;
@implementation TGStickerItemPreviewView
- (instancetype)initWithFrame:(CGRect)frame
- (instancetype)initWithContext:(id<LegacyComponentsContext>)context frame:(CGRect)frame
{
self = [super initWithFrame:frame];
self = [super initWithContext:context frame:frame];
if (self != nil)
{
self.eccentric = true;

View File

@@ -6,9 +6,11 @@
@interface TGStickerKeyboardTabCell : UICollectionViewCell
- (void)setFavorite;
- (void)setRecent;
- (void)setNone;
- (void)setDocumentMedia:(TGDocumentMediaAttachment *)documentMedia;
- (void)setUrl:(NSString *)url;
- (void)setStyle:(TGStickerKeyboardViewStyle)style;

View File

@@ -6,6 +6,7 @@
#import "TGStringUtils.h"
#import <LegacyComponents/TGImageView.h>
#import <LegacyComponents/TGRemoteImageView.h>
static void setViewFrame(UIView *view, CGRect frame)
{
@@ -19,7 +20,9 @@ static void setViewFrame(UIView *view, CGRect frame)
@interface TGStickerKeyboardTabCell ()
{
TGImageView *_imageView;
TGRemoteImageView *_remoteImageView;
TGStickerKeyboardViewStyle _style;
bool _favorite;
bool _recent;
}
@@ -52,17 +55,16 @@ static void setViewFrame(UIView *view, CGRect frame)
[_imageView reset];
}
- (void)_updateRecentIcon
- (void)_updateIcon:(UIImage *)image
{
UIImage *recentTabImage = TGComponentsImageNamed(@"StickerKeyboardRecentTab.png");
if (_style == TGStickerKeyboardViewPaintDarkStyle)
{
UIColor *color = self.selected ? [UIColor blackColor] : UIColorRGB(0xb4b5b5);
_imageView.image = TGTintedImage(recentTabImage, color);
_imageView.image = TGTintedImage(image, color);
}
else
{
_imageView.image = recentTabImage;
_imageView.image = image;
}
}
@@ -71,22 +73,46 @@ static void setViewFrame(UIView *view, CGRect frame)
[super setSelected:selected];
if (_recent)
[self _updateRecentIcon];
[self _updateIcon:TGComponentsImageNamed(@"StickerKeyboardRecentTab.png")];
else if (_favorite)
[self _updateIcon:TGComponentsImageNamed(@"StickerKeyboardFavoriteTab.png")];
}
- (void)setFavorite
{
_recent = false;
_favorite = true;
_remoteImageView.hidden = true;
_imageView.hidden = false;
[_imageView reset];
_imageView.contentMode = UIViewContentModeCenter;
[self _updateIcon:TGComponentsImageNamed(@"StickerKeyboardFavoriteTab.png")];
}
- (void)setRecent
{
_recent = true;
_favorite = false;
_remoteImageView.hidden = true;
_imageView.hidden = false;
[_imageView reset];
_imageView.contentMode = UIViewContentModeCenter;
[self _updateRecentIcon];
[self _updateIcon:TGComponentsImageNamed(@"StickerKeyboardRecentTab.png")];
}
- (void)setNone
{
_recent = false;
_favorite = false;
_remoteImageView.hidden = true;
_imageView.hidden = false;
[_imageView reset];
_imageView.image = nil;
@@ -95,7 +121,10 @@ static void setViewFrame(UIView *view, CGRect frame)
- (void)setDocumentMedia:(TGDocumentMediaAttachment *)documentMedia
{
_recent = false;
_favorite = false;
_remoteImageView.hidden = true;
_imageView.hidden = false;
_imageView.contentMode = UIViewContentModeScaleAspectFit;
NSMutableString *uri = [[NSMutableString alloc] initWithString:@"sticker-preview://?"];
@@ -116,6 +145,24 @@ static void setViewFrame(UIView *view, CGRect frame)
[_imageView loadUri:uri withOptions:nil];
}
- (void)setUrl:(NSString *)url
{
_recent = false;
_favorite = false;
_imageView.contentMode = UIViewContentModeScaleAspectFit;
if (_remoteImageView == nil)
{
_remoteImageView = [[TGRemoteImageView alloc] initWithFrame:_imageView.frame];
[_imageView.superview addSubview:_remoteImageView];
}
_remoteImageView.hidden = false;
_imageView.hidden = true;
[_remoteImageView loadImage:url filter:@"circle:37x37" placeholder:nil];
}
- (void)setStyle:(TGStickerKeyboardViewStyle)style
{
_style = style;
@@ -143,7 +190,9 @@ static void setViewFrame(UIView *view, CGRect frame)
self.selectedBackgroundView.clipsToBounds = true;
if (_recent)
[self _updateRecentIcon];
[self _updateIcon:TGComponentsImageNamed(@"StickerKeyboardRecentTab.png")];
else if (_favorite)
[self _updateIcon:TGComponentsImageNamed(@"StickerKeyboardFavoriteTab.png")];
}
break;

View File

@@ -21,12 +21,14 @@ typedef enum
- (instancetype)initWithFrame:(CGRect)frame style:(TGStickerKeyboardViewStyle)style;
- (void)setStickerPacks:(NSArray *)stickerPacks showRecent:(bool)showRecent showGifs:(bool)showGifs showTrendingFirst:(bool)showTrendingFirst showTrendingLast:(bool)showTrendingLast;
- (void)setStickerPacks:(NSArray *)stickerPacks showRecent:(bool)showRecent showFavorite:(bool)showFavorite showGroup:(bool)showGroup showGifs:(bool)showGifs showTrendingFirst:(bool)showTrendingFirst showTrendingLast:(bool)showTrendingLast;
- (void)setCurrentStickerPackIndex:(NSUInteger)currentStickerPackIndex animated:(bool)animated;
- (void)setCurrentGifsModeSelected;
- (void)setCurrentTrendingModeSelected;
- (void)setTrendingStickersBadge:(NSString *)badge;
- (void)setAvatarUrl:(NSString *)avatarUrl;
- (void)setInnerAlpha:(CGFloat)alpha;
- (void)setExpanded:(bool)expanded;

View File

@@ -12,6 +12,8 @@
TGStickerKeyboardViewStyle _style;
bool _showRecent;
bool _showFavorite;
bool _showGroup;
bool _showGifs;
bool _showTrendingFirst;
bool _showTrendingLast;
@@ -24,6 +26,8 @@
NSString *_trendingStickersBadge;
CGFloat _innerAlpha;
NSString *_avatarUrl;
bool _expanded;
}
@@ -96,6 +100,14 @@
return self;
}
- (void)setAvatarUrl:(NSString *)avatarUrl
{
_avatarUrl = avatarUrl;
TGStickerKeyboardTabCell *cell = (TGStickerKeyboardTabCell *)[_collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:1]];
[cell setUrl:_avatarUrl];
}
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if (_expanded)
@@ -157,7 +169,7 @@
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)__unused collectionView
{
return 2 + ((_style == TGStickerKeyboardViewDefaultStyle) ? 1 : 0);
return 5 + ((_style == TGStickerKeyboardViewDefaultStyle) ? 1 : 0);
}
- (NSInteger)collectionView:(UICollectionView *)__unused collectionView numberOfItemsInSection:(NSInteger)__unused section
@@ -165,8 +177,14 @@
if (section == 0) {
return (_showGifs ? 1 : 0) + (_showTrendingFirst ? 1 : 0);
} else if (section == 1) {
return 1 + _stickerPacks.count;
return (_showFavorite ? 1 : 0);
} else if (section == 2) {
return (_showRecent ? 1 : 0);
} else if (section == 3) {
return (_showGroup ? 1 : 0);
} else if (section == 4) {
return _stickerPacks.count;
} else if (section == 5) {
return 1 + (_showTrendingLast ? 1 : 0);
} else {
return 0;
@@ -175,9 +193,6 @@
- (CGSize)collectionView:(UICollectionView *)__unused collectionView layout:(UICollectionViewLayout*)__unused collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)__unused indexPath
{
if (indexPath.section == 1 && indexPath.item == 0 && !_showRecent)
return CGSizeMake(1.0f, _collectionView.frame.size.height);
CGFloat width = 52.0f;
if (_style == TGStickerKeyboardViewDefaultStyle)
width = 48.0f;
@@ -218,21 +233,35 @@
}
return cell;
} else if (indexPath.section == 1) {
} else if (indexPath.section == 1 || indexPath.section == 2 || indexPath.section == 3 || indexPath.section == 4) {
TGStickerKeyboardTabCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TGStickerKeyboardTabCell" forIndexPath:indexPath];
[cell setStyle:_style];
if (indexPath.item == 0) {
if (indexPath.section == 1) {
if (_showFavorite) {
[cell setFavorite];
} else {
[cell setNone];
}
}
else if (indexPath.section == 2) {
if (_showRecent) {
[cell setRecent];
} else {
[cell setNone];
}
}
else if (indexPath.section == 3) {
if (_showGroup) {
[cell setUrl:_avatarUrl];
} else {
[cell setNone];
}
}
else
{
if (((TGStickerPack *)_stickerPacks[indexPath.item - 1]).documents.count != 0)
[cell setDocumentMedia:((TGStickerPack *)_stickerPacks[indexPath.item - 1]).documents[0]];
if (((TGStickerPack *)_stickerPacks[indexPath.item]).documents.count != 0)
[cell setDocumentMedia:((TGStickerPack *)_stickerPacks[indexPath.item]).documents[0]];
else
[cell setNone];
}
@@ -240,7 +269,7 @@
[cell setInnerAlpha:_innerAlpha];
return cell;
} else if (indexPath.section == 2) {
} else if (indexPath.section == 5) {
TGStickerKeyboardTabSettingsCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TGStickerKeyboardTabSettingsCell" forIndexPath:indexPath];
[cell setStyle:_style];
@@ -325,19 +354,21 @@
} else {
[self scrollToTrendingButton];
}
} else if (indexPath.section == 1) {
} else if (indexPath.section == 1 || indexPath.section == 2 || indexPath.section == 3 || indexPath.section == 4) {
if (_currentStickerPackIndexChanged)
_currentStickerPackIndexChanged(indexPath.item);
} else if (indexPath.section == 2) {
_currentStickerPackIndexChanged(indexPath.section - 1 + indexPath.row);
} else if (indexPath.section == 5) {
if (indexPath.item == 0 && _showTrendingLast) {
[self scrollToTrendingButton];
}
}
}
- (void)setStickerPacks:(NSArray *)stickerPacks showRecent:(bool)showRecent showGifs:(bool)showGifs showTrendingFirst:(bool)showTrendingFirst showTrendingLast:(bool)showTrendingLast {
- (void)setStickerPacks:(NSArray *)stickerPacks showRecent:(bool)showRecent showFavorite:(bool)showFavorite showGroup:(bool)showGroup showGifs:(bool)showGifs showTrendingFirst:(bool)showTrendingFirst showTrendingLast:(bool)showTrendingLast {
_stickerPacks = stickerPacks;
_showRecent = showRecent;
_showFavorite = showFavorite;
_showGroup = showGroup;
_showGifs = showGifs;
_showTrendingFirst = showTrendingFirst;
_showTrendingLast = showTrendingLast;
@@ -347,11 +378,20 @@
- (void)setCurrentStickerPackIndex:(NSUInteger)currentStickerPackIndex animated:(bool)animated
{
NSInteger section = currentStickerPackIndex + 1;
NSInteger row = 0;
if (section >= 4)
{
section = 4;
row = currentStickerPackIndex - 4;
}
NSArray *selectedItems = [_collectionView indexPathsForSelectedItems];
if (selectedItems.count == 1 && ((NSIndexPath *)selectedItems[0]).item == (NSInteger)currentStickerPackIndex)
if (selectedItems.count == 1 && ((NSIndexPath *)selectedItems[0]).section == (NSInteger)section && ((NSIndexPath *)selectedItems[0]).row == (NSInteger)row)
return;
UICollectionViewLayoutAttributes *attributes = [_collectionLayout layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:currentStickerPackIndex inSection:1]];
UICollectionViewLayoutAttributes *attributes = [_collectionLayout layoutAttributesForItemAtIndexPath:[NSIndexPath indexPathForItem:row inSection:section]];
UICollectionViewScrollPosition scrollPosition = UICollectionViewScrollPositionNone;
if (!CGRectContainsRect(_collectionView.bounds, attributes.frame))
{
@@ -362,7 +402,7 @@
else
scrollPosition = UICollectionViewScrollPositionRight;
}
[_collectionView selectItemAtIndexPath:[NSIndexPath indexPathForItem:currentStickerPackIndex inSection:1] animated:animated scrollPosition:scrollPosition];
[_collectionView selectItemAtIndexPath:[NSIndexPath indexPathForItem:row inSection:section] animated:animated scrollPosition:scrollPosition];
}
- (void)setCurrentGifsModeSelected {
@@ -395,7 +435,7 @@
- (void)scrollToTrendingButton {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_showGifs ? 1 : 0 inSection:0];
if (_showTrendingLast) {
indexPath = [NSIndexPath indexPathForItem:0 inSection:2];
indexPath = [NSIndexPath indexPathForItem:0 inSection:5];
}
if (indexPath.section < [self numberOfSectionsInCollectionView:_collectionView] && indexPath.item < [self collectionView:_collectionView numberOfItemsInSection:indexPath.section]) {
UICollectionViewLayoutAttributes *attributes = [_collectionLayout layoutAttributesForItemAtIndexPath:indexPath];
@@ -432,7 +472,7 @@
}
}
}
TGStickerKeyboardTabSettingsCell *cell = (TGStickerKeyboardTabSettingsCell *)[_collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:2]];
TGStickerKeyboardTabSettingsCell *cell = (TGStickerKeyboardTabSettingsCell *)[_collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:5]];
if (cell != nil) {
[cell setBadge:badge];
}
@@ -451,6 +491,9 @@
if (iosMajorVersion() < 8)
return;
if (!_showGifs)
return;
[UIView animateWithDuration:0.2 animations:^
{
_collectionView.contentInset = expanded ? UIEdgeInsetsMake(0.0f, -48.0f, 0.0f, 0.0f) : UIEdgeInsetsZero;