mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 21:33:59 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
42
iphone/Maps/Classes/Components/DimBackground.swift
Normal file
42
iphone/Maps/Classes/Components/DimBackground.swift
Normal file
@@ -0,0 +1,42 @@
|
||||
@objc(MWMDimBackground)
|
||||
final class DimBackground: SolidTouchView {
|
||||
private let mainView: UIView
|
||||
private var tapAction: () -> Void
|
||||
|
||||
@objc init(mainView: UIView, tapAction: @escaping () -> Void) {
|
||||
self.mainView = mainView
|
||||
self.tapAction = tapAction
|
||||
super.init(frame: mainView.superview!.bounds)
|
||||
setStyle(.fadeBackground)
|
||||
autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onTap)))
|
||||
}
|
||||
|
||||
required init?(coder _: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc func setVisible(_ visible: Bool, completion: (() -> Void)?) {
|
||||
if visible {
|
||||
let sv = mainView.superview!
|
||||
frame = sv.bounds
|
||||
sv.insertSubview(self, belowSubview: mainView)
|
||||
alpha = 0
|
||||
} else {
|
||||
alpha = 0.8
|
||||
}
|
||||
UIView.animate(withDuration: kDefaultAnimationDuration,
|
||||
animations: { self.alpha = visible ? 0.8 : 0 },
|
||||
completion: { _ in
|
||||
if !visible {
|
||||
self.removeFromSuperview()
|
||||
}
|
||||
completion?()
|
||||
})
|
||||
}
|
||||
|
||||
@objc
|
||||
private func onTap() {
|
||||
tapAction()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user