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,22 @@
extension BottomMenuLayerButton {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
BottomMenuLayerButtonRenderer.render(self, style: style)
}
}
}
class BottomMenuLayerButtonRenderer {
class func render(_ control: BottomMenuLayerButton, style: Style) {
if let font = style.font {
control.titleLabel.font = font
}
if let fontColor = style.fontColor {
control.titleLabel.textColor = fontColor
}
UIImageViewRenderer.render(control.imageView, style: style)
}
}

View file

@ -0,0 +1,26 @@
import Chart
extension ChartView {
override func applyTheme() {
if styleName.isEmpty {
setStyle(.ppChartView)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {
ChartViewRenderer.render(self, style: style)
}
}
}
fileprivate final class ChartViewRenderer {
class func render(_ control: ChartView, style: Style) {
control.backgroundColor = style.backgroundColor
control.textColor = style.fontColor!
control.font = style.font!
control.gridColor = style.gridColor!
control.previewSelectorColor = style.previewSelectorColor!
control.previewTintColor = style.previewTintColor!
control.infoBackgroundColor = style.infoBackground!
control.infoShadowColor = style.shadowColor!
control.infoShadowOpacity = style.shadowOpacity!
}
}

View file

@ -0,0 +1,25 @@
import Foundation
extension Checkmark {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.checkmark)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
CheckmarkRenderer.render(self, style: style)
}
}
}
class CheckmarkRenderer {
class func render(_ control: Checkmark, style: Style) {
if let onTintColor = style.onTintColor {
control.onTintColor = onTintColor
}
if let offTintColor = style.offTintColor {
control.offTintColor = offTintColor
}
}
}

View file

@ -0,0 +1,29 @@
import DatePicker
extension DatePickerView {
override func applyTheme() {
if styleName.isEmpty {
setStyle(.datePickerView)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {
DatePickerViewRenderer.render(self, style: style)
}
}
}
fileprivate final class DatePickerViewRenderer {
class func render(_ control: DatePickerView, style: Style) {
control.backgroundColor = style.backgroundColor
var theme = DatePickerViewTheme()
theme.monthHeaderBackgroundColor = style.backgroundColor!
theme.monthHeaderColor = style.fontColorDisabled!
theme.weekdaySymbolsColor = style.fontColorDisabled!
theme.dayColor = style.fontColor!
theme.selectedDayColor = style.fontColorSelected!
theme.selectedDayBackgroundColor = style.backgroundColorSelected!
theme.selectedRangeBackgroundColor = style.backgroundColorHighlighted!
theme.inactiveDayColor = style.fontColorDisabled!
control.theme = theme
}
}

View file

@ -0,0 +1,25 @@
import Foundation
extension DifficultyView {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.difficultyView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
DifficultyViewRenderer.render(self, style: style)
}
}
}
class DifficultyViewRenderer: UIViewRenderer {
class func render(_ control: DifficultyView, style: Style) {
super.render(control, style: style)
if let colors = style.colors {
control.colors = colors
}
if let emptyColor = style.offTintColor {
control.emptyColor = emptyColor
}
}
}

View file

@ -0,0 +1,17 @@
extension InsetsLabel {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
InsetsLabelRenderer.render(self, style: style)
}
}
}
class InsetsLabelRenderer: UILabelRenderer {
class func render(_ control: InsetsLabel, style: Style) {
super.render(control, style: style)
if let insets = style.textContainerInset {
control.insets = insets
}
}
}

View file

@ -0,0 +1,21 @@
extension MWMButton {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
MWMButtonRenderer.render(self, style: style)
}
}
}
class MWMButtonRenderer {
class func render(_ control: MWMButton, style: Style) {
UIButtonRenderer.render(control, style: style)
if let coloring = style.coloring {
control.coloring = coloring
}
if let imageName = style.mwmImage {
control.imageName = imageName
}
}
}

View file

@ -0,0 +1,18 @@
import Foundation
extension MWMTableViewCell {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.tableViewCell)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
MWMTableViewCellRenderer.render(self, style: style)
}
}
}
class MWMTableViewCellRenderer: UITableViewCellRenderer {
class func render(_ control: MWMTableViewCell, style: Style) {
super.render(control, style: style)
}
}

View file

