8000 [ios] Fix PP editing animation and background shadow · organicmaps/organicmaps@d005eb7 · GitHub
[go: up one dir, main page]

Skip to content

Commit d005eb7

Browse files
committed
[ios] Fix PP editing animation and background shadow
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
1 parent fc0016d commit d005eb7

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

iphone/Maps/Core/Theme/PlacePageStyleSheet.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,13 @@ extension PlacePageStyleSheet: IStyleSheet {
125125
case .ppBackgroundView:
126126
return .addFrom(GlobalStyleSheet.modalSheetBackground) { s in
127127
s.backgroundColor = colors.pressBackground
128-
s.maskedCorners = isiPad ? CACornerMask.all : [.layerMinXMinYCorner, .layerMaxXMinYCorner]
129-
s.clip = false
128+
s.maskedCorners = .all
130129
}
131130
case .ppView:
132131
return .add { s in
133-
s.backgroundColor = colors.clear
132+
s.backgroundColor = .clear
133+
s.maskedCorners = .all
134+
s.cornerRadius = .modalSheet
134135
s.clip = true
135136
}
136137
case .ppHeaderCircleIcon:

iphone/Maps/UI/PlacePage/PlacePage.storyboard

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24128" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bX8-ZQ-XDA">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24412" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bX8-ZQ-XDA">
33
<device id="retina4_7" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24063"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24405"/>
77
<capability name="Named colors" minToolsVersion="9.0"/>
88
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
99
<capability name="Stack View standard spacing" minToolsVersion="9.0"/>
@@ -19,7 +19,7 @@
1919
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
2020
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2121
<subviews>
22-
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" bouncesZoom="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dJ0-97-CDh" customClass="PlacePageScrollView" customModule="Organic_Maps" customModuleProvider="target">
22+
<scrollView multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" bouncesZoom="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dJ0-97-CDh" customClass="PlacePageScrollView" customModule="Organic_Maps" customModuleProvider="target">
2323
<rect key="frame" x="0.0" y="20" width="375" height="597"/>
2424
<subviews>
2525
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="24" translatesAutoresizingMaskIntoConstraints="NO" id="bsv-S8-EiF">
@@ -38,9 +38,6 @@
3838
</constraints>
3939
<viewLayoutGuide key="contentLayoutGuide" id="VD0-9k-Kda"/>
4040
<viewLayoutGuide key="frameLayoutGuide" id="fDP-bR-gGe"/>
41-
<userDefinedRuntimeAttributes>
42-
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="PPView"/>
43-
</userDefinedRuntimeAttributes>
4441
<connections>
4542
<outlet property="delegate" destination="bX8-ZQ-XDA" id="ASo-bI-N1l"/>
4643
</connections>
@@ -1092,13 +1089,13 @@
10921089
<rect key="frame" x="0.0" y="0.0" width="293" height="60"/>
10931090
<subviews>
10941091
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillProportionally" spacing="2" translatesAutoresizingMaskIntoConstraints="NO" id="tDA-E0-cFj">
1095-
<rect key="frame" x="16" y="16" width="277" height="38"/>
1092+
<rect key="frame" x="16" y="18" width="277" height="34"/>
10961093
<subviews>
10971094
<view contentMode="scaleToFill" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="FPZ-be-cyu" userLabel="Title Container">
1098-
<rect key="frame" x="0.0" y="0.0" width="277" height="36"/>
1095+
<rect key="frame" x="0.0" y="0.0" width="277" height="32"/>
10991096
<subviews>
11001097
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" verticalCompressionResistancePriority="1000" bounces="NO" scrollEnabled="NO" bouncesZoom="NO" text="Title" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="ct0-4B-Xfk">
1101-
<rect key="frame" x="0.0" y="0.0" width="255" height="36"/>
1098+
<rect key="frame" x="0.0" y="0.0" width="255" height="32"/>
11021099
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
11031100
<color key="textColor" systemColor="labelColor"/>
11041101
<fontDescription key="fontDescription" type="system" pointSize="14"/>
@@ -1124,7 +1121,7 @@
11241121
</constraints>
11251122
</view>
11261123
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4iT-AD-Eyf">
1127-
<rect key="frame" x="0.0" y="38" width="277" height="0.0"/>
1124+
<rect key="frame" x="0.0" y="34" width="277" height="0.0"/>
11281125
<fontDescription key="fontDescription" type="system" pointSize="17"/>
11291126
<nil key="textColor"/>
11301127
<nil key="highlightedColor"/>
@@ -1134,8 +1131,8 @@
11341131
</subviews>
11351132
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
11361133
<constraints>
1137-
<constraint firstItem="tDA-E0-cFj" firstAttribute="top" secondItem="Gdy-g5-gbM" secondAttribute="top" constant="16" id="O3l-MB-Z1R"/>
1138-
<constraint firstAttribute="bottom" secondItem="tDA-E0-cFj" secondAttribute="bottom" constant="6" id="X9o-Cb-aOD"/>
1134+
<constraint firstItem="tDA-E0-cFj" firstAttribute="top" secondItem="Gdy-g5-gbM" secondAttribute="top" constant="18" id="O3l-MB-Z1R"/>
1135+
<constraint firstAttribute="bottom" secondItem="tDA-E0-cFj" secondAttribute="bottom" constant="8" id="X9o-Cb-aOD"/>
11391136
<constraint firstAttribute="trailing" secondItem="tDA-E0-cFj" secondAttribute="trailing" id="u8l-Jl-e3m"/>
11401137
<constraint firstItem="tDA-E0-cFj" firstAttribute="leading" secondItem="Gdy-g5-gbM" secondAttribute="leading" constant="16" id="vm7-Hr-ryU"/>
11411138
</constraints>
@@ -1191,7 +1188,7 @@
11911188
</userDefinedRuntimeAttributes>
11921189
</view>
11931190
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" horizontalCompressionResistancePriority="1000" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zrr-8j-bGC" userLabel="Cancel Buton">
1194-
<rect key="frame" x="293" y="17" width="70" height="30"/>
1191+
<rect key="frame" x="293" y="19" width="70" height="30"/>
11951192
<fontDescription key="fontDescription" type="system" pointSize="15"/>
11961193
<color key="tintColor" name="AccentColor"/>
11971194
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>

iphone/Maps/UI/PlacePage/PlacePageViewController.swift

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ final class PlacePageScrollView: UIScrollView {
6464

6565
override func viewDidLayoutSubviews() {
6666
super.viewDidLayoutSubviews()
67-
guard !self.layout.headerViewController.isEditingTitle else { return }
67+
guard !layout.headerViewController.isEditingTitle else { return }
6868
if #available(iOS 13.0, *) {
6969
// See https://github.com/organicmaps/organicmaps/issues/6917 for the details.
7070
} else if previousTraitCollection == nil {
@@ -74,6 +74,7 @@ final class PlacePageScrollView: UIScrollView {
7474
}
7575
panGesture.isEnabled = alternativeSizeClass(iPhone: false, iPad: true)
7676
previousTraitCollection = traitCollection
77+
updateBackgroundViewFrame()
7778
}
7879

7980
override func viewDidAppear(_ animated: Bool) {
@@ -163,13 +164,16 @@ final class PlacePageScrollView: UIScrollView {
163164
}
164165

165166
private func setupView() {
166-
headerStackView.axis = .vertical
167-
headerStackView.distribution = .fill
167+
view.insertSubview(backgroundView, at: 0)
168+
backgroundView.setStyle(.ppBackgroundView)
168169

169170
scrollView.decelerationRate = .fast
170-
scrollView.backgroundColor = .clear
171+
scrollView.setStyle(.ppView)
171172

172-
stackView.setStyle(.ppBackgroundView)
173+
headerStackView.axis = .vertical
174+
headerStackView.distribution = .fill
175+
176+
stackView.backgroundColor = .clear
173177

174178
if isiPad {
175179
let bottomCorners: CACornerMask = [.layerMinXMaxYCorner, .layerMaxXMaxYCorner]
@@ -193,6 +197,7 @@ final class PlacePageScrollView: UIScrollView {
193197
fillHeader(with: layout.headerViewControllers, showSeparator: showSeparator)
194198
fillBody(with: layout.bodyViewControllers, showSeparator: showSeparator)
195199

200+
scrollView.isScrollEnabled = true
196201
beginDragging = false
197202
if let actionBar = layout.actionBar {
198203
hideActionBar(false)
@@ -288,6 +293,7 @@ final class PlacePageScrollView: UIScrollView {
288293
}
289294
ModalPresentationAnimator.animate(animations: { [weak scrollView] in
290295
scrollView?.contentOffset = contentOffset
296+
self.updateBackgroundViewFrame()
291297
self.layoutIfNeeded()
292298
}, completion: { complete in
293299
if complete {
@@ -296,6 +302,7 @@ final class PlacePageScrollView: UIScrollView {
296302
})
297303
} else {
298304
scrollView?.contentOffset = contentOffset
305+
self.updateBackgroundViewFrame()
299306
completion?()
300307
}
301308
}
@@ -314,6 +321,13 @@ final class PlacePageScrollView: UIScrollView {
314321
self.interactor?.updateVisibleAreaInsets(insets)
315322
}, iPad: {})
316323
}
324+
325+
private func updateBackgroundViewFrame() {
326+
backgroundView.frame = CGRect(x: 0,
327+
y: max(scrollView.origin.y, -scrollView.contentOffset.y),
328+
width: scrollView.width,
329+
height: stackView.height + actionBarContainerView.height)
330+
}
317331
}
318332

319333
// MARK: - PlacePageViewProtocol
@@ -368,6 +382,7 @@ extension PlacePageViewController: PlacePageViewProtocol {
368382
}
369383

370384
func showNextStop() {
385+
guard scrollView.isScrollEnabled else { return }
371386
if let nextStop = scrollSteps.last(where: { $0.offset > scrollView.contentOffset.y }) {
372387
scrollTo(CGPoint(x: 0, y: nextStop.offset), forced: true)
373388
}
@@ -407,6 +422,7 @@ extension PlacePageViewController: UIScrollViewDelegate {
407422
interactor?.close()
408423
}
409424
onOffsetChanged(scrollView.contentOffset.y)
425+
updateBackgroundViewFrame()
410426
}
411427

412428
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
@@ -465,7 +481,7 @@ extension PlacePageViewController: UIScrollViewDelegate {
465481

466482
extension PlacePageViewController: MWMKeyboardObserver {
467483
func onKeyboardWillAnimate() {
468-
guard !isiPad else { return }
484+
guard !isiPad, isVisible else { return }
469485
scrollView.contentOffset = contentOffsetForTitleEditing()
470486
}
471487

0 commit comments

Comments
 (0)
0