Skip to content

Commit

Permalink
Update SwiftLint
Browse files Browse the repository at this point in the history
  • Loading branch information
ppraveentr committed Oct 25, 2024
1 parent 84f9e40 commit fc740b1
Show file tree
Hide file tree
Showing 34 changed files with 90 additions and 86 deletions.
3 changes: 2 additions & 1 deletion Example/MobileCoreExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@
/* Begin PBXShellScriptBuildPhase section */
D437653C230E8E5B004974CC /* swiftlint Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -654,7 +655,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.ft.$(TARGET_NAME)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG -warn-long-expression-type-checking=300";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OBJC_BRIDGING_HEADER = "$(SWIFT_MODULE_NAME)/$(SWIFT_MODULE_NAME)-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import AppTheming
import CoreComponents
#endif

class SampleTableViewController: UIViewController, @preconcurrency TableViewControllerProtocol {
class SampleTableViewController: UIViewController, TableViewControllerProtocol {

@IBOutlet var footerView: UIView!

Expand Down
9 changes: 2 additions & 7 deletions Sources/AppTheming/AppearanceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension UIView: AppearanceManagerProtocol {

@discardableResult
@objc public class func setUpAppearance(theme: ThemeModel, containerClass: [UIAppearanceContainer.Type]?) -> UIAppearance {
let appearance = (containerClass == nil) ? self.appearance() : self.appearance(whenContainedInInstancesOf: containerClass!)
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 @@ -81,11 +81,6 @@ extension UIView: AppearanceManagerProtocol {
}

extension UISegmentedControl {
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!)
// return appearance
}

public class func setBackgroundImage(imageType: String, image: UIImage) {
let image = image.withRenderingMode(.alwaysTemplate)
Expand All @@ -104,7 +99,7 @@ extension UINavigationBar {
// swiftlint:disable cyclomatic_complexity
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 Down
4 changes: 2 additions & 2 deletions Sources/AppTheming/ThemeComponents/UIButton+Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import UIKit

extension UIButton: ControlThemeProtocol {
// check view state, to update style
open func subStyleName() -> ThemeStyle? {
public func subStyleName() -> ThemeStyle? {
if self.isEnabled {
return nil
}
Expand All @@ -26,7 +26,7 @@ extension UIButton: ControlThemeProtocol {
}

// For custome key:value pairs
open func update(themeDic: ThemeModel, state: UIControl.State) {
public func update(themeDic: ThemeModel, state: UIControl.State) {
let text = self.title(for: state) ?? ""
let range = NSRange(location: 0, length: text.count)
let attribute = NSMutableAttributedString(string: text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2017 Praveen Prabhakar. All rights reserved.
//

import CoreUtility
import Foundation
import UIKit

Expand Down
4 changes: 2 additions & 2 deletions Sources/AppTheming/ThemeComponents/UISearchBar+Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import UIKit

// MARK: AssociatedKey
private extension AssociatedKey {
static var searchUITextField = "searchUITextField"
static var searchBarAttributes = "searchBarAttributes"
static var searchUITextField = Int8(0) // "searchUITextField"
static var searchBarAttributes = Int8(1) // "searchBarAttributes"
}

// MARK: UISearchBar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

extension UISegmentedControl: ControlThemeProtocol {
// check view state, to update style
open func subStyleName() -> ThemeStyle? { nil }
public func subStyleName() -> ThemeStyle? { nil }

public func update(themeDic: ThemeModel, state: UIControl.State) {
if let text = themeDic[ThemeType.Key.tintColor] as? String, let color: UIColor = ThemesManager.getColor(text) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/AppTheming/ThemeComponents/UIView+Themes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import UIKit

// MARK: AssociatedKey
private extension AssociatedKey {
static var gradientLayer = "gradientLayer"
static var gradientLayer = Int8(0) // "gradientLayer"
}

extension UIView: ShadowPathProtocol {
extension UIView: @retroactive ShadowPathProtocol {
// Theme style-name for the view
@IBInspectable
public var theme: String? {
Expand Down
6 changes: 3 additions & 3 deletions Sources/AppTheming/ThemesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ open class ThemesManager {
public static func getColor(_ colorName: String?) -> UIColor? {
guard let colorName = colorName else { return nil }
// Check if its image coded string
if (colorName.hasPrefix("@")), let image = ThemesManager.getImage(colorName) {
if colorName.hasPrefix("@"), let image = ThemesManager.getImage(colorName) {
return image.getColor()
}
// Get hex color
Expand Down Expand Up @@ -296,7 +296,7 @@ extension ThemesManager {
// Component - validity
fileprivate static func isThemeComponentValid(_ component: String) -> Bool {
// Get all the components of spefic type
guard self.themeComponent?[component] as? ThemeModel != nil else { return false }
guard self.themeComponent?[component] is ThemeModel else { return false }
return true
}

Expand Down Expand Up @@ -375,7 +375,7 @@ extension ThemesManager {
data.removeValue(forKey: arg.key)
let dataVersion = NSString(string: key).floatValue
if dataVersion <= deviceVersion, let val = arg.value as? ThemeModel,
(baseModel == nil || (baseModel!.1 < dataVersion)) {
baseModel == nil || (baseModel!.1 < dataVersion) {
baseModel = (val, dataVersion)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import CoreUtility
import Foundation
import UIKit

private var kAOCollectionVC = "k.FT.AO.CollectionViewController"
// MARK: AssociatedKey

private extension AssociatedKey {
static var CollectionVC = Int8(0) // "k.FT.AO.CollectionViewController"
}

public protocol CollectionViewControllerProtocol: ViewControllerProtocol {
var flowLayout: UICollectionViewLayout { get }
Expand Down Expand Up @@ -47,7 +51,7 @@ public extension CollectionViewControllerProtocol {
}

var collectionViewController: UICollectionViewController {
guard let collection = AssociatedObject<UICollectionViewController>.getAssociated(self, key: &kAOCollectionVC) else {
guard let collection = AssociatedObject<UICollectionViewController>.getAssociated(self, key: &AssociatedKey.CollectionVC) else {
return setupCoreCollectionVC()
}
return collection
Expand Down Expand Up @@ -76,7 +80,7 @@ private extension CollectionViewControllerProtocol {
self.addChild(collectionVC)
self.mainView?.pin(view: collectionVC.collectionView, edgeOffsets: .zero)

AssociatedObject<UICollectionViewController>.setAssociated(self, value: collectionVC, key: &kAOCollectionVC)
AssociatedObject<UICollectionViewController>.setAssociated(self, value: collectionVC, key: &AssociatedKey.CollectionVC)

return collectionVC
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ import CoreUtility
import Foundation
import UIKit

private var kAOScrollVC = "k.FT.AO.ScrollViewController"
// MARK: AssociatedKey

private extension AssociatedKey {
static var ScrollVC = Int8(0) // "k.FT.AO.ScrollViewController"
}

public protocol ScrollViewControllerProtocol: ViewControllerProtocol {
var scrollView: UIScrollView { get }
}

public extension ScrollViewControllerProtocol {

var scrollView: UIScrollView {
get {
guard let scroll = AssociatedObject<UIScrollView>.getAssociated(self, key: &kAOScrollVC) else {
guard let scroll = AssociatedObject<UIScrollView>.getAssociated(self, key: &AssociatedKey.ScrollVC) else {
return self.setupScrollView()
}
return scroll
Expand All @@ -37,22 +41,22 @@ private extension ScrollViewControllerProtocol {

@discardableResult
func setupScrollView(_ local: UIScrollView = UIScrollView() ) -> UIScrollView {

// Load Base view
setupCoreView()
if let scroll: UIScrollView = AssociatedObject<UIScrollView>.getAssociated(self, key: &kAOScrollVC) {

if let scroll: UIScrollView = AssociatedObject<UIScrollView>.getAssociated(self, key: &AssociatedKey.ScrollVC) {
scroll.removeSubviews()
AssociatedObject<Any>.resetAssociated(self, key: &kAOScrollVC)
AssociatedObject<Any>.resetAssociated(self, key: &AssociatedKey.ScrollVC)
}

if local.superview == nil {
self.mainView?.pin(view: local, edgeOffsets: .zero)
local.setupContentView(local.contentView)
}
AssociatedObject<UIScrollView>.setAssociated(self, value: local, key: &kAOScrollVC)

AssociatedObject<UIScrollView>.setAssociated(self, value: local, key: &AssociatedKey.ScrollVC)

return local
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public protocol TableViewControllerProtocol: ViewControllerProtocol {

// MARK: AssociatedKey
private extension AssociatedKey {
static var kAOTableVC = "k.FT.AO.TableViewController"
static var kAOTableVC = Int8(0) // "k.FT.AO.TableViewController"
}

public extension TableViewControllerProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension UIViewController {

var isBaseViewAdded: Bool {
// If baseView is not added, then retun false
return (self.baseView?.superview != self.view && self.view != self.baseView)
(self.baseView?.superview != self.view && self.view != self.baseView)
}

// MARK: Utility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public protocol ViewControllerProtocol where Self: UIViewController {
}

private extension AssociatedKey {
static var baseView = "baseView"
static var screenIdentifier = "screenIdentifier"
static var modelStack = "modelStack"
static var completionBlock = "completionBlock"
static var baseView = Int8(0) // "baseView"
static var screenIdentifier = Int8(1) // "screenIdentifier"
static var modelStack = Int8(2) // "modelStack"
static var completionBlock = Int8(3) // "completionBlock"
}

extension UIViewController: ViewControllerProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import CoreUtility
import UIKit
import WebKit

private var kContentVC = "k.FT.AO.ContentViewController"
private extension AssociatedKey {
static var contentVC = Int8(0) // "k.FT.AO.ContentViewController"
}

public protocol WebViewControllerProtocol: ViewControllerProtocol {
var contentView: WKWebView { get }
}

public extension WebViewControllerProtocol {
var contentView: WKWebView {
get { AssociatedObject<WKWebView>.getAssociated(self, key: &kContentVC) { self.setupContentView() }! }
get { AssociatedObject<WKWebView>.getAssociated(self, key: &AssociatedKey.contentVC) { self.setupContentView() }! }
set { setupContentView(newValue) }
}
}
Expand All @@ -33,14 +35,14 @@ private extension WebViewControllerProtocol {
}
// Load Base view
setupCoreView()
if let scroll: WKWebView = AssociatedObject<WKWebView>.getAssociated(self, key: &kContentVC) {
if let scroll: WKWebView = AssociatedObject<WKWebView>.getAssociated(self, key: &AssociatedKey.contentVC) {
scroll.removeFromSuperview()
AssociatedObject<Any>.resetAssociated(self, key: &kContentVC)
AssociatedObject<Any>.resetAssociated(self, key: &AssociatedKey.contentVC)
}
if local.superview == nil {
self.mainView?.pin(view: local, edgeOffsets: .zero)
}
AssociatedObject<WKWebView>.setAssociated(self, value: local, key: &kContentVC)
AssociatedObject<WKWebView>.setAssociated(self, value: local, key: &AssociatedKey.contentVC)
return local
}
}
3 changes: 1 addition & 2 deletions Sources/CoreUtility/AppBundle/BundleURLScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ open class BundleURLScheme {
for urlType in bundleURLTypes {
if
let urlSchemes = (urlType as? NSDictionary)?.value(forKey: "CFBundleURLSchemes") as? NSArray,
urlSchemes.contains(scheme)
{
urlSchemes.contains(scheme) {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreUtility/Extensions/ActionBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public typealias ActionWithObjectBlock = (_ object: AnyObject?) -> Swift.Void

public extension UIControl {
private struct AssociatedKey {
static var actionBlockTapped = "actionBlockTapped"
static var actionBlockTapped = Int8(0) // "actionBlockTapped"
}

func addTapActionBlock(_ actionBlock: @escaping ActionBlock) {
Expand Down
16 changes: 8 additions & 8 deletions Sources/CoreUtility/Extensions/AttributedLabelProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ protocol AttributedLabelProtocol where Self: UILabel {
}

private extension AssociatedKey {
static var textContainer = "textContainer"
static var layoutManager = "layoutManager"
static var styleProperties = "styleProperties"
static var textContainer = Int8(0) // "textContainer"
static var layoutManager = Int8(1) // "layoutManager"
static var styleProperties = Int8(2) // "styleProperties"

static var linkRanges = "linkRanges"
static var islinkDetectionEnabled = "islinkDetectionEnabled"
static var isLinkUnderLineEnabled = "isLinkUnderLineEnabled"
static var linkHandler = "linkHandler"
static var tapGestureRecognizer = "tapGestureRecognizer"
static var linkRanges = Int8(3) // "linkRanges"
static var islinkDetectionEnabled = Int8(4) // "islinkDetectionEnabled"
static var isLinkUnderLineEnabled = Int8(5) // "isLinkUnderLineEnabled"
static var linkHandler = Int8(6) // "linkHandler"
static var tapGestureRecognizer = Int8(7) // "tapGestureRecognizer"
}

extension UILabel: AttributedLabelProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public protocol ScrollingNavBarProtocol where Self: UIViewController {
}

private extension AssociatedKey {
static var navBarScrollableView = "navBar.scrollableView"
static var navBarScrollableView = Int8(0) // "navBar.scrollableView"
}

extension UIViewController: ScrollingNavBarProtocol {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreUtility/Extensions/UIView+Utiltiy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public extension UIView {
if val is T {
return val as? T
}
else if !val.subviews.isEmpty, let subType: T? = val.findInSubView() {
else if !val.subviews.isEmpty, let subType: T? = val.findInSubView() {
return subType
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreUtility/Generic/AssociatedObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import UIKit

public enum AssociatedKey {
public static var defaultKey = "AssociatedKey.defaultKey"
public static var defaultKey = Int8(0) // "AssociatedKey.defaultKey"
}

// Generic way of storing values on runtime
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreUtility/Generic/FlattenIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public extension FlattenIterator {
}
// Array
else if var dicArray = self as? [Any?] {
dicArray = dicArray.filter({ $0 != nil })
dicArray = dicArray.filter { $0 != nil }
self = dicArray.map { val -> Any in
var value = val
return stripSubElements(&value!)
Expand Down
2 changes: 1 addition & 1 deletion Sources/MobileTheming/ThemesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//

#if canImport(MobileTheming)
//import CoreUtility
// import CoreUtility
#endif
import Foundation
import SwiftUI
Expand Down
Loading

0 comments on commit fc740b1

Please sign in to comment.