[ios] Improved performance.

This commit is contained in:
Ilya Grechuhin 2016-03-25 15:13:29 +03:00
parent 818139ca0b
commit ac3bc19a40
9 changed files with 55 additions and 12 deletions

View file

@ -95,7 +95,8 @@
[Statistics logEvent:kStatEventName(kStatBookmarks, kStatToggleVisibility)
withParameters:@{kStatValue : visible ? kStatVisible : kStatHidden}];
cell.imageView.image = [UIImage imageNamed:(visible ? @"ic_show" : @"ic_hide")];
[cell.imageView makeImageAlwaysTemplate];
if (isIOS7)
[cell.imageView makeImageAlwaysTemplate];
cell.imageView.mwm_coloring = visible ? MWMImageColoringBlue : MWMImageColoringBlack;
{
BookmarkCategory::Guard guard(*cat);
@ -129,7 +130,8 @@
BOOL const isVisible = cat->IsVisible();
cell.imageView.image = [UIImage imageNamed:(isVisible ? @"ic_show" : @"ic_hide")];
cell.imageView.mwm_coloring = isVisible ? MWMImageColoringBlue : MWMImageColoringBlack;
[cell.imageView makeImageAlwaysTemplate];
if (isIOS7)
[cell.imageView makeImageAlwaysTemplate];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld", cat->GetUserMarkCount() + cat->GetTracksCount()];
}
cell.backgroundColor = [UIColor white];

View file

