[iOS] refresh bookmark section in PP after bookmark editing.

Fix bookmark section layout issues
This commit is contained in:
Aleksey Belousov 2020-04-10 05:02:30 +03:00 committed by Vladimir Byko-Ianko
parent fc70d6832f
commit 707d82b1dc
13 changed files with 63 additions and 25 deletions

View file

@ -61,7 +61,7 @@
47942D98237D675400DEFAE3 /* CatalogPromoItem+Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 47942D96237D675400DEFAE3 /* CatalogPromoItem+Core.h */; settings = {ATTRIBUTES = (Public, ); }; };
47942D9C237D927800DEFAE3 /* PlacePageBookmarkData.h in Headers */ = {isa = PBXBuildFile; fileRef = 47942D9A237D927800DEFAE3 /* PlacePageBookmarkData.h */; settings = {ATTRIBUTES = (Public, ); }; };
47942D9D237D927800DEFAE3 /* PlacePageBookmarkData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 47942D9B237D927800DEFAE3 /* PlacePageBookmarkData.mm */; };
47942DA0237D954400DEFAE3 /* PlacePageBookmarkData+Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 47942D9E237D954400DEFAE3 /* PlacePageBookmarkData+Core.h */; };
47942DA0237D954400DEFAE3 /* PlacePageBookmarkData+Core.h in Headers */ = {isa = PBXBuildFile; fileRef = 47942D9E237D954400DEFAE3 /* PlacePageBookmarkData+Core.h */; settings = {ATTRIBUTES = (Public, ); }; };
47942DAB237ED9FE00DEFAE3 /* IOpeningHoursLocalization.h in Headers */ = {isa = PBXBuildFile; fileRef = 47942DAA237ED9FE00DEFAE3 /* IOpeningHoursLocalization.h */; settings = {ATTRIBUTES = (Public, ); }; };
47942DAE2382ABE100DEFAE3 /* UgcSummaryRating.h in Headers */ = {isa = PBXBuildFile; fileRef = 47942DAC2382ABE100DEFAE3 /* UgcSummaryRating.h */; settings = {ATTRIBUTES = (Public, ); }; };
47942DAF2382ABE100DEFAE3 /* UgcSummaryRating.mm in Sources */ = {isa = PBXBuildFile; fileRef = 47942DAD2382ABE100DEFAE3 /* UgcSummaryRating.mm */; };

View file

@ -7,6 +7,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface PlacePageBookmarkData (Core)
- (instancetype)initWithRawData:(place_page::Info const &)rawData;
- (kml::ColorData)kmlColor;
@end

View file

@ -1,5 +1,11 @@
#import "PlacePageBookmarkData+Core.h"
@interface PlacePageBookmarkData() {
kml::ColorData _kmlColor;
}
@end
@implementation PlacePageBookmarkData
@end
@ -16,8 +22,13 @@
_bookmarkCategory = rawData.IsBookmark() ? @(rawData.GetBookmarkCategoryName().c_str()) : nil;
_isHtmlDescription = strings::IsHTML(GetPreferredBookmarkStr(rawData.GetBookmarkData().m_description));
_isEditable = GetFramework().GetBookmarkManager().IsEditableBookmark(_bookmarkId);
_kmlColor = rawData.GetBookmarkData().m_color;
}
return self;
}
- (kml::ColorData)kmlColor {
return _kmlColor;
}
@end

View file

@ -1,5 +1,9 @@
#import "MWMTableViewController.h"
@class PlacePageData;
@interface MWMEditBookmarkController : MWMTableViewController
@property(strong, nonatomic) PlacePageData *placePageData;
@end

View file

@ -6,6 +6,10 @@
#import "SelectSetVC.h"
#import "SwiftBridge.h"
#import <CoreApi/PlacePageData.h>
#import <CoreApi/PlacePageBookmarkData+Core.h>
#import <CoreApi/PlacePagePreviewData.h>
#include <CoreApi/Framework.h>
namespace
@ -49,13 +53,12 @@ enum RowInMetaInfo
{
[super viewDidLoad];
self.cachedNewBookmarkCatId = kml::kInvalidMarkGroupId;
auto const & info = GetFramework().GetCurrentPlacePageInfo();
self.cachedDescription = @(GetPreferredBookmarkStr(info.GetBookmarkData().m_description).c_str());
self.cachedTitle = info.GetTitle().empty() ? nil : @(info.GetTitle().c_str());
self.cachedCategory = @(info.GetBookmarkCategoryName().c_str());
self.cachedColor = info.GetBookmarkData().m_color.m_predefinedColor;
m_cachedBookmarkId = info.GetBookmarkId();
m_cachedBookmarkCatId = info.GetBookmarkCategoryId();
self.cachedDescription = self.placePageData.bookmarkData.bookmarkDescription;
self.cachedTitle = self.placePageData.previewData.title;
self.cachedCategory = self.placePageData.bookmarkData.bookmarkCategory;
self.cachedColor = [self.placePageData.bookmarkData kmlColor].m_predefinedColor;
m_cachedBookmarkId = self.placePageData.bookmarkData.bookmarkId;
m_cachedBookmarkCatId = self.placePageData.bookmarkData.bookmarkGroupId;
[self configNavBar];
[self registerCells];
}
@ -108,6 +111,7 @@ enum RowInMetaInfo
bookmark->SetCustomName(self.cachedTitle.UTF8String);
f.UpdatePlacePageInfoForCurrentSelection();
[self.placePageData updateBookmarkStatus];
[self goBack];
}

View file

@ -6,6 +6,7 @@ class PlacePageBookmarkViewController: UIViewController {
@IBOutlet var stackView: UIStackView!
@IBOutlet var spinner: UIImageView!
@IBOutlet var editButton: UIButton!
@IBOutlet var topConstraint: NSLayoutConstraint!
@IBOutlet var expandableLabel: ExpandableLabel! {
didSet {
expandableLabel.font = UIFont.regular14()
@ -34,9 +35,13 @@ class PlacePageBookmarkViewController: UIViewController {
if let description = bookmarkData.bookmarkDescription {
if bookmarkData.isHtmlDescription {
setHtmlDescription(description)
topConstraint.constant = 16
} else {
expandableLabel.text = description
topConstraint.constant = description.count > 0 ? 16 : 0
}
} else {
topConstraint.constant = 0
}
}

View file

@ -461,7 +461,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="4pU-ex-66e">
<rect key="frame" x="16" y="0.0" width="343" height="147"/>
<rect key="frame" x="16" y="16" width="343" height="131"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" relation="lessThanOrEqual" constant="150" id="E6c-1w-LKj"/>
@ -499,7 +499,7 @@
<constraint firstItem="soI-1J-JL6" firstAttribute="leading" secondItem="99j-36-7TK" secondAttribute="leading" constant="16" id="Vac-L0-pTZ"/>
<constraint firstAttribute="bottom" secondItem="soI-1J-JL6" secondAttribute="bottom" id="XvI-Sc-kIL"/>
<constraint firstAttribute="trailing" secondItem="4pU-ex-66e" secondAttribute="trailing" constant="16" id="bVa-3L-AtD"/>
<constraint firstItem="4pU-ex-66e" firstAttribute="top" secondItem="99j-36-7TK" secondAttribute="top" id="f7d-q9-70I"/>
<constraint firstItem="4pU-ex-66e" firstAttribute="top" secondItem="99j-36-7TK" secondAttribute="top" constant="16" id="f7d-q9-70I"/>
<constraint firstItem="soI-1J-JL6" firstAttribute="top" secondItem="4pU-ex-66e" secondAttribute="bottom" id="i4f-1B-jfo"/>
<constraint firstAttribute="trailing" secondItem="soI-1J-JL6" secondAttribute="trailing" constant="16" id="tu6-L8-fUt"/>
</constraints>
@ -2804,17 +2804,17 @@
</userDefinedRuntimeAttributes>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="iB6-kj-Bi1">
<rect key="frame" x="16" y="1" width="343" height="199"/>
<rect key="frame" x="16" y="17" width="343" height="183"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5nz-eA-gNS" customClass="ExpandableLabel" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="343" height="155"/>
<view contentMode="scaleToFill" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5nz-eA-gNS" customClass="ExpandableLabel" customModule="maps_me" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="343" height="139"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Background"/>
</userDefinedRuntimeAttributes>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wB7-XJ-Nck">
<rect key="frame" x="0.0" y="155" width="343" height="44"/>
<rect key="frame" x="0.0" y="139" width="343" height="44"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XR5-Np-W07">
<rect key="frame" x="0.0" y="0.0" width="343" height="44"/>
@ -2866,7 +2866,7 @@
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Ygp-O9-RnI" secondAttribute="trailing" id="6G3-el-OLU"/>
<constraint firstItem="iB6-kj-Bi1" firstAttribute="top" secondItem="G5y-H6-EfE" secondAttribute="bottom" id="Afw-Mq-NV9"/>
<constraint firstItem="iB6-kj-Bi1" firstAttribute="top" secondItem="G5y-H6-EfE" secondAttribute="bottom" constant="16" id="Afw-Mq-NV9"/>
<constraint firstAttribute="bottom" secondItem="Ygp-O9-RnI" secondAttribute="bottom" id="FWu-Cg-vld"/>
<constraint firstItem="Ygp-O9-RnI" firstAttribute="leading" secondItem="bRD-Uv-Uak" secondAttribute="leading" id="OVz-qv-hfp"/>
<constraint firstAttribute="bottom" secondItem="iB6-kj-Bi1" secondAttribute="bottom" id="QQY-yn-M6D"/>
@ -2887,6 +2887,7 @@
<outlet property="expandableLabel" destination="5nz-eA-gNS" id="iui-Iu-EiB"/>
<outlet property="spinner" destination="OUV-mg-G9u" id="7Og-Ix-dr7"/>
<outlet property="stackView" destination="iB6-kj-Bi1" id="CSH-xH-X4b"/>
<outlet property="topConstraint" destination="Afw-Mq-NV9" id="Oth-ao-05T"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="fcE-Xu-odc" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

View file

@ -183,7 +183,7 @@ extension PlacePageInteractor: CatalogGalleryViewControllerDelegate {
extension PlacePageInteractor: PlacePageBookmarkViewControllerDelegate {
func bookmarkDidPressEdit() {
MWMPlacePageManagerHelper.editBookmark()
MWMPlacePageManagerHelper.editBookmark(placePageData)
}
}

View file

@ -1,6 +1,7 @@
#import "MWMPlacePageManager.h"
#import "CLLocation+Mercator.h"
#import "MWMActivityViewController.h"
#import "MWMEditBookmarkController.h"
#import "MWMLocationHelpers.h"
#import "MWMLocationObserver.h"
#import "MWMRoutePoint+CPP.h"
@ -288,8 +289,11 @@ void RegisterEventIfPossible(eye::MapObject::Event::Type const type)
}
}
- (void)editBookmark {
[self.ownerViewController openBookmarkEditor];
- (void)editBookmark:(PlacePageData *)data {
MWMEditBookmarkController *editBookmarkController = [[UIStoryboard instance:MWMStoryboardMain]
instantiateViewControllerWithIdentifier:@"MWMEditBookmarkController"];
editBookmarkController.placePageData = data;
[[MapViewController sharedController].navigationController pushViewController:editBookmarkController animated:YES];
}
- (void)showPlaceDescription:(NSString *)htmlString

View file

@ -27,7 +27,7 @@
+ (void)openCatalogMoreItems:(PlacePageData *)data;
+ (void)addBookmark:(PlacePageData *)data;
+ (void)removeBookmark:(PlacePageData *)data;
+ (void)editBookmark;
+ (void)editBookmark:(PlacePageData *)data;
+ (void)openPartner:(PlacePageData *)data;
+ (void)book:(PlacePageData *)data;
+ (void)share:(PlacePageData *)data;

View file

@ -29,7 +29,7 @@
- (void)openCatalogMoreItems:(PlacePageData *)data;
- (void)addBookmark:(PlacePageData *)data;
- (void)removeBookmark:(PlacePageData *)data;
- (void)editBookmark;
- (void)editBookmark:(PlacePageData *)data;
- (void)openPartner:(PlacePageData *)data;
- (void)book:(PlacePageData *)data;
- (void)share:(PlacePageData *)data;
@ -125,8 +125,8 @@
[[MWMMapViewControlsManager manager].placePageManager removeBookmark:data];
}
+ (void)editBookmark {
[[MWMMapViewControlsManager manager].placePageManager editBookmark];
+ (void)editBookmark:(PlacePageData *)data {
[[MWMMapViewControlsManager manager].placePageManager editBookmark:data];
}
+ (void)openPartner:(PlacePageData *)data {

View file

@ -52,6 +52,12 @@ final class ExpandableLabel: UIView {
}
}
override func setContentHuggingPriority(_ priority: UILayoutPriority, for axis: NSLayoutConstraint.Axis) {
super.setContentHuggingPriority(priority, for: axis)
textLabel.setContentHuggingPriority(priority, for: axis)
expandLabel.setContentHuggingPriority(priority, for: axis)
}
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
@ -71,6 +77,8 @@ final class ExpandableLabel: UIView {
textLabel.textColor = textColor
textLabel.text = text
textLabel.attributedText = attributedText
textLabel.setContentHuggingPriority(contentHuggingPriority(for: .vertical), for: .vertical)
expandLabel.setContentHuggingPriority(contentHuggingPriority(for: .vertical), for: .vertical)
expandLabel.font = font
expandLabel.textColor = expandColor
expandLabel.text = expandText

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Wns-nH-AQU">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Wns-nH-AQU">
<device id="retina4_7" orientation="landscape" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -242,7 +242,7 @@
<!--Edit Bookmark Controller-->
<scene sceneID="jjY-Mo-EIt">
<objects>
<tableViewController id="lFr-lA-JTW" customClass="MWMEditBookmarkController" sceneMemberID="viewController">
<tableViewController storyboardIdentifier="MWMEditBookmarkController" id="lFr-lA-JTW" customClass="MWMEditBookmarkController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="Rb3-ea-7LJ">
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>