@ -0,0 +1,33 @@
extension TabView {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.tabView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
TabViewRenderer.render(self, style: style)
}
}
}
class TabViewRenderer {
class func render(_ control: TabView, style: Style) {
if let backgroundColor = style.backgroundColor {
control.backgroundColor = backgroundColor
}
if let barTintColor = style.barTintColor {
control.barTintColor = barTintColor
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
}
if let font = style.font, let fontColor = style.fontColorHighlighted {
control.selectedHeaderTextAttributes = [.foregroundColor: fontColor,
.font: font]
}
if let font = style.font, let fontColor = style.fontColor {
control.deselectedHeaderTextAttributes = [.foregroundColor: fontColor,
.font: font]
}
}
}

View file

@ -0,0 +1,16 @@
extension UIActivityIndicatorView {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UIActivityIndicatorRenderer.render(self, style: style)
}
}
}
class UIActivityIndicatorRenderer {
class func render(_ control: UIActivityIndicatorView, style: Style) {
if let color = style.color {
control.color = color
}
}
}

View file

@ -0,0 +1,34 @@
import UIKit
class UIBarButtonItemRenderer {
class func render(_ control: UIBarButtonItem, style: Style) {
var normalAttributes = [NSAttributedString.Key: Any]()
var disableAttributes = [NSAttributedString.Key: Any]()
var highlightedAttributes = [NSAttributedString.Key: Any]()
if let backgroundImage = style.backgroundImage {
control.setBackgroundImage(backgroundImage, for: .normal, barMetrics: .default)
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
}
if let font = style.font {
normalAttributes[NSAttributedString.Key.font] = font
disableAttributes[NSAttributedString.Key.font] = font
highlightedAttributes[NSAttributedString.Key.font] = font
}
if let fontColor = style.fontColor {
normalAttributes[NSAttributedString.Key.foregroundColor] = fontColor
}
if let fontColorDisabled = style.fontColorDisabled {
disableAttributes[NSAttributedString.Key.foregroundColor] = fontColorDisabled
}
if let fontColorHighlighted = style.fontColorHighlighted {
highlightedAttributes[NSAttributedString.Key.foregroundColor] = fontColorHighlighted
}
control.setTitleTextAttributes(normalAttributes, for: .normal)
control.setTitleTextAttributes(disableAttributes, for: .disabled)
control.setTitleTextAttributes(highlightedAttributes, for: .highlighted)
}
}

View file

@ -0,0 +1,55 @@
extension UIButton {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UIButtonRenderer.render(self, style: style)
}
}
}
class UIButtonRenderer {
class func render(_ control: UIButton, style: Style) {
if let titleLabel = control.titleLabel {
if let font = style.font {
titleLabel.font = font
}
}
if let fontColor = style.fontColor {
control.setTitleColor(fontColor, for: .normal)
}
if let backgroundColor = style.backgroundColor {
control.setBackgroundImage(backgroundColor.getImage(), for: .normal)
control.backgroundColor = UIColor.clear
}
if let backgroundColorSelected = style.backgroundColorSelected {
control.setBackgroundImage(backgroundColorSelected.getImage(), for: .selected)
}
if let backgroundColorHighlighted = style.backgroundColorHighlighted {
control.setBackgroundImage(backgroundColorHighlighted.getImage(), for: .highlighted)
}
if let backgroundColorDisabled = style.backgroundColorDisabled {
control.setBackgroundImage(backgroundColorDisabled.getImage(), for: .disabled)
}
if let fontColorSelected = style.fontColorSelected {
control.setTitleColor(fontColorSelected, for: .selected)
}
if let fontColorHighlighted = style.fontColorHighlighted {
control.setTitleColor(fontColorHighlighted, for: .highlighted)
}
if let fontColorDisabled = style.fontColorDisabled {
control.setTitleColor(fontColorDisabled, for: .disabled)
}
if let image = style.image {
control.setImage(UIImage(named: image), for: .normal)
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
}
UIViewRenderer.renderBorder(control, style: style)
UIViewRenderer.renderShadow(control, style: style)
}
}

View file

@ -0,0 +1,23 @@
extension UIImageView {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UIImageViewRenderer.render(self, style: style)
}
}
}
class UIImageViewRenderer: UIViewRenderer {
class func render(_ control: UIImageView, style: Style) {
super.render(control, style: style)
if let image = style.image {
control.image = UIImage(named: image)
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
}
if let imageName = style.mwmImage {
control.mwm_name = imageName
}
}
}

View file

@ -0,0 +1,62 @@
extension UILabel {
var isAttributed: Bool {
guard let attributedText = attributedText else {
return false
}
guard !attributedText.string.isEmpty else {
return false
}
var range = NSRange()
attributedText.attributes(at: 0, effectiveRange: &range)
return attributedText.string.count != range.length
}
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UILabelRenderer.render(self, style: style)
}
}
@objc func sw_setAttributedText(text: NSAttributedString) -> CGRect {
var attributedString = text
if styleName.isEmpty == false {
let styles = StyleManager.shared.getStyle(styleName)
for style in styles where style.attributes != nil {
attributedString = UILabelRenderer.transformText(style: style,
text: attributedString)
}
}
return self.sw_setAttributedText(text: attributedString)
}
}
class UILabelRenderer: UIViewRenderer {
class func render(_ control: UILabel, style: Style) {
super.render(control, style: style)
if let font = style.font {
control.font = font
}
if let fontColor = style.fontColor {
control.textColor = fontColor
}
if let textAlignment = style.textAlignment {
control.textAlignment = textAlignment
}
if style.attributes != nil,
control.isAttributed,
let attributedText = control.attributedText {
control.attributedText = attributedText
}
}
class func transformText(style: Style, text: NSAttributedString) -> NSAttributedString {
if let attributes = style.attributes,
attributes.isEmpty == false,
let attributedtext = text.mutableCopy() as? NSMutableAttributedString{
attributedtext.setAttributes(attributes, range: NSRange(location: 0, length: attributedtext.length));
return attributedtext
}
return text
}
}

View file

@ -0,0 +1,39 @@
extension UINavigationBar {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.navigationBar)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UINavigationBarRenderer.render(self, style: style)
}
}
}
class UINavigationBarRenderer: UIViewRenderer {
class func render(_ control: UINavigationBar, style: Style) {
super.render(control, style: style)
if let barTintColor = style.barTintColor {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = barTintColor
control.standardAppearance = appearance
control.scrollEdgeAppearance = appearance
}
if let shadowImage = style.shadowImage {
control.standardAppearance.shadowImage = shadowImage
control.scrollEdgeAppearance!.shadowImage = shadowImage
}
var attributes = [NSAttributedString.Key: Any]()
if let font = style.font {
attributes[NSAttributedString.Key.font] = font
}
if let fontColor = style.fontColor {
attributes[NSAttributedString.Key.foregroundColor] = fontColor
}
control.standardAppearance.titleTextAttributes = attributes
control.scrollEdgeAppearance!.titleTextAttributes = attributes
}
}

View file

@ -0,0 +1,24 @@
extension UINavigationItem {
@objc func applyTheme() {
if styleName.isEmpty {
setStyle(.navigationBarItem)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty {
UINavigationItemRenderer.render(self, style: style)
}
}
}
class UINavigationItemRenderer {
class func render(_ control: UINavigationItem, style: Style) {
if let item = control.backBarButtonItem {
UIBarButtonItemRenderer.render(item, style: style)
}
if let item = control.leftBarButtonItem {
UIBarButtonItemRenderer.render(item, style: style)
}
if let item = control.rightBarButtonItem {
UIBarButtonItemRenderer.render(item, style: style)
}
}
}

View file

@ -0,0 +1,25 @@
extension UIPageControl {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.pageControl)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UIPageControlenderer.render(self, style: style)
}
}
}
class UIPageControlenderer {
class func render(_ control: UIPageControl, style: Style) {
if let backgroundColor = style.backgroundColor {
control.backgroundColor = backgroundColor
}
if let pageIndicatorTintColor = style.pageIndicatorTintColor {
control.pageIndicatorTintColor = pageIndicatorTintColor
}
if let currentPageIndicatorTintColor = style.currentPageIndicatorTintColor {
control.currentPageIndicatorTintColor = currentPageIndicatorTintColor
}
}
}

View file

@ -0,0 +1,84 @@
import Foundation
extension UISearchBar {
@objc override func applyTheme() {
if #available(iOS 26, *) {
return;
}
if styleName.isEmpty {
setStyle(.searchBar)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UISearchBarRenderer.render(self, style: style)
}
}
@objc override func sw_didMoveToWindow() {
guard MapsAppDelegate.theApp().window === window else {
sw_didMoveToWindow();
return
}
applyTheme()
isStyleApplied = true
sw_didMoveToWindow();
}
}
class UISearchBarRenderer: UIViewRenderer {
class func render(_ control: UISearchBar, style: Style) {
super.render(control, style: style)
if #available(iOS 26, *) {
return;
}
let searchTextField = control.searchTextField
// Default search bar implementation adds the grey transparent image for background. This code removes it and updates the corner radius. This is not working on iPad designed for mac.
if !ProcessInfo.processInfo.isiOSAppOnMac {
control.setSearchFieldBackgroundImage(UIImage(), for: .normal)
}
searchTextField.layer.setCornerRadius(.buttonDefault)
searchTextField.layer.masksToBounds = true
// Placeholder color
if let placeholder = searchTextField.placeholder {
searchTextField.attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [.foregroundColor: UIColor.gray])
}
if let backgroundColor = style.backgroundColor {
searchTextField.backgroundColor = backgroundColor
}
if let font = style.font {
searchTextField.font = font
}
if let fontColor = style.fontColor {
searchTextField.textColor = fontColor
}
if let tintColor = style.tintColor {
searchTextField.leftView?.tintColor = tintColor
// Placeholder indicator color
searchTextField.tintColor = tintColor
// Clear button image
let clearButtonImage = UIImage(named: "ic_clear")?.withRenderingMode(.alwaysTemplate).withTintColor(tintColor)
control.setImage(clearButtonImage, for: .clear, state: .normal)
}
if let barTintColor = style.barTintColor {
let position = control.delegate?.position?(for: control) ?? control.barPosition
control.setBackgroundImage(barTintColor.getImage(), for: position, barMetrics: .defaultPrompt)
control.setBackgroundImage(barTintColor.getImage(), for: position, barMetrics: .default)
control.backgroundColor = barTintColor
}
if let fontColorDetailed = style.fontColorDetailed {
// Cancel button color
control.tintColor = fontColorDetailed
}
}
@available(iOS, deprecated: 13.0)
private static let kiOS12DefaultSystemTextFieldHeight = 36
@available(iOS, deprecated: 13.0)
private static var searchBarBackgroundColor: UIColor?
@available(iOS, deprecated: 13.0)
private static var searchBarBackgroundImage: UIImage?
}

View file

@ -0,0 +1,20 @@
extension UISwitch {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.switch)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UISwitchRenderer.render(self, style: style)
}
}
}
class UISwitchRenderer: UIViewRenderer {
class func render(_ control: UISwitch, style: Style) {
super.render(control, style: style)
if let onTintColor = style.onTintColor {
control.onTintColor = onTintColor
}
}
}

View file

@ -0,0 +1,46 @@
extension UITableViewCell {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.tableCell)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UITableViewCellRenderer.render(self, style: style)
}
}
}
class UITableViewCellRenderer {
class func render(_ control: UITableViewCell, style: Style) {
if let label = control.textLabel {
if let font = style.font {
label.font = font
}
if let fontColor = style.fontColor {
label.textColor = fontColor
}
}
if let detailedLabel = control.detailTextLabel {
if let fontDetailed = style.fontDetailed {
detailedLabel.font = fontDetailed
}
if let fontColorDetailed = style.fontColorDetailed {
detailedLabel.textColor = fontColorDetailed
}
}
if let fontColorDetailed = style.fontColorDetailed {
control.imageView?.tintColor = fontColorDetailed
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
control.accessoryView?.tintColor = tintColor
}
if let backgroundColor = style.backgroundColor {
control.backgroundColor = backgroundColor
control.backgroundView = UIImageView(image: backgroundColor.getImage())
}
if let backgroundColorSelected = style.backgroundColorSelected {
control.selectedBackgroundView = UIImageView(image: backgroundColorSelected.getImage())
}
}
}

View file

@ -0,0 +1,22 @@
extension UITableViewHeaderFooterView {
@objc override func applyTheme() {
if styleName.isEmpty {
setStyle(.tableViewHeaderFooterView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UITableViewHeaderFooterViewRenderer.render(self, style: style)
}
}
}
class UITableViewHeaderFooterViewRenderer {
class func render(_ control: UITableViewHeaderFooterView, style: Style) {
if let backgroundColor = style.backgroundColor {
control.backgroundView = UIImageView(image: backgroundColor.getImage())
}
if let fontColor = style.fontColor {
control.textLabel?.textColor = fontColor
}
}
}

View file

@ -0,0 +1,25 @@
extension UITableView {
@objc override func applyTheme() {
if styleName.isEmpty, style != .insetGrouped, style != .grouped {
setStyle(.tableView)
}
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UITableViewRenderer.render(self, style: style)
}
}
}
class UITableViewRenderer: UIViewRenderer {
class func render(_ control: UITableView, style: Style) {
super.render(control, style: style)
if let backgroundColor = style.backgroundColor {
control.backgroundView = UIImageView(image: backgroundColor.getImage())
}
if let separatorColor = style.separatorColor {
control.separatorColor = separatorColor
}
UIViewRenderer.renderBorder(control, style: style)
UIViewRenderer.renderShadow(control, style: style)
}
}

View file

@ -0,0 +1,47 @@
extension UITextField {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UITextFieldRenderer.render(self, style: style)
}
}
@objc override func sw_didMoveToWindow() {
guard MapsAppDelegate.theApp().window === window else {
sw_didMoveToWindow();
return
}
applyTheme()
isStyleApplied = true
sw_didMoveToWindow();
}
}
class UITextFieldRenderer {
class func render(_ control: UITextField, style: Style) {
if let cornerRadius = style.cornerRadius {
control.layer.setCornerRadius(cornerRadius)
control.clipsToBounds = true
}
control.borderStyle = .none
var placeholderAttributes = [NSAttributedString.Key : Any]()
if let backgroundColor = style.backgroundColor {
control.backgroundColor = backgroundColor
}
if let font = style.font {
control.font = font
placeholderAttributes[NSAttributedString.Key.font] = font
}
if let fontColor = style.fontColor {
control.textColor = fontColor
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
placeholderAttributes[NSAttributedString.Key.foregroundColor] = tintColor
}
if let attributedPlaceholder = control.attributedPlaceholder, !attributedPlaceholder.string.isEmpty {
control.attributedPlaceholder = NSAttributedString(string: attributedPlaceholder.string,
attributes: placeholderAttributes)
}
}
}

View file

@ -0,0 +1,28 @@
extension UITextView {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UITextViewRenderer.render(self, style: style)
}
}
}
class UITextViewRenderer {
class func render(_ control: UITextView, style: Style) {
if let backgroundColor = style.backgroundColor {
control.backgroundColor = backgroundColor
}
if let font = style.font {
control.font = font
}
if let fontColor = style.fontColor {
control.textColor = fontColor
}
if let textContainerInset = style.textContainerInset {
control.textContainerInset = textContainerInset
}
if let linkAttributes = style.linkAttributes {
control.linkTextAttributes = linkAttributes
}
}
}

View file

@ -0,0 +1,19 @@
extension UIToolbar {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UIToolbarRenderer.render(self, style: style)
}
}
}
class UIToolbarRenderer {
class func render(_ control: UIToolbar, style: Style) {
if let backgroundColor = style.backgroundColor {
control.setBackgroundImage(backgroundColor.getImage(), forToolbarPosition: .any, barMetrics: .default)
}
if let tintColor = style.tintColor {
control.tintColor = tintColor
}
}
}

View file

@ -0,0 +1,4 @@
extension UIViewController {
@objc func applyTheme() {
}
}

View file

@ -0,0 +1,62 @@
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
}
control.layer.cornerCurve = .continuous
}
}

View file

@ -0,0 +1,21 @@
extension UIWindow {
@objc override func applyTheme() {
for style in StyleManager.shared.getStyle(styleName)
where !style.isEmpty && !style.hasExclusion(view: self) {
UIWindowRenderer.render(self, style: style)
}
}
@objc func sw_becomeKeyWindow() {
if !isStyleApplied {
self.applyTheme()
}
self.isStyleApplied = true
self.sw_becomeKeyWindow();
}
}
class UIWindowRenderer {
class func render(_ control: UIView, style: Style) {
}
}

View file

@ -0,0 +1,19 @@
extension ValueStepperView {
override func applyTheme() {
if styleName.isEmpty {
setStyle(.valueStepperView)
}
for style in StyleManager.shared.getStyle(styleName) where !style.isEmpty && !style.hasExclusion(view: self) {
ValueStepperViewRenderer.render(self, style: style)
}
}
}
fileprivate final class ValueStepperViewRenderer {
class func render(_ control: ValueStepperView, style: Style) {
control.plusButton.coloring = style.coloring!
control.minusButton.coloring = style.coloring!
control.valueLabel.font = style.font
control.valueLabel.textColor = style.fontColor
}
}