Files
comaps/iphone/Maps/Core/Search/SearchBanners.swift
Konstantin Pastbin e3e4a1985a 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
2025-05-08 21:10:51 +07:00

40 lines
1001 B
Swift

@objc(MWMSearchBanners)
final class SearchBanners: NSObject {
private var banners: [MWMBanner] = []
weak var searchIndex: SearchIndex?
@objc init(searchIndex: SearchIndex) {
self.searchIndex = searchIndex
super.init()
}
@objc func add(_ banner: MWMBanner) {
guard let searchIndex = searchIndex else { return }
banners.append(banner)
let type: MWMSearchItemType
let prefferedPosition: Int
switch banner.mwmType {
case .mopub:
type = .mopub
prefferedPosition = 2
case .facebook:
type = .facebook
prefferedPosition = 2
default:
assert(false, "Unsupported banner type")
type = .regular
prefferedPosition = 0
}
searchIndex.addItem(type: type, prefferedPosition: prefferedPosition, containerIndex: banners.count - 1)
}
@objc func banner(atIndex index: Int) -> MWMBanner {
return banners[index]
}
deinit {
banners.forEach { BannersCache.cache.bannerIsOutOfScreen(coreBanner: $0) }
}
}