@ -1,3 +1,4 @@
#import "Common.h"
#import "MWMButton.h"
#import "UIColor+MapsMeColor.h"
@ -25,7 +26,8 @@ namespace
- (void)setColoring:(MWMButtonColoring)coloring
{
_coloring = coloring;
[self.imageView makeImageAlwaysTemplate];
if (isIOS7)
[self.imageView makeImageAlwaysTemplate];
[self setDefaultTintColor];
}
@ -59,7 +61,8 @@ namespace
- (void)setHighlighted:(BOOL)highlighted
{
[super setHighlighted:highlighted];
[self.imageView makeImageAlwaysTemplate];
if (isIOS7)
[self.imageView makeImageAlwaysTemplate];
if (highlighted)
{
switch (self.coloring)
@ -89,7 +92,8 @@ namespace
- (void)setSelected:(BOOL)selected
{
[super setSelected:selected];
[self.imageView makeImageAlwaysTemplate];
if (isIOS7)
[self.imageView makeImageAlwaysTemplate];
if (selected)
{
switch (self.coloring)

View file

@ -28,7 +28,7 @@ using MWMCircularProgressStateVec = vector<MWMCircularProgressState>;
@property (nonatomic) CGFloat progress;
@property (nonatomic) MWMCircularProgressState state;
@property (weak, nonatomic) id<MWMCircularProgressProtocol> delegate;
@property (weak, nonatomic) id<MWMCircularProgressProtocol> _Nullable delegate;
- (void)setImage:(nonnull UIImage *)image forStates:(MWMCircularProgressStateVec const &)states;
- (void)setColor:(nonnull UIColor *)color forStates:(MWMCircularProgressStateVec const &)states;

View file

@ -1,6 +1,17 @@
#import "MWMCircularProgress.h"
#import "MWMCircularProgressView.h"
namespace
{
UINib * const progressViewNib = [UINib nibWithNibName:@"MWMCircularProgress" bundle:[NSBundle mainBundle]];
} // namespace
@interface MWMCircularProgressView ()
@property (nonatomic) BOOL suspendRefreshProgress;
@end
@interface MWMCircularProgress ()
@property (nonatomic) IBOutlet MWMCircularProgressView * rootView;
@ -14,6 +25,8 @@
{
MWMCircularProgress * progress = [[MWMCircularProgress alloc] initWithParentView:parentView];
progress.rootView.suspendRefreshProgress = YES;
[progress setImage:[UIImage imageNamed:@"ic_download"]
forStates:{MWMCircularProgressStateNormal, MWMCircularProgressStateSelected}];
[progress setImage:[UIImage imageNamed:@"ic_close_spinner"]
@ -29,6 +42,8 @@
[progress setColoring:MWMButtonColoringOther forStates:{MWMCircularProgressStateFailed}];
[progress setColoring:MWMButtonColoringBlue forStates:{MWMCircularProgressStateCompleted}];
progress.rootView.suspendRefreshProgress = NO;
return progress;
}
@ -37,7 +52,7 @@
self = [super init];
if (self)
{
[[NSBundle mainBundle] loadNibNamed:self.class.className owner:self options:nil];
[progressViewNib instantiateWithOwner:self options:nil];
[parentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
[parentView addSubview:self.rootView];
self.state = MWMCircularProgressStateNormal;

View file

@ -29,6 +29,8 @@ static inline CGFloat angleWithProgress(CGFloat progress)
@property (weak, nonatomic) IBOutlet UIImageView * spinner;
@property (weak, nonatomic) IBOutlet MWMButton * button;
@property (nonatomic) BOOL suspendRefreshProgress;
@end
@implementation MWMCircularProgressView
@ -39,9 +41,11 @@ static inline CGFloat angleWithProgress(CGFloat progress)
- (void)awakeFromNib
{
self.images = [NSMutableDictionary dictionary];
self.suspendRefreshProgress = YES;
[self setupColors];
[self setupButtonColoring];
[self setupAnimationLayers];
self.suspendRefreshProgress = NO;
}
- (void)layoutSubviews
@ -78,7 +82,9 @@ static inline CGFloat angleWithProgress(CGFloat progress)
- (void)mwm_refreshUI
{
self.suspendRefreshProgress = YES;
[self setupColors];
self.suspendRefreshProgress = NO;
}
- (void)setupAnimationLayers
@ -113,6 +119,8 @@ static inline CGFloat angleWithProgress(CGFloat progress)
- (void)refreshProgress
{
if (self.suspendRefreshProgress)
return;
self.backgroundLayer.fillColor = self.progressLayer.fillColor = UIColor.clearColor.CGColor;
self.backgroundLayer.lineWidth = self.progressLayer.lineWidth = kLineWidth;
self.backgroundLayer.strokeColor = self.backgroundLayerColor;
@ -229,4 +237,11 @@ static inline CGFloat angleWithProgress(CGFloat progress)
return [self.progressLayer animationForKey:kAnimationKey] != nil;
}
- (void)setSuspendRefreshProgress:(BOOL)suspendRefreshProgress
{
_suspendRefreshProgress = suspendRefreshProgress;
if (!suspendRefreshProgress)
[self refreshProgress];
}
@end

View file

@ -1,3 +1,4 @@
#import "Common.h"
#import "MWMBottomMenuCollectionViewCell.h"
#import "UIFont+MapsMeFonts.h"
#import "UIColor+MapsMeColor.h"
@ -23,7 +24,8 @@
isEnabled:(BOOL)isEnabled
{
self.icon.image = [UIImage imageNamed:imageName];
[self.icon makeImageAlwaysTemplate];
if (isIOS7)
[self.icon makeImageAlwaysTemplate];
self.label.text = label;
if (badgeCount > 0)
{

View file

@ -1,3 +1,4 @@
#import "Common.h"
#import "MWMSearchManager.h"
#import "MWMSearchTabButtonsView.h"
#import "UIColor+MapsMeColor.h"
@ -91,7 +92,8 @@ static CGFloat const kIconToLabelSpacing = 4.0;
{
_iconImage = iconImage;
[self.icon setImage:iconImage forState:UIControlStateNormal];
[self.icon.imageView makeImageAlwaysTemplate];
if (isIOS7)
[self.icon.imageView makeImageAlwaysTemplate];
}
- (void)setLocalizedText:(NSString *)localizedText

View file

@ -38,7 +38,8 @@
- (void)configureWithEntity:(MWMNavigationDashboardEntity *)entity
{
self.direction.image = entity.turnImage;
[self.direction makeImageAlwaysTemplate];
if (isIOS7)
[self.direction makeImageAlwaysTemplate];
if (!entity.isPedestrian)
self.direction.transform = CGAffineTransformIdentity;
self.distanceToNextAction.text = entity.distanceToTurn;

View file

@ -22,7 +22,8 @@
objc_setAssociatedObject(self, @selector(mwm_coloring), @(mwm_coloring), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
if (mwm_coloring == MWMImageColoringOther)
return;
[self makeImageAlwaysTemplate];
if (isIOS7)
[self makeImageAlwaysTemplate];
[self applyColoring];
}
@ -49,7 +50,8 @@
self.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@_%@", self.mwm_name, [UIColor isNightMode] ? @"dark" : @"light"]];
return;
}
[self makeImageAlwaysTemplate];
if (isIOS7)
[self makeImageAlwaysTemplate];
[self applyColoring];
}