Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:58:55 +01:00
parent 4af19165ec
commit 68073add76
12458 changed files with 12350765 additions and 2 deletions

View file

@ -0,0 +1,14 @@
@objc class BottomTabBarBuilder: NSObject {
@objc static func build(mapViewController: MapViewController, controlsManager: MWMMapViewControlsManager) -> BottomTabBarViewController {
let viewController = BottomTabBarViewController(nibName: nil, bundle: nil)
let interactor = BottomTabBarInteractor(viewController: viewController,
mapViewController: mapViewController,
controlsManager: controlsManager)
let presenter = BottomTabBarPresenter(interactor: interactor)
interactor.presenter = presenter
viewController.presenter = presenter
return viewController
}
}

View file

@ -0,0 +1,32 @@
import UIKit
class BottomTabBarButton: MWMButton {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.bottomTabBarButton)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {
BottomTabBarButtonRenderer.render(self, style: style)
}
}
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return bounds.insetBy(dx: kExtendedTabBarTappableMargin, dy: kExtendedTabBarTappableMargin).contains(point)
}
}
class BottomTabBarButtonRenderer {
class func render(_ control: BottomTabBarButton, style: Style) {
UIViewRenderer.renderShadow(control, style: style)
UIViewRenderer.renderBorder(control, style: style)
if let coloring = style.coloring {
control.coloring = coloring
}
if let backgroundColor = style.backgroundColor {
control.backgroundColor = backgroundColor
}
}
}

View file

@ -0,0 +1,75 @@
protocol BottomTabBarInteractorProtocol: AnyObject {
func openSearch()
func openLeftButton()
func openBookmarks()
func openMenu()
}
class BottomTabBarInteractor {
weak var presenter: BottomTabBarPresenterProtocol?
private weak var viewController: UIViewController?
private weak var mapViewController: MapViewController?
private weak var controlsManager: MWMMapViewControlsManager?
private let searchManager: SearchOnMapManager
init(viewController: UIViewController, mapViewController: MapViewController, controlsManager: MWMMapViewControlsManager) {
self.viewController = viewController
self.mapViewController = mapViewController
self.controlsManager = controlsManager
self.searchManager = mapViewController.searchManager
}
}
extension BottomTabBarInteractor: BottomTabBarInteractorProtocol {
func openSearch() {
searchManager.isSearching ? searchManager.close() : searchManager.startSearching(isRouting: false)
}
func openLeftButton() {
switch Settings.leftButtonType {
case .addPlace:
if let delegate = controlsManager as? BottomMenuDelegate {
delegate.addPlace()
}
case .settings:
mapViewController?.openSettings()
case .recordTrack:
let mapViewController = MapViewController.shared()!
let trackRecorder: TrackRecordingManager = .shared
switch trackRecorder.recordingState {
case .active:
mapViewController.showTrackRecordingPlacePage()
case .inactive:
trackRecorder.start { result in
switch result {
case .success:
mapViewController.showTrackRecordingPlacePage()
case .failure:
break
}
}
}
default:
mapViewController?.openAbout()
}
}
func openBookmarks() {
mapViewController?.bookmarksCoordinator.open()
}
func openMenu() {
guard let state = controlsManager?.menuState else {
fatalError("ERROR: Failed to retrieve the current MapViewControlsManager's state.")
}
switch state {
case .inactive: controlsManager?.menuState = .active
case .active: controlsManager?.menuState = .inactive
case .hidden:
// When the current controls manager's state is hidden, accidental taps on the menu button during the hiding animation should be skipped.
break;
case .layers: fallthrough
@unknown default: fatalError("ERROR: Unexpected MapViewControlsManager's state: \(state)")
}
}
}

View file

@ -0,0 +1,37 @@
protocol BottomTabBarPresenterProtocol: AnyObject {
func configure()
func onLeftButtonPressed()
func onSearchButtonPressed()
func onBookmarksButtonPressed()
func onMenuButtonPressed()
}
class BottomTabBarPresenter: NSObject {
private let interactor: BottomTabBarInteractorProtocol
init(interactor: BottomTabBarInteractorProtocol) {
self.interactor = interactor
}
}
extension BottomTabBarPresenter: BottomTabBarPresenterProtocol {
func configure() {
}
func onLeftButtonPressed() {
interactor.openLeftButton()
}
func onSearchButtonPressed() {
interactor.openSearch()
}
func onBookmarksButtonPressed() {
interactor.openBookmarks()
}
func onMenuButtonPressed() {
interactor.openMenu()
}
}

View file

@ -0,0 +1,28 @@
let kExtendedTabBarTappableMargin: CGFloat = -15
final class BottomTabBarView: SolidTouchView {
@IBOutlet var mainButtonsView: ExtendedBottomTabBarContainerView!
override var placePageAreaAffectDirections: MWMAvailableAreaAffectDirections {
return alternative(iPhone: [], iPad: [.bottom])
}
override var widgetsAreaAffectDirections: MWMAvailableAreaAffectDirections {
return [.bottom]
}
override var sideButtonsAreaAffectDirections: MWMAvailableAreaAffectDirections {
return [.bottom]
}
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return bounds.insetBy(dx: kExtendedTabBarTappableMargin, dy: kExtendedTabBarTappableMargin).contains(point)
}
}
final class ExtendedBottomTabBarContainerView: UIView {
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
return bounds.insetBy(dx: kExtendedTabBarTappableMargin, dy: kExtendedTabBarTappableMargin).contains(point)
}
}

View file

@ -0,0 +1,131 @@
class BottomTabBarViewController: UIViewController {
var presenter: BottomTabBarPresenterProtocol!
@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 {
didSet {
updateFrame(animated: true)
}
}
@objc var isApplicationBadgeHidden: Bool = true {
didSet {
updateBadge()
}
}
var tabBarView: BottomTabBarView {
return view as! BottomTabBarView
}
@objc static var controller: BottomTabBarViewController? {
return MWMMapViewControlsManager.manager()?.tabBarController
}
override func viewDidLoad() {
super.viewDidLoad()
presenter.configure()
NotificationCenter.default.addObserver(forName: UserDefaults.didChangeNotification, object: nil, queue: nil) { _ in
DispatchQueue.main.async {
self.updateLeftButton()
}
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
leftButton?.imageView?.contentMode = .scaleAspectFit
updateBadge()
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
updateLeftButton()
}
static func updateAvailableArea(_ frame: CGRect) {
BottomTabBarViewController.controller?.updateAvailableArea(frame)
}
@IBAction func onSearchButtonPressed(_ sender: Any) {
presenter.onSearchButtonPressed()
}
@IBAction func onLeftButtonPressed(_ sender: Any) {
presenter.onLeftButtonPressed()
}
@IBAction func onBookmarksButtonPressed(_ sender: Any) {
presenter.onBookmarksButtonPressed()
}
@IBAction func onMenuButtonPressed(_ sender: Any) {
presenter.onMenuButtonPressed()
}
private func updateAvailableArea(_ frame:CGRect) {
avaliableArea = frame
updateFrame(animated: false)
self.view.layoutIfNeeded()
}
private func updateFrame(animated: Bool) {
if avaliableArea == .zero {
return
}
let newFrame = CGRect(x: avaliableArea.minX,
y: isHidden ? avaliableArea.minY + avaliableArea.height : avaliableArea.minY,
width: avaliableArea.width,
height: avaliableArea.height)
let alpha:CGFloat = isHidden ? 0 : 1
if animated {
UIView.animate(withDuration: kDefaultAnimationDuration,
delay: 0,
options: [.beginFromCurrentState],
animations: {
self.view.frame = newFrame
self.view.alpha = alpha
}, completion: nil)
} else {
self.view.frame = newFrame
self.view.alpha = alpha
}
}
private func updateLeftButton() {
let leftButtonType = Settings.leftButtonType
if leftButtonType == .hidden {
leftButton?.isHidden = true
if let searchConstraintWithLeftButton, let searchConstraintWithoutLeftButton, let bookmarksConstraintWithLeftButton, let bookmarksConstraintWithoutLeftButton {
NSLayoutConstraint.activate([searchConstraintWithoutLeftButton, bookmarksConstraintWithoutLeftButton])
NSLayoutConstraint.deactivate([searchConstraintWithLeftButton, bookmarksConstraintWithLeftButton])
}
} else {
leftButton?.isHidden = false
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.activate([searchConstraintWithLeftButton, bookmarksConstraintWithLeftButton])
NSLayoutConstraint.deactivate([searchConstraintWithoutLeftButton, bookmarksConstraintWithoutLeftButton])
}
}
}
private func updateBadge() {
downloadBadge?.isHidden = isApplicationBadgeHidden
}
}

View file

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<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="24063"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BottomTabBarViewController" customModule="CoMaps" customModuleProvider="target">
<connections>
<outlet property="bookmarksButton" destination="dgG-ki-3tB" id="md5-3T-9tb"/>
<outlet property="bookmarksConstraintWithLeftButton" destination="Jc7-nc-elY" id="gW7-8e-E6m"/>
<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="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"/>
<outlet property="searchConstraintWithoutLeftButton" destination="cQg-jW-uSD" id="cMy-EC-G07"/>
<outlet property="view" destination="zuH-WU-hiP" id="eoa-4I-wKs"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="zuH-WU-hiP" customClass="BottomTabBarView" customModule="CoMaps" customModuleProvider="target" propertyAccessControl="none">
<rect key="frame" x="0.0" y="0.0" width="373" height="84"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vum-s3-PHx" userLabel="MainButtons" customClass="ExtendedBottomTabBarContainerView" customModule="CoMaps" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="373" height="48"/>
<subviews>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dzf-7Z-N6a" userLabel="LeftButton" customClass="BottomTabBarButton" customModule="CoMaps" customModuleProvider="target">
<rect key="frame" x="22.5" y="0.0" width="48" height="48"/>
<accessibility key="accessibilityConfiguration" identifier="helpButton"/>
<constraints>
<constraint firstAttribute="width" secondItem="dzf-7Z-N6a" secondAttribute="height" id="qNJ-0K-sK0"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<inset key="imageEdgeInsets" minX="9" minY="9" maxX="9" maxY="9"/>
<state key="normal" image="info.circle" catalog="system"/>
<connections>
<action selector="onLeftButtonPressed:" destination="-1" eventType="touchUpInside" id="1gx-P2-sRJ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="249" horizontalCompressionResistancePriority="751" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="No0-ld-JX3" userLabel="Search" customClass="BottomTabBarButton" customModule="CoMaps" customModuleProvider="target">
<rect key="frame" x="116" y="0.0" width="48" height="48"/>
<accessibility key="accessibilityConfiguration" identifier="searchButton"/>
<constraints>
<constraint firstAttribute="width" secondItem="No0-ld-JX3" secondAttribute="height" id="2bW-fc-Hsh"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="ic_menu_search"/>
<connections>
<action selector="onSearchButtonPressed:" destination="-1" eventType="touchUpInside" id="0D5-RB-HBQ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dgG-ki-3tB" userLabel="Bookmarks" customClass="BottomTabBarButton" customModule="CoMaps" customModuleProvider="target">
<rect key="frame" x="209" y="0.0" width="48" height="48"/>
<accessibility key="accessibilityConfiguration" identifier="bookmarksButton"/>
<constraints>
<constraint firstAttribute="width" secondItem="dgG-ki-3tB" secondAttribute="height" id="o3b-it-lrV"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="ic_menu_bookmark_list"/>
<connections>
<action selector="onBookmarksButtonPressed:" destination="-1" eventType="touchUpInside" id="9Z1-eg-xth"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="svD-yi-GrZ" userLabel="Menu" customClass="BottomTabBarButton" customModule="CoMaps" customModuleProvider="target">
<rect key="frame" x="302.5" y="0.0" width="48" height="48"/>
<accessibility key="accessibilityConfiguration" identifier="menuButton"/>
<constraints>
<constraint firstAttribute="width" secondItem="svD-yi-GrZ" secondAttribute="height" id="gmG-3a-Mqe"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="ic_menu"/>
<connections>
<action selector="onMenuButtonPressed:" destination="-1" eventType="touchUpInside" id="rzb-y4-nR1"/>
</connections>
</button>
<view userInteractionEnabled="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uDI-ZC-4wx" userLabel="DownloadBadge">
<rect key="frame" x="329.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="width" constant="10" id="tEP-Xi-qnU"/>
<constraint firstAttribute="height" constant="10" id="wNg-5Z-7AO"/>
</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="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" 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" 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"/>
<constraint firstItem="dzf-7Z-N6a" firstAttribute="height" secondItem="vum-s3-PHx" secondAttribute="height" id="yTg-8g-H1p"/>
<constraint firstItem="uDI-ZC-4wx" firstAttribute="centerY" secondItem="svD-yi-GrZ" secondAttribute="centerY" constant="-8" id="yq3-ui-IaL"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="cQg-jW-uSD"/>
<exclude reference="NRb-vj-MFg"/>
</mask>
</variation>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="aaw-Hz-zma"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="vum-s3-PHx" firstAttribute="top" secondItem="zuH-WU-hiP" secondAttribute="top" id="PQS-ro-25e"/>
<constraint firstItem="vum-s3-PHx" firstAttribute="leading" secondItem="zuH-WU-hiP" secondAttribute="leading" id="kza-JN-Dul"/>
<constraint firstAttribute="trailing" secondItem="vum-s3-PHx" secondAttribute="trailing" id="sM6-P2-rN9"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outlet property="mainButtonsView" destination="vum-s3-PHx" id="fBi-DA-orA"/>
</connections>
<point key="canvasLocation" x="72" y="254"/>
</view>
</objects>
<resources>
<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>