mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 14:13:45 +00:00
[ios] Fix hang on launch in certain conditions related to the main buttons
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
committed by
Yannik Bloscheck
parent
8520f32f2d
commit
db6ad05406
@@ -89,11 +89,9 @@ NSArray<UIImage *> *imagesWithName(NSString *name) {
|
||||
auto const fitInAvailableArea = CGRectGetMaxY(self.view.frame) < CGRectGetMaxY(availableArea) + kTopOffset;
|
||||
auto const shouldHide = self.hidden || !fitInAvailableArea;
|
||||
auto const leftOffset = shouldHide ? -self.view.width : availableArea.origin.x + kViewControlsOffsetToBounds;
|
||||
[self.view.superview animateConstraintsWithAnimations:^{
|
||||
self.topOffset.constant = availableArea.origin.y + kTopOffset;
|
||||
self.leftOffset.constant = leftOffset;
|
||||
self.view.alpha = shouldHide ? 0 : 1;
|
||||
}];
|
||||
self.topOffset.constant = availableArea.origin.y + kTopOffset;
|
||||
self.leftOffset.constant = leftOffset;
|
||||
self.view.alpha = shouldHide ? 0 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ extension Settings {
|
||||
case .addPlace:
|
||||
return UIImage(systemName: "plus", withConfiguration: configuration)!
|
||||
case .recordTrack:
|
||||
return UIImage.MainButtons.LeftButton.recordTrack.withConfiguration(configuration)
|
||||
return UIImage(systemName: "record.circle", withConfiguration: configuration)!
|
||||
case .settings:
|
||||
return UIImage(systemName: "gearshape.fill", withConfiguration: UIImage.SymbolConfiguration(pointSize: 22, weight: .semibold))!
|
||||
case .help:
|
||||
|
||||
@@ -24,9 +24,6 @@ class BottomTabBarButtonRenderer {
|
||||
if let coloring = style.coloring {
|
||||
control.coloring = coloring
|
||||
}
|
||||
if let imageName = style.mwmImage {
|
||||
control.imageName = imageName
|
||||
}
|
||||
if let backgroundColor = style.backgroundColor {
|
||||
control.backgroundColor = backgroundColor
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
protocol BottomTabBarInteractorProtocol: AnyObject {
|
||||
func openSearch()
|
||||
func openLeftButton()
|
||||
func openFaq()
|
||||
func openBookmarks()
|
||||
func openMenu()
|
||||
}
|
||||
@@ -55,10 +54,6 @@ extension BottomTabBarInteractor: BottomTabBarInteractorProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func openFaq() {
|
||||
mapViewController?.openAbout()
|
||||
}
|
||||
|
||||
func openBookmarks() {
|
||||
mapViewController?.bookmarksCoordinator.open()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
protocol BottomTabBarPresenterProtocol: AnyObject {
|
||||
func configure()
|
||||
func onLeftButtonPressed()
|
||||
func onSearchButtonPressed()
|
||||
func onLeftButtonPressed(withBadge: Bool)
|
||||
func onBookmarksButtonPressed()
|
||||
func onMenuButtonPressed()
|
||||
}
|
||||
@@ -17,15 +17,15 @@ class BottomTabBarPresenter: NSObject {
|
||||
extension BottomTabBarPresenter: BottomTabBarPresenterProtocol {
|
||||
func configure() {
|
||||
}
|
||||
|
||||
func onLeftButtonPressed() {
|
||||
interactor.openLeftButton()
|
||||
}
|
||||
|
||||
func onSearchButtonPressed() {
|
||||
interactor.openSearch()
|
||||
}
|
||||
|
||||
func onLeftButtonPressed(withBadge: Bool) {
|
||||
withBadge ? interactor.openFaq() : interactor.openLeftButton()
|
||||
}
|
||||
|
||||
func onBookmarksButtonPressed() {
|
||||
interactor.openBookmarks()
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
|
||||
private let kUDDidShowFirstTimeRoutingEducationalHint = "kUDDidShowFirstTimeRoutingEducationalHint"
|
||||
|
||||
class BottomTabBarViewController: UIViewController {
|
||||
var presenter: BottomTabBarPresenterProtocol!
|
||||
|
||||
@IBOutlet var searchButton: MWMButton!
|
||||
@IBOutlet var searchConstraintWithLeftButton: NSLayoutConstraint!
|
||||
@IBOutlet var searchConstraintWithoutLeftButton: NSLayoutConstraint!
|
||||
@IBOutlet var leftButton: MWMButton!
|
||||
@IBOutlet var bookmarksButton: MWMButton!
|
||||
@IBOutlet var bookmarksConstraintWithLeftButton: NSLayoutConstraint!
|
||||
@IBOutlet var bookmarksConstraintWithoutLeftButton: NSLayoutConstraint!
|
||||
@IBOutlet var moreButton: MWMButton!
|
||||
@IBOutlet var downloadBadge: UIView!
|
||||
@IBOutlet var leftButtonBadge: UIView!
|
||||
|
||||
@IBOutlet var leftButton: MWMButton?
|
||||
@IBOutlet var searchButton: MWMButton?
|
||||
@IBOutlet var searchConstraintWithLeftButton: NSLayoutConstraint?
|
||||
@IBOutlet var searchConstraintWithoutLeftButton: NSLayoutConstraint?
|
||||
@IBOutlet var bookmarksButton: MWMButton?
|
||||
@IBOutlet var bookmarksConstraintWithLeftButton: NSLayoutConstraint?
|
||||
@IBOutlet var bookmarksConstraintWithoutLeftButton: NSLayoutConstraint?
|
||||
@IBOutlet var moreButton: MWMButton?
|
||||
@IBOutlet var downloadBadge: UIView?
|
||||
|
||||
private var avaliableArea = CGRect.zero
|
||||
@objc var isHidden: Bool = false {
|
||||
@@ -47,7 +44,7 @@ class BottomTabBarViewController: UIViewController {
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
leftButton.imageView?.contentMode = .scaleAspectFit
|
||||
leftButton?.imageView?.contentMode = .scaleAspectFit
|
||||
updateBadge()
|
||||
}
|
||||
|
||||
@@ -65,12 +62,7 @@ class BottomTabBarViewController: UIViewController {
|
||||
}
|
||||
|
||||
@IBAction func onLeftButtonPressed(_ sender: Any) {
|
||||
if !leftButtonBadge.isHidden {
|
||||
presenter.onLeftButtonPressed(withBadge: true)
|
||||
setLeftButtonBadgeShown()
|
||||
} else {
|
||||
presenter.onLeftButtonPressed(withBadge: false)
|
||||
}
|
||||
presenter.onLeftButtonPressed()
|
||||
}
|
||||
|
||||
@IBAction func onBookmarksButtonPressed(_ sender: Any) {
|
||||
@@ -113,41 +105,27 @@ class BottomTabBarViewController: UIViewController {
|
||||
private func updateLeftButton() {
|
||||
let leftButtonType = Settings.leftButtonType
|
||||
if leftButtonType == .hidden {
|
||||
leftButton.isHidden = true
|
||||
leftButtonBadge.isHidden = true
|
||||
leftButton?.isHidden = true
|
||||
|
||||
if let searchConstraintWithLeftButton, let searchConstraintWithoutLeftButton, let bookmarksConstraintWithLeftButton, let bookmarksConstraintWithoutLeftButton {
|
||||
NSLayoutConstraint.deactivate([searchConstraintWithLeftButton, bookmarksConstraintWithLeftButton])
|
||||
NSLayoutConstraint.activate([searchConstraintWithoutLeftButton, bookmarksConstraintWithoutLeftButton])
|
||||
NSLayoutConstraint.deactivate([searchConstraintWithLeftButton, bookmarksConstraintWithLeftButton])
|
||||
}
|
||||
} else {
|
||||
leftButton.isHidden = false
|
||||
leftButtonBadge.isHidden = !needsToShowleftButtonBadge()
|
||||
leftButton?.isHidden = false
|
||||
|
||||
leftButton.setTitle(nil, for: .normal)
|
||||
leftButton.setImage(leftButtonType.image, for: .normal)
|
||||
leftButton.accessibilityLabel = leftButtonType.description;
|
||||
leftButton?.setTitle(nil, for: .normal)
|
||||
leftButton?.setImage(leftButtonType.image, for: .normal)
|
||||
leftButton?.accessibilityLabel = leftButtonType.description;
|
||||
|
||||
if let searchConstraintWithLeftButton, let searchConstraintWithoutLeftButton, let bookmarksConstraintWithLeftButton, let bookmarksConstraintWithoutLeftButton {
|
||||
NSLayoutConstraint.deactivate([searchConstraintWithoutLeftButton, bookmarksConstraintWithoutLeftButton])
|
||||
NSLayoutConstraint.activate([searchConstraintWithLeftButton, bookmarksConstraintWithLeftButton])
|
||||
NSLayoutConstraint.deactivate([searchConstraintWithoutLeftButton, bookmarksConstraintWithoutLeftButton])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func updateBadge() {
|
||||
downloadBadge.isHidden = isApplicationBadgeHidden
|
||||
leftButtonBadge.isHidden = !needsToShowleftButtonBadge() || Settings.leftButtonType == .hidden
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Help badge
|
||||
private extension BottomTabBarViewController {
|
||||
private func needsToShowleftButtonBadge() -> Bool {
|
||||
!UserDefaults.standard.bool(forKey: kUDDidShowFirstTimeRoutingEducationalHint)
|
||||
}
|
||||
|
||||
private func setLeftButtonBadgeShown() {
|
||||
UserDefaults.standard.set(true, forKey: kUDDidShowFirstTimeRoutingEducationalHint)
|
||||
downloadBadge?.isHidden = isApplicationBadgeHidden
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23727" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24128" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23721"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24063"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
@@ -15,7 +15,6 @@
|
||||
<outlet property="bookmarksConstraintWithoutLeftButton" destination="NRb-vj-MFg" id="C3Z-Ia-D6i"/>
|
||||
<outlet property="downloadBadge" destination="uDI-ZC-4wx" id="fAf-cy-Ozn"/>
|
||||
<outlet property="leftButton" destination="dzf-7Z-N6a" id="LMZ-H7-ftQ"/>
|
||||
<outlet property="leftButtonBadge" destination="0pe-0n-d1F" id="tmx-0P-tch"/>
|
||||
<outlet property="moreButton" destination="svD-yi-GrZ" id="kjk-ZW-nZN"/>
|
||||
<outlet property="searchButton" destination="No0-ld-JX3" id="m5F-UT-j94"/>
|
||||
<outlet property="searchConstraintWithLeftButton" destination="tDb-w1-ueQ" id="WaI-Xb-1bu"/>
|
||||
@@ -39,7 +38,7 @@
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="30"/>
|
||||
<inset key="imageEdgeInsets" minX="9" minY="9" maxX="9" maxY="9"/>
|
||||
<state key="normal" image="Logo"/>
|
||||
<state key="normal" image="info.circle" catalog="system"/>
|
||||
<connections>
|
||||
<action selector="onLeftButtonPressed:" destination="-1" eventType="touchUpInside" id="1gx-P2-sRJ"/>
|
||||
</connections>
|
||||
@@ -94,37 +93,21 @@
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Badge"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0pe-0n-d1F" userLabel="LeftButtonBadge">
|
||||
<rect key="frame" x="49.5" y="11" width="10" height="10"/>
|
||||
<color key="backgroundColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<accessibility key="accessibilityConfiguration">
|
||||
<accessibilityTraits key="traits" notEnabled="YES"/>
|
||||
</accessibility>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="10" id="FgD-lk-SxR"/>
|
||||
<constraint firstAttribute="width" constant="10" id="OwT-jV-hqZ"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="string" keyPath="styleName" value="Badge"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
</subviews>
|
||||
<accessibility key="accessibilityConfiguration" identifier="MainButtons"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="48" id="69A-eu-uLp"/>
|
||||
<constraint firstItem="No0-ld-JX3" firstAttribute="centerY" secondItem="vum-s3-PHx" secondAttribute="centerY" id="8nL-zT-Y7b"/>
|
||||
<constraint firstItem="No0-ld-JX3" firstAttribute="height" secondItem="vum-s3-PHx" secondAttribute="height" id="9eR-I7-7at"/>
|
||||
<constraint firstItem="0pe-0n-d1F" firstAttribute="centerX" secondItem="dzf-7Z-N6a" secondAttribute="centerX" constant="8" id="Ab0-g9-N4P"/>
|
||||
<constraint firstItem="svD-yi-GrZ" firstAttribute="height" secondItem="vum-s3-PHx" secondAttribute="height" id="Fde-um-JL6"/>
|
||||
<constraint firstItem="dgG-ki-3tB" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" multiplier="1.25" id="Jc7-nc-elY"/>
|
||||
<constraint firstItem="dgG-ki-3tB" firstAttribute="centerY" secondItem="vum-s3-PHx" secondAttribute="centerY" id="JjT-sc-hIY"/>
|
||||
<constraint firstItem="dgG-ki-3tB" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" id="NRb-vj-MFg"/>
|
||||
<constraint firstItem="dgG-ki-3tB" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" priority="900" id="NRb-vj-MFg"/>
|
||||
<constraint firstItem="svD-yi-GrZ" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" multiplier="1.75" id="Q0b-gd-HwS"/>
|
||||
<constraint firstItem="dgG-ki-3tB" firstAttribute="height" secondItem="vum-s3-PHx" secondAttribute="height" id="Rs8-Hl-CAc"/>
|
||||
<constraint firstItem="uDI-ZC-4wx" firstAttribute="centerX" secondItem="svD-yi-GrZ" secondAttribute="centerX" constant="8" id="XNb-Ba-Hn7"/>
|
||||
<constraint firstItem="dzf-7Z-N6a" firstAttribute="centerY" secondItem="vum-s3-PHx" secondAttribute="centerY" id="Zug-zY-KIX"/>
|
||||
<constraint firstItem="No0-ld-JX3" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" multiplier="0.25" id="cQg-jW-uSD"/>
|
||||
<constraint firstItem="0pe-0n-d1F" firstAttribute="centerY" secondItem="dzf-7Z-N6a" secondAttribute="centerY" constant="-8" id="pgw-rN-LCe"/>
|
||||
<constraint firstItem="No0-ld-JX3" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" multiplier="0.25" priority="900" id="cQg-jW-uSD"/>
|
||||
<constraint firstItem="svD-yi-GrZ" firstAttribute="centerY" secondItem="vum-s3-PHx" secondAttribute="centerY" id="sja-hO-YY3"/>
|
||||
<constraint firstItem="No0-ld-JX3" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" multiplier="0.75" id="tDb-w1-ueQ"/>
|
||||
<constraint firstItem="dzf-7Z-N6a" firstAttribute="centerX" secondItem="vum-s3-PHx" secondAttribute="centerX" multiplier="0.25" id="u3G-gY-98J"/>
|
||||
@@ -157,9 +140,9 @@
|
||||
</view>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="Logo" width="1024" height="1024"/>
|
||||
<image name="ic_menu" width="48" height="48"/>
|
||||
<image name="ic_menu_bookmark_list" width="48" height="48"/>
|
||||
<image name="ic_menu_search" width="48" height="48"/>
|
||||
<image name="info.circle" catalog="system" width="128" height="123"/>
|
||||
</resources>
|
||||
</document>
|
||||
|
||||
Reference in New Issue
Block a user