From 8e9d36d7fa94363830caac6c25a0819e9b5581d4 Mon Sep 17 00:00:00 2001 From: VladiMihaylenko Date: Tue, 12 Jan 2016 18:09:20 +0300 Subject: [PATCH] [ios] Night mode bugfix. (code) --- iphone/Maps/ActiveMapsVC.h | 2 -- iphone/Maps/ActiveMapsVC.mm | 1 - iphone/Maps/Bookmarks/SelectSetVC.mm | 7 ++----- iphone/Maps/Classes/AddSetTableViewCell.mm | 4 ++++ .../MapViewControls/BottomMenu/MWMBottomMenuView.mm | 8 ++------ .../BottomMenu/MWMBottomMenuViewController.mm | 7 +++++-- .../MapViewControls/Search/MWMSearchManager.mm | 1 - .../MapViewControls/Search/MWMSearchTextField.mm | 2 -- iphone/Maps/MWMNightModeController.mm | 5 +++++ iphone/Maps/SettingsAndMoreVC.h | 2 -- iphone/Maps/UIButton+Coloring.mm | 4 ++-- iphone/Maps/UIColor+MapsMeColor.mm | 5 +++-- iphone/Maps/UIImageView+Coloring.mm | 10 ++-------- iphone/Maps/UILabel+RuntimeAttributes.mm | 5 +++++ 14 files changed, 30 insertions(+), 33 deletions(-) diff --git a/iphone/Maps/ActiveMapsVC.h b/iphone/Maps/ActiveMapsVC.h index 0d6b8f531e..b0bc0ce073 100644 --- a/iphone/Maps/ActiveMapsVC.h +++ b/iphone/Maps/ActiveMapsVC.h @@ -1,5 +1,3 @@ - -#import #import "DownloaderParentVC.h" @interface ActiveMapsVC : DownloaderParentVC diff --git a/iphone/Maps/ActiveMapsVC.mm b/iphone/Maps/ActiveMapsVC.mm index a6b2fd051a..638b87077c 100644 --- a/iphone/Maps/ActiveMapsVC.mm +++ b/iphone/Maps/ActiveMapsVC.mm @@ -1,4 +1,3 @@ - #import "ActiveMapsVC.h" #import "BadgeView.h" #import "Common.h" diff --git a/iphone/Maps/Bookmarks/SelectSetVC.mm b/iphone/Maps/Bookmarks/SelectSetVC.mm index e45f90cc5a..0b1f12cfde 100644 --- a/iphone/Maps/Bookmarks/SelectSetVC.mm +++ b/iphone/Maps/Bookmarks/SelectSetVC.mm @@ -75,11 +75,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - static NSString * kSetCellId = @"AddSetCell"; - UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:kSetCellId]; - if (cell == nil) - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kSetCellId]; - // Customize cell + UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]]; if (indexPath.section == 0) { cell.textLabel.text = L(@"add_new_set"); @@ -99,6 +95,7 @@ cell.accessoryType = UITableViewCellAccessoryNone; } cell.backgroundColor = [UIColor white]; + cell.textLabel.textColor = [UIColor blackPrimaryText]; return cell; } diff --git a/iphone/Maps/Classes/AddSetTableViewCell.mm b/iphone/Maps/Classes/AddSetTableViewCell.mm index 64e68bd1cb..20c3c21607 100644 --- a/iphone/Maps/Classes/AddSetTableViewCell.mm +++ b/iphone/Maps/Classes/AddSetTableViewCell.mm @@ -1,4 +1,5 @@ #import "AddSetTableViewCell.h" +#import "UIColor+MapsMeColor.h" @interface AddSetTableViewCell () @@ -9,6 +10,9 @@ - (void)awakeFromNib { self.textField.placeholder = L(@"bookmark_set_name"); + self.textField.textColor = [UIColor blackPrimaryText]; + UILabel * label = [self.textField valueForKey:@"_placeholderLabel"]; + label.textColor = [UIColor blackHintText]; } #pragma mark - UITextFieldDelegate diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm index da10a8f1ee..09bf2c8e86 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm @@ -232,7 +232,8 @@ NSInteger const stepValue = direct ? 1 : -1; NSMutableArray * morphImages = [NSMutableArray arrayWithCapacity:morphImagesCount]; for (NSUInteger i = startValue, j = 0; i != endValue; i += stepValue, j++) - morphImages[j] = [UIImage imageNamed:[morphTemplate stringByAppendingString:@(i).stringValue]]; + morphImages[j] = [UIImage imageNamed:[NSString stringWithFormat:@"%@%@_%@", morphTemplate, @(i).stringValue, + [UIColor isNightMode] ? @"dark" : @"light"]]; btn.imageView.animationImages = morphImages; btn.imageView.animationRepeatCount = 1; btn.imageView.image = morphImages.lastObject; @@ -258,17 +259,12 @@ case MWMBottomMenuStateGo: case MWMBottomMenuStateText: [btn setImage:[UIImage imageNamed:@"ic_menu"] forState:UIControlStateNormal]; - [btn setImage:[UIImage imageNamed:@"ic_menu_press"] forState:UIControlStateHighlighted]; break; case MWMBottomMenuStateActive: [btn setImage:[UIImage imageNamed:@"ic_menu_down"] forState:UIControlStateNormal]; - [btn setImage:[UIImage imageNamed:@"ic_menu_down_press"] - forState:UIControlStateHighlighted]; break; case MWMBottomMenuStateCompact: [btn setImage:[UIImage imageNamed:@"ic_menu_left"] forState:UIControlStateNormal]; - [btn setImage:[UIImage imageNamed:@"ic_menu_left_press"] - forState:UIControlStateHighlighted]; break; } } diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm index 57a7ea3788..bfeec51ed7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm @@ -195,7 +195,10 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) NSUInteger const endValue = morphImagesCount + 1; NSMutableArray * morphImages = [NSMutableArray arrayWithCapacity:morphImagesCount]; for (NSUInteger i = 1, j = 0; i != endValue; i++, j++) - morphImages[j] = [UIImage imageNamed:[@"ic_follow_mode_" stringByAppendingString:@(i).stringValue]]; + { + morphImages[j] = [UIImage imageNamed:[NSString stringWithFormat:@"ic_follow_mode_%@_%@", @(i).stringValue, + [UIColor isNightMode] ? @"dark" : @"light"]]; + } locBtn.imageView.animationImages = morphImages; locBtn.imageView.animationRepeatCount = 1; locBtn.imageView.image = morphImages.lastObject; @@ -203,7 +206,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell) break; } } - [self refreshLocationButtonState: state]; + [self refreshLocationButtonState:state]; } - (void)refreshLocationButtonState:(location::EMyPositionMode)state diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm index e30f457028..7ffcac43d5 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchManager.mm @@ -54,7 +54,6 @@ extern NSString * const kSearchStateKey = @"SearchStateKey"; self.delegate = delegate; self.rootView.delegate = delegate; self.parentView = view; - self.searchTextField.placeholder = L(@"search"); self.state = MWMSearchManagerStateHidden; } return self; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchTextField.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchTextField.mm index 7f55d93b83..a41f89d72a 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchTextField.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/Search/MWMSearchTextField.mm @@ -12,8 +12,6 @@ self.isSearching = NO; self.leftViewMode = UITextFieldViewModeAlways; self.textColor = [UIColor blackSecondaryText]; - UILabel * p = [self valueForKey:@"_placeholderLabel"]; - p.textColor = [UIColor blackHintText]; return self; } diff --git a/iphone/Maps/MWMNightModeController.mm b/iphone/Maps/MWMNightModeController.mm index 421d708a42..c4f23c1506 100644 --- a/iphone/Maps/MWMNightModeController.mm +++ b/iphone/Maps/MWMNightModeController.mm @@ -53,8 +53,11 @@ extern NSString * const kUDAutoNightMode; _selectedCell = cell; auto & f = GetFramework(); auto app = MapsAppDelegate.theApp; + auto const style = f.GetMapStyle(); if ([cell isEqual:self.on]) { + if (style == MapStyleDark) + return; f.SetMapStyle(MapStyleDark); [UIColor setNightMode:YES]; [app stopMapStyleChecker]; @@ -62,6 +65,8 @@ extern NSString * const kUDAutoNightMode; } else if ([cell isEqual:self.off]) { + if (style == MapStyleClear || style == MapStyleLight) + return; f.SetMapStyle(MapStyleClear); [UIColor setNightMode:NO]; [app stopMapStyleChecker]; diff --git a/iphone/Maps/SettingsAndMoreVC.h b/iphone/Maps/SettingsAndMoreVC.h index 1833d23ea6..1d98407c74 100644 --- a/iphone/Maps/SettingsAndMoreVC.h +++ b/iphone/Maps/SettingsAndMoreVC.h @@ -1,5 +1,3 @@ - -#import #import "TableViewController.h" @interface SettingsAndMoreVC : TableViewController diff --git a/iphone/Maps/UIButton+Coloring.mm b/iphone/Maps/UIButton+Coloring.mm index 583ec98488..fb2cfcc8d5 100644 --- a/iphone/Maps/UIButton+Coloring.mm +++ b/iphone/Maps/UIButton+Coloring.mm @@ -77,15 +77,15 @@ NSString * const kSelectedPattern = @"%@_selected_%@"; case MWMButtonColoringOther: break; } - self.imageView.image = [self imageForState:UIControlStateHighlighted]; } else { if (self.selected) return; [self setDefaultTintColor]; - self.imageView.image = [self imageForState:UIControlStateNormal]; } + if (UIImage * image = [self imageForState:highlighted ? UIControlStateHighlighted : UIControlStateNormal]) + self.imageView.image = image; } - (void)setSelected:(BOOL)selected diff --git a/iphone/Maps/UIColor+MapsMeColor.mm b/iphone/Maps/UIColor+MapsMeColor.mm index 7cde3157a1..128fd25d66 100644 --- a/iphone/Maps/UIColor+MapsMeColor.mm +++ b/iphone/Maps/UIColor+MapsMeColor.mm @@ -11,6 +11,7 @@ CGFloat const alpha54 = 0.54; CGFloat const alpha70 = 0.7; CGFloat const alpha80 = 0.8; CGFloat const alpha87 = 0.87; +CGFloat const alpha90 = 0.9; CGFloat const alpha100 = 1.; BOOL isNightMode = NO; @@ -44,7 +45,7 @@ NSDictionary * night = @"white" : [UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha100], @"whiteSecondaryText" : [UIColor colorWithWhite:1. alpha:alpha70], @"buttonDisabledBlueText" : [UIColor colorWithRed:scaled(255.) green:scaled(230.) blue:scaled(140.) alpha:alpha30], - @"alertBackground" : [UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha100] + @"alertBackground" : [UIColor colorWithRed:scaled(60.) green:scaled(64.) blue:scaled(68.) alpha:alpha90] }; NSDictionary * day = @@ -71,7 +72,7 @@ NSDictionary * day = @"white" : [UIColor colorWithWhite:1. alpha:alpha100], @"whiteSecondaryText" : [UIColor colorWithWhite:1. alpha:alpha54], @"buttonDisabledBlueText" :[UIColor colorWithRed:scaled(3.) green:scaled(122.) blue:scaled(255.) alpha:alpha26], - @"alertBackground" : [UIColor colorWithWhite:1. alpha:alpha87] + @"alertBackground" : [UIColor colorWithWhite:1. alpha:alpha90] }; UIColor * color(SEL cmd) diff --git a/iphone/Maps/UIImageView+Coloring.mm b/iphone/Maps/UIImageView+Coloring.mm index c03597c3f4..6e1c84ea4d 100644 --- a/iphone/Maps/UIImageView+Coloring.mm +++ b/iphone/Maps/UIImageView+Coloring.mm @@ -65,17 +65,11 @@ switch (self.mwm_coloring) { case MWMImageColoringBlack: - if (highlighted) - self.tintColor = [UIColor linkBlue]; - else - self.tintColor = [UIColor blackSecondaryText]; + self.tintColor = highlighted ? [UIColor linkBlue] : [UIColor blackSecondaryText]; break; case MWMImageColoringGray: - if (highlighted) - self.tintColor = [UIColor blackSecondaryText]; - else - self.tintColor = [UIColor blackHintText]; + self.tintColor = highlighted ? [UIColor blackSecondaryText] : [UIColor blackHintText]; break; case MWMImageColoringBlue: case MWMImageColoringOther: diff --git a/iphone/Maps/UILabel+RuntimeAttributes.mm b/iphone/Maps/UILabel+RuntimeAttributes.mm index 19b835e6af..1d0139755d 100644 --- a/iphone/Maps/UILabel+RuntimeAttributes.mm +++ b/iphone/Maps/UILabel+RuntimeAttributes.mm @@ -66,6 +66,11 @@ self.tintColor = [UIColor colorWithName:colorName]; } +- (void)setColorName:(NSString *)colorName +{ + self.textColor = [UIColor colorWithName:colorName]; +} + @end @implementation MWMTextView (RuntimeAttributes)