Skip to content

Commit

Permalink
Update Fastfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ppraveentr committed Oct 26, 2024
1 parent 45e56a6 commit eb3ae0f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
49 changes: 25 additions & 24 deletions Sources/AppTheming/AppearanceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public enum AppearanceManager {
static func setupApplicationTheme() {
guard let app = ThemesManager.getAppearance() as? ThemeModel else { return }
for theme in app where ((theme.value as? ThemeModel) != nil) {
if let themeObj: ThemeModel = theme.value as? ThemeModel {
if let themeObj = theme.value as? ThemeModel {
let components = getComponentName(theme.key)
// Setup 'appearance' from Theme
if let classTy: AppearanceManagerProtocol = Reflection.swiftClassFromString(components.0) as? AppearanceManagerProtocol {
if let classTy = Reflection.swiftClassFromString(components.0) as? AppearanceManagerProtocol {
var appearanceContainer: [UIAppearanceContainer.Type]?
if let className = components.1,
let objecClass = Reflection.swiftClassTypeFromString(className) {
Expand All @@ -47,13 +47,16 @@ public enum AppearanceManager {
}

extension UIView: AppearanceManagerProtocol {
public func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance {
public func setUpAppearance(theme: ThemeModel,
containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance {
type(of: self).setUpAppearance(theme: theme, containerClass: containerClass)
}

@discardableResult
@objc public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance {
let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!)
@discardableResult @objc
public class func setUpAppearance(theme: ThemeModel,
containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance {
let appearance = (containerClass == nil) ?
self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!)
if let tintColor = theme[ThemeType.Key.tintColor] {
appearance.tintColor = ThemesManager.getColor(tintColor as? String)
}
Expand Down Expand Up @@ -97,9 +100,11 @@ extension UISegmentedControl {

extension UINavigationBar {
// swiftlint:disable cyclomatic_complexity
override public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance {
override public class func setUpAppearance(
theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance {
super.setUpAppearance(theme: theme, containerClass: containerClass)
let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!)
let appearance = (containerClass == nil) ?
self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!)

for type in ThemeType.Key.allCases {
guard let value = theme[type.rawValue] else { continue }
Expand All @@ -115,37 +120,32 @@ extension UINavigationBar {
case .isTranslucent:
if let value = value as? Bool {
appearance.isTranslucent = value
// FIXIT: Not able to update statusbar color if not set to `blackTranslucent`
if value {
appearance.barStyle = .blackTranslucent
}
}
case .titleText:
if let attributes = ThemesManager.getTextAttributes(value as? ThemeModel) {
appearance.titleTextAttributes = attributes
if #available(iOS 13.0, *) {
appearance.largeTitleTextAttributes = attributes
}
appearance.largeTitleTextAttributes = attributes
}
default:
break
}
}

if #available(iOS 13.0, *) {
let navAppe = navBarAppearance(theme: theme, tile: appearance.titleTextAttributes, largeTitle: appearance.largeTitleTextAttributes)
appearance.standardAppearance = navAppe
appearance.compactAppearance = navAppe
appearance.scrollEdgeAppearance = navAppe
}
let navAppe = navBarAppearance(theme: theme, tile: appearance.titleTextAttributes,
largeTitle: appearance.largeTitleTextAttributes)
appearance.standardAppearance = navAppe
appearance.compactAppearance = navAppe
appearance.scrollEdgeAppearance = navAppe
return appearance
}

@available(iOS 13.0, *)
private class func navBarAppearance(theme: ThemeModel, tile: AttributedDictionary?, largeTitle: AttributedDictionary?) -> UINavigationBarAppearance {
private class func navBarAppearance(theme: ThemeModel, tile: AttributedDictionary?,
largeTitle: AttributedDictionary?) -> UINavigationBarAppearance {
let navAppe = UINavigationBarAppearance()
if let imageTheme = theme[ThemeType.Key.backgroundImage] as? ThemeModel,
let defaultImage = ThemesManager.getImage(imageTheme[ThemeType.Key.defaultValue]), let bgColor = defaultImage.getColor() {
let defaultImage = ThemesManager.getImage(imageTheme[ThemeType.Key.defaultValue]),
let bgColor = defaultImage.getColor() {
navAppe.backgroundColor = bgColor
}
if let attributes = tile {
Expand All @@ -169,7 +169,8 @@ extension UINavigationBar {
}

if defaultImage != nil {
self.applyBackgroundImage(navigationBar: nil, defaultImage: defaultImage!, landScapeImage: landScapeImage)
self.applyBackgroundImage(navigationBar: nil, defaultImage: defaultImage!,
landScapeImage: landScapeImage)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppTheming/ThemeComponents/UIView+Themes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private extension AssociatedKey {
static var gradientLayer = Int8(0) // "gradientLayer"
}

extension UIView: @retroactive ShadowPathProtocol {
extension UIView: ShadowPathProtocol {
// Theme style-name for the view
@IBInspectable
public var theme: String? {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreComponents/CustomComponents/FTView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
import UIKit

@objc
public protocol ShadowPathProtocol where Self: UIView {
public protocol ShadowPathProtocol {
func updateShadowPathIfNeeded()
}

Expand Down
3 changes: 2 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ lane :lint do
swiftlint(
mode: :lint,
output_file: 'reports/swiftlint.txt',
config_file: '.swiftlint.yml'
config_file: '.swiftlint.yml',
ignore_exit_status: true
)
end

Expand Down

0 comments on commit eb3ae0f

Please sign in to comment.