Skip to content

Commit

Permalink
- Handled all swiftlint warnings and errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hackiftekhar committed Oct 19, 2023
1 parent e0880d8 commit 76b5093
Show file tree
Hide file tree
Showing 71 changed files with 1,557 additions and 1,511 deletions.
23 changes: 0 additions & 23 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
disabled_rules:
- function_parameter_count
- cyclomatic_complexity

excluded:
- Pods

force_cast: warning

type_name:
validates_start_with_lowercase: false

function_body_length:
warning: 100
error: 400

file_length:
warning: 800
error: 1200

line_length: 400

identifier_name:
min_length:
warning: 2
error: 1
16 changes: 16 additions & 0 deletions Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
C0017B791BAD943400BD1D70 /* CustomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0017B781BAD943400BD1D70 /* CustomViewController.swift */; };
C01955F22ADB4A3A00012505 /* NonScrollTextView1979ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C01955F12ADB4A3A00012505 /* NonScrollTextView1979ViewController.swift */; };
C01C943E2ACDF39000540DD6 /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C01C943D2ACDF39000540DD6 /* NavigationController.swift */; };
C0382D222AE1632B00EBE4B4 /* SettingsViewController+TableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0382D212AE1632B00EBE4B4 /* SettingsViewController+TableView.swift */; };
C03C87F51B8DCBF100295DFA /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03C87F41B8DCBF100295DFA /* SettingsViewController.swift */; };
C03C87F71B8DCC1400295DFA /* OptionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03C87F61B8DCC1400295DFA /* OptionsViewController.swift */; };
C03C87F91B8DCEC400295DFA /* NavigationTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C03C87F81B8DCEC400295DFA /* NavigationTableViewCell.swift */; };
Expand All @@ -71,6 +72,7 @@
C06E24F62ACB3FA7002ECBE4 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E24F52ACB3FA7002ECBE4 /* TableViewController.swift */; };
C06E24F82ACB3FD8002ECBE4 /* StackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E24F72ACB3FD8002ECBE4 /* StackViewController.swift */; };
C06E24FA2ACB4015002ECBE4 /* PageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C06E24F92ACB4015002ECBE4 /* PageViewController.swift */; };
C07DF1302AE17BB600698057 /* UITableView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C07DF12F2AE17BB600698057 /* UITableView+Extension.swift */; };
C08372572ACAFE6500416081 /* ReloadLayout1892ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C08372562ACAFE6500416081 /* ReloadLayout1892ViewController.swift */; };
C08372592ACB046900416081 /* SafeAreaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C08372582ACB046900416081 /* SafeAreaViewController.swift */; };
C083725D2ACB1C2100416081 /* EdgesForExtendedLayoutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C083725C2ACB1C2100416081 /* EdgesForExtendedLayoutViewController.swift */; };
Expand Down Expand Up @@ -225,6 +227,7 @@
C0017B781BAD943400BD1D70 /* CustomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomViewController.swift; sourceTree = "<group>"; };
C01955F12ADB4A3A00012505 /* NonScrollTextView1979ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NonScrollTextView1979ViewController.swift; sourceTree = "<group>"; };
C01C943D2ACDF39000540DD6 /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = "<group>"; };
C0382D212AE1632B00EBE4B4 /* SettingsViewController+TableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SettingsViewController+TableView.swift"; sourceTree = "<group>"; };
C03C87F41B8DCBF100295DFA /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
C03C87F61B8DCC1400295DFA /* OptionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OptionsViewController.swift; sourceTree = "<group>"; };
C03C87F81B8DCEC400295DFA /* NavigationTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationTableViewCell.swift; sourceTree = "<group>"; };
Expand All @@ -242,6 +245,7 @@
C06E24F52ACB3FA7002ECBE4 /* TableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = "<group>"; };
C06E24F72ACB3FD8002ECBE4 /* StackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackViewController.swift; sourceTree = "<group>"; };
C06E24F92ACB4015002ECBE4 /* PageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PageViewController.swift; sourceTree = "<group>"; };
C07DF12F2AE17BB600698057 /* UITableView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITableView+Extension.swift"; sourceTree = "<group>"; };
C08372562ACAFE6500416081 /* ReloadLayout1892ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReloadLayout1892ViewController.swift; sourceTree = "<group>"; };
C08372582ACB046900416081 /* SafeAreaViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafeAreaViewController.swift; sourceTree = "<group>"; };
C083725C2ACB1C2100416081 /* EdgesForExtendedLayoutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EdgesForExtendedLayoutViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -413,6 +417,7 @@
children = (
C03C87F61B8DCC1400295DFA /* OptionsViewController.swift */,
C03C87F41B8DCBF100295DFA /* SettingsViewController.swift */,
C0382D212AE1632B00EBE4B4 /* SettingsViewController+TableView.swift */,
);
name = Settings;
sourceTree = "<group>";
Expand All @@ -429,6 +434,14 @@
path = DemoExtension;
sourceTree = "<group>";
};
C07DF12E2AE17B9900698057 /* Extension */ = {
isa = PBXGroup;
children = (
C07DF12F2AE17BB600698057 /* UITableView+Extension.swift */,
);
path = Extension;
sourceTree = "<group>";
};
C0B63B901781FAB0008D3B64 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -619,6 +632,7 @@
C0CB61D31B884D4100C33368 /* Resources */,
C0CB61D71B884D4100C33368 /* Storyboard */,
C0CB61D91B884D4100C33368 /* ViewController */,
C07DF12E2AE17B9900698057 /* Extension */,
4CE6119E1B98B7250020591A /* DemoObjCUITests */,
);
name = Swift_Demo;
Expand Down Expand Up @@ -1089,6 +1103,7 @@
C03C87FB1B8DCED400295DFA /* OptionTableViewCell.swift in Sources */,
C03C87FF1B8DCEF400295DFA /* SwitchTableViewCell.swift in Sources */,
C03C87FD1B8DCEE700295DFA /* StepperTableViewCell.swift in Sources */,
C0382D222AE1632B00EBE4B4 /* SettingsViewController+TableView.swift in Sources */,
C0CB61EF1B884F2700C33368 /* ExampleTableViewController.swift in Sources */,
C0CB61F31B884F2700C33368 /* SpecialCaseViewController.swift in Sources */,
C06E24F42ACB3F6F002ECBE4 /* TableViewContainerViewController.swift in Sources */,
Expand All @@ -1097,6 +1112,7 @@
C08372572ACAFE6500416081 /* ReloadLayout1892ViewController.swift in Sources */,
4CE74F5D1CF185F70093AC0C /* HFColorPickerView.m in Sources */,
C0CB61FC1B884F7900C33368 /* AppDelegate.swift in Sources */,
C07DF1302AE17BB600698057 /* UITableView+Extension.swift in Sources */,
C06E24FA2ACB4015002ECBE4 /* PageViewController.swift in Sources */,
C0CB61EE1B884F2700C33368 /* CollectionViewDemoController.swift in Sources */,
C0CB61F81B884F2700C33368 /* ViewController.swift in Sources */,
Expand Down
3 changes: 2 additions & 1 deletion Demo/Swift_Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

window?.backgroundColor = UIColor.white
Expand Down
5 changes: 0 additions & 5 deletions Demo/Swift_Demo/Cell/ColorTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ class ColorTableViewCell: UITableViewCell {
@IBOutlet var labelTitle: UILabel!
@IBOutlet var labelSubtitle: UILabel!
@IBOutlet var colorPickerTextField: ColorPickerTextField!

override func awakeFromNib() {
super.awakeFromNib()
}

}
4 changes: 0 additions & 4 deletions Demo/Swift_Demo/Cell/ImageSwitchTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@
class ImageSwitchTableViewCell: SwitchTableViewCell {

@IBOutlet var arrowImageView: UIImageView!

override func awakeFromNib() {
super.awakeFromNib()
}
}
4 changes: 0 additions & 4 deletions Demo/Swift_Demo/Cell/NavigationTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ class NavigationTableViewCell: UITableViewCell {

@IBOutlet var labelTitle: UILabel!
@IBOutlet var labelSubtitle: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
}
}
4 changes: 0 additions & 4 deletions Demo/Swift_Demo/Cell/OptionTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ import UIKit
class OptionTableViewCell: UITableViewCell {

@IBOutlet var labelOption: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
}
}
4 changes: 0 additions & 4 deletions Demo/Swift_Demo/Cell/StepperTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@ class StepperTableViewCell: UITableViewCell {
@IBOutlet var labelSubtitle: UILabel!
@IBOutlet var stepper: UIStepper!
@IBOutlet var labelStepperValue: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
}
}
4 changes: 0 additions & 4 deletions Demo/Swift_Demo/Cell/SwitchTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ class SwitchTableViewCell: UITableViewCell {
@IBOutlet var labelTitle: UILabel!
@IBOutlet var labelSubtitle: UILabel!
@IBOutlet var switchEnable: UISwitch!

override func awakeFromNib() {
super.awakeFromNib()
}
}
4 changes: 0 additions & 4 deletions Demo/Swift_Demo/Cell/TextFieldTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ class TextFieldTableViewCell: UITableViewCell {
@IBOutlet var labelTitle: UILabel!
@IBOutlet var labelSubtitle: UILabel!
@IBOutlet var textField: UITextField!

override func awakeFromNib() {
super.awakeFromNib()
}
}
29 changes: 29 additions & 0 deletions Demo/Swift_Demo/Extension/UITableView+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// UITableView+Extension.swift
// DemoSwift
//
// Created by Iftekhar on 10/19/23.
// Copyright © 2023 Iftekhar. All rights reserved.
//

import UIKit

extension UITableView {
func dequeueCell<T: UITableViewCell>(_: T.Type, for indexPath: IndexPath) -> T {
let identifier: String = String(describing: T.self)
guard let cell = dequeueReusableCell(withIdentifier: identifier, for: indexPath) as? T else {
fatalError("Could not dequeue \(T.self)")
}

return cell
}

func dequeueHeaderFooter<T: UITableViewHeaderFooterView>(_: T.Type) -> T {
let identifier: String = String(describing: T.self)
if let view = dequeueReusableHeaderFooterView(withIdentifier: identifier) as? T {
return view
} else {
return T(reuseIdentifier: identifier)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import UIKit

class AutofillPasswordViewController: BaseViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

@IBAction private func loginActin(_ sender: UIButton) {
self.view.endEditing(true)
DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: {
Expand Down
18 changes: 10 additions & 8 deletions Demo/Swift_Demo/ViewController/BaseTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import UIKit

class BaseTableViewController: UITableViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

let presentButtonTitle = (self.presentingViewController == nil) ? "Present" : "Dismiss"
let presentBarButtonItem = UIBarButtonItem(title: presentButtonTitle, style: .done, target: self, action: #selector(presentAction(_:)))

let settingsBarButtongItem = UIBarButtonItem(image: UIImage(named: "settings"), style: .done, target: self, action: #selector(settingsAction(_:)))
let presentBarButtonItem = UIBarButtonItem(title: presentButtonTitle,
style: .done,
target: self,
action: #selector(presentAction(_:)))

let settingsBarButtongItem = UIBarButtonItem(image: UIImage(named: "settings"),
style: .done,
target: self,
action: #selector(settingsAction(_:)))
self.navigationItem.rightBarButtonItems = [settingsBarButtongItem, presentBarButtonItem]
}

Expand Down Expand Up @@ -104,7 +106,7 @@ extension BaseTableViewController {

@IBAction private func settingsAction(_ sender: UIBarButtonItem) {
let storyboard = UIStoryboard(name: "Settings", bundle: nil)
let controller: UIViewController = storyboard.instantiateViewController(withIdentifier: "SettingsViewController")
let controller = storyboard.instantiateViewController(withIdentifier: "SettingsViewController")
controller.popoverPresentationController?.barButtonItem = sender

let heightWidth = max(UIScreen.main.bounds.width, UIScreen.main.bounds.height)
Expand Down
18 changes: 10 additions & 8 deletions Demo/Swift_Demo/ViewController/BaseViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import UIKit

class BaseViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

let presentButtonTitle = (self.presentingViewController == nil) ? "Present" : "Dismiss"
let presentBarButtonItem = UIBarButtonItem(title: presentButtonTitle, style: .done, target: self, action: #selector(presentAction(_:)))

let settingsBarButtongItem = UIBarButtonItem(image: UIImage(named: "settings"), style: .done, target: self, action: #selector(settingsAction(_:)))
let presentBarButtonItem = UIBarButtonItem(title: presentButtonTitle,
style: .done,
target: self,
action: #selector(presentAction(_:)))

let settingsBarButtongItem = UIBarButtonItem(image: UIImage(named: "settings"),
style: .done,
target: self,
action: #selector(settingsAction(_:)))
self.navigationItem.rightBarButtonItems = [settingsBarButtongItem, presentBarButtonItem]
}

Expand Down Expand Up @@ -104,7 +106,7 @@ extension BaseViewController {

@IBAction private func settingsAction(_ sender: UIBarButtonItem) {
let storyboard = UIStoryboard(name: "Settings", bundle: nil)
let controller: UIViewController = storyboard.instantiateViewController(withIdentifier: "SettingsViewController")
let controller = storyboard.instantiateViewController(withIdentifier: "SettingsViewController")
controller.popoverPresentationController?.barButtonItem = sender

let heightWidth = max(UIScreen.main.bounds.width, UIScreen.main.bounds.height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ class CollectionViewDemoController: BaseViewController, UICollectionViewDelegate

@IBOutlet var collectionView: UICollectionView!

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
func collectionView(_ collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return 10
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

let cell: UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "TextFieldCollectionViewCell", for: indexPath)
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TextFieldCollectionViewCell",
for: indexPath)

let textField = cell.viewWithTag(10) as? UITextField
textField?.placeholder = "\(indexPath.section) \(indexPath.row)"
Expand Down
73 changes: 48 additions & 25 deletions Demo/Swift_Demo/ViewController/CustomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,54 @@ class CustomViewController: BaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

switchDisableViewController.isOn = IQKeyboardManager.shared.disabledDistanceHandlingClasses.contains(where: { element in
return element == CustomViewController.self
})

switchEnableViewController.isOn = IQKeyboardManager.shared.enabledDistanceHandlingClasses.contains(where: { element in
return element == CustomViewController.self
})

switchDisableToolbar.isOn = IQKeyboardManager.shared.disabledToolbarClasses.contains(where: { element in
return element == CustomViewController.self
})
switchEnableToolbar.isOn = IQKeyboardManager.shared.enabledToolbarClasses.contains(where: { element in
return element == CustomViewController.self
})

switchDisableTouchResign.isOn = IQKeyboardManager.shared.disabledTouchResignedClasses.contains(where: { element in
return element == CustomViewController.self
})
switchEnableTouchResign.isOn = IQKeyboardManager.shared.enabledTouchResignedClasses.contains(where: { element in
return element == CustomViewController.self
})

switchAllowPreviousNext.isOn = IQKeyboardManager.shared.toolbarPreviousNextAllowedClasses.contains(where: { element in
return element == IQPreviousNextView.self
})
do {
let classes = IQKeyboardManager.shared.disabledDistanceHandlingClasses
switchDisableViewController.isOn = classes.contains(where: { element in
return element == CustomViewController.self
})
}

do {
let classes = IQKeyboardManager.shared.enabledDistanceHandlingClasses
switchEnableViewController.isOn = classes.contains(where: { element in
return element == CustomViewController.self
})
}

do {
let classes = IQKeyboardManager.shared.disabledToolbarClasses
switchDisableToolbar.isOn = classes.contains(where: { element in
return element == CustomViewController.self
})
}

do {
let classes = IQKeyboardManager.shared.enabledToolbarClasses
switchEnableToolbar.isOn = classes.contains(where: { element in
return element == CustomViewController.self
})
}

do {
let classes = IQKeyboardManager.shared.disabledTouchResignedClasses
switchDisableTouchResign.isOn = classes.contains(where: { element in
return element == CustomViewController.self
})
}

do {
let classes = IQKeyboardManager.shared.enabledTouchResignedClasses
switchEnableTouchResign.isOn = classes.contains(where: { element in
return element == CustomViewController.self
})
}

do {
let classes = IQKeyboardManager.shared.toolbarPreviousNextAllowedClasses
switchAllowPreviousNext.isOn = classes.contains(where: { element in
return element == IQPreviousNextView.self
})
}
}

@IBAction func tapAction(_ sender: UITapGestureRecognizer) {
Expand Down
Loading

0 comments on commit 76b5093

Please sign in to comment.