Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Grechuhin <i.grechuhin@gmail.com>2017-10-26 16:29:20 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2017-11-09 13:20:24 +0300
commit243cb104827b36490a6e898f932b681c08f01681 (patch)
treef227ecdb615cb587992f17457e14c7be8eb4ae05 /iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC
parent0a34c7c185ca8257cc68bd40ea67075cccfd5d10 (diff)
[release-76-ios-xc] [ios] Fixed crash on iOS 9.
Diffstat (limited to 'iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC')
-rw-r--r--iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.swift33
-rw-r--r--iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib6
2 files changed, 8 insertions, 31 deletions
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.swift
index 4f23f6ac72..58ea64e0f1 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.swift
+++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.swift
@@ -2,9 +2,6 @@
final class UGCYourReviewCell: MWMTableViewCell {
private enum Config {
static let defaultReviewBottomOffset: CGFloat = 16
- static let minimumInteritemSpacing: CGFloat = 16
- static let minItemsPerRow: CGFloat = 3
- static let estimatedItemSize = CGSize(width: 96, height: 32)
}
@IBOutlet private weak var titleLabel: UILabel! {
@@ -36,8 +33,6 @@ final class UGCYourReviewCell: MWMTableViewCell {
@IBOutlet private weak var ratingCollectionView: UICollectionView! {
didSet {
ratingCollectionView.register(cellClass: UGCSummaryRatingStarsCell.self)
- let layout = ratingCollectionView.collectionViewLayout as! UICollectionViewFlowLayout
- layout.estimatedItemSize = Config.estimatedItemSize
}
}
@@ -46,7 +41,7 @@ final class UGCYourReviewCell: MWMTableViewCell {
override var frame: CGRect {
didSet {
if frame.size != oldValue.size {
- updateCollectionView(nil)
+ updateCollectionView()
}
}
}
@@ -57,36 +52,18 @@ final class UGCYourReviewCell: MWMTableViewCell {
reviewLabel.text = yourReview.text
reviewBottomOffset.constant = yourReview.text.isEmpty ? 0 : Config.defaultReviewBottomOffset
reviewLabel.onUpdate = onUpdate
- updateCollectionView { [weak self] in
- self?.ratingCollectionView.reloadSections(IndexSet(integer: 0))
- }
+ updateCollectionView()
isSeparatorHidden = true
}
override func didMoveToSuperview() {
super.didMoveToSuperview()
- updateCollectionView(nil)
+ updateCollectionView()
}
- private func updateCollectionView(_ updates: (() -> Void)?) {
- guard let sv = superview else { return }
+ private func updateCollectionView() {
DispatchQueue.main.async {
- let layout = self.ratingCollectionView.collectionViewLayout as! UICollectionViewFlowLayout
- let inset = layout.sectionInset
- let viewWidth = sv.size.width - inset.left - inset.right
- let maxItemWidth = layout.estimatedItemSize.width
-
- let ratingsCount = CGFloat(self.yourReview?.ratings.count ?? 0)
- let itemsPerRow = floor(min(max(viewWidth / maxItemWidth, Config.minItemsPerRow), ratingsCount))
- let itemWidth = floor(min((viewWidth - (itemsPerRow - 1) * Config.minimumInteritemSpacing) / itemsPerRow, maxItemWidth))
- let interitemSpacing = floor((viewWidth - itemWidth * itemsPerRow) / (itemsPerRow - 1))
- layout.minimumInteritemSpacing = interitemSpacing
- layout.itemSize = CGSize(width: itemWidth, height: Config.estimatedItemSize.height)
-
- assert(itemsPerRow > 0);
- let rowsCount = ceil(ratingsCount / itemsPerRow)
- self.ratingCollectionViewHeight.constant = rowsCount * Config.estimatedItemSize.height + (rowsCount - 1) * layout.minimumLineSpacing + inset.top + inset.bottom
- self.ratingCollectionView.performBatchUpdates(updates, completion: nil)
+ self.ratingCollectionView.reloadData()
}
}
}
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib
index 50e78095d7..eb086875ae 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib
+++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCYourReviewCell.xib
@@ -5,7 +5,7 @@
</device>
<dependencies>
<deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13174"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@@ -63,13 +63,13 @@
<constraint firstItem="nht-6C-S3i" firstAttribute="top" secondItem="M3q-L0-4Y7" secondAttribute="top" constant="16" id="v5J-lZ-cdA"/>
</constraints>
</view>
- <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" prefetchingEnabled="NO" translatesAutoresizingMaskIntoConstraints="NO" id="w6j-GC-6Bv">
+ <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" pagingEnabled="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" prefetchingEnabled="NO" translatesAutoresizingMaskIntoConstraints="NO" id="w6j-GC-6Bv">
<rect key="frame" x="0.0" y="135" width="320" height="55.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" priority="999" constant="56" id="2hn-mr-UAw"/>
</constraints>
- <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="12" minimumInteritemSpacing="16" id="MWR-PM-MMO">
+ <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="12" minimumInteritemSpacing="16" id="MWR-PM-MMO">
<size key="itemSize" width="120" height="32"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>