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

65 lines
1.9 KiB
Swift

extension UIView {
@objc func applyTheme() {
if type(of: self.superview) == UINavigationBar.self {
return;
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UIViewRenderer.render(self, style: style)
}
}
}
class UIViewRenderer {
class func render(_ control: UIView, style: Style) {
if let backgroundColor = style.backgroundColor {
control.backgroundColor = backgroundColor
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
}
UIViewRenderer.renderShadow(control, style: style)
UIViewRenderer.renderBorder(control, style: style)
}
class func renderShadow(_ control: UIView, style: Style) {
if let shadowColor = style.shadowColor {
control.layer.shadowColor = shadowColor.cgColor
}
if let shadowOffset = style.shadowOffset {
control.layer.shadowOffset = shadowOffset
}
if let shadowOpacity = style.shadowOpacity {
control.layer.shadowOpacity = shadowOpacity
}
if let shadowRadius = style.shadowRadius {
control.layer.shadowRadius = shadowRadius
}
}
class func renderBorder(_ control: UIView, style: Style) {
if let borderColor = style.borderColor {
control.layer.borderColor = borderColor.cgColor
}
if let borderWidth = style.borderWidth {
control.layer.borderWidth = borderWidth
}
if let cornerRadius = style.cornerRadius {
control.layer.cornerRadius = cornerRadius.value
}
if let maskedCorners = style.maskedCorners {
control.layer.maskedCorners = maskedCorners
}
if let clip = style.clip {
control.clipsToBounds = clip
}
if let round = style.round, round == true {
control.layer.cornerRadius = control.size.height / 2
}
if #available(iOS 13.0, *) {
control.layer.cornerCurve = .continuous
}
}
}