forked from organicmaps/organicmaps-tmp
[ios] New place page.
This commit is contained in:
parent
180eb5e6d2
commit
aafeaf916d
33 changed files with 875 additions and 637 deletions
|
@ -1,11 +1,16 @@
|
|||
#import "MWMTableViewController.h"
|
||||
#include "Framework.h"
|
||||
|
||||
@class MWMPlacePageViewManager;
|
||||
@protocol MWMSelectSetDelegate <NSObject>
|
||||
|
||||
- (void)didSelectCategory:(NSString *)category withBac:(BookmarkAndCategory const &)bac;
|
||||
|
||||
@end
|
||||
|
||||
@interface SelectSetVC : MWMTableViewController
|
||||
|
||||
- (instancetype)initWithPlacePageManager:(MWMPlacePageViewManager *)manager;
|
||||
|
||||
@property (weak, nonatomic) UINavigationController * iPadOwnerNavigationController;
|
||||
- (instancetype)initWithCategory:(NSString *)category
|
||||
bac:(BookmarkAndCategory const &)bac
|
||||
delegate:(id<MWMSelectSetDelegate>)delegate;
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,61 +1,42 @@
|
|||
#import "AddSetVC.h"
|
||||
#import "Common.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "SelectSetVC.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
@interface SelectSetVC () <AddSetVCDelegate>
|
||||
{
|
||||
BookmarkAndCategory m_bac;
|
||||
}
|
||||
|
||||
@property (weak, nonatomic) MWMPlacePageViewManager * manager;
|
||||
@property (copy, nonatomic) NSString * category;
|
||||
@property (weak, nonatomic) id<MWMSelectSetDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SelectSetVC
|
||||
|
||||
- (instancetype)initWithPlacePageManager:(MWMPlacePageViewManager *)manager
|
||||
- (instancetype)initWithCategory:(NSString *)category
|
||||
bac:(BookmarkAndCategory const &)bac
|
||||
delegate:(id<MWMSelectSetDelegate>)delegate
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStyleGrouped];
|
||||
if (self)
|
||||
{
|
||||
self.manager = manager;
|
||||
self.title = L(@"bookmark_sets");
|
||||
_category = category;
|
||||
m_bac = bac;
|
||||
_delegate = delegate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self.iPadOwnerNavigationController setNavigationBarHidden:NO];
|
||||
if (self.iPadOwnerNavigationController)
|
||||
{
|
||||
[(UIViewController *)self showBackButton];
|
||||
[self.tableView reloadData];
|
||||
CGFloat const navBarHeight = self.navigationController.navigationBar.height;
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
[self.manager changeHeight:self.tableView.contentSize.height + navBarHeight];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)popViewController
|
||||
{
|
||||
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
- (void)backTap
|
||||
{
|
||||
[self popViewController];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
return YES;
|
||||
[super viewDidLoad];
|
||||
NSAssert(self.category, @"Category can't be nil!");
|
||||
NSAssert(self.delegate, @"Delegate can't be nil!");
|
||||
NSAssert(IsValid(m_bac), @"Invalid BookmarkAndCategory's instance!");
|
||||
self.title = L(@"bookmark_sets");
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
|
@ -86,9 +67,7 @@
|
|||
if (cat)
|
||||
cell.textLabel.text = @(cat->GetName().c_str());
|
||||
|
||||
BookmarkAndCategory const bac = self.manager.entity.bac;
|
||||
|
||||
if (bac.first == indexPath.row)
|
||||
if (m_bac.first == indexPath.row)
|
||||
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
||||
else
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
|
@ -99,21 +78,19 @@
|
|||
- (void)addSetVC:(AddSetVC *)vc didAddSetWithIndex:(int)setIndex
|
||||
{
|
||||
[self moveBookmarkToSetWithIndex:setIndex];
|
||||
|
||||
[self.tableView reloadData];
|
||||
[self.manager reloadBookmark];
|
||||
[self.delegate didSelectCategory:self.category withBac:m_bac];
|
||||
}
|
||||
|
||||
- (void)moveBookmarkToSetWithIndex:(int)setIndex
|
||||
{
|
||||
MWMPlacePageEntity * entity = self.manager.entity;
|
||||
BookmarkAndCategory bac;
|
||||
bac.second = static_cast<int>(GetFramework().MoveBookmark(entity.bac.second, entity.bac.first, setIndex));
|
||||
bac.second = static_cast<int>(GetFramework().MoveBookmark(m_bac.second, m_bac.first, setIndex));
|
||||
bac.first = setIndex;
|
||||
entity.bac = bac;
|
||||
m_bac = bac;
|
||||
|
||||
BookmarkCategory const * category = GetFramework().GetBookmarkManager().GetBmCategory(bac.first);
|
||||
entity.bookmarkCategory = @(category->GetName().c_str());
|
||||
self.category = @(category->GetName().c_str());
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
|
@ -123,15 +100,13 @@
|
|||
{
|
||||
AddSetVC * asVC = [[AddSetVC alloc] init];
|
||||
asVC.delegate = self;
|
||||
if (IPAD)
|
||||
asVC.preferredContentSize = self.preferredContentSize;
|
||||
[self.navigationController pushViewController:asVC animated:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self moveBookmarkToSetWithIndex:static_cast<int>(indexPath.row)];
|
||||
[self.manager reloadBookmark];
|
||||
[self popViewController];
|
||||
[self.delegate didSelectCategory:self.category withBac:m_bac];
|
||||
[self backTap];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
iphone/Maps/Classes/Editor/MWMButtonCell.h
Normal file
13
iphone/Maps/Classes/Editor/MWMButtonCell.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
@protocol MWMButtonCellDelegate <NSObject>
|
||||
|
||||
- (void)cellSelect:(UITableViewCell *)cell;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMButtonCell : MWMTableViewCell
|
||||
|
||||
- (void)configureWithDelegate:(id<MWMButtonCellDelegate>)delegate title:(NSString *)title;
|
||||
|
||||
@end
|
|
@ -1,15 +1,15 @@
|
|||
#import "MWMNoteButtonCell.h"
|
||||
#import "MWMButtonCell.h"
|
||||
|
||||
@interface MWMNoteButtonCell ()
|
||||
@interface MWMButtonCell ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton * button;
|
||||
@property (weak, nonatomic) id<MWMEditorCellProtocol> delegate;
|
||||
@property (weak, nonatomic) id<MWMButtonCellDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMNoteButtonCell
|
||||
@implementation MWMButtonCell
|
||||
|
||||
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate title:(NSString *)title
|
||||
- (void)configureWithDelegate:(id<MWMButtonCellDelegate>)delegate title:(NSString *)title
|
||||
{
|
||||
[self.button setTitle:title forState:UIControlStateNormal];
|
||||
self.delegate = delegate;
|
|
@ -13,7 +13,7 @@
|
|||
#import "MWMNoteCell.h"
|
||||
#import "MWMObjectsCategorySelectorController.h"
|
||||
#import "MWMOpeningHoursEditorViewController.h"
|
||||
#import "MWMNoteButtonCell.h"
|
||||
#import "MWMButtonCell.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageOpeningHoursCell.h"
|
||||
#import "MWMStreetEditorViewController.h"
|
||||
|
@ -66,7 +66,7 @@ MWMPlacePageCellTypeValueMap const kCellType2ReuseIdentifier{
|
|||
{MWMPlacePageCellTypeCuisine, "MWMEditorSelectTableViewCell"},
|
||||
{MWMPlacePageCellTypeWiFi, "MWMEditorSwitchTableViewCell"},
|
||||
{MWMPlacePageCellTypeNote, "MWMNoteCell"},
|
||||
{MWMPlacePageCellTypeReportButton, "MWMNoteButtonCell"}};
|
||||
{MWMPlacePageCellTypeReportButton, "MWMButtonCell"}};
|
||||
|
||||
NSString * reuseIdentifier(MWMPlacePageCellType cellType)
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
MWMPlacePageOpeningHoursCellProtocol,
|
||||
MWMEditorCellProtocol, MWMCuisineEditorProtocol,
|
||||
MWMStreetEditorProtocol, MWMObjectsCategorySelectorDelegate,
|
||||
MWMNoteCelLDelegate>
|
||||
MWMNoteCelLDelegate, MWMButtonCellDelegate>
|
||||
|
||||
@property (nonatomic) NSMutableDictionary<NSString *, UITableViewCell *> * offscreenCells;
|
||||
@property (nonatomic) NSMutableArray<NSIndexPath *> * invalidCells;
|
||||
|
@ -501,12 +501,13 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
case MWMPlacePageCellTypeNote:
|
||||
{
|
||||
MWMNoteCell * tCell = static_cast<MWMNoteCell *>(cell);
|
||||
[tCell configWithDelegate:self noteText:self.note];
|
||||
[tCell configWithDelegate:self noteText:self.note
|
||||
placeholder:L(@"editor_detailed_description_hint")];
|
||||
break;
|
||||
}
|
||||
case MWMPlacePageCellTypeReportButton:
|
||||
{
|
||||
MWMNoteButtonCell * tCell = static_cast<MWMNoteButtonCell *>(cell);
|
||||
MWMButtonCell * tCell = static_cast<MWMButtonCell *>(cell);
|
||||
|
||||
auto title = ^ NSString * (osm::Editor::FeatureStatus s, BOOL isUploaded)
|
||||
{
|
||||
|
@ -673,7 +674,7 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (void)setOpeningHoursCellExpanded:(BOOL)openingHoursCellExpanded forCell:(UITableViewCell *)cell
|
||||
- (void)setOpeningHoursCellExpanded:(BOOL)openingHoursCellExpanded
|
||||
{
|
||||
[self performSegueWithIdentifier:kOpeningHoursEditorSegue sender:nil];
|
||||
}
|
||||
|
@ -763,6 +764,8 @@ void registerCellsForTableView(vector<MWMPlacePageCellType> const & cells, UITab
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - MWMEditorCellProtocol && MWMButtonCellDelegate
|
||||
|
||||
- (void)cellSelect:(UITableViewCell *)cell
|
||||
{
|
||||
NSIndexPath * indexPath = [self.tableView indexPathForCell:cell];
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#import "MWMEditorCommon.h"
|
||||
#import "MWMTableViewCell.h"
|
||||
|
||||
@interface MWMNoteButtonCell : MWMTableViewCell
|
||||
|
||||
- (void)configureWithDelegate:(id<MWMEditorCellProtocol>)delegate title:(NSString *)title;
|
||||
|
||||
@end
|
|
@ -11,7 +11,12 @@
|
|||
|
||||
@interface MWMNoteCell : MWMTableViewCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMNoteCelLDelegate>)delegate noteText:(NSString *)text;
|
||||
- (void)configWithDelegate:(id<MWMNoteCelLDelegate>)delegate noteText:(NSString *)text
|
||||
placeholder:(NSString *)placeholder;
|
||||
- (CGFloat)cellHeight;
|
||||
- (void)updateTextViewForHeight:(CGFloat)height;
|
||||
- (UITextView *)textView;
|
||||
+ (CGFloat)minimalHeight;
|
||||
- (void)registerObserver;
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
#import "MWMTextView.h"
|
||||
#import "MWMNoteCell.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
CGFloat const kMinimalTextViewHeight = 104.;
|
||||
CGFloat const kTopTextViewOffset = 12.;
|
||||
NSString * const kTextViewContentSizeKeyPath = @"contentSize";
|
||||
} // namespace
|
||||
CGFloat const kTopTextViewOffset = 12.;
|
||||
NSString * const kTextViewContentSizeKeyPath = @"contentSize";
|
||||
CGFloat const kMinimalTextViewHeight = 104.;
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface MWMNoteCell () <UITextViewDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITextView * textView;
|
||||
@property (weak, nonatomic) IBOutlet MWMTextView * textView;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewHeight;
|
||||
@property (weak, nonatomic) id<MWMNoteCelLDelegate> delegate;
|
||||
|
||||
|
@ -20,9 +22,31 @@ static void * kContext = &kContext;
|
|||
@implementation MWMNoteCell
|
||||
|
||||
- (void)configWithDelegate:(id<MWMNoteCelLDelegate>)delegate noteText:(NSString *)text
|
||||
placeholder:(NSString *)placeholder
|
||||
{
|
||||
self.delegate = delegate;
|
||||
self.textView.text = text;
|
||||
static_cast<MWMTextView *>(self.textView).placeholder = placeholder;
|
||||
}
|
||||
|
||||
- (void)updateTextViewForHeight:(CGFloat)height
|
||||
{
|
||||
if (height > kMinimalTextViewHeight)
|
||||
{
|
||||
self.textViewHeight.constant = height;
|
||||
[self.delegate cellShouldChangeSize:self text:self.textView.text];
|
||||
}
|
||||
else
|
||||
{
|
||||
CGFloat const currentHeight = self.textViewHeight.constant;
|
||||
if (currentHeight > kMinimalTextViewHeight)
|
||||
{
|
||||
self.textViewHeight.constant = kMinimalTextViewHeight;
|
||||
[self.delegate cellShouldChangeSize:self text:self.textView.text];
|
||||
}
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
|
@ -34,25 +58,7 @@ static void * kContext = &kContext;
|
|||
{
|
||||
NSValue * s = change[@"new"];
|
||||
CGFloat const height = s.CGSizeValue.height;
|
||||
|
||||
if (height > kMinimalTextViewHeight)
|
||||
{
|
||||
self.textViewHeight.constant = height;
|
||||
[self.delegate cellShouldChangeSize:self text:self.textView.text];
|
||||
}
|
||||
else
|
||||
{
|
||||
CGFloat const currentHeight = self.textViewHeight.constant;
|
||||
if (currentHeight > kMinimalTextViewHeight)
|
||||
{
|
||||
self.textViewHeight.constant = kMinimalTextViewHeight;
|
||||
[self.delegate cellShouldChangeSize:self text:self.textView.text];
|
||||
}
|
||||
}
|
||||
|
||||
[self setNeedsLayout];
|
||||
[self layoutIfNeeded];
|
||||
|
||||
[self updateTextViewForHeight:height];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,6 +70,11 @@ static void * kContext = &kContext;
|
|||
return self.textViewHeight.constant + 2 * kTopTextViewOffset;
|
||||
}
|
||||
|
||||
+ (CGFloat)minimalHeight
|
||||
{
|
||||
return kMinimalTextViewHeight;
|
||||
}
|
||||
|
||||
- (void)textViewDidEndEditing:(UITextView *)textView
|
||||
{
|
||||
[self.delegate cell:self didFinishEditingWithText:textView.text];
|
||||
|
|
|
@ -3,13 +3,17 @@
|
|||
@interface MWMBasePlacePageView : SolidTouchView
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * typeLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIView * downloadProgressView;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * externalTitleLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * subtitleLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * placeScheduleLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * addressLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * distanceLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * directionArrow;
|
||||
@property (weak, nonatomic) IBOutlet UITableView * featureTable;
|
||||
@property (weak, nonatomic) IBOutlet UIView * separatorView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * directionButton;
|
||||
@property (weak, nonatomic) IBOutlet UIView * ppPreview;
|
||||
|
||||
- (void)configureWithEntity:(MWMPlacePageEntity *)entity;
|
||||
- (void)addBookmark;
|
||||
|
|
|
@ -15,16 +15,22 @@
|
|||
|
||||
#include "map/place_page_info.hpp"
|
||||
|
||||
extern CGFloat const kBottomPlacePageOffset = 15.;
|
||||
extern CGFloat const kLabelsBetweenOffset = 8.;
|
||||
#include "3party/opening_hours/opening_hours.hpp"
|
||||
#include "editor/opening_hours_ui.hpp"
|
||||
#include "editor/ui2oh.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
CGFloat const kDownloadProgressViewLeftOffset = 12.;
|
||||
CGFloat const kDownloadProgressViewTopOffset = 10.;
|
||||
CGFloat const kLabelsBetweenMainOffset = 8.;
|
||||
CGFloat const kLabelsBetweenSmallOffset = 4.;
|
||||
CGFloat const kBottomPlacePageOffset = 16.;
|
||||
CGFloat const kLeftOffset = 16.;
|
||||
CGFloat const kDefaultHeaderHeight = 16.;
|
||||
CGFloat const kLabelsPadding = kLeftOffset * 2;
|
||||
CGFloat const kDirectionArrowSide = 20.;
|
||||
CGFloat const kOffsetFromTitleToDistance = 8.;
|
||||
CGFloat const kOffsetFromLabelsToDistance = 8.;
|
||||
CGFloat const kOffsetFromDistanceToArrow = 5.;
|
||||
CGFloat const kMaximumWidth = 360.;
|
||||
|
||||
|
@ -89,30 +95,29 @@ CGFloat placePageWidth()
|
|||
enum class AttributePosition
|
||||
{
|
||||
Title,
|
||||
Type,
|
||||
ExternalTitle,
|
||||
Subtitle,
|
||||
Schedule,
|
||||
Address
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@interface MWMBasePlacePageView () <MWMPlacePageOpeningHoursCellProtocol>
|
||||
@interface MWMBasePlacePageView () <UITableViewDelegate, UITableViewDataSource,
|
||||
MWMPlacePageOpeningHoursCellProtocol, MWMPlacePageBookmarkDelegate>
|
||||
{
|
||||
vector<PlacePageSection> m_sections;
|
||||
map<PlacePageSection, vector<MWMPlacePageCellType>> m_cells;
|
||||
map<MWMPlacePageCellType, UITableViewCell *> m_offscreenCells;
|
||||
}
|
||||
|
||||
@property (weak, nonatomic) MWMPlacePageEntity * entity;
|
||||
@property (weak, nonatomic) IBOutlet MWMPlacePage * ownerPlacePage;
|
||||
@property (weak, nonatomic) IBOutlet UIView * ppPreview;
|
||||
|
||||
@property (nonatomic) NSMutableDictionary<NSString *, UITableViewCell *> * offscreenCells;
|
||||
|
||||
@property (nonatomic, readwrite) BOOL openingHoursCellExpanded;
|
||||
@property (nonatomic) BOOL isBookmarkCellExpanded;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMBasePlacePageView (UITableView) <UITableViewDelegate, UITableViewDataSource>
|
||||
@end
|
||||
|
||||
@implementation MWMBasePlacePageView
|
||||
|
||||
- (void)awakeFromNib
|
||||
|
@ -121,18 +126,21 @@ enum class AttributePosition
|
|||
self.featureTable.delegate = self;
|
||||
self.featureTable.dataSource = self;
|
||||
self.featureTable.separatorColor = [UIColor blackDividers];
|
||||
|
||||
for (auto const & type : kCellType2ReuseIdentifier)
|
||||
{
|
||||
NSString * identifier = @(type.second.c_str());
|
||||
[self.featureTable registerNib:[UINib nibWithNibName:identifier bundle:nil]
|
||||
forCellReuseIdentifier:identifier];
|
||||
}
|
||||
|
||||
self.directionArrow.autoresizingMask = UIViewAutoresizingNone;
|
||||
}
|
||||
|
||||
- (void)configureWithEntity:(MWMPlacePageEntity *)entity
|
||||
{
|
||||
self.entity = entity;
|
||||
self.isBookmarkCellExpanded = NO;
|
||||
[self configTable];
|
||||
[self configure];
|
||||
}
|
||||
|
@ -141,6 +149,7 @@ enum class AttributePosition
|
|||
{
|
||||
m_sections.clear();
|
||||
m_cells.clear();
|
||||
m_offscreenCells.clear();
|
||||
for (auto const cellSection : kCellTypesSectionMap)
|
||||
{
|
||||
for (auto const cellType : cellSection.first)
|
||||
|
@ -159,27 +168,44 @@ enum class AttributePosition
|
|||
- (void)configure
|
||||
{
|
||||
MWMPlacePageEntity * entity = self.entity;
|
||||
|
||||
// TODO(Iliya): We need to determine that mwm was already uploaded (not only that we can download mwm).
|
||||
// Probably we should determine it in MWMPlacePageEntity, but I'm not sure about core interface.
|
||||
// I typed some placeholder in MWMPlacePageEntity class. Please look and use it or implement smth better.
|
||||
self.downloadProgressView.hidden = YES;
|
||||
// TODO(Vlad): We need to display external name not only for bookmarks but the same in case when we have localized and default place name.
|
||||
// Probably we need to move bookmark naming logic in core.
|
||||
if (entity.isBookmark)
|
||||
{
|
||||
self.titleLabel.text = entity.bookmarkTitle.length > 0 ? entity.bookmarkTitle : entity.title;
|
||||
self.typeLabel.text = entity.bookmarkCategory;
|
||||
if (![entity.bookmarkTitle isEqualToString:entity.title] && entity.bookmarkTitle.length > 0)
|
||||
{
|
||||
self.titleLabel.text = entity.bookmarkTitle;
|
||||
self.externalTitleLabel.text = entity.title;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.titleLabel.text = entity.title;
|
||||
self.externalTitleLabel.text = @"";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.titleLabel.text = entity.title;
|
||||
auto const ranges = [entity.category rangesOfString:@(place_page::Info::kSubtitleSeparator)];
|
||||
if (!ranges.empty())
|
||||
{
|
||||
NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:entity.category];
|
||||
for (auto const & r : ranges)
|
||||
[str addAttributes:@{NSForegroundColorAttributeName : [UIColor blackHintText]} range:r];
|
||||
self.externalTitleLabel.text = @"";
|
||||
}
|
||||
|
||||
self.typeLabel.attributedText = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.typeLabel.text = entity.category;
|
||||
}
|
||||
auto const ranges = [entity.subtitle rangesOfString:@(place_page::Info::kSubtitleSeparator)];
|
||||
if (!ranges.empty())
|
||||
{
|
||||
NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:entity.subtitle];
|
||||
for (auto const & r : ranges)
|
||||
[str addAttributes:@{NSForegroundColorAttributeName : [UIColor blackHintText]} range:r];
|
||||
|
||||
self.subtitleLabel.attributedText = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.subtitleLabel.text = entity.subtitle;
|
||||
}
|
||||
|
||||
BOOL const isMyPosition = entity.isMyPosition;
|
||||
|
@ -192,50 +218,87 @@ enum class AttributePosition
|
|||
self.directionButton.hidden = hideDirection;
|
||||
|
||||
[self.featureTable reloadData];
|
||||
[self configureCurrentShedule];
|
||||
[self setNeedsLayout];
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
- (void)configureCurrentShedule
|
||||
{
|
||||
MWMPlacePageOpeningHoursCell * cell =
|
||||
static_cast<MWMPlacePageOpeningHoursCell *>(m_offscreenCells[MWMPlacePageCellTypeOpenHours]);
|
||||
if (cell)
|
||||
{
|
||||
self.placeScheduleLabel.text = cell.isClosed ? L(@"closed_now") : L(@"editor_time_open");
|
||||
self.placeScheduleLabel.textColor = cell.isClosed ? [UIColor red] : [UIColor blackSecondaryText];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.placeScheduleLabel.text = @"";
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Layout
|
||||
|
||||
- (AttributePosition)distanceAttributePosition
|
||||
{
|
||||
if (self.typeLabel.text.length)
|
||||
return AttributePosition::Type;
|
||||
else if (!self.typeLabel.text.length && self.addressLabel.text.length)
|
||||
if (self.addressLabel.text.length)
|
||||
return AttributePosition::Address;
|
||||
else if (!self.addressLabel.text.length && self.placeScheduleLabel.text.length)
|
||||
return AttributePosition::Schedule;
|
||||
else if (!self.placeScheduleLabel.text.length && self.subtitleLabel.text.length)
|
||||
return AttributePosition::Subtitle;
|
||||
else if (self.externalTitleLabel.text.length)
|
||||
return AttributePosition::ExternalTitle;
|
||||
else
|
||||
return AttributePosition::Title;
|
||||
}
|
||||
|
||||
- (void)setupLabelsWidthWithBoundedWidth:(CGFloat)bound distancePosition:(AttributePosition)position
|
||||
{
|
||||
CGFloat const labelsMaxWidth = placePageWidth() - kLabelsPadding;
|
||||
auto const defaultMaxWidth = placePageWidth() - kLabelsPadding;
|
||||
CGFloat const labelsMaxWidth = self.downloadProgressView.hidden ? defaultMaxWidth :
|
||||
defaultMaxWidth - 2 * kDownloadProgressViewLeftOffset - self.downloadProgressView.width;
|
||||
switch (position)
|
||||
{
|
||||
case AttributePosition::Title:
|
||||
self.titleLabel.width = labelsMaxWidth - bound;
|
||||
self.typeLabel.width = self.addressLabel.width = 0;
|
||||
self.subtitleLabel.width = self.addressLabel.width = self.externalTitleLabel.width = self.placeScheduleLabel.width = 0;
|
||||
break;
|
||||
case AttributePosition::Type:
|
||||
if (self.addressLabel.text.length > 0)
|
||||
{
|
||||
self.titleLabel.width = self.addressLabel.width = labelsMaxWidth;
|
||||
self.typeLabel.width = labelsMaxWidth - bound;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.titleLabel.width = labelsMaxWidth;
|
||||
self.typeLabel.width = labelsMaxWidth - bound;
|
||||
self.addressLabel.width = 0;
|
||||
}
|
||||
case AttributePosition::ExternalTitle:
|
||||
self.addressLabel.width = self.subtitleLabel.width = self.placeScheduleLabel.width = 0;
|
||||
self.externalTitleLabel.width = labelsMaxWidth - bound;
|
||||
self.titleLabel.width = self.titleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
break;
|
||||
case AttributePosition::Subtitle:
|
||||
self.addressLabel.width = self.placeScheduleLabel.width = 0;
|
||||
self.titleLabel.width = self.titleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.externalTitleLabel.width = self.externalTitleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.subtitleLabel.width = labelsMaxWidth - bound;
|
||||
break;
|
||||
case AttributePosition::Schedule:
|
||||
self.addressLabel.width = 0;
|
||||
self.titleLabel.width = self.titleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.externalTitleLabel.width = self.externalTitleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.subtitleLabel.width = self.subtitleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.placeScheduleLabel.width = labelsMaxWidth - bound;
|
||||
break;
|
||||
case AttributePosition::Address:
|
||||
self.titleLabel.width = labelsMaxWidth;
|
||||
self.typeLabel.width = 0;
|
||||
self.titleLabel.width = self.titleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.subtitleLabel.width = self.subtitleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.externalTitleLabel.width = self.externalTitleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.placeScheduleLabel.width = self.placeScheduleLabel.text.length > 0 ? labelsMaxWidth : 0;
|
||||
self.addressLabel.width = labelsMaxWidth - bound;
|
||||
break;
|
||||
}
|
||||
|
||||
self.externalTitleLabel.width = self.entity.isBookmark ? labelsMaxWidth : 0;
|
||||
|
||||
[self.titleLabel sizeToFit];
|
||||
[self.subtitleLabel sizeToFit];
|
||||
[self.addressLabel sizeToFit];
|
||||
[self.externalTitleLabel sizeToFit];
|
||||
[self.placeScheduleLabel sizeToFit];
|
||||
}
|
||||
|
||||
- (void)setDistance:(NSString *)distance
|
||||
|
@ -249,27 +312,33 @@ enum class AttributePosition
|
|||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
CGFloat const bound = self.distanceLabel.width + kDirectionArrowSide + kOffsetFromDistanceToArrow + kOffsetFromTitleToDistance;
|
||||
CGFloat const bound = self.distanceLabel.width + kDirectionArrowSide + kOffsetFromDistanceToArrow + kOffsetFromLabelsToDistance;
|
||||
AttributePosition const position = [self distanceAttributePosition];
|
||||
[self setupLabelsWidthWithBoundedWidth:bound distancePosition:position];
|
||||
[self.titleLabel sizeToFit];
|
||||
[self.typeLabel sizeToFit];
|
||||
[self.addressLabel sizeToFit];
|
||||
[self layoutLabels];
|
||||
[self layoutTableViewWithPosition:position];
|
||||
[self setDistance:self.distanceLabel.text];
|
||||
self.height = self.featureTable.height + self.separatorView.height + self.titleLabel.height +
|
||||
(self.typeLabel.text.length > 0 ? self.typeLabel.height + kLabelsBetweenOffset : 0) +
|
||||
(self.addressLabel.text.length > 0 ? self.addressLabel.height + kLabelsBetweenOffset : 0) + kBottomPlacePageOffset;
|
||||
self.height = self.featureTable.height + self.ppPreview.height;
|
||||
}
|
||||
|
||||
- (void)layoutLabels
|
||||
{
|
||||
self.titleLabel.origin = {kLeftOffset, 0};
|
||||
self.typeLabel.origin = {kLeftOffset, self.titleLabel.maxY + kLabelsBetweenOffset};
|
||||
self.addressLabel.origin = self.typeLabel.text.length > 0 ?
|
||||
CGPointMake(kLeftOffset, self.typeLabel.maxY + kLabelsBetweenOffset) :
|
||||
self.typeLabel.origin;
|
||||
BOOL const isDownloadProgressViewHidden = self.downloadProgressView.hidden;
|
||||
if (!isDownloadProgressViewHidden)
|
||||
self.downloadProgressView.origin = {kDownloadProgressViewLeftOffset, kDownloadProgressViewTopOffset};
|
||||
|
||||
CGFloat const leftOffset = isDownloadProgressViewHidden ? kLeftOffset : self.downloadProgressView.maxX + kDownloadProgressViewLeftOffset;
|
||||
|
||||
auto originFrom = ^ CGPoint (UILabel * l)
|
||||
{
|
||||
return {leftOffset, l.text.length == 0 ? l.minY : l.maxY + kLabelsBetweenMainOffset};
|
||||
};
|
||||
|
||||
self.titleLabel.origin = {leftOffset, kLabelsBetweenSmallOffset};
|
||||
self.externalTitleLabel.origin = originFrom(self.titleLabel);
|
||||
self.subtitleLabel.origin = originFrom(self.externalTitleLabel);
|
||||
self.placeScheduleLabel.origin = originFrom(self.subtitleLabel);
|
||||
self.addressLabel.origin = originFrom(self.placeScheduleLabel);
|
||||
}
|
||||
|
||||
- (void)layoutDistanceBoxWithPosition:(AttributePosition)position
|
||||
|
@ -282,8 +351,12 @@ enum class AttributePosition
|
|||
{
|
||||
case AttributePosition::Title:
|
||||
return self.titleLabel.minY + defaultCenter;
|
||||
case AttributePosition::Type:
|
||||
return self.typeLabel.minY + defaultCenter;
|
||||
case AttributePosition::ExternalTitle:
|
||||
return self.externalTitleLabel.minY + defaultCenter;
|
||||
case AttributePosition::Subtitle:
|
||||
return self.subtitleLabel.minY + defaultCenter;
|
||||
case AttributePosition::Schedule:
|
||||
return self.placeScheduleLabel.minY + defaultCenter;
|
||||
case AttributePosition::Address:
|
||||
return self.addressLabel.minY + defaultCenter;
|
||||
}
|
||||
|
@ -306,15 +379,19 @@ enum class AttributePosition
|
|||
{
|
||||
case AttributePosition::Title:
|
||||
return self.titleLabel.maxY + kBottomPlacePageOffset;
|
||||
case AttributePosition::Type:
|
||||
return (self.addressLabel.text.length > 0 ? self.addressLabel.maxY : self.typeLabel.maxY) + kBottomPlacePageOffset;
|
||||
case AttributePosition::ExternalTitle:
|
||||
return self.externalTitleLabel.maxY + kBottomPlacePageOffset;
|
||||
case AttributePosition::Subtitle:
|
||||
return self.subtitleLabel.maxY + kBottomPlacePageOffset;
|
||||
case AttributePosition::Schedule:
|
||||
return self.placeScheduleLabel.maxY + kBottomPlacePageOffset;
|
||||
case AttributePosition::Address:
|
||||
return self.addressLabel.maxY + kBottomPlacePageOffset;
|
||||
}
|
||||
};
|
||||
|
||||
self.separatorView.minY = getY(position);
|
||||
self.ppPreview.height = self.separatorView.maxY;
|
||||
self.ppPreview.frame = {{}, {self.ppPreview.superview.width, self.separatorView.maxY}};
|
||||
self.featureTable.minY = self.separatorView.maxY;
|
||||
self.featureTable.height = self.featureTable.contentSize.height;
|
||||
}
|
||||
|
@ -325,12 +402,11 @@ enum class AttributePosition
|
|||
{
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatToggleBookmark)
|
||||
withParameters:@{kStatValue : kStatAdd}];
|
||||
[self.typeLabel sizeToFit];
|
||||
[self.subtitleLabel sizeToFit];
|
||||
|
||||
m_sections.push_back(PlacePageSection::Bookmark);
|
||||
m_cells[PlacePageSection::Bookmark].push_back(MWMPlacePageCellTypeBookmark);
|
||||
sort(m_sections.begin(), m_sections.end());
|
||||
|
||||
[self configure];
|
||||
}
|
||||
|
||||
|
@ -346,29 +422,55 @@ enum class AttributePosition
|
|||
m_cells.erase(PlacePageSection::Bookmark);
|
||||
}
|
||||
|
||||
m_offscreenCells.erase(MWMPlacePageCellTypeBookmark);
|
||||
|
||||
[self configure];
|
||||
}
|
||||
|
||||
- (void)reloadBookmarkCell
|
||||
{
|
||||
MWMPlacePageCellType const type = MWMPlacePageCellTypeBookmark;
|
||||
[self fillCell:m_offscreenCells[type] withType:type];
|
||||
[self configure];
|
||||
[self.featureTable reloadData];
|
||||
[self setNeedsLayout];
|
||||
[self layoutIfNeeded];
|
||||
[CATransaction begin];
|
||||
[CATransaction setCompletionBlock:^
|
||||
{
|
||||
[self setNeedsLayout];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [self.ownerPlacePage refresh]; });
|
||||
}];
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (IBAction)directionButtonTap
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatCompass)];
|
||||
[self.ownerPlacePage.manager showDirectionViewWithTitle:self.titleLabel.text type:self.typeLabel.text];
|
||||
[self.ownerPlacePage.manager showDirectionViewWithTitle:self.titleLabel.text type:self.subtitleLabel.text];
|
||||
}
|
||||
|
||||
- (void)updateAndLayoutMyPositionSpeedAndAltitude:(NSString *)text
|
||||
{
|
||||
self.typeLabel.text = text;
|
||||
self.subtitleLabel.text = text;
|
||||
[self setNeedsLayout];
|
||||
}
|
||||
|
||||
#pragma mark - MWMPlacePageBookmarkDelegate
|
||||
|
||||
- (void)reloadBookmark
|
||||
{
|
||||
[self reloadBookmarkCell];
|
||||
}
|
||||
|
||||
- (void)editBookmarkTap
|
||||
{
|
||||
[self.ownerPlacePage editBookmark];
|
||||
}
|
||||
|
||||
- (void)moreTap
|
||||
{
|
||||
self.isBookmarkCellExpanded = YES;
|
||||
[self reloadBookmarkCell];
|
||||
}
|
||||
|
||||
#pragma mark - MWMPlacePageOpeningHoursCellProtocol
|
||||
|
||||
- (BOOL)forcedButton
|
||||
|
@ -386,37 +488,37 @@ enum class AttributePosition
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (void)setOpeningHoursCellExpanded:(BOOL)openingHoursCellExpanded forCell:(UITableViewCell *)cell
|
||||
- (void)setOpeningHoursCellExpanded:(BOOL)openingHoursCellExpanded
|
||||
{
|
||||
_openingHoursCellExpanded = openingHoursCellExpanded;
|
||||
UITableView * tv = self.featureTable;
|
||||
NSIndexPath * indexPath = [tv indexPathForCell:cell];
|
||||
[CATransaction begin];
|
||||
MWMPlacePageCellType const type = MWMPlacePageCellTypeOpenHours;
|
||||
[self fillCell:m_offscreenCells[MWMPlacePageCellTypeOpenHours] withType:type];
|
||||
[tv beginUpdates];
|
||||
[CATransaction begin];
|
||||
[CATransaction setCompletionBlock:^
|
||||
{
|
||||
[self setNeedsLayout];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{ [self.ownerPlacePage refresh]; });
|
||||
}];
|
||||
[tv reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
[tv endUpdates];
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (UITableViewCell *)offscreenCellForIdentifier:(NSString *)reuseIdentifier
|
||||
- (UITableViewCell *)offscreenCellForCellType:(MWMPlacePageCellType)type
|
||||
{
|
||||
UITableViewCell * cell = self.offscreenCells[reuseIdentifier];
|
||||
UITableViewCell * cell = m_offscreenCells[type];
|
||||
if (!cell)
|
||||
{
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:reuseIdentifier owner:nil options:nil] firstObject];
|
||||
self.offscreenCells[reuseIdentifier] = cell;
|
||||
NSString * identifier = reuseIdentifier(type);
|
||||
cell = [[[NSBundle mainBundle] loadNibNamed:identifier owner:nil options:nil] firstObject];
|
||||
[self fillCell:cell withType:type];
|
||||
m_offscreenCells[type] = cell;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMBasePlacePageView (UITableView)
|
||||
#pragma mark - UITableView
|
||||
|
||||
- (MWMPlacePageCellType)cellTypeForIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
|
@ -429,14 +531,17 @@ enum class AttributePosition
|
|||
return reuseIdentifier(cellType);
|
||||
}
|
||||
|
||||
- (void)fillCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath * _Nonnull)indexPath forHeight:(BOOL)forHeight
|
||||
- (void)fillCell:(UITableViewCell *)cell withType:(MWMPlacePageCellType)cellType
|
||||
{
|
||||
MWMPlacePageEntity * entity = self.entity;
|
||||
MWMPlacePageCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
switch (cellType)
|
||||
{
|
||||
case MWMPlacePageCellTypeBookmark:
|
||||
[(MWMPlacePageBookmarkCell *)cell config:self.ownerPlacePage forHeight:NO];
|
||||
[static_cast<MWMPlacePageBookmarkCell *>(cell) configWithText:entity.bookmarkDescription
|
||||
delegate:self
|
||||
placePageWidth:placePageWidth()
|
||||
isOpen:self.isBookmarkCellExpanded
|
||||
isHtml:entity.isHTMLDescription];
|
||||
break;
|
||||
case MWMPlacePageCellTypeOpenHours:
|
||||
[(MWMPlacePageOpeningHoursCell *)cell configWithDelegate:self info:[entity getCellValue:cellType]];
|
||||
|
@ -458,10 +563,8 @@ enum class AttributePosition
|
|||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSString * reuseIdentifier = [self cellIdentifierForIndexPath:indexPath];
|
||||
UITableViewCell * cell = [self offscreenCellForIdentifier:reuseIdentifier];
|
||||
[self fillCell:cell atIndexPath:indexPath forHeight:YES];
|
||||
MWMPlacePageCellType const cellType = [self cellTypeForIndexPath:indexPath];
|
||||
UITableViewCell * cell = [self offscreenCellForCellType:cellType];
|
||||
switch (cellType)
|
||||
{
|
||||
case MWMPlacePageCellTypeBookmark:
|
||||
|
@ -481,11 +584,6 @@ enum class AttributePosition
|
|||
}
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView * _Nonnull)tableView willDisplayCell:(UITableViewCell * _Nonnull)cell forRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath
|
||||
{
|
||||
[self fillCell:cell atIndexPath:indexPath forHeight:NO];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return [self cellsForSection:section].size();
|
||||
|
@ -498,8 +596,13 @@ enum class AttributePosition
|
|||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSString * reuseIdentifier = [self cellIdentifierForIndexPath:indexPath];
|
||||
return [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
|
||||
MWMPlacePageCellType const type = [self cellTypeForIndexPath:indexPath];
|
||||
NSString * identifier = reuseIdentifier(type);
|
||||
UITableViewCell * cell = m_offscreenCells[type];
|
||||
if (!cell)
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:identifier];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
|
@ -509,6 +612,8 @@ enum class AttributePosition
|
|||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
if (m_sections[section] == PlacePageSection::Bookmark)
|
||||
return 0.001;
|
||||
return kDefaultHeaderHeight;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
@interface MWMBookmarkColorCell : MWMTableViewCell
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton * colorButton;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * approveImageView;
|
||||
|
||||
- (void)configureWithColorString:(NSString *)colorString;
|
||||
|
||||
@end
|
|
@ -1,31 +0,0 @@
|
|||
#import "MWMBookmarkColorCell.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
|
||||
@interface MWMBookmarkColorCell ()
|
||||
|
||||
@property (copy, nonatomic) NSString * currentImageName;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMBookmarkColorCell
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
self.backgroundColor = [UIColor white];
|
||||
}
|
||||
|
||||
- (void)configureWithColorString:(NSString *)colorString
|
||||
{
|
||||
self.currentImageName = colorString;
|
||||
self.titleLabel.text = L([colorString stringByReplacingOccurrencesOfString:@"placemark-" withString:@""]);
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
|
||||
{
|
||||
[super setSelected:selected animated:animated];
|
||||
[self.colorButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@%@", self.currentImageName, selected ? @"-on" : @"-off"]] forState:UIControlStateNormal];
|
||||
self.approveImageView.hidden = !selected;
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,10 +1,27 @@
|
|||
#import "MWMTableViewController.h"
|
||||
|
||||
@class MWMPlacePageViewManager;
|
||||
namespace ios_bookmark_ui_helper
|
||||
{
|
||||
inline NSString * LocalizedTitleForBookmarkColor(NSString * color)
|
||||
{
|
||||
return L([color stringByReplacingOccurrencesOfString:@"placemark-" withString:@""]);
|
||||
}
|
||||
|
||||
inline UIImage * ImageForBookmarkColor(NSString * color, BOOL isSelected)
|
||||
{
|
||||
return [UIImage imageNamed:[NSString stringWithFormat:@"%@%@%@", @"img_", color, isSelected ? @"-on" : @"-off"]];
|
||||
}
|
||||
|
||||
} // namespace ios_bookmark_ui_helper
|
||||
|
||||
@protocol MWMBookmarkColorDelegate <NSObject>
|
||||
|
||||
- (void)didSelectColor:(NSString *)color;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMBookmarkColorViewController : MWMTableViewController
|
||||
|
||||
@property (weak, nonatomic) MWMPlacePageViewManager * placePageManager;
|
||||
@property (weak, nonatomic) UINavigationController * iPadOwnerNavigationController;
|
||||
- (instancetype)initWithColor:(NSString *)color delegate:(id<MWMBookmarkColorDelegate>)delegate;
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
#import "Common.h"
|
||||
#import "MWMBookmarkColorCell.h"
|
||||
#import "MWMBookmarkColorViewController.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "Statistics.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
#import "UIViewController+navigation.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "std/array.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
NSArray<NSString *> * const kBookmarkColorsVariant = @[
|
||||
array<NSString *, 8> const kBookmarkColorsVariant
|
||||
{{
|
||||
@"placemark-red",
|
||||
@"placemark-yellow",
|
||||
@"placemark-blue",
|
||||
|
@ -19,58 +17,36 @@ NSArray<NSString *> * const kBookmarkColorsVariant = @[
|
|||
@"placemark-orange",
|
||||
@"placemark-brown",
|
||||
@"placemark-pink"
|
||||
];
|
||||
|
||||
NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
||||
}};
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@interface MWMBookmarkColorViewController ()
|
||||
|
||||
@property (nonatomic) BOOL colorWasChanged;
|
||||
@property (copy, nonatomic) NSString * bookmarkColor;
|
||||
@property (weak, nonatomic) id<MWMBookmarkColorDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMBookmarkColorViewController
|
||||
|
||||
- (instancetype)initWithColor:(NSString *)color delegate:(id<MWMBookmarkColorDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
_bookmarkColor = color;
|
||||
_delegate = delegate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
NSAssert(self.bookmarkColor, @"Color can't be nil!");
|
||||
NSAssert(self.delegate, @"Delegate can't be nil!");
|
||||
self.title = L(@"bookmark_color");
|
||||
[self.tableView registerNib:[UINib nibWithNibName:kBookmarkColorCellIdentifier bundle:nil] forCellReuseIdentifier:kBookmarkColorCellIdentifier];
|
||||
self.colorWasChanged = NO;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
[self.iPadOwnerNavigationController setNavigationBarHidden:NO];
|
||||
[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
|
||||
{
|
||||
if (self.iPadOwnerNavigationController)
|
||||
[self.iPadOwnerNavigationController setNavigationBarHidden:YES];
|
||||
[self.placePageManager reloadBookmark];
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated
|
||||
{
|
||||
[super viewWillDisappear:animated];
|
||||
if (self.colorWasChanged && !self.iPadOwnerNavigationController)
|
||||
[self.placePageManager reloadBookmark];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -79,22 +55,18 @@ NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
|||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
MWMBookmarkColorCell * cell = (MWMBookmarkColorCell *)[tableView dequeueReusableCellWithIdentifier:kBookmarkColorCellIdentifier];
|
||||
if (!cell)
|
||||
cell = [[MWMBookmarkColorCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kBookmarkColorCellIdentifier];
|
||||
|
||||
NSString * const currentColor = kBookmarkColorsVariant[indexPath.row];
|
||||
[cell configureWithColorString:kBookmarkColorsVariant[indexPath.row]];
|
||||
|
||||
if ([currentColor isEqualToString:self.placePageManager.entity.bookmarkColor] && !cell.selected)
|
||||
[tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
|
||||
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
NSString * currentColor = kBookmarkColorsVariant[indexPath.row];
|
||||
cell.textLabel.text = ios_bookmark_ui_helper::LocalizedTitleForBookmarkColor(currentColor);
|
||||
BOOL const isSelected = [currentColor isEqualToString:self.bookmarkColor];
|
||||
cell.imageView.image = ios_bookmark_ui_helper::ImageForBookmarkColor(currentColor, isSelected);
|
||||
cell.accessoryType = isSelected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return kBookmarkColorsVariant.count;
|
||||
return kBookmarkColorsVariant.size();
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
|
@ -102,12 +74,8 @@ NSString * const kBookmarkColorCellIdentifier = @"MWMBookmarkColorCell";
|
|||
NSString * bookmarkColor = kBookmarkColorsVariant[indexPath.row];
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatChangeBookmarkColor)
|
||||
withParameters:@{kStatValue : bookmarkColor}];
|
||||
self.colorWasChanged = YES;
|
||||
self.placePageManager.entity.bookmarkColor = bookmarkColor;
|
||||
if (!self.iPadOwnerNavigationController)
|
||||
return;
|
||||
|
||||
[self.placePageManager.entity synchronize];
|
||||
[self.delegate didSelectColor:bookmarkColor];
|
||||
[self backTap];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
13
iphone/Maps/Classes/MWMBookmarkTitleCell.h
Normal file
13
iphone/Maps/Classes/MWMBookmarkTitleCell.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
@protocol MWMBookmarkTitleDelegate <NSObject>
|
||||
|
||||
- (void)didFinishEditingBookmarkTitle:(NSString *)title;
|
||||
|
||||
@end
|
||||
|
||||
@interface MWMBookmarkTitleCell : MWMTableViewCell
|
||||
|
||||
- (void)configureWithName:(NSString *)name delegate:(id<MWMBookmarkTitleDelegate>)delegate;
|
||||
|
||||
@end
|
23
iphone/Maps/Classes/MWMBookmarkTitleCell.m
Normal file
23
iphone/Maps/Classes/MWMBookmarkTitleCell.m
Normal file
|
@ -0,0 +1,23 @@
|
|||
#import "MWMBookmarkTitleCell.h"
|
||||
|
||||
@interface MWMBookmarkTitleCell () <UITextFieldDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITextField * name;
|
||||
@property (weak, nonatomic) id<MWMBookmarkTitleDelegate> delegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMBookmarkTitleCell
|
||||
|
||||
- (void)configureWithName:(NSString *)name delegate:(id<MWMBookmarkTitleDelegate>)delegate
|
||||
{
|
||||
self.name.text = name;
|
||||
self.delegate = delegate;
|
||||
}
|
||||
|
||||
- (void)textFieldDidEndEditing:(UITextField *)textField
|
||||
{
|
||||
[self.delegate didFinishEditingBookmarkTitle:textField.text];
|
||||
}
|
||||
|
||||
@end
|
9
iphone/Maps/Classes/MWMEditBookmarkController.h
Normal file
9
iphone/Maps/Classes/MWMEditBookmarkController.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#import "MWMTableViewController.h"
|
||||
|
||||
@class MWMPlacePageViewManager;
|
||||
|
||||
@interface MWMEditBookmarkController : MWMTableViewController
|
||||
|
||||
@property (nonatomic) MWMPlacePageViewManager * manager;
|
||||
|
||||
@end
|
287
iphone/Maps/Classes/MWMEditBookmarkController.mm
Normal file
287
iphone/Maps/Classes/MWMEditBookmarkController.mm
Normal file
|
@ -0,0 +1,287 @@
|
|||
#import "MWMBookmarkTitleCell.h"
|
||||
#import "MWMButtonCell.h"
|
||||
#import "MWMBookmarkColorViewController.h"
|
||||
#import "MWMEditBookmarkController.h"
|
||||
#import "MWMNoteCell.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "SelectSetVC.h"
|
||||
#import "UIImageView+Coloring.h"
|
||||
#import "UIViewController+Navigation.h"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
enum Sections
|
||||
{
|
||||
MetaInfo,
|
||||
Description,
|
||||
Delete,
|
||||
SectionsCount
|
||||
};
|
||||
|
||||
enum RowInMetaInfo
|
||||
{
|
||||
Title,
|
||||
Color,
|
||||
Category,
|
||||
RowsInMetaInfoCount
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface MWMEditBookmarkController () <MWMButtonCellDelegate, MWMNoteCelLDelegate, MWMBookmarkColorDelegate,
|
||||
MWMSelectSetDelegate, MWMBookmarkTitleDelegate>
|
||||
{
|
||||
BookmarkAndCategory m_cachedBac;
|
||||
}
|
||||
|
||||
@property (nonatomic) MWMNoteCell * cachedNote;
|
||||
@property (copy, nonatomic) NSString * cachedDescription;
|
||||
@property (copy, nonatomic) NSString * cachedTitle;
|
||||
@property (copy, nonatomic) NSString * cachedColor;
|
||||
@property (copy, nonatomic) NSString * cachedCategory;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMEditBookmarkController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
NSAssert(self.manager, @"Entity can't be nil!");
|
||||
MWMPlacePageEntity * en = self.manager.entity;
|
||||
self.cachedDescription = en.bookmarkDescription;
|
||||
self.cachedTitle = en.bookmarkTitle;
|
||||
self.cachedCategory = en.bookmarkCategory;
|
||||
self.cachedColor = en.bookmarkColor;
|
||||
m_cachedBac = en.bac;
|
||||
|
||||
[self configNavBar];
|
||||
[self registerCells];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
[self.cachedNote updateTextViewForHeight:self.cachedNote.textView.contentSize.height];
|
||||
}
|
||||
|
||||
- (void)configNavBar
|
||||
{
|
||||
[self showBackButton];
|
||||
self.title = L(@"bookmark").capitalizedString;
|
||||
self.navigationItem.rightBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
|
||||
target:self
|
||||
action:@selector(onSave)];
|
||||
}
|
||||
|
||||
- (void)registerCells
|
||||
{
|
||||
auto registerClass = ^ (Class c)
|
||||
{
|
||||
NSString * className = NSStringFromClass(c);
|
||||
[self.tableView registerNib:[UINib nibWithNibName:className bundle:nil]
|
||||
forCellReuseIdentifier:className];
|
||||
};
|
||||
|
||||
registerClass([MWMButtonCell class]);
|
||||
registerClass([MWMBookmarkTitleCell class]);
|
||||
registerClass([MWMNoteCell class]);
|
||||
}
|
||||
|
||||
- (void)onSave
|
||||
{
|
||||
[self.view endEditing:YES];
|
||||
MWMPlacePageEntity * en = self.manager.entity;
|
||||
en.bookmarkDescription = self.cachedDescription;
|
||||
en.bookmarkColor = self.cachedColor;
|
||||
en.bookmarkCategory = self.cachedCategory;
|
||||
en.bookmarkTitle = self.cachedTitle;
|
||||
en.bac = m_cachedBac;
|
||||
[en synchronize];
|
||||
[self.manager reloadBookmark];
|
||||
[self backTap];
|
||||
}
|
||||
|
||||
- (void)backTap
|
||||
{
|
||||
if (IPAD)
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
else
|
||||
[super backTap];
|
||||
}
|
||||
|
||||
#pragma mark - UITableView
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return SectionsCount;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
case MetaInfo:
|
||||
return RowsInMetaInfoCount;
|
||||
case Description:
|
||||
case Delete:
|
||||
return 1;
|
||||
default:
|
||||
NSAssert(false, @"Incorrect section!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
switch (indexPath.section)
|
||||
{
|
||||
case MetaInfo:
|
||||
switch (indexPath.row)
|
||||
{
|
||||
case Title:
|
||||
{
|
||||
MWMBookmarkTitleCell * cell = [tableView dequeueReusableCellWithIdentifier:[MWMBookmarkTitleCell className]];
|
||||
[cell configureWithName:self.cachedTitle delegate:self];
|
||||
return cell;
|
||||
}
|
||||
case Color:
|
||||
{
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
cell.textLabel.text = ios_bookmark_ui_helper::LocalizedTitleForBookmarkColor(self.cachedColor);
|
||||
cell.imageView.image = ios_bookmark_ui_helper::ImageForBookmarkColor(self.cachedColor, YES);
|
||||
cell.imageView.layer.cornerRadius = cell.imageView.width / 2;
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
return cell;
|
||||
}
|
||||
case Category:
|
||||
{
|
||||
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:[UITableViewCell className]];
|
||||
cell.textLabel.text = self.cachedCategory;
|
||||
cell.imageView.image = [UIImage imageNamed:@"ic_folder"];
|
||||
cell.imageView.mwm_coloring = MWMImageColoringBlack;
|
||||
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
|
||||
return cell;
|
||||
}
|
||||
default:
|
||||
NSAssert(false, @"Incorrect row!");
|
||||
return nil;
|
||||
}
|
||||
case Description:
|
||||
{
|
||||
NSAssert(indexPath.row == 0, @"Incorrect row!");
|
||||
if (self.cachedNote)
|
||||
{
|
||||
return self.cachedNote;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.cachedNote = [tableView dequeueReusableCellWithIdentifier:[MWMNoteCell className]];
|
||||
[self.cachedNote configWithDelegate:self noteText:self.cachedDescription
|
||||
placeholder:L(@"personal_description")];
|
||||
return self.cachedNote;
|
||||
}
|
||||
}
|
||||
case Delete:
|
||||
{
|
||||
NSAssert(indexPath.row == 0, @"Incorrect row!");
|
||||
MWMButtonCell * cell = [tableView dequeueReusableCellWithIdentifier:[MWMButtonCell className]];
|
||||
[cell configureWithDelegate:self title:L(@"remove_bookmark")];
|
||||
return cell;
|
||||
}
|
||||
default:
|
||||
NSAssert(false, @"Incorrect section!");
|
||||
return nil;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.section == Description)
|
||||
{
|
||||
NSAssert(indexPath.row == 0, @"Incorrect row!");
|
||||
return self.cachedNote ? self.cachedNote.cellHeight : [MWMNoteCell minimalHeight];
|
||||
}
|
||||
return self.tableView.rowHeight;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
switch (indexPath.row)
|
||||
{
|
||||
case Color:
|
||||
{
|
||||
MWMBookmarkColorViewController * cvc = [[MWMBookmarkColorViewController alloc] initWithColor:self.cachedColor
|
||||
delegate:self];
|
||||
[self.navigationController pushViewController:cvc animated:YES];
|
||||
break;
|
||||
}
|
||||
case Category:
|
||||
{
|
||||
SelectSetVC * svc = [[SelectSetVC alloc] initWithCategory:self.cachedCategory
|
||||
bac:m_cachedBac
|
||||
delegate:self];
|
||||
[self.navigationController pushViewController:svc animated:YES];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MWMButtonCellDelegate
|
||||
|
||||
- (void)cellSelect:(UITableViewCell *)cell
|
||||
{
|
||||
[self.manager removeBookmark];
|
||||
[self backTap];
|
||||
}
|
||||
|
||||
#pragma mark - MWMNoteCellDelegate
|
||||
|
||||
- (void)cell:(MWMNoteCell *)cell didFinishEditingWithText:(NSString *)text
|
||||
{
|
||||
self.cachedDescription = text;
|
||||
}
|
||||
|
||||
- (void)cellShouldChangeSize:(MWMNoteCell *)cell text:(NSString *)text
|
||||
{
|
||||
self.cachedDescription = text;
|
||||
[self.tableView beginUpdates];
|
||||
[self.tableView endUpdates];
|
||||
[self.tableView scrollToRowAtIndexPath:[self.tableView indexPathForCell:cell]
|
||||
atScrollPosition:UITableViewScrollPositionBottom
|
||||
animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark - MWMBookmarkColorDelegate
|
||||
|
||||
- (void)didSelectColor:(NSString *)color
|
||||
{
|
||||
self.cachedColor = color;
|
||||
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:Color inSection:MetaInfo]] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
}
|
||||
|
||||
#pragma mark - MWMSelectSetDelegate
|
||||
|
||||
- (void)didSelectCategory:(NSString *)category withBac:(BookmarkAndCategory const &)bac
|
||||
{
|
||||
self.cachedCategory = category;
|
||||
m_cachedBac = bac;
|
||||
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:Category inSection:MetaInfo]] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
}
|
||||
|
||||
#pragma mark - MWMBookmarkTitleDelegate
|
||||
|
||||
- (void)didFinishEditingBookmarkTitle:(NSString *)title
|
||||
{
|
||||
self.cachedTitle = title;
|
||||
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:Title inSection:MetaInfo]] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
}
|
||||
|
||||
@end
|
|
@ -24,9 +24,7 @@
|
|||
#pragma mark - Actions
|
||||
- (void)addBookmark;
|
||||
- (void)removeBookmark;
|
||||
- (void)changeBookmarkColor;
|
||||
- (void)changeBookmarkCategory;
|
||||
- (void)changeBookmarkDescription;
|
||||
- (void)editBookmark;
|
||||
- (void)editPlace;
|
||||
- (void)addBusiness;
|
||||
- (void)addPlace;
|
||||
|
@ -34,8 +32,6 @@
|
|||
- (void)route;
|
||||
- (void)reloadBookmark;
|
||||
- (void)apiBack;
|
||||
- (void)willStartEditingBookmarkTitle;
|
||||
- (void)willFinishEditingBookmarkTitle:(NSString *)title;
|
||||
- (void)addPlacePageShadowToView:(UIView *)view offset:(CGSize)offset;
|
||||
|
||||
- (IBAction)didTap:(UITapGestureRecognizer *)sender;
|
||||
|
@ -44,9 +40,6 @@
|
|||
- (void)setDistance:(NSString *)distance;
|
||||
- (void)updateMyPositionStatus:(NSString *)status;
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)aNotification;
|
||||
- (void)keyboardWillHide;
|
||||
|
||||
- (void)refresh;
|
||||
|
||||
- (instancetype)init __attribute__((unavailable("call initWithManager: instead")));
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
static NSString * const kPlacePageNibIdentifier = @"PlacePageView";
|
||||
static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
||||
extern NSString * const kPP2BookmarkEditingSegue = @"PP2BookmarkEditing";
|
||||
extern NSString * const kPP2BookmarkEditingIPADSegue = @"PP2BookmarkEditingIPAD";
|
||||
|
||||
@interface MWMPlacePage ()
|
||||
|
||||
|
@ -30,24 +32,10 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
[[NSBundle mainBundle] loadNibNamed:kPlacePageNibIdentifier owner:self options:nil];
|
||||
self.manager = manager;
|
||||
if (!IPAD)
|
||||
{
|
||||
[self.extendedPlacePageView addObserver:self
|
||||
forKeyPath:kPlacePageViewCenterKeyPath
|
||||
options:NSKeyValueObservingOptionNew
|
||||
context:nullptr];
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillShow:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillHide)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
});
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -55,21 +43,7 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
- (void)dealloc
|
||||
{
|
||||
if (!IPAD)
|
||||
{
|
||||
[self.extendedPlacePageView removeObserver:self forKeyPath:kPlacePageViewCenterKeyPath];
|
||||
}
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)aNotification
|
||||
{
|
||||
NSDictionary * info = [aNotification userInfo];
|
||||
self.keyboardHeight = [info[UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
|
||||
}
|
||||
|
||||
- (void)keyboardWillHide
|
||||
{
|
||||
self.keyboardHeight = 0.0;
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
|
@ -77,8 +51,7 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
change:(NSDictionary *)change
|
||||
context:(void *)context
|
||||
{
|
||||
if ([self.extendedPlacePageView isEqual:object] &&
|
||||
[keyPath isEqualToString:kPlacePageViewCenterKeyPath])
|
||||
if ([self.extendedPlacePageView isEqual:object] && [keyPath isEqualToString:kPlacePageViewCenterKeyPath])
|
||||
[self.manager dragPlacePage:self.extendedPlacePageView.frame];
|
||||
}
|
||||
|
||||
|
@ -129,8 +102,8 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
|
||||
- (void)removeBookmark
|
||||
{
|
||||
[self.manager removeBookmark];
|
||||
[self.basePlacePageView removeBookmark];
|
||||
self.actionBar.isBookmark = NO;
|
||||
}
|
||||
|
||||
- (void)editPlace
|
||||
|
@ -185,27 +158,10 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
[self.basePlacePageView updateAndLayoutMyPositionSpeedAndAltitude:status];
|
||||
}
|
||||
|
||||
- (void)changeBookmarkCategory
|
||||
- (void)editBookmark
|
||||
{
|
||||
MWMPlacePageViewManager * manager = self.manager;
|
||||
MapViewController * ovc = static_cast<MapViewController *>(manager.ownerViewController);
|
||||
SelectSetVC * vc = [[SelectSetVC alloc] initWithPlacePageManager:manager];
|
||||
[ovc.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)changeBookmarkColor
|
||||
{
|
||||
MWMBookmarkColorViewController * controller = [[MWMBookmarkColorViewController alloc] initWithNibName:[MWMBookmarkColorViewController className] bundle:nil];
|
||||
controller.placePageManager = self.manager;
|
||||
[self.manager.ownerViewController.navigationController pushViewController:controller animated:YES];
|
||||
}
|
||||
|
||||
- (void)changeBookmarkDescription
|
||||
{
|
||||
MWMPlacePageViewManager * manager = self.manager;
|
||||
MapViewController * ovc = static_cast<MapViewController *>(manager.ownerViewController);
|
||||
MWMBookmarkDescriptionViewController * viewController = [[MWMBookmarkDescriptionViewController alloc] initWithPlacePageManager:manager];
|
||||
[ovc.navigationController pushViewController:viewController animated:YES];
|
||||
[self.manager.ownerViewController performSegueWithIdentifier:IPAD ? kPP2BookmarkEditingIPADSegue :
|
||||
kPP2BookmarkEditingSegue sender:self.manager];
|
||||
}
|
||||
|
||||
- (void)reloadBookmark
|
||||
|
@ -213,18 +169,6 @@ static NSString * const kPlacePageViewCenterKeyPath = @"center";
|
|||
[self.basePlacePageView reloadBookmarkCell];
|
||||
}
|
||||
|
||||
- (void)willStartEditingBookmarkTitle
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatRename)];
|
||||
// This method should be оverridden.
|
||||
}
|
||||
|
||||
- (void)willFinishEditingBookmarkTitle:(NSString *)title
|
||||
{
|
||||
self.basePlacePageView.titleLabel.text = title;
|
||||
[self.basePlacePageView layoutIfNeeded];
|
||||
}
|
||||
|
||||
- (IBAction)didTap:(UITapGestureRecognizer *)sender
|
||||
{
|
||||
// This method should be оverridden if you want to process custom tap.
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
#import "MWMTableViewCell.h"
|
||||
|
||||
@protocol MWMPlacePageBookmarkDelegate <NSObject>
|
||||
|
||||
- (void)reloadBookmark;
|
||||
- (void)editBookmarkTap;
|
||||
- (void)moreTap;
|
||||
|
||||
@end
|
||||
|
||||
@class MWMPlacePage;
|
||||
|
||||
@interface MWMPlacePageBookmarkCell : MWMTableViewCell
|
||||
|
||||
- (void)config:(MWMPlacePage *)placePage forHeight:(BOOL)forHeight;
|
||||
- (void)configWithText:(NSString *)text
|
||||
delegate:(id<MWMPlacePageBookmarkDelegate>)delegate
|
||||
placePageWidth:(CGFloat)width
|
||||
isOpen:(BOOL)isOpen
|
||||
isHtml:(BOOL)isHtml;
|
||||
|
||||
- (CGFloat)cellHeight;
|
||||
|
||||
|
|
|
@ -1,191 +1,173 @@
|
|||
#import "MWMBasePlacePageView.h"
|
||||
#import "MWMPlacePage.h"
|
||||
#import "MWMPlacePageBookmarkCell.h"
|
||||
#import "MWMPlacePageEntity.h"
|
||||
#import "MWMPlacePageViewManager.h"
|
||||
#import "MWMTextView.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
extern CGFloat const kBookmarkCellHeight = 136.0;
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
|
||||
static CGFloat const kSeparatorAndTitleHeight = 52.0;
|
||||
namespace
|
||||
{
|
||||
CGFloat const kBoundedTextViewHeight = 240.;
|
||||
CGFloat const kTextViewTopOffset = 12.;
|
||||
CGFloat const kMoreButtonHeight = 33.;
|
||||
CGFloat const kTextViewLeft = 16.;
|
||||
|
||||
static NSUInteger sWebViewHeight = 0;
|
||||
} // namespace
|
||||
|
||||
@interface MWMPlacePageBookmarkCell () <UITextFieldDelegate, UIWebViewDelegate>
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UITextField * title;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * categoryButton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * markButton;
|
||||
@property (weak, nonatomic) IBOutlet UITextView * textView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * moreButton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * editButton;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * separator;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * gradient;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView * spinner;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIView * note;
|
||||
@property (weak, nonatomic) IBOutlet UILabel * noteLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIWebView * noteWebView;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * noteViewHeight;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * editBookmarkButton;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewTopOffset;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewBottomOffset;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * textViewHeight;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint * moreButtonHeight;
|
||||
|
||||
@property (weak, nonatomic) MWMPlacePage * placePage;
|
||||
@property (weak, nonatomic) id<MWMPlacePageBookmarkDelegate> delegate;
|
||||
|
||||
@property (nonatomic) BOOL forHeight;
|
||||
|
||||
@property (nonatomic) NSString * webViewContent;
|
||||
@property (copy, nonatomic) NSAttributedString * attributedHtml;
|
||||
@property (copy, nonatomic) NSString * cachedHtml;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MWMPlacePageBookmarkCell
|
||||
|
||||
- (void)config:(MWMPlacePage *)placePage forHeight:(BOOL)forHeight
|
||||
- (void)configWithText:(NSString *)text
|
||||
delegate:(id<MWMPlacePageBookmarkDelegate>)delegate
|
||||
placePageWidth:(CGFloat)width
|
||||
isOpen:(BOOL)isOpen
|
||||
isHtml:(BOOL)isHtml
|
||||
{
|
||||
self.placePage = placePage;
|
||||
self.forHeight = forHeight;
|
||||
|
||||
[self configNote];
|
||||
|
||||
if (forHeight && self.entity.isHTMLDescription)
|
||||
return;
|
||||
|
||||
self.title.text = self.entity.bookmarkTitle;
|
||||
[self.categoryButton setTitle:[NSString stringWithFormat:@"%@ >", self.entity.bookmarkCategory]
|
||||
forState:UIControlStateNormal];
|
||||
[self.markButton
|
||||
setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@-on", self.entity.bookmarkColor]]
|
||||
forState:UIControlStateNormal];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillShown:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(keyboardWillBeHidden)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
self.delegate = delegate;
|
||||
self.textView.width = width - 2 * kTextViewLeft;
|
||||
BOOL const isEmpty = text.length == 0;
|
||||
if (isEmpty)
|
||||
[self configEmptyDescription];
|
||||
else if (isHtml)
|
||||
[self configHtmlDescription:text isOpen:isOpen];
|
||||
else
|
||||
[self configPlaintTextDescription:text isOpen:isOpen];
|
||||
}
|
||||
|
||||
- (void)configNote
|
||||
- (void)configEmptyDescription
|
||||
{
|
||||
if (self.entity.bookmarkDescription.length == 0)
|
||||
self.textView.hidden = self.separator.hidden = self.gradient.hidden = self.moreButton.hidden = self.spinner.hidden = YES;
|
||||
self.textViewTopOffset.constant = self.textViewBottomOffset.constant = self.textViewHeight.constant =
|
||||
self.moreButtonHeight.constant = 0;
|
||||
}
|
||||
|
||||
- (void)startSpinner
|
||||
{
|
||||
self.editButton.hidden = YES;
|
||||
NSUInteger const animationImagesCount = 12;
|
||||
NSMutableArray * animationImages = [NSMutableArray arrayWithCapacity:animationImagesCount];
|
||||
NSString * postfix = [UIColor isNightMode] ? @"dark" : @"light";
|
||||
for (NSUInteger i = 0; i < animationImagesCount; ++i)
|
||||
animationImages[i] = [UIImage imageNamed:[NSString stringWithFormat:@"Spinner_%@_%@", @(i+1), postfix]];
|
||||
|
||||
self.spinner.animationDuration = 0.8;
|
||||
self.spinner.animationImages = animationImages;
|
||||
self.spinner.hidden = NO;
|
||||
[self.spinner startAnimating];
|
||||
}
|
||||
|
||||
- (void)stopSpinner
|
||||
{
|
||||
[self.spinner stopAnimating];
|
||||
self.editButton.hidden = NO;
|
||||
self.spinner.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)configPlaintTextDescription:(NSString *)text isOpen:(BOOL)isOpen
|
||||
{
|
||||
self.spinner.hidden = YES;
|
||||
self.textView.scrollEnabled = YES;
|
||||
self.textViewTopOffset.constant = kTextViewTopOffset;
|
||||
self.textView.hidden = self.separator.hidden = NO;
|
||||
self.textView.text = text;
|
||||
CGFloat const textViewHeight = self.textView.contentSize.height;
|
||||
if (textViewHeight > kBoundedTextViewHeight && !isOpen)
|
||||
{
|
||||
self.note.hidden = YES;
|
||||
[self.editBookmarkButton setTitle:L(@"description") forState:UIControlStateNormal];
|
||||
self.textViewHeight.constant = kBoundedTextViewHeight;
|
||||
self.moreButton.hidden = self.gradient.hidden = NO;
|
||||
self.moreButtonHeight.constant = kMoreButtonHeight;
|
||||
self.textViewBottomOffset.constant = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.note.hidden = NO;
|
||||
[self.editBookmarkButton setTitle:L(@"edit") forState:UIControlStateNormal];
|
||||
if (self.entity.isHTMLDescription)
|
||||
self.textViewHeight.constant = textViewHeight;
|
||||
self.moreButton.hidden = self.gradient.hidden = YES;
|
||||
self.moreButtonHeight.constant = 0;
|
||||
self.textViewBottomOffset.constant = kTextViewTopOffset;
|
||||
}
|
||||
self.textView.scrollEnabled = NO;
|
||||
}
|
||||
|
||||
- (void)configHtmlDescription:(NSString *)text isOpen:(BOOL)isOpen
|
||||
{
|
||||
// html already was rendered and text is same as text which was cached into html
|
||||
if (self.attributedHtml && [self.cachedHtml isEqualToString:text])
|
||||
{
|
||||
self.textView.scrollEnabled = YES;
|
||||
self.textViewTopOffset.constant = kTextViewTopOffset;
|
||||
self.textView.hidden = self.separator.hidden = NO;
|
||||
self.textView.attributedText = self.attributedHtml;
|
||||
CGFloat const textViewHeight = self.textView.contentSize.height;
|
||||
if (textViewHeight > kBoundedTextViewHeight && !isOpen)
|
||||
{
|
||||
self.noteWebView.hidden = NO;
|
||||
self.noteLabel.hidden = YES;
|
||||
if (!self.forHeight && ![self.webViewContent isEqualToString:self.entity.bookmarkDescription])
|
||||
{
|
||||
sWebViewHeight = 0.0;
|
||||
self.webViewContent = self.entity.bookmarkDescription;
|
||||
[self.noteWebView loadHTMLString:self.entity.bookmarkDescription baseURL:nil];
|
||||
self.noteWebView.scrollView.scrollEnabled = NO;
|
||||
}
|
||||
self.textViewHeight.constant = kBoundedTextViewHeight;
|
||||
self.moreButton.hidden = self.gradient.hidden = NO;
|
||||
self.moreButtonHeight.constant = kMoreButtonHeight;
|
||||
self.textViewBottomOffset.constant = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.noteWebView.hidden = YES;
|
||||
self.noteLabel.hidden = NO;
|
||||
self.noteLabel.text = self.entity.bookmarkDescription;
|
||||
[self.noteLabel sizeToFit];
|
||||
self.noteViewHeight.constant = kSeparatorAndTitleHeight + self.noteLabel.height;
|
||||
self.textViewHeight.constant = textViewHeight;
|
||||
self.moreButton.hidden = self.gradient.hidden = YES;
|
||||
self.moreButtonHeight.constant = 0;
|
||||
self.textViewBottomOffset.constant = kTextViewTopOffset;
|
||||
}
|
||||
self.textView.scrollEnabled = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
[self configEmptyDescription];
|
||||
[self startSpinner];
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
|
||||
{
|
||||
self.cachedHtml = text;
|
||||
self.attributedHtml = [[NSAttributedString alloc]
|
||||
initWithData:[text dataUsingEncoding:NSUnicodeStringEncoding]
|
||||
options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType}
|
||||
documentAttributes:nil
|
||||
error:nil];
|
||||
dispatch_async(dispatch_get_main_queue(), ^
|
||||
{
|
||||
[self stopSpinner];
|
||||
[self.delegate reloadBookmark];
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyboardWillShown:(NSNotification *)aNotification
|
||||
- (IBAction)moreTap
|
||||
{
|
||||
if ([self.title isEditing])
|
||||
[self.placePage willStartEditingBookmarkTitle];
|
||||
}
|
||||
|
||||
- (void)keyboardWillBeHidden
|
||||
{
|
||||
if ([self.title isEditing])
|
||||
[self.placePage willFinishEditingBookmarkTitle:self.title.text.length > 0 ? self.title.text : self.entity.title];
|
||||
}
|
||||
|
||||
- (void)textFieldDidEndEditing:(UITextField *)textField
|
||||
{
|
||||
self.entity.bookmarkTitle = textField.text.length > 0 ? textField.text : self.entity.title;
|
||||
[self.entity synchronize];
|
||||
[textField resignFirstResponder];
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldClear:(UITextField *)textField
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldReturn:(UITextField *)textField
|
||||
{
|
||||
[textField resignFirstResponder];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if (!self.forHeight)
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (IBAction)colorPickerButtonTap
|
||||
{
|
||||
[self.placePage changeBookmarkColor];
|
||||
[self endEditing:YES];
|
||||
}
|
||||
|
||||
- (IBAction)categoryButtonTap
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatChangeBookmarkGroup)];
|
||||
[self.placePage changeBookmarkCategory];
|
||||
[self endEditing:YES];
|
||||
[self.delegate moreTap];
|
||||
}
|
||||
|
||||
- (IBAction)editTap
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatChangeBookmarkDescription)];
|
||||
[self.placePage changeBookmarkDescription];
|
||||
[self endEditing:YES];
|
||||
}
|
||||
|
||||
- (MWMPlacePageEntity *)entity
|
||||
{
|
||||
return self.placePage.manager.entity;
|
||||
[self.delegate editBookmarkTap];
|
||||
}
|
||||
|
||||
- (CGFloat)cellHeight
|
||||
{
|
||||
CGFloat const noteViewHeight = self.entity.isHTMLDescription ? sWebViewHeight : self.noteViewHeight.constant;
|
||||
return kBookmarkCellHeight + ceil(self.note.hidden ? 0.0 : noteViewHeight);
|
||||
}
|
||||
|
||||
#pragma mark - UIWebViewDelegate
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView * _Nonnull)webView
|
||||
{
|
||||
webView.height = webView.scrollView.contentSize.height;
|
||||
NSUInteger webViewHeight = ceil(kSeparatorAndTitleHeight + webView.height);
|
||||
self.noteViewHeight.constant = webViewHeight;
|
||||
if (sWebViewHeight != webViewHeight)
|
||||
{
|
||||
sWebViewHeight = webViewHeight;
|
||||
[self.placePage reloadBookmark];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)webView:(UIWebView *)inWeb
|
||||
shouldStartLoadWithRequest:(NSURLRequest *)inRequest
|
||||
navigationType:(UIWebViewNavigationType)inType
|
||||
{
|
||||
if (inType == UIWebViewNavigationTypeLinkClicked)
|
||||
{
|
||||
[[UIApplication sharedApplication] openURL:[inRequest URL]];
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
return self.textViewTopOffset.constant + self.textViewHeight.constant +
|
||||
self.textViewBottomOffset.constant + self.moreButtonHeight.constant +
|
||||
self.separator.height + self.editButton.height;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "indexer/feature_meta.hpp"
|
||||
|
||||
#include "storage/index.hpp"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MWMPlacePageCellType)
|
||||
{
|
||||
MWMPlacePageCellTypePostcode = feature::Metadata::EType::FMD_COUNT,
|
||||
|
@ -36,7 +38,7 @@ using MWMPlacePageCellTypeValueMap = map<MWMPlacePageCellType, string>;
|
|||
@interface MWMPlacePageEntity : NSObject
|
||||
|
||||
@property (copy, nonatomic) NSString * title;
|
||||
@property (copy, nonatomic) NSString * category;
|
||||
@property (copy, nonatomic) NSString * subtitle;
|
||||
@property (copy, nonatomic) NSString * address;
|
||||
@property (copy, nonatomic) NSString * bookmarkTitle;
|
||||
@property (copy, nonatomic) NSString * bookmarkCategory;
|
||||
|
@ -63,5 +65,8 @@ using MWMPlacePageCellTypeValueMap = map<MWMPlacePageCellType, string>;
|
|||
|
||||
- (NSString *)getCellValue:(MWMPlacePageCellType)cellType;
|
||||
- (place_page::Info const &)info;
|
||||
// TODO (SeregaE, Ilia): uncoment this line and method's implementation in .mm file,
|
||||
// or please implement better solution.
|
||||
//- (storage::TCountryId const &)countryId;
|
||||
|
||||
@end
|
||||
|
|
|
@ -87,15 +87,16 @@ void initFieldsMap()
|
|||
{
|
||||
self.title = @(m_info.GetTitle().c_str());
|
||||
self.address = @(m_info.GetAddress().c_str());
|
||||
self.subtitle = @(m_info.GetSubtitle().c_str());
|
||||
}
|
||||
|
||||
- (void)configureFeature
|
||||
{
|
||||
// Category can also be custom-formatted, please check m_info getters.
|
||||
self.category = @(m_info.GetSubtitle().c_str());
|
||||
// TODO(Vlad): Refactor using osm::Props instead of direct Metadata access.
|
||||
feature::Metadata const & md = m_info.GetMetadata();
|
||||
for (auto const type : md.GetPresentTypes())
|
||||
auto const types = md.GetPresentTypes();
|
||||
for (auto const type : types)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
@ -123,7 +124,7 @@ void initFieldsMap()
|
|||
BookmarkData const & data = static_cast<Bookmark const *>(cat->GetUserMark(bac.second))->GetData();
|
||||
|
||||
self.bookmarkTitle = @(data.GetName().c_str());
|
||||
self.bookmarkCategory = @(cat->GetName().c_str());
|
||||
self.bookmarkCategory = @(m_info.GetBookmarkCategoryName().c_str());
|
||||
string const & description = data.GetDescription();
|
||||
self.bookmarkDescription = @(description.c_str());
|
||||
_isHTMLDescription = strings::IsHTML(description);
|
||||
|
@ -178,6 +179,12 @@ void initFieldsMap()
|
|||
return m_info.GetID();
|
||||
}
|
||||
|
||||
//- (storage::TCountryId const &)countryId
|
||||
//{
|
||||
// TODO(SeregaE): We probably should store countryId in instance of place_page::Info and here will be something like
|
||||
// return m_info.CountryId();
|
||||
//}
|
||||
|
||||
- (BOOL)isMyPosition
|
||||
{
|
||||
return m_info.IsMyPosition();
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class MWMiPhonePortraitPlacePage;
|
||||
|
||||
@interface MWMPlacePageNavigationBar : UIView
|
||||
@interface MWMPlacePageNavigationBar : SolidTouchView
|
||||
|
||||
+ (void)dismissNavigationBar;
|
||||
+ (void)showNavigationBarForPlacePage:(MWMiPhonePortraitPlacePage *)placePage;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#import <objc/runtime.h>
|
||||
|
||||
static NSString * const kPlacePageNavigationBarNibName = @"PlacePageNavigationBar";
|
||||
static CGFloat const kNavigationBarHeight = 64.;
|
||||
static CGFloat const kNavigationBarHeight = 36.;
|
||||
|
||||
static inline CGPoint const openCenter(CGFloat xPosition)
|
||||
{
|
||||
|
@ -22,7 +22,6 @@ static inline CGPoint const dismissCenter(CGFloat xPosition)
|
|||
|
||||
@interface MWMPlacePageNavigationBar ()
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UILabel * titleLabel;
|
||||
@property (weak, nonatomic) MWMiPhonePortraitPlacePage * placePage;
|
||||
|
||||
@end
|
||||
|
@ -53,8 +52,6 @@ static inline CGPoint const dismissCenter(CGFloat xPosition)
|
|||
}
|
||||
|
||||
navBar.placePage = placePage;
|
||||
MWMPlacePageEntity * entity = placePage.manager.entity;
|
||||
navBar.titleLabel.text = entity.isMyPosition ? entity.bookmarkTitle : entity.title;
|
||||
[navBar show];
|
||||
}
|
||||
|
||||
|
@ -98,7 +95,7 @@ static inline CGPoint const dismissCenter(CGFloat xPosition)
|
|||
return navBar;
|
||||
}
|
||||
|
||||
- (IBAction)backTap:(id)sender
|
||||
- (IBAction)dismissTap
|
||||
{
|
||||
[Statistics logEvent:kStatEventName(kStatPlacePage, kStatBack)];
|
||||
[self dismiss];
|
||||
|
@ -111,10 +108,4 @@ static inline CGPoint const dismissCenter(CGFloat xPosition)
|
|||
self.origin = CGPointZero;
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
// Prevent super call to stop event propagation
|
||||
// [super touchesBegan:touches withEvent:event];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -113,7 +113,7 @@ extern NSString * const kBookmarksChangedNotification;
|
|||
if (self.entity.isMyPosition)
|
||||
{
|
||||
BOOL hasSpeed;
|
||||
self.entity.category = [[MapsAppDelegate theApp].locationManager formattedSpeedAndAltitude:hasSpeed];
|
||||
self.entity.subtitle = [[MapsAppDelegate theApp].locationManager formattedSpeedAndAltitude:hasSpeed];
|
||||
}
|
||||
self.placePage.parentViewHeight = self.ownerViewController.view.height;
|
||||
[self.placePage configure];
|
||||
|
@ -219,8 +219,8 @@ extern NSString * const kBookmarksChangedNotification;
|
|||
name = self.entity.title;
|
||||
else if (self.entity.address.length > 0)
|
||||
name = self.entity.address;
|
||||
else if (self.entity.category.length > 0)
|
||||
name = self.entity.category;
|
||||
else if (self.entity.subtitle.length > 0)
|
||||
name = self.entity.subtitle;
|
||||
else if (self.entity.isBookmark)
|
||||
name = self.entity.bookmarkTitle;
|
||||
else
|
||||
|
@ -306,6 +306,7 @@ extern NSString * const kBookmarksChangedNotification;
|
|||
object:nil
|
||||
userInfo:nil];
|
||||
[self updateDistance];
|
||||
[self.placePage removeBookmark];
|
||||
}
|
||||
|
||||
- (void)reloadBookmark
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
@interface MWMTextView : UITextView
|
||||
|
||||
@property (copy, nonatomic) NSString * placeholder;
|
||||
@property (nonatomic, readonly) UILabel * placeholderView;
|
||||
|
||||
@end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@interface MWMTextView ()
|
||||
|
||||
@property (nonatomic) UILabel * placeholderView;
|
||||
@property (nonatomic, readwrite) UILabel * placeholderView;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -195,18 +195,6 @@ static CGFloat const kKeyboardOffset = 12.;
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)willStartEditingBookmarkTitle
|
||||
{
|
||||
[super willStartEditingBookmarkTitle];
|
||||
[self updatePlacePagePosition];
|
||||
}
|
||||
|
||||
- (void)willFinishEditingBookmarkTitle:(NSString *)title
|
||||
{
|
||||
[super willFinishEditingBookmarkTitle:title];
|
||||
[self updatePlacePageLayoutAnimated:NO];
|
||||
}
|
||||
|
||||
- (void)addBookmark
|
||||
{
|
||||
[super addBookmark];
|
||||
|
@ -230,29 +218,6 @@ static CGFloat const kKeyboardOffset = 12.;
|
|||
[self updatePlacePageLayoutAnimated:YES];
|
||||
}
|
||||
|
||||
- (void)changeBookmarkColor
|
||||
{
|
||||
MWMBookmarkColorViewController * controller = [[MWMBookmarkColorViewController alloc] initWithNibName:[MWMBookmarkColorViewController className] bundle:nil];
|
||||
controller.iPadOwnerNavigationController = self.navigationController;
|
||||
controller.placePageManager = self.manager;
|
||||
[self.navigationController pushViewController:controller animated:YES];
|
||||
}
|
||||
|
||||
- (void)changeBookmarkCategory
|
||||
{
|
||||
SelectSetVC * controller = [[SelectSetVC alloc] initWithPlacePageManager:self.manager];
|
||||
controller.iPadOwnerNavigationController = self.navigationController;
|
||||
[self.navigationController pushViewController:controller animated:YES];
|
||||
}
|
||||
|
||||
- (void)changeBookmarkDescription
|
||||
{
|
||||
MWMBookmarkDescriptionViewController * controller = [[MWMBookmarkDescriptionViewController alloc] initWithPlacePageManager:self.manager];
|
||||
controller.iPadOwnerNavigationController = self.navigationController;
|
||||
[self.navigationController pushViewController:controller animated:YES];
|
||||
[self updatePlacePageLayoutAnimated:NO];
|
||||
}
|
||||
|
||||
- (IBAction)didPan:(UIPanGestureRecognizer *)sender
|
||||
{
|
||||
UIView * view = self.navigationController.view;
|
||||
|
@ -301,7 +266,7 @@ static CGFloat const kKeyboardOffset = 12.;
|
|||
UITableView * featureTable = self.basePlacePageView.featureTable;
|
||||
CGFloat const height = self.navigationController.view.height;
|
||||
CGFloat const tableContentHeight = featureTable.contentSize.height;
|
||||
CGFloat const headerHeight = self.basePlacePageView.separatorView.maxY;
|
||||
CGFloat const headerHeight = self.basePlacePageView.ppPreview.height;
|
||||
CGFloat const actionBarHeight = self.actionBar.height;
|
||||
CGFloat const anchorHeight = self.anchorImageView.height;
|
||||
CGFloat const availableTableHeight = height - headerHeight - actionBarHeight - anchorHeight;
|
||||
|
@ -318,18 +283,6 @@ static CGFloat const kKeyboardOffset = 12.;
|
|||
}
|
||||
}
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)aNotification
|
||||
{
|
||||
[super keyboardWillShow:aNotification];
|
||||
[self refresh];
|
||||
}
|
||||
|
||||
- (void)keyboardWillHide
|
||||
{
|
||||
[super keyboardWillHide];
|
||||
[self refresh];
|
||||
}
|
||||
|
||||
- (CGFloat)getAvailableHeight
|
||||
{
|
||||
CGFloat const bottomOffset = self.keyboardHeight > 0.0 ? kKeyboardOffset : kBottomOffset;
|
||||
|
|
|
@ -66,7 +66,7 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState)
|
|||
CGFloat const actionBarHeight = self.actionBar.height;
|
||||
UITableView * featureTable = self.basePlacePageView.featureTable;
|
||||
CGFloat const tableContentHeight = featureTable.contentSize.height;
|
||||
CGFloat const headerViewHeight = self.basePlacePageView.separatorView.maxY;
|
||||
CGFloat const headerViewHeight = self.basePlacePageView.ppPreview.height;
|
||||
CGFloat const availableTableHeight = height - headerViewHeight - actionBarHeight;
|
||||
CGFloat const externalHeight = tableContentHeight - availableTableHeight;
|
||||
if (externalHeight > 0)
|
||||
|
@ -137,32 +137,6 @@ typedef NS_ENUM(NSUInteger, MWMiPhoneLandscapePlacePageState)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)willStartEditingBookmarkTitle
|
||||
{
|
||||
[super willStartEditingBookmarkTitle];
|
||||
CGFloat const statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
|
||||
MWMBasePlacePageView * basePPV = self.basePlacePageView;
|
||||
UITableView const * tableView = basePPV.featureTable;
|
||||
CGFloat const baseViewHeight = basePPV.height;
|
||||
CGFloat const tableHeight = tableView.contentSize.height;
|
||||
CGFloat const headerViewHeight = baseViewHeight - tableHeight;
|
||||
CGFloat const titleOriginY = tableHeight - kBookmarkCellHeight - tableView.contentOffset.y;
|
||||
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.basePlacePageView.transform = CGAffineTransformMakeTranslation(0., statusBarHeight - headerViewHeight - titleOriginY);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)willFinishEditingBookmarkTitle:(NSString *)title
|
||||
{
|
||||
[super willFinishEditingBookmarkTitle:title];
|
||||
[UIView animateWithDuration:kDefaultAnimationDuration animations:^
|
||||
{
|
||||
self.basePlacePageView.transform = CGAffineTransformMakeTranslation(0., 0.);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (void)setState:(MWMiPhoneLandscapePlacePageState)state
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
|
||||
#include "Framework.h"
|
||||
|
||||
extern CGFloat const kBottomPlacePageOffset;
|
||||
extern CGFloat const kLabelsBetweenOffset;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState)
|
||||
{
|
||||
MWMiPhonePortraitPlacePageStateClosed,
|
||||
|
@ -192,12 +189,7 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState)
|
|||
MWMBasePlacePageView * basePPV = self.basePlacePageView;
|
||||
CGFloat const anchorHeight = self.anchorImageView.height;
|
||||
CGFloat const actionBarHeight = self.actionBar.height;
|
||||
BOOL const typeIsNotEmpty = basePPV.typeLabel.text.length > 0;
|
||||
BOOL const addressIsNotEmpty = basePPV.addressLabel.text.length > 0;
|
||||
CGFloat const titleHeight = basePPV.titleLabel.height + (typeIsNotEmpty ? kLabelsBetweenOffset : 0);
|
||||
CGFloat const typeHeight = typeIsNotEmpty ? basePPV.typeLabel.height + (addressIsNotEmpty ? kLabelsBetweenOffset : 0) : 0;
|
||||
CGFloat const addressHeight = addressIsNotEmpty ? basePPV.addressLabel.height : 0;
|
||||
return anchorHeight + titleHeight + typeHeight + addressHeight + kBottomPlacePageOffset + actionBarHeight;
|
||||
return anchorHeight + basePPV.ppPreview.height /*+ kBottomPlacePageOffset*/ + actionBarHeight - 1;
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
@ -287,21 +279,6 @@ typedef NS_ENUM(NSUInteger, MWMiPhonePortraitPlacePageState)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)willStartEditingBookmarkTitle
|
||||
{
|
||||
[super willStartEditingBookmarkTitle];
|
||||
if (self.isHover)
|
||||
self.state = MWMiPhonePortraitPlacePageStateHover;
|
||||
else
|
||||
self.state = MWMiPhonePortraitPlacePageStateOpen;
|
||||
}
|
||||
|
||||
- (void)willFinishEditingBookmarkTitle:(NSString *)title
|
||||
{
|
||||
[super willFinishEditingBookmarkTitle:title];
|
||||
[self refresh];
|
||||
}
|
||||
|
||||
- (void)setAnchorImage
|
||||
{
|
||||
NSString * anchorImageName = nil;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#import "MWMAuthorizationCommon.h"
|
||||
#import "MWMAuthorizationLoginViewController.h"
|
||||
#import "MWMAuthorizationWebViewLoginViewController.h"
|
||||
#import "MWMEditBookmarkController.h"
|
||||
#import "MWMEditorViewController.h"
|
||||
#import "MWMFirstLaunchController.h"
|
||||
#import "MWMFrameworkListener.h"
|
||||
|
@ -872,6 +873,17 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
MWMAuthorizationWebViewLoginViewController * dvc = segue.destinationViewController;
|
||||
dvc.authType = MWMWebViewAuthorizationTypeGoogle;
|
||||
}
|
||||
else if ([segue.identifier isEqualToString:@"PP2BookmarkEditingIPAD"])
|
||||
{
|
||||
UINavigationController * nav = segue.destinationViewController;
|
||||
MWMEditBookmarkController * dvc = nav.viewControllers.firstObject;
|
||||
dvc.manager = sender;
|
||||
}
|
||||
else if ([segue.identifier isEqualToString:@"PP2BookmarkEditing"])
|
||||
{
|
||||
MWMEditBookmarkController * dvc = segue.destinationViewController;
|
||||
dvc.manager = sender;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
|
Loading…
Add table
Reference in a new issue