diff options
author | VladiMihaylenko <vxmihaylenko@gmail.com> | 2016-02-11 13:24:34 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:17:06 +0300 |
commit | 4bed7f2cb30eb0b0e9e3014736665ee2db800fa1 (patch) | |
tree | fde5b85d48aabde82b8ff70ff485776616b64cdf | |
parent | e821eadeee820b77bfeffd99e9e077e6686995e4 (diff) |
[ios] Refactored bookmark color view controller.
-rw-r--r-- | iphone/Maps/Classes/MWMBookmarkColorViewController.h | 4 | ||||
-rw-r--r-- | iphone/Maps/Classes/MWMBookmarkColorViewController.mm | 64 | ||||
-rw-r--r-- | iphone/Maps/Classes/MWMBookmarkColorViewController.xib | 34 |
3 files changed, 23 insertions, 79 deletions
diff --git a/iphone/Maps/Classes/MWMBookmarkColorViewController.h b/iphone/Maps/Classes/MWMBookmarkColorViewController.h index 7ef7939721..6f73460d15 100644 --- a/iphone/Maps/Classes/MWMBookmarkColorViewController.h +++ b/iphone/Maps/Classes/MWMBookmarkColorViewController.h @@ -1,8 +1,8 @@ -#import "ViewController.h" +#import "TableViewController.h" @class MWMPlacePageViewManager; -@interface MWMBookmarkColorViewController : ViewController +@interface MWMBookmarkColorViewController : TableViewController @property (weak, nonatomic) MWMPlacePageViewManager * placePageManager; @property (weak, nonatomic) UINavigationController * iPadOwnerNavigationController; diff --git a/iphone/Maps/Classes/MWMBookmarkColorViewController.mm b/iphone/Maps/Classes/MWMBookmarkColorViewController.mm index f83c1c3b76..d0469d1526 100644 --- a/iphone/Maps/Classes/MWMBookmarkColorViewController.mm +++ b/iphone/Maps/Classes/MWMBookmarkColorViewController.mm @@ -1,3 +1,4 @@ +#import "Common.h" #import "MWMBookmarkColorCell.h" #import "MWMBookmarkColorViewController.h" #import "MWMPlacePageEntity.h" @@ -6,7 +7,10 @@ #import "UIColor+MapsMeColor.h" #import "UIViewController+navigation.h" -static NSArray * const kBookmarkColorsVariant = @[ +namespace +{ + +NSArray<NSString *> * const kBookmarkColorsVariant = @[ @"placemark-red", @"placemark-yellow", @"placemark-blue", @@ -17,17 +21,15 @@ static NSArray * const kBookmarkColorsVariant = @[ @"placemark-pink" ]; -static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; +NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; + +} // namespace + @interface MWMBookmarkColorViewController () -@property (weak, nonatomic) IBOutlet UITableView * tableView; @property (nonatomic) BOOL colorWasChanged; -@property (weak, nonatomic) IBOutlet NSLayoutConstraint * tableViewHeight; - -@end -@interface MWMBookmarkColorViewController (TableView) <UITableViewDataSource, UITableViewDelegate> @end @implementation MWMBookmarkColorViewController @@ -36,8 +38,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; { [super viewDidLoad]; self.title = L(@"bookmark_color"); - self.tableView.separatorColor = [UIColor blackDividers]; - self.view.backgroundColor = [UIColor pressBackground]; [self.tableView registerNib:[UINib nibWithNibName:kBookmarkColorCellIdentifier bundle:nil] forCellReuseIdentifier:kBookmarkColorCellIdentifier]; self.colorWasChanged = NO; } @@ -45,15 +45,17 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - [self configureTableViewForOrientation:self.interfaceOrientation]; - [self.tableView reloadData]; if (!self.iPadOwnerNavigationController) return; [self.iPadOwnerNavigationController setNavigationBarHidden:NO]; - CGFloat const bottomOffset = 88.; - self.iPadOwnerNavigationController.view.height = self.tableView.height + bottomOffset; [self showBackButton]; + CGFloat const navBarHeight = self.navigationController.navigationBar.height; + [self.tableView reloadData]; + [UIView animateWithDuration:kDefaultAnimationDuration animations:^ + { + [self.placePageManager changeHeight:self.tableView.contentSize.height + navBarHeight]; + }]; } - (void)backTap @@ -64,42 +66,6 @@ static NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell"; [self.navigationController popViewControllerAnimated:YES]; } -- (void)configureTableViewForOrientation:(UIInterfaceOrientation)orientation -{ - if (self.iPadOwnerNavigationController) - return; - - CGSize const size = self.navigationController.view.bounds.size; - CGFloat const defaultHeight = 352.; - switch (orientation) - { - case UIInterfaceOrientationPortrait: - case UIInterfaceOrientationPortraitUpsideDown: - case UIInterfaceOrientationUnknown: - self.tableViewHeight.constant = defaultHeight; - break; - case UIInterfaceOrientationLandscapeLeft: - case UIInterfaceOrientationLandscapeRight: - { - CGFloat const topOffset = 24.; - CGFloat const navBarHeight = 64.; - self.tableViewHeight.constant = MIN(defaultHeight, MIN(size.width, size.height) - 2 * topOffset - navBarHeight); - break; - } - } - [self.tableView setNeedsLayout]; -} - -- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation -{ - [self configureTableViewForOrientation:self.interfaceOrientation]; -} - -- (BOOL)shouldAutorotate -{ - return YES; -} - - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; diff --git a/iphone/Maps/Classes/MWMBookmarkColorViewController.xib b/iphone/Maps/Classes/MWMBookmarkColorViewController.xib index b8421df4f2..4ef352f5de 100644 --- a/iphone/Maps/Classes/MWMBookmarkColorViewController.xib +++ b/iphone/Maps/Classes/MWMBookmarkColorViewController.xib @@ -7,37 +7,15 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMBookmarkColorViewController"> <connections> - <outlet property="tableView" destination="07I-Yr-hrI" id="cuQ-HB-occ"/> - <outlet property="tableViewHeight" destination="Q3E-d1-c2p" id="4be-XT-doO"/> - <outlet property="view" destination="TjH-fk-Ez1" id="avG-d0-UHK"/> + <outlet property="view" destination="TDK-os-A99" id="sVU-ZA-N7j"/> </connections> </placeholder> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> - <view contentMode="scaleToFill" id="TjH-fk-Ez1"> + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="TDK-os-A99"> <rect key="frame" x="0.0" y="0.0" width="320" height="568"/> - <autoresizingMask key="autoresizingMask"/> - <subviews> - <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="1" sectionFooterHeight="1" translatesAutoresizingMaskIntoConstraints="NO" id="07I-Yr-hrI"> - <rect key="frame" x="0.0" y="22" width="320" height="352"/> - <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> - <constraints> - <constraint firstAttribute="height" constant="352" id="Q3E-d1-c2p"/> - </constraints> - <color key="separatorColor" red="0.0" green="0.0" blue="0.0" alpha="0.12" colorSpace="custom" customColorSpace="sRGB"/> - <connections> - <outlet property="dataSource" destination="-1" id="sfi-es-NXL"/> - <outlet property="delegate" destination="-1" id="C78-4z-O7V"/> - </connections> - </tableView> - </subviews> - <color key="backgroundColor" red="0.96078431369999995" green="0.96078431369999995" blue="0.96078431369999995" alpha="1" colorSpace="calibratedRGB"/> - <constraints> - <constraint firstAttribute="trailing" secondItem="07I-Yr-hrI" secondAttribute="trailing" id="VBs-Fh-muY"/> - <constraint firstItem="07I-Yr-hrI" firstAttribute="leading" secondItem="TjH-fk-Ez1" secondAttribute="leading" id="eMR-5m-KpO"/> - <constraint firstItem="07I-Yr-hrI" firstAttribute="top" secondItem="TjH-fk-Ez1" secondAttribute="top" constant="22" id="l4B-e3-TRl"/> - </constraints> - <simulatedOrientationMetrics key="simulatedOrientationMetrics"/> - <point key="canvasLocation" x="931" y="273"/> - </view> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/> + <point key="canvasLocation" x="877" y="211"/> + </tableView> </objects> </document> |