diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.h b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.h index 938f7e328b..e4f702caee 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.h @@ -9,7 +9,7 @@ @interface MWMPlacePageOpeningHoursCell : UITableViewCell -- (void)configWithInfo:(NSString *)info editable:(BOOL)editable delegate:(id)delegate; +- (void)configWithInfo:(NSString *)info delegate:(id)delegate; - (CGFloat)cellHeight; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.mm index 3c74e18664..34ce67c59b 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.mm @@ -17,7 +17,6 @@ using WeekDayView = MWMPlacePageOpeningHoursDayView *; @property (weak, nonatomic) IBOutlet WeekDayView currentDay; @property (weak, nonatomic) IBOutlet UIView * middleSeparator; @property (weak, nonatomic) IBOutlet UIView * weekDaysView; -@property (weak, nonatomic) IBOutlet UIButton * editButton; @property (weak, nonatomic) IBOutlet UIImageView * expandImage; @property (weak, nonatomic) IBOutlet UIButton * toggleButton; @@ -57,42 +56,30 @@ WeekDayView getWeekDayView() ui::TimeTableSet timeTableSet; } -- (void)configWithInfo:(NSString *)info editable:(BOOL)editable delegate:(id)delegate +- (void)configWithInfo:(NSString *)info delegate:(id)delegate { - self.toggleButton.hidden = !editable; self.delegate = delegate; WeekDayView cd = self.currentDay; cd.currentDay = YES; - if (info) + self.toggleButton.hidden = YES; + self.expandImage.hidden = YES; + NSAssert(info, @"Schedule can not be empty"); + osmoh::OpeningHours oh(info.UTF8String); + if (MakeTimeTableSet(oh, timeTableSet)) { - osmoh::OpeningHours oh(info.UTF8String); - if (MakeTimeTableSet(oh, timeTableSet)) - { - cd.mode = MWMPlacePageOpeningHoursDayViewModeRegular; - self.isClosed = oh.IsClosed(time(nullptr)); - [self processSchedule]; - } - else - { - cd.mode = MWMPlacePageOpeningHoursDayViewModeCompatibility; - [cd setCompatibilityText:info]; - } - BOOL const isExpanded = delegate.openingHoursCellExpanded; - self.middleSeparator.hidden = !isExpanded; - self.weekDaysView.hidden = !isExpanded; - self.editButton.hidden = !editable || !isExpanded; - self.expandImage.hidden = !editable; - self.expandImage.image = [UIImage imageNamed:isExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"]; + cd.isCompatibility = NO; + self.isClosed = oh.IsClosed(time(nullptr)); + [self processSchedule]; } else { - cd.mode = MWMPlacePageOpeningHoursDayViewModeEmpty; - self.middleSeparator.hidden = YES; - self.weekDaysView.hidden = YES; - self.editButton.hidden = YES; - self.expandImage.hidden = YES; + cd.isCompatibility = YES; + [cd setCompatibilityText:info]; } + BOOL const isExpanded = delegate.openingHoursCellExpanded; + self.middleSeparator.hidden = !isExpanded; + self.weekDaysView.hidden = !isExpanded; [cd invalidate]; } @@ -107,7 +94,6 @@ WeekDayView getWeekDayView() BOOL const isExpanded = self.delegate.openingHoursCellExpanded; self.weekDaysViewEstimatedHeight = 0.0; [self.weekDaysView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; - [self.currentDay setCanExpand:YES]; for (size_t idx = 0; idx < timeTablesCount; ++idx) { ui::TTimeTableProxy tt = timeTableSet.Get(idx); @@ -122,8 +108,14 @@ WeekDayView getWeekDayView() } if (!haveCurrentDay) [self addEmptyCurrentDay]; - if (haveExpandSchedule && isExpanded) - [self addClosedDays]; + if (haveExpandSchedule) + { + self.toggleButton.hidden = NO; + self.expandImage.hidden = NO; + self.expandImage.image = [UIImage imageNamed:isExpanded ? @"ic_arrow_gray_up" : @"ic_arrow_gray_down"]; + if (isExpanded) + [self addClosedDays]; + } self.weekDaysViewHeight.constant = ceil(self.weekDaysViewEstimatedHeight); } @@ -197,10 +189,9 @@ WeekDayView getWeekDayView() CGFloat height = self.currentDay.viewHeight; if (self.delegate.openingHoursCellExpanded) { - MWMPlacePageOpeningHoursDayViewMode const mode = self.currentDay.mode; - if (mode != MWMPlacePageOpeningHoursDayViewModeEmpty && !self.toggleButton.hidden) - height += self.editButton.height; - if (mode == MWMPlacePageOpeningHoursDayViewModeRegular) + CGFloat const bottomOffset = 12.0; + height += bottomOffset; + if (!self.currentDay.isCompatibility) height += self.weekDaysViewHeight.constant; } return ceil(height); @@ -210,22 +201,7 @@ WeekDayView getWeekDayView() - (IBAction)toggleButtonTap { - switch (self.currentDay.mode) - { - case MWMPlacePageOpeningHoursDayViewModeRegular: - case MWMPlacePageOpeningHoursDayViewModeCompatibility: - [self.delegate setOpeningHoursCellExpanded:!self.delegate.openingHoursCellExpanded forCell:self]; - break; - case MWMPlacePageOpeningHoursDayViewModeEmpty: - [self editButtonTap]; - break; - } -} - -- (IBAction)editButtonTap -{ - [[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatEditTime)]; - [self.delegate editPlaceTime]; + [self.delegate setOpeningHoursCellExpanded:!self.delegate.openingHoursCellExpanded forCell:self]; } @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib index de5bfe668b..8c47b3dbc7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursCell.xib @@ -8,10 +8,10 @@ - + - + @@ -143,7 +143,6 @@ - @@ -167,23 +166,8 @@ - - + @@ -196,7 +180,6 @@ - @@ -205,15 +188,12 @@ - - - diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.h index 0a39f74757..02359a38f7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.h @@ -1,21 +1,13 @@ -typedef NS_ENUM(NSUInteger, MWMPlacePageOpeningHoursDayViewMode) -{ - MWMPlacePageOpeningHoursDayViewModeRegular, - MWMPlacePageOpeningHoursDayViewModeCompatibility, - MWMPlacePageOpeningHoursDayViewModeEmpty -}; - @interface MWMPlacePageOpeningHoursDayView : UIView @property (nonatomic) BOOL currentDay; @property (nonatomic) CGFloat viewHeight; -@property (nonatomic) MWMPlacePageOpeningHoursDayViewMode mode; +@property (nonatomic) BOOL isCompatibility; - (void)setLabelText:(NSString *)text isRed:(BOOL)isRed; - (void)setOpenTimeText:(NSString *)text; - (void)setBreaks:(NSArray *)breaks; - (void)setClosed:(BOOL)closed; -- (void)setCanExpand:(BOOL)canExpand; - (void)setCompatibilityText:(NSString *)text; - (void)invalidate; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.mm index 565e6b2dc2..b839e223f9 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/PlacePage/Cells/OpeningHours/MWMPlacePageOpeningHoursDayView.mm @@ -13,8 +13,6 @@ @property (weak, nonatomic) IBOutlet UILabel * closedLabel; -@property (weak, nonatomic) IBOutlet UIImageView * expandImage; - @property (weak, nonatomic) IBOutlet NSLayoutConstraint * height; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * labelWidth; @property (weak, nonatomic) IBOutlet NSLayoutConstraint * breakLabelWidth; @@ -77,11 +75,6 @@ self.closedLabel.hidden = !closed; } -- (void)setCanExpand:(BOOL)canExpand -{ - self.expandImage.hidden = !canExpand; -} - - (void)setCompatibilityText:(NSString *)text { self.compatibilityLabel.text = text; @@ -90,8 +83,13 @@ - (void)invalidate { CGFloat viewHeight; - BOOL const isRegular = (self.mode == MWMPlacePageOpeningHoursDayViewModeRegular); - if (isRegular) + if (self.isCompatibility) + { + [self.compatibilityLabel sizeToIntegralFit]; + CGFloat const compatibilityLabelVerticalOffsets = 24.0; + viewHeight = self.compatibilityLabel.height + compatibilityLabelVerticalOffsets; + } + else { [self.label sizeToIntegralFit]; self.labelWidth.constant = self.label.width; @@ -107,12 +105,6 @@ if (!self.closedLabel.hidden) viewHeight += heightForClosedLabel; } - else - { - [self.compatibilityLabel sizeToIntegralFit]; - CGFloat const compatibilityLabelVerticalOffsets = 24.0; - viewHeight = self.compatibilityLabel.height + compatibilityLabelVerticalOffsets; - } self.viewHeight = ceil(viewHeight); @@ -137,20 +129,15 @@ } } -- (void)setMode:(MWMPlacePageOpeningHoursDayViewMode)mode +- (void)setIsCompatibility:(BOOL)isCompatibility { - _mode = mode; - BOOL const isRegular = (mode == MWMPlacePageOpeningHoursDayViewModeRegular); - BOOL const isEmpty = (mode == MWMPlacePageOpeningHoursDayViewModeEmpty); - self.compatibilityLabel.hidden = isRegular; - self.label.hidden = !isRegular; - self.openTime.hidden = !isRegular; - self.breakLabel.hidden = !isRegular; - self.breaksHolder.hidden = !isRegular; - self.closedLabel.hidden = !isRegular; - - if (isEmpty) - self.compatibilityLabel.text = L(@"add_opening_hours"); + _isCompatibility = isCompatibility; + self.compatibilityLabel.hidden = !isCompatibility; + self.label.hidden = isCompatibility; + self.openTime.hidden = isCompatibility; + self.breakLabel.hidden = isCompatibility; + self.breaksHolder.hidden = isCompatibility; + self.closedLabel.hidden = isCompatibility; } @end diff --git a/iphone/Maps/Classes/MWMBasePlacePageView.mm b/iphone/Maps/Classes/MWMBasePlacePageView.mm index 08445d6ead..dab4ff60de 100644 --- a/iphone/Maps/Classes/MWMBasePlacePageView.mm +++ b/iphone/Maps/Classes/MWMBasePlacePageView.mm @@ -185,7 +185,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.; [self.typeDescriptionView removeFromSuperview]; self.typeDescriptionView = nil; [self.typeLabel sizeToFit]; - [self.entity insertBookmarkInTypes]; + [self.entity addBookmarkField]; [self configure]; } @@ -194,7 +194,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.; [[Statistics instance] logEvent:kStatEventName(kStatPlacePage, kStatToggleBookmark) withParameters:@{kStatValue : kStatRemove}]; self.entity.type = MWMPlacePageEntityTypeRegular; - [self.entity removeBookmarkFromTypes]; + [self.entity removeBookmarkField]; [self configure]; } @@ -257,47 +257,36 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.; @implementation MWMBasePlacePageView (UITableView) -- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - return 44.0; -} - - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { MWMPlacePageEntity * entity = self.entity; MWMPlacePageMetadataField const field = [entity getFieldType:indexPath.row]; UITableViewCell * cell = [self offscreenCellForIdentifier:[self cellIdentifierForField:field]]; - if (field == MWMPlacePageMetadataFieldBookmark) + if ([cell isKindOfClass:[MWMPlacePageBookmarkCell class]]) { MWMPlacePageBookmarkCell * tCell = (MWMPlacePageBookmarkCell *)cell; [tCell config:self.ownerPlacePage forHeight:YES]; return tCell.cellHeight; } - else if (field == MWMPlacePageMetadataFieldOpenHours) + else if ([cell isKindOfClass:[MWMPlacePageOpeningHoursCell class]]) { MWMPlacePageOpeningHoursCell * tCell = (MWMPlacePageOpeningHoursCell *)cell; - [tCell configWithInfo:[entity getFieldValue:field] - editable:[entity isFieldEditable:field] - delegate:self]; + [tCell configWithInfo:[entity getFieldValue:field] delegate:self]; return tCell.cellHeight; } - else if (field == MWMPlacePageMetadataFieldEditButton) - { - return [MWMPlacePageButtonCell height]; - } - else + else if ([cell isKindOfClass:[MWMPlacePageInfoCell class]]) { MWMPlacePageInfoCell * tCell = (MWMPlacePageInfoCell *)cell; tCell.currentEntity = self.entity; [tCell configureWithType:field info:[entity getFieldValue:field]]; - [tCell setNeedsUpdateConstraints]; - [tCell updateConstraintsIfNeeded]; - tCell.bounds = {{}, {CGRectGetWidth(tableView.bounds), CGRectGetHeight(tCell.bounds)}}; - [tCell setNeedsLayout]; - [tCell layoutIfNeeded]; - CGSize const size = [tCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; - return size.height; } + [cell setNeedsUpdateConstraints]; + [cell updateConstraintsIfNeeded]; + cell.bounds = {{}, {CGRectGetWidth(tableView.bounds), CGRectGetHeight(cell.bounds)}}; + [cell setNeedsLayout]; + [cell layoutIfNeeded]; + CGSize const size = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]; + return size.height; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -316,9 +305,7 @@ extern CGFloat const kBasePlacePageViewTitleBottomOffset = 2.; } else if (field == MWMPlacePageMetadataFieldOpenHours) { - [(MWMPlacePageOpeningHoursCell *)cell configWithInfo:[entity getFieldValue:field] - editable:[entity isFieldEditable:field] - delegate:self]; + [(MWMPlacePageOpeningHoursCell *)cell configWithInfo:[entity getFieldValue:field] delegate:self]; } else if (field == MWMPlacePageMetadataFieldEditButton) { diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.h b/iphone/Maps/Classes/MWMPlacePageButtonCell.h index 260c710133..213eb5875b 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.h +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.h @@ -2,8 +2,6 @@ @interface MWMPlacePageButtonCell : UITableViewCell -+ (CGFloat)height; - - (void)config:(MWMPlacePage *)placePage; @end diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.mm b/iphone/Maps/Classes/MWMPlacePageButtonCell.mm index a6c5744e5f..21ed9cfdc5 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.mm +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.mm @@ -10,11 +10,6 @@ @implementation MWMPlacePageButtonCell -+ (CGFloat)height -{ - return 44.0; -} - - (void)config:(MWMPlacePage *)placePage { self.placePage = placePage; diff --git a/iphone/Maps/Classes/MWMPlacePageButtonCell.xib b/iphone/Maps/Classes/MWMPlacePageButtonCell.xib index cab546b21c..208c193188 100644 --- a/iphone/Maps/Classes/MWMPlacePageButtonCell.xib +++ b/iphone/Maps/Classes/MWMPlacePageButtonCell.xib @@ -16,16 +16,19 @@