[ios] Night mode bugfix.

This commit is contained in:
VladiMihaylenko 2016-01-20 17:54:24 +03:00
parent fbbf28bbd7
commit 5e14c072fa
38 changed files with 214 additions and 82 deletions

View file

@ -94,8 +94,9 @@
bool visible = !cat->IsVisible();
[[Statistics instance] logEvent:kStatEventName(kStatBookmarks, kStatToggleVisibility)
withParameters:@{kStatValue : visible ? kStatVisible : kStatHidden}];
cell.imageView.mwm_coloring = visible ? MWMImageColoringBlue : MWMImageColoringBlack;
cell.imageView.image = [UIImage imageNamed:(visible ? @"ic_show" : @"ic_hide")];
[cell.imageView makeImageAlwaysTemplate];
cell.imageView.mwm_coloring = visible ? MWMImageColoringBlue : MWMImageColoringBlack;
{
BookmarkCategory::Guard guard(*cat);
guard.m_controller.SetIsVisible(visible);
@ -126,8 +127,9 @@
NSString * title = @(cat->GetName().c_str());
cell.textLabel.text = [self truncateString:title toWidth:(self.tableView.width - 122) withFont:cell.textLabel.font];
BOOL const isVisible = cat->IsVisible();
cell.imageView.mwm_coloring = isVisible ? MWMImageColoringBlue : MWMImageColoringBlack;
cell.imageView.image = [UIImage imageNamed:(isVisible ? @"ic_show" : @"ic_hide")];
cell.imageView.mwm_coloring = isVisible ? MWMImageColoringBlue : MWMImageColoringBlack;
[cell.imageView makeImageAlwaysTemplate];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%ld", cat->GetUserMarkCount() + cat->GetTracksCount()];
}
cell.backgroundColor = [UIColor white];

View file

@ -51,6 +51,12 @@ static inline CGFloat LengthCGPoint(CGPoint point)
@end
@interface UIImageView (IOS7Workaround)
- (void)makeImageAlwaysTemplate;
@end
@interface UIApplication (URLs)
- (void)rateVersionFrom:(NSString *)launchPlaceName;

View file

@ -179,6 +179,7 @@
if ([v respondsToSelector:@selector(refresh)])
[v refresh];
}
[self setNeedsDisplay];
}
@end
@ -187,7 +188,33 @@
- (void)refresh
{
[super refresh];
if (isIOSVersionLessThan(8))
{
UIColor * opposite = self.backgroundColor.opposite;
if (opposite)
self.backgroundColor = opposite;
for (UIView * v in self.subviews)
{
// There is workaroung for iOS7 only.
if (isIOSVersionLessThan(8))
{
if ([v isKindOfClass:NSClassFromString(@"UITableViewCellScrollView")])
{
for (UIView * subview in v.subviews)
[subview refresh];
}
continue;
}
if ([v respondsToSelector:@selector(refresh)])
[v refresh];
}
}
else
{
[super refresh];
}
[self.selectedBackgroundView refresh];
}
@ -297,11 +324,22 @@
- (void)refresh
{
[super refresh];
[self changeColoringToOpposite];
}
@end
@implementation UIImageView (IOS7Workaround)
- (void)makeImageAlwaysTemplate
{
if (isIOSVersionLessThan(8))
self.image = [self.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
}
@end
@implementation SolidTouchImageView
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}

View file

@ -113,6 +113,7 @@ static inline CGFloat angleWithProgress(CGFloat progress)
self.button.mwm_coloring = MWMButtonColoringBlue;
break;
case MWMCircularProgressStateFailed:
normalImage = self.images[@(MWMCircularProgressStateFailed)];
self.button.mwm_coloring = MWMButtonColoringBlue;
break;
case MWMCircularProgressStateCompleted:
@ -154,7 +155,8 @@ static inline CGFloat angleWithProgress(CGFloat progress)
NSUInteger const animationImagesCount = 12;
NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount];
for (NSUInteger i = 0; i < animationImagesCount; ++i)
animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@", @(i+1)]];
animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i+1),
[UIColor isNightMode] ? @"dark" : @"light"]];
self.spinner.animationImages = animationImages;
[self.spinner startAnimating];

View file

@ -10,6 +10,4 @@
label:(NSString *)label
badgeCount:(NSUInteger)badgeCount;
- (void)highlighted:(BOOL)highlighted;
@end

View file

@ -20,6 +20,7 @@
badgeCount:(NSUInteger)badgeCount
{
self.icon.image = image;
[self.icon makeImageAlwaysTemplate];
self.label.text = label;
if (badgeCount > 0)
{
@ -32,7 +33,6 @@
self.badgeBackground.hidden = YES;
self.badgeCount.hidden = YES;
}
[self highlighted:NO];
}
- (void)configureWithImageName:(NSString *)imageName label:(NSString *)label badgeCount:(NSUInteger)badgeCount
@ -40,9 +40,15 @@
[self configureWithImage:[UIImage imageNamed:imageName] label:label badgeCount:badgeCount];
}
- (void)highlighted:(BOOL)highlighted
- (void)setHighlighted:(BOOL)highlighted
{
[super setHighlighted:highlighted];
self.icon.tintColor = self.label.textColor = highlighted ? [UIColor blackHintText] : [UIColor blackSecondaryText];
}
- (void)setSelected:(BOOL)selected
{
// There is don't need to do something after cell was selected.
}
@end

View file

@ -3,6 +3,7 @@
#import "MWMBottomMenuView.h"
#import "MWMBottomMenuViewController.h"
#import "MapsAppDelegate.h"
#import "UIButton+Coloring.h"
#import "UIButton+RuntimeAttributes.h"
#import "UIColor+MapsMeColor.h"
#import "UIFont+MapsMeFonts.h"
@ -251,6 +252,7 @@
else
{
UIButton * btn = self.menuButton;
NSString * name = nil;
switch (self.state)
{
case MWMBottomMenuStateHidden:
@ -258,21 +260,28 @@
case MWMBottomMenuStatePlanning:
case MWMBottomMenuStateGo:
case MWMBottomMenuStateText:
[btn setImage:[UIImage imageNamed:@"ic_menu"] forState:UIControlStateNormal];
name = @"ic_menu";
break;
case MWMBottomMenuStateActive:
[btn setImage:[UIImage imageNamed:@"ic_menu_down"] forState:UIControlStateNormal];
name = @"ic_menu_down";
break;
case MWMBottomMenuStateCompact:
[btn setImage:[UIImage imageNamed:@"ic_menu_left"] forState:UIControlStateNormal];
name = @"ic_menu_left";
break;
}
if (!name)
return;
UIImage * image = [UIImage imageNamed:name];
if (isIOSVersionLessThan(8))
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[btn setImage:image forState:UIControlStateNormal];
}
});
}
- (void)refreshOnOrientationChange
{
[self refreshButtonsColor];
if (IPAD || self.state != MWMBottomMenuStateCompact)
return;
BOOL const isPortrait = self.superview.width < self.superview.height;
@ -284,6 +293,18 @@
{
self.layoutDuration = kDefaultAnimationDuration;
[self setNeedsLayout];
[self refreshButtonsColor];
}
- (void)refreshButtonsColor
{
if (!isIOSVersionLessThan(8))
return;
auto const coloring = self.p2pButton.mwm_coloring;
self.p2pButton.mwm_coloring = coloring;
self.bookmarksButton.mwm_coloring = coloring;
self.locationButton.mwm_coloring = self.locationButton.mwm_coloring;
self.searchButton.mwm_coloring = self.searchButton.mwm_coloring;
}
#pragma mark - Properties

View file

@ -325,22 +325,6 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
}
}
- (void)collectionView:(nonnull UICollectionView *)collectionView
didHighlightItemAtIndexPath:(nonnull NSIndexPath *)indexPath
{
MWMBottomMenuCollectionViewCell * cell =
(MWMBottomMenuCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell highlighted:YES];
}
- (void)collectionView:(nonnull UICollectionView *)collectionView
didUnhighlightItemAtIndexPath:(nonnull NSIndexPath *)indexPath
{
MWMBottomMenuCollectionViewCell * cell =
(MWMBottomMenuCollectionViewCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell highlighted:NO];
}
#pragma mark - Buttons actions
- (void)menuActionDownloadMaps

View file

@ -112,7 +112,7 @@ extern NSString * const kAlohalyticsTapEventKey;
- (void)refreshHelperPanels:(BOOL)isLandscape
{
if (!self.placePageManager.entity)
if (!self.placePageManager.placePage)
return;
if (isLandscape)
[self.navigationManager hideHelperPanels];
@ -485,7 +485,8 @@ extern NSString * const kAlohalyticsTapEventKey;
[self.menuController setInactive];
[self resetRoutingPoint];
[self navigationDashBoardDidUpdate];
[MapsAppDelegate resetToDefaultMapStyle];
if ([MapsAppDelegate isAutoNightMode])
[MapsAppDelegate resetToDefaultMapStyle];
GetFramework().CloseRouting();
}

View file

@ -30,6 +30,11 @@
[[MWMDownloadMapRequest alloc] initWithParentView:self.downloadRequestHolder delegate:self];
}
- (void)refresh
{
[self.view refresh];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];

View file

@ -62,6 +62,9 @@ extern NSString * const kSearchStateKey = @"SearchStateKey";
- (void)refresh
{
[self.rootView refresh];
[self.tabbedController refresh];
[self.tableViewController refresh];
[self.downloadController refresh];
}
- (void)beginSearch

View file

@ -1,5 +1,6 @@
#import "BookmarksVC.h"
#import "MWMSearchBookmarksCell.h"
#import "UIColor+MapsMeColor.h"
#import "UIFont+MapsMeFonts.h"
#include "Framework.h"
@ -21,6 +22,8 @@
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
self.layer.shouldRasterize = YES;
self.layer.rasterizationScale = UIScreen.mainScreen.scale;
}

View file

@ -1,5 +1,6 @@
#import "Macros.h"
#import "MWMSearchCategoryCell.h"
#import "UIColor+MapsMeColor.h"
#import "UIImageView+Coloring.h"
@interface MWMSearchCategoryCell ()
@ -13,6 +14,8 @@
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
CALayer * sl = self.layer;
sl.shouldRasterize = YES;
sl.rasterizationScale = UIScreen.mainScreen.scale;

View file

@ -1,4 +1,5 @@
#import "MWMSearchHistoryClearCell.h"
#import "UIColor+MapsMeColor.h"
@interface MWMSearchHistoryClearCell ()
@ -10,6 +11,8 @@
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
CALayer * sl = self.layer;
sl.shouldRasterize = YES;
sl.rasterizationScale = UIScreen.mainScreen.scale;

View file

@ -1,9 +1,12 @@
#import "MWMSearchHistoryMyPositionCell.h"
#import "UIColor+MapsMeColor.h"
@implementation MWMSearchHistoryMyPositionCell
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
CALayer * sl = self.layer;
sl.shouldRasterize = YES;
sl.rasterizationScale = UIScreen.mainScreen.scale;

View file

@ -1,5 +1,6 @@
#import "Common.h"
#import "MWMSearchHistoryRequestCell.h"
#import "UIColor+MapsMeColor.h"
#import "UIFont+MapsMeFonts.h"
@interface MWMSearchHistoryRequestCell ()
@ -13,6 +14,8 @@
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
self.layer.shouldRasterize = YES;
self.layer.rasterizationScale = UIScreen.mainScreen.scale;
}

View file

@ -56,6 +56,11 @@ BOOL isOffsetInButton(CGFloat offset, MWMSearchTabButtonsView * button)
[self resetSelectedTab];
}
- (void)refresh
{
[self.view refresh];
}
- (void)resetSelectedTab
{
self.selectedButtonTag = GetFramework().GetLastSearchQueries().empty() && !self.historyManager.isRouteSearchMode ? 1 : 0;

View file

@ -1,4 +1,5 @@
#import "MWMSearchCell.h"
#import "UIColor+MapsMeColor.h"
#include "Framework.h"
@ -12,6 +13,8 @@
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
CALayer * sl = self.layer;
sl.shouldRasterize = YES;
sl.rasterizationScale = UIScreen.mainScreen.scale;

View file

@ -1,9 +1,12 @@
#import "MWMSearchShowOnMapCell.h"
#import "UIColor+MapsMeColor.h"
@implementation MWMSearchShowOnMapCell
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
CALayer * sl = self.layer;
sl.shouldRasterize = YES;
sl.rasterizationScale = UIScreen.mainScreen.scale;

View file

@ -11,6 +11,12 @@
@implementation MWMSearchSuggestionCell
- (void)awakeFromNib
{
if (IPAD)
self.contentView.backgroundColor = [UIColor white];
}
- (NSDictionary *)selectedTitleAttributes
{
return @{NSForegroundColorAttributeName : UIColor.linkBlue, NSFontAttributeName : UIFont.bold16};

View file

@ -76,6 +76,11 @@ LocationObserver>
[self setupTableView];
}
- (void)refresh
{
[self.view refresh];
}
- (void)setupTableView
{
[self.tableView registerNib:[UINib nibWithNibName:kTableShowOnMapCell bundle:nil]

View file

@ -1,3 +1,4 @@
#import "Common.h"
#import "LocationManager.h"
#import "MapsAppDelegate.h"
#import "MWMNavigationDashboardEntity.h"
@ -115,7 +116,7 @@ UIImage * image(routing::turns::TurnDirection t, bool isNextTurn)
}
if (!imageName)
return nil;
return [UIImage imageNamed: isNextTurn ? [imageName stringByAppendingString:@"_then"] : imageName];
return [UIImage imageNamed:isNextTurn ? [imageName stringByAppendingString:@"_then"] : imageName];
}
@end

View file

@ -11,6 +11,7 @@
#import "MWMRoutePreview.h"
#import "MWMTextToSpeech.h"
#import "Statistics.h"
#import "UIButton+Coloring.h"
static NSString * const kRoutePreviewXibName = @"MWMRoutePreview";
static NSString * const kRoutePreviewIPADXibName = @"MWMiPadRoutePreview";
@ -298,7 +299,8 @@ extern NSString * const kTTSStatusWasChangedNotification;
[tts enable];
else
[tts disable];
sender.selected = isEnable;
self.navigationDashboardPortrait.soundButton.selected = isEnable;
self.navigationDashboardLandscape.soundButton.selected = isEnable;
}
#pragma mark - MWMNavigationGo

View file

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

View file

@ -1,3 +1,4 @@
#import "Common.h"
#import "MapsAppDelegate.h"
#import "MWMBasePlacePageView.h"
#import "MWMPlacePage.h"

View file

@ -1,7 +1,9 @@
#import "Common.h"
#import "MWMPlacePageEntity.h"
#import "MWMPlacePageInfoCell.h"
#import "Statistics.h"
#import "UIFont+MapsMeFonts.h"
#import "UIImageView+Coloring.h"
#include "platform/settings.hpp"
#include "platform/measurement_utils.hpp"
@ -57,9 +59,15 @@ extern NSString * const kUserDefaultsLatLonAsDMSKey;
self.icon.image = image;
if ([self.textContainer isKindOfClass:[UITextView class]])
{
[self.textContainer setAttributedText:[[NSAttributedString alloc] initWithString:info attributes:@{NSFontAttributeName : [UIFont light16]}]];
self.icon.mwm_coloring = MWMImageColoringBlue;
}
else
{
[self.textContainer setText:info];
self.icon.mwm_coloring = MWMImageColoringBlack;
}
UILongPressGestureRecognizer * longTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTap:)];
longTap.minimumPressDuration = 0.3;

View file

@ -1,12 +1,13 @@
#include "Framework.h"
@class MWMPlacePageEntity, MWMPlacePageNavigationBar;
@class MWMPlacePageEntity, MWMPlacePageNavigationBar, MWMPlacePage;
@protocol MWMPlacePageViewManagerProtocol;
@interface MWMPlacePageViewManager : NSObject
@property (weak, nonatomic, readonly) UIViewController * ownerViewController;
@property (nonatomic, readonly) MWMPlacePageEntity * entity;
@property (nonatomic, readonly) MWMPlacePage * placePage;
@property (nonatomic) MWMPlacePageNavigationBar * iPhoneNavigationBar;
@property (nonatomic) CGFloat topBound;
@property (nonatomic) CGFloat leftBound;

View file

@ -37,7 +37,7 @@ typedef NS_ENUM(NSUInteger, MWMPlacePageManagerState)
@property (weak, nonatomic) UIViewController * ownerViewController;
@property (nonatomic, readwrite) MWMPlacePageEntity * entity;
@property (nonatomic) MWMPlacePage * placePage;
@property (nonatomic, readwrite) MWMPlacePage * placePage;
@property (nonatomic) MWMPlacePageManagerState state;
@property (nonatomic) MWMDirectionView * directionView;

View file

@ -35,7 +35,7 @@
#import "../../../private.h"
extern NSString * const kAlohalyticsTapEventKey = @"$onClick";
extern NSString * const kUDWhatsNewWasShown = @"WhatsNewWith3dAndPerspectiveWasShown";
extern NSString * const kUDWhatsNewWasShown = @"WhatsNewWithNightModeWasShown";
extern char const * kAdForbiddenSettingsKey;
extern char const * kAdServerForbiddenKey;
@ -424,6 +424,7 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
{
if (isIOSVersionLessThan(8))
return;
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
BOOL const whatsNewWasShown = [ud boolForKey:kUDWhatsNewWasShown];
if (whatsNewWasShown)
@ -471,15 +472,14 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
- (UIStatusBarStyle)preferredStatusBarStyle
{
BOOL const isNightMode = [UIColor isNightMode];
BOOL const isLight = !self.controlsManager.searchHidden ||
self.controlsManager.menuState == MWMBottomMenuStateActive ||
self.controlsManager.isDirectionViewShown ||
(GetFramework().GetMapStyle() == MapStyleDark &&
self.controlsManager.navigationState == MWMNavigationDashboardStateHidden) ||
MapsAppDelegate.theApp.routingPlaneMode != MWMRoutingPlaneModeNone;
if (isLight)
return UIStatusBarStyleLightContent;
return UIStatusBarStyleDefault;
(isNightMode &&
self.controlsManager.navigationState != MWMNavigationDashboardStateHidden) ||
MapsAppDelegate.theApp.routingPlaneMode != MWMRoutingPlaneModeNone;
return (isLight || (!isLight && isNightMode)) ? UIStatusBarStyleLightContent : UIStatusBarStyleDefault;
}
- (void)updateStatusBarStyle

View file

@ -41,7 +41,7 @@ typedef NS_ENUM(NSUInteger, MWMRoutingPlaneMode)
- (void)showMap;
- (void)startMapStyleChecker;
- (void)stopMapStyleChecker;
+ (void)setAutoNightModeOn:(BOOL)on;
+ (void)setAutoNightModeOff:(BOOL)off;
+ (BOOL)isAutoNightMode;
+ (void)resetToDefaultMapStyle;
+ (void)changeMapStyleIfNedeed;

View file

@ -43,7 +43,7 @@ static NSString * const kUDFirstVersionKey = @"FirstVersion";
static NSString * const kUDLastRateRequestDate = @"LastRateRequestDate";
extern NSString * const kUDAlreadySharedKey = @"UserAlreadyShared";
static NSString * const kUDLastShareRequstDate = @"LastShareRequestDate";
extern NSString * const kUDAutoNightMode = @"AutoNightMode";
static NSString * const kUDAutoNightModeOff = @"AutoNightModeOff";
static NSString * const kNewWatchUserEventKey = @"NewWatchUser";
static NSString * const kOldWatchUserEventKey = @"OldWatchUser";
static NSString * const kUDWatchEventAlreadyTracked = @"WatchEventAlreadyTracked";
@ -249,24 +249,30 @@ void InitLocalizedStrings()
- (void)determineMapStyle
{
GetFramework().SetMapStyle(MapStyleClear);
[UIColor setNightMode:NO];
auto & f = GetFramework();
if ([MapsAppDelegate isAutoNightMode])
[self startMapStyleChecker];
{
f.SetMapStyle(MapStyleClear);
[UIColor setNightMode:NO];
}
else
{
[UIColor setNightMode:f.GetMapStyle() == MapStyleDark];
}
}
+ (void)setAutoNightModeOn:(BOOL)on
+ (void)setAutoNightModeOff:(BOOL)off
{
NSUserDefaults * ud = [NSUserDefaults standardUserDefaults];
[ud setBool:on forKey:kUDAutoNightMode];
[ud setBool:off forKey:kUDAutoNightModeOff];
[ud synchronize];
if (!on)
if (!off)
[MapsAppDelegate.theApp stopMapStyleChecker];
}
+ (BOOL)isAutoNightMode
{
return [[NSUserDefaults standardUserDefaults] boolForKey:kUDAutoNightMode];
return ![[NSUserDefaults standardUserDefaults] boolForKey:kUDAutoNightModeOff];
}
- (void)startMapStyleChecker
@ -526,8 +532,8 @@ void InitLocalizedStrings()
barBtn.tintColor = [UIColor whitePrimaryText];
UIPageControl * pageControl = [UIPageControl appearance];
pageControl.pageIndicatorTintColor = [UIColor blackSecondaryText];
pageControl.currentPageIndicatorTintColor = [UIColor blackPrimaryText];
pageControl.pageIndicatorTintColor = [UIColor blackHintText];
pageControl.currentPageIndicatorTintColor = [UIColor blackSecondaryText];
pageControl.backgroundColor = [UIColor white];
}

View file

@ -53,25 +53,25 @@
auto const style = f.GetMapStyle();
if ([cell isEqual:self.on])
{
[MapsAppDelegate setAutoNightModeOff:YES];
if (style == MapStyleDark)
return;
f.SetMapStyle(MapStyleDark);
[UIColor setNightMode:YES];
[MapsAppDelegate setAutoNightModeOn:NO];
[self refresh];
}
else if ([cell isEqual:self.off])
{
[MapsAppDelegate setAutoNightModeOff:YES];
if (style == MapStyleClear || style == MapStyleLight)
return;
f.SetMapStyle(MapStyleClear);
[UIColor setNightMode:NO];
[MapsAppDelegate setAutoNightModeOn:NO];
[self refresh];
}
else if ([cell isEqual:self.autoSwitch])
{
[MapsAppDelegate setAutoNightModeOn:YES];
[MapsAppDelegate setAutoNightModeOff:NO];
[MapsAppDelegate changeMapStyleIfNedeed];
if (style == MapStyleClear || style == MapStyleLight)
return;

View file

@ -11,8 +11,7 @@ typedef NS_ENUM(NSUInteger, DurationInHours)
Two = 2,
Six = 6,
Twelve = 12,
Day = 24,
TwoDays = 48
Day = 24
};
@interface MWMRecentTrackSettingsController ()
@ -23,7 +22,6 @@ typedef NS_ENUM(NSUInteger, DurationInHours)
@property (weak, nonatomic) IBOutlet SelectableCell * sixHours;
@property (weak, nonatomic) IBOutlet SelectableCell * twelveHours;
@property (weak, nonatomic) IBOutlet SelectableCell * oneDay;
@property (weak, nonatomic) IBOutlet SelectableCell * twoDays;
@property (weak, nonatomic) SelectableCell * selectedCell;
@end
@ -58,9 +56,6 @@ typedef NS_ENUM(NSUInteger, DurationInHours)
case Day:
_selectedCell = self.oneDay;
break;
case TwoDays:
_selectedCell = self.twoDays;
break;
default:
NSAssert(false, @"Incorrect hours value");
break;
@ -80,7 +75,8 @@ typedef NS_ENUM(NSUInteger, DurationInHours)
}
else
{
GpsTracker::Instance().SetEnabled(true);
if (!GpsTracker::Instance().IsEnabled())
GpsTracker::Instance().SetEnabled(true);
f.ConnectToGpsTracker();
if ([selectedCell isEqual:self.oneHour])
@ -91,10 +87,8 @@ typedef NS_ENUM(NSUInteger, DurationInHours)
GpsTracker::Instance().SetDuration(hours(Six));
else if ([selectedCell isEqual:self.twelveHours])
GpsTracker::Instance().SetDuration(hours(Twelve));
else if ([selectedCell isEqual:self.oneDay])
else
GpsTracker::Instance().SetDuration(hours(Day));
else
GpsTracker::Instance().SetDuration(hours(TwoDays));
}
selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
}

View file

@ -138,6 +138,8 @@ typedef NS_ENUM(NSUInteger, Section)
bool on = true, _ = true;
GetFramework().Load3dMode(_, on);
customCell.titleLabel.text = L(@"pref_map_3d_buildings_title");
customCell.switchButton.on = on;
customCell.delegate = self;
break;
}
// Zoom buttons

View file

@ -16,13 +16,13 @@
- (void)refresh
{
[self.navigationController.navigationBar refresh];
MapViewController * mapViewController = [MapsAppDelegate theApp].mapViewController;
for (UIViewController * vc in self.navigationController.viewControllers.reverseObjectEnumerator)
{
if (![vc isKindOfClass:[MapViewController class]])
if (![vc isEqual:mapViewController])
[vc.view refresh];
}
if (![self isKindOfClass:[MapViewController class]])
[[MapsAppDelegate theApp].mapViewController refresh];
[mapViewController refresh];
}
- (void)viewDidLoad

View file

@ -28,6 +28,7 @@ NSString * const kSelectedPattern = @"%@_selected_%@";
- (void)setMwm_coloring:(MWMButtonColoring)mwm_coloring
{
objc_setAssociatedObject(self, @selector(mwm_coloring), @(mwm_coloring), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[self.imageView makeImageAlwaysTemplate];
[self setDefaultTintColor];
}
@ -61,8 +62,11 @@ NSString * const kSelectedPattern = @"%@_selected_%@";
- (void)setHighlighted:(BOOL)highlighted
{
[super setHighlighted:highlighted];
UIImage * image = [self imageForState:highlighted ? UIControlStateHighlighted : UIControlStateNormal];
if (highlighted)
{
self.imageView.image = image;
[self.imageView makeImageAlwaysTemplate];
switch (self.mwm_coloring)
{
case MWMButtonColoringBlue:
@ -82,15 +86,20 @@ NSString * const kSelectedPattern = @"%@_selected_%@";
{
if (self.selected)
return;
self.imageView.image = image;
[self.imageView makeImageAlwaysTemplate];
[self setDefaultTintColor];
}
if (UIImage * image = [self imageForState:highlighted ? UIControlStateHighlighted : UIControlStateNormal])
self.imageView.image = image;
}
- (void)setSelected:(BOOL)selected
{
[super setSelected:selected];
if (UIImage * image = [self imageForState:selected ? UIControlStateSelected : UIControlStateNormal])
{
self.imageView.image = image;
[self.imageView makeImageAlwaysTemplate];
}
if (selected)
{
switch (self.mwm_coloring)
@ -103,12 +112,10 @@ NSString * const kSelectedPattern = @"%@_selected_%@";
case MWMButtonColoringGray:
break;
}
self.imageView.image = [self imageForState:UIControlStateSelected];
}
else
{
[self setDefaultTintColor];
self.imageView.image = [self imageForState:UIControlStateNormal];
}
}
@ -124,6 +131,7 @@ NSString * const kSelectedPattern = @"%@_selected_%@";
break;
case MWMButtonColoringGray:
self.tintColor = [UIColor blackHintText];
break;
case MWMButtonColoringOther:
self.imageView.image = [self imageForState:UIControlStateNormal];
break;

View file

@ -39,7 +39,7 @@ NSDictionary<NSString *, UIColor *> * night =
// Blue color (use for links and phone numbers)
@"linkBlue" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha100],
@"linkBlueDark" : [UIColor colorWithRed:scaled(200.) green:scaled(180.) blue:scaled(110.) alpha:alpha100],
@"blackPrimaryText" : [UIColor colorWithWhite:1. alpha:alpha100],
@"blackPrimaryText" : [UIColor colorWithWhite:1. alpha:alpha90],
@"blackSecondaryText" : [UIColor colorWithWhite:1. alpha:alpha70],
@"blackHintText" : [UIColor colorWithWhite:1. alpha:alpha30],
@"blackDividers" : [UIColor colorWithWhite:1. alpha:alpha12],

View file

@ -19,11 +19,10 @@
- (void)setMwm_coloring:(MWMImageColoring)mwm_coloring
{
objc_setAssociatedObject(self, @selector(mwm_coloring), @(mwm_coloring), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
if (mwm_coloring != MWMImageColoringOther)
self.tintColor = [[UIColor class] performSelector:self.coloringSelector];
#pragma clang diagnostic pop
if (mwm_coloring == MWMImageColoringOther)
return;
[self makeImageAlwaysTemplate];
[self applyColoring];
}
- (MWMImageColoring)mwm_coloring
@ -31,6 +30,14 @@
return static_cast<MWMImageColoring>([objc_getAssociatedObject(self, @selector(mwm_coloring)) integerValue]);
}
- (void)applyColoring
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
self.tintColor = [[UIColor class] performSelector:self.coloringSelector];
#pragma clang diagnostic pop
}
- (void)changeColoringToOpposite
{
if (self.mwm_coloring == MWMImageColoringOther)
@ -39,10 +46,8 @@
self.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@_%@", self.mwm_name, [UIColor isNightMode] ? @"dark" : @"light"]];
return;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
self.tintColor = [[UIColor class] performSelector:self.coloringSelector];
#pragma clang diagnostic pop
[self makeImageAlwaysTemplate];
[self applyColoring];
}
- (SEL)coloringSelector
@ -71,8 +76,8 @@
case MWMImageColoringGray:
self.tintColor = highlighted ? [UIColor blackSecondaryText] : [UIColor blackHintText];
break;
case MWMImageColoringBlue:
case MWMImageColoringOther:
case MWMImageColoringBlue:
break;
}
}