Files
comaps/iphone/Maps/Core/Theme/StyleApplicable.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

55 lines
1.8 KiB
Swift

protocol StyleApplicable: AnyObject {
var styleName: String { get set }
var isStyleApplied: Bool { get set }
func setStyleName(_ styleName: String)
func setStyleNameAndApply(_ styleName: String)
func setStyle(_ style: StyleStringRepresentable)
func setStyleAndApply(_ style: StyleStringRepresentable)
func applyTheme()
}
extension StyleApplicable {
func setStyleName(_ styleName: String) {
self.styleName = styleName
}
func setStyleNameAndApply(_ styleName: String) {
self.styleName = styleName
applyTheme()
}
func setStyle(_ style: StyleStringRepresentable) {
styleName = style.rawValue
}
func setStyleAndApply(_ style: StyleStringRepresentable) {
styleName = style.rawValue
applyTheme()
}
}
// Overload for the direct usage of the nested StyleSheet enums
extension StyleApplicable {
func setStyle(_ style: GlobalStyleSheet) { setStyle(style) }
func setStyle(_ style: PlacePageStyleSheet) { setStyle(style) }
func setStyle(_ style: MapStyleSheet) { setStyle(style) }
func setStyle(_ style: BookmarksStyleSheet) { setStyle(style) }
func setStyle(_ style: SearchStyleSheet) { setStyle(style) }
func setStyleAndApply(_ style: GlobalStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: PlacePageStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: MapStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: BookmarksStyleSheet) { setStyleAndApply(style) }
func setStyleAndApply(_ style: SearchStyleSheet) { setStyleAndApply(style) }
func setStyles(_ styles: [GlobalStyleSheet]) { styleName = styles.joinedStyle }
}
private extension Collection where Element: RawRepresentable, Element.RawValue == String {
var joinedStyle: String {
map(\.rawValue).joined(separator: ":")
}
}