[ios] Fixed disappearing navigation bar at the bottom

TODO: Improve the code and fix not beautiful appear animation
Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk 2021-05-22 22:05:30 +02:00 committed by Viktor Govako
parent 553c198171
commit 99c1a621b2
4 changed files with 30 additions and 100 deletions

View file

@ -47,8 +47,8 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MapO
private weak var navigationInfo: MWMNavigationDashboardEntity?
private var hiddenConstraint: NSLayoutConstraint!
private var extendedConstraint: NSLayoutConstraint!
private var notExtendedConstraint: NSLayoutConstraint!
@objc var isVisible = false {
didSet {
guard isVisible != oldValue else { return }
@ -57,13 +57,6 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MapO
} else {
removeView()
}
alpha = isVisible ? 0 : 1
DispatchQueue.main.async {
self.superview?.animateConstraints {
self.alpha = self.isVisible ? 1 : 0
self.hiddenConstraint.isActive = !self.isVisible
}
}
}
}
@ -79,7 +72,13 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MapO
dimBackground.setVisible(isExtended, completion: nil)
extendedView.isHidden = !isExtended
superview!.animateConstraints(animations: {
self.extendedConstraint.isActive = self.isExtended
if (self.isExtended) {
self.notExtendedConstraint.isActive = false
self.extendedConstraint.isActive = true
} else {
self.extendedConstraint.isActive = false
self.notExtendedConstraint.isActive = true
}
})
}
}
@ -88,28 +87,15 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MapO
guard superview != ownerView else { return }
ownerView.addSubview(self)
var lAnchor = ownerView.leadingAnchor
var tAnchor = ownerView.trailingAnchor
var bAnchor = ownerView.bottomAnchor
let layoutGuide = ownerView.safeAreaLayoutGuide
lAnchor = layoutGuide.leadingAnchor
tAnchor = layoutGuide.trailingAnchor
bAnchor = layoutGuide.bottomAnchor
let lg = ownerView.safeAreaLayoutGuide
leadingAnchor.constraint(equalTo: lg.leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: lg.trailingAnchor).isActive = true
leadingAnchor.constraint(equalTo: lAnchor).isActive = true
trailingAnchor.constraint(equalTo: tAnchor).isActive = true
extendedConstraint = bottomAnchor.constraint(equalTo: lg.bottomAnchor)
extendedConstraint.isActive = false
hiddenConstraint = topAnchor.constraint(equalTo: ownerView.bottomAnchor)
hiddenConstraint.isActive = true
let visibleConstraint = progressView.bottomAnchor.constraint(equalTo: bAnchor)
visibleConstraint.priority = UILayoutPriority.defaultLow
visibleConstraint.isActive = true
extendedConstraint = bottomAnchor.constraint(equalTo: bAnchor)
extendedConstraint.priority = UILayoutPriority(rawValue: UILayoutPriority.RawValue(Int(UILayoutPriority.defaultHigh.rawValue) - 1))
ownerView.layoutIfNeeded()
notExtendedConstraint = progressView.bottomAnchor.constraint(equalTo: lg.bottomAnchor)
notExtendedConstraint.isActive = true
}
private func removeView() {
@ -120,7 +106,6 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MapO
override func awakeFromNib() {
super.awakeFromNib()
translatesAutoresizingMaskIntoConstraints = false
updateLegendSize()

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina3_5" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@ -14,9 +14,8 @@
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="9fq-65-qd9" customClass="MWMNavigationControlView" propertyAccessControl="none">
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9fq-65-qd9" customClass="MWMNavigationControlView" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="320" height="116"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jBZ-WO-Nz7">
<rect key="frame" x="-100" y="0.0" width="520" height="216"/>

View file

@ -35,7 +35,6 @@ final class BaseRoutePreviewStatus: SolidTouchView {
@IBOutlet private var manageRouteBoxBottom: NSLayoutConstraint!
@IBOutlet private var heightBoxBottomManageRouteBoxTop: NSLayoutConstraint!
private var hiddenConstraint: NSLayoutConstraint!
@objc weak var ownerView: UIView!
weak var navigationInfo: MWMNavigationDashboardEntity?
@ -51,16 +50,8 @@ final class BaseRoutePreviewStatus: SolidTouchView {
guard isVisible != oldValue else { return }
if isVisible {
addView()
}
DispatchQueue.main.async {
guard let sv = self.superview else { return }
sv.animateConstraints(animations: {
self.hiddenConstraint.isActive = !self.isVisible
}, completion: {
if !self.isVisible {
self.removeFromSuperview()
}
})
} else {
self.removeFromSuperview()
}
}
}
@ -69,29 +60,10 @@ final class BaseRoutePreviewStatus: SolidTouchView {
guard superview != ownerView else { return }
ownerView.addSubview(self)
addConstraints()
}
private func addConstraints() {
var lAnchor = ownerView.leadingAnchor
var tAnchor = ownerView.trailingAnchor
var bAnchor = ownerView.bottomAnchor
let layoutGuide = ownerView.safeAreaLayoutGuide
lAnchor = layoutGuide.leadingAnchor
tAnchor = layoutGuide.trailingAnchor
bAnchor = layoutGuide.bottomAnchor
leadingAnchor.constraint(equalTo: lAnchor).isActive = true
trailingAnchor.constraint(equalTo: tAnchor).isActive = true
hiddenConstraint = topAnchor.constraint(equalTo: bAnchor)
hiddenConstraint.priority = UILayoutPriority.defaultHigh
hiddenConstraint.isActive = true
let visibleConstraint = bottomAnchor.constraint(equalTo: bAnchor)
visibleConstraint.priority = UILayoutPriority.defaultLow
visibleConstraint.isActive = true
ownerView.layoutIfNeeded()
let lg = ownerView.safeAreaLayoutGuide
leadingAnchor.constraint(equalTo: lg.leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: lg.trailingAnchor).isActive = true
bottomAnchor.constraint(equalTo: lg.bottomAnchor).isActive = true
}
private func updateHeight() {

View file

@ -4,7 +4,6 @@ final class TransportRoutePreviewStatus: SolidTouchView {
@IBOutlet private weak var stepsCollectionView: TransportTransitStepsCollectionView!
@IBOutlet private weak var stepsCollectionViewHeight: NSLayoutConstraint!
private var hiddenConstraint: NSLayoutConstraint!
@objc weak var ownerView: UIView!
weak var navigationInfo: MWMNavigationDashboardEntity?
@ -14,16 +13,8 @@ final class TransportRoutePreviewStatus: SolidTouchView {
guard isVisible != oldValue else { return }
if isVisible {
addView()
}
DispatchQueue.main.async {
guard let sv = self.superview else { return }
sv.animateConstraints(animations: {
self.hiddenConstraint.isActive = !self.isVisible
}, completion: {
if !self.isVisible {
self.removeFromSuperview()
}
})
} else {
self.removeFromSuperview()
}
}
}
@ -32,27 +23,10 @@ final class TransportRoutePreviewStatus: SolidTouchView {
guard superview != ownerView else { return }
ownerView.addSubview(self)
addConstraints()
}
private func addConstraints() {
var lAnchor = ownerView.leadingAnchor
var tAnchor = ownerView.trailingAnchor
var bAnchor = ownerView.bottomAnchor
let layoutGuide = ownerView.safeAreaLayoutGuide
lAnchor = layoutGuide.leadingAnchor
tAnchor = layoutGuide.trailingAnchor
bAnchor = layoutGuide.bottomAnchor
leadingAnchor.constraint(equalTo: lAnchor).isActive = true
trailingAnchor.constraint(equalTo: tAnchor).isActive = true
hiddenConstraint = topAnchor.constraint(equalTo: bAnchor)
hiddenConstraint.priority = UILayoutPriority.defaultHigh
hiddenConstraint.isActive = true
let visibleConstraint = bottomAnchor.constraint(equalTo: bAnchor)
visibleConstraint.priority = UILayoutPriority.defaultLow
visibleConstraint.isActive = true
let lg = ownerView.safeAreaLayoutGuide
leadingAnchor.constraint(equalTo: lg.leadingAnchor).isActive = true
trailingAnchor.constraint(equalTo: lg.trailingAnchor).isActive = true
bottomAnchor.constraint(equalTo: lg.bottomAnchor).isActive = true
}
@objc func hide() {