Skip to content

Commit

Permalink
- Added SwiftLint in demo project to fix coding style.
Browse files Browse the repository at this point in the history
- Moved responsibilities of IQKeyboradManger functions to respective extension files.
-  Internal Code improvements.
  • Loading branch information
hackiftekhar committed Aug 26, 2020
1 parent 4dc6bc7 commit 4da83f5
Show file tree
Hide file tree
Showing 59 changed files with 3,384 additions and 3,239 deletions.
22 changes: 22 additions & 0 deletions .swiftlint.yml
@@ -0,0 +1,22 @@
disabled_rules:
- identifier_name
- 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
26 changes: 22 additions & 4 deletions Demo.xcodeproj/project.pbxproj
Expand Up @@ -635,6 +635,7 @@
C0ACB0F119CF104B0057B571 /* Sources */,
C0ACB0F219CF104B0057B571 /* Frameworks */,
C0ACB0F319CF104B0057B571 /* Resources */,
C0B6F1C124F668D6009A24B2 /* ShellScript */,
17B2CF02857B50C3053DFA79 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
Expand Down Expand Up @@ -818,6 +819,23 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
C0B6F1C124F668D6009A24B2 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\"\n";
};
D85D78F460B5CF0FF9536757 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1120,7 +1138,7 @@
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = NO;
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 6.5.6;
CURRENT_PROJECT_VERSION = 6.5.7;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)";
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
Expand Down Expand Up @@ -1157,7 +1175,7 @@
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = NO;
CLANG_WARN_UNREACHABLE_CODE = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
CURRENT_PROJECT_VERSION = 6.5.6;
CURRENT_PROJECT_VERSION = 6.5.7;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
Expand Down Expand Up @@ -1328,7 +1346,7 @@
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Iftekhar Qurashi (RFN29V7Q6Y)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 6.5.6;
CURRENT_PROJECT_VERSION = 6.5.7;
DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -1365,7 +1383,7 @@
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Iftekhar Qurashi (RFN29V7Q6Y)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 6.5.6;
CURRENT_PROJECT_VERSION = 6.5.7;
DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down
Expand Up @@ -41,7 +41,7 @@ - (IBAction)presentClicked:(id)sender
@try {
if (self.navigationController)
{
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:"TextViewSpecialCaseViewController"];
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"TextViewSpecialCaseViewController"];

[controller setModalTransitionStyle:arc4random()%4];

Expand Down
2 changes: 1 addition & 1 deletion Demo/Objective_C_Demo/ViewController/WebViewController.m
Expand Up @@ -28,7 +28,7 @@ - (void)viewDidLoad
self.webView = [[WKWebView alloc] initWithFrame:_webContainerView.bounds configuration:configuration];
self.webView.UIDelegate = self;
self.webView.navigationDelegate = self;
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.webContainerView addSubview:self.webView];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
Expand Down
12 changes: 5 additions & 7 deletions Demo/Swift_Demo/AppDelegate.swift
Expand Up @@ -17,22 +17,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
#if swift(>=4.2)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

IQKeyboardManager.shared.enable = true

return true
}
#else
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

IQKeyboardManager.shared.enable = true
IQKeyboardManager.shared.enableDebugging = true

return true
}
#endif

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
Expand All @@ -55,6 +55,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

8 changes: 4 additions & 4 deletions Demo/Swift_Demo/Cell/ColorTableViewCell.swift
Expand Up @@ -8,10 +8,10 @@

class ColorTableViewCell: UITableViewCell {

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

override func awakeFromNib() {
super.awakeFromNib()
}
Expand Down
5 changes: 2 additions & 3 deletions Demo/Swift_Demo/Cell/ImageSwitchTableViewCell.swift
Expand Up @@ -6,11 +6,10 @@
// Copyright © 2016 Iftekhar. All rights reserved.
//


class ImageSwitchTableViewCell: SwitchTableViewCell {

@IBOutlet var arrowImageView : UIImageView!
@IBOutlet var arrowImageView: UIImageView!

override func awakeFromNib() {
super.awakeFromNib()
}
Expand Down
4 changes: 2 additions & 2 deletions Demo/Swift_Demo/Cell/NavigationTableViewCell.swift
Expand Up @@ -8,8 +8,8 @@

class NavigationTableViewCell: UITableViewCell {

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

override func awakeFromNib() {
super.awakeFromNib()
Expand Down
5 changes: 2 additions & 3 deletions Demo/Swift_Demo/Cell/OptionTableViewCell.swift
Expand Up @@ -6,11 +6,10 @@
// Copyright (c) 2015 Iftekhar. All rights reserved.
//


class OptionTableViewCell: UITableViewCell {

@IBOutlet var labelOption : UILabel!
@IBOutlet var labelOption: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
}
Expand Down
10 changes: 5 additions & 5 deletions Demo/Swift_Demo/Cell/StepperTableViewCell.swift
Expand Up @@ -8,11 +8,11 @@

class StepperTableViewCell: UITableViewCell {

@IBOutlet var labelTitle : UILabel!
@IBOutlet var labelSubtitle : UILabel!
@IBOutlet var stepper : UIStepper!
@IBOutlet var labelStepperValue : UILabel!
@IBOutlet var labelTitle: UILabel!
@IBOutlet var labelSubtitle: UILabel!
@IBOutlet var stepper: UIStepper!
@IBOutlet var labelStepperValue: UILabel!

override func awakeFromNib() {
super.awakeFromNib()
}
Expand Down
8 changes: 4 additions & 4 deletions Demo/Swift_Demo/Cell/SwitchTableViewCell.swift
Expand Up @@ -8,10 +8,10 @@

class SwitchTableViewCell: UITableViewCell {

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

override func awakeFromNib() {
super.awakeFromNib()
}
Expand Down
9 changes: 4 additions & 5 deletions Demo/Swift_Demo/Cell/TextFieldTableViewCell.swift
Expand Up @@ -6,13 +6,12 @@
// Copyright © 2016 Iftekhar. All rights reserved.
//


class TextFieldTableViewCell: UITableViewCell {

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

override func awakeFromNib() {
super.awakeFromNib()
}
Expand Down
38 changes: 19 additions & 19 deletions Demo/Swift_Demo/ViewController/CollectionViewDemoController.swift
Expand Up @@ -8,51 +8,51 @@

import UIKit

class CollectionViewDemoController: UIViewController , UICollectionViewDelegate , UICollectionViewDataSource, UIPopoverPresentationControllerDelegate {
class CollectionViewDemoController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UIPopoverPresentationControllerDelegate {

@IBOutlet var collectionView : UICollectionView!
@IBOutlet var collectionView: UICollectionView!

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

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell : UICollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: "TextFieldCollectionViewCell", for: indexPath)
let textField : UITextField = cell.viewWithTag(10) as! UITextField
textField.placeholder = "\((indexPath as NSIndexPath).section) \((indexPath as NSIndexPath).row)"

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

let textField = cell.viewWithTag(10) as? UITextField
textField?.placeholder = "\((indexPath as NSIndexPath).section) \((indexPath as NSIndexPath).row)"

return cell
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

if let identifier = segue.identifier {

if identifier == "SettingsNavigationController" {

let controller = segue.destination

controller.modalPresentationStyle = .popover
controller.popoverPresentationController?.barButtonItem = sender as? UIBarButtonItem
let heightWidth = max(UIScreen.main.bounds.width, UIScreen.main.bounds.height);

let heightWidth = max(UIScreen.main.bounds.width, UIScreen.main.bounds.height)
controller.preferredContentSize = CGSize(width: heightWidth, height: heightWidth)
controller.popoverPresentationController?.delegate = self
}
}
}

func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}

func prepareForPopoverPresentation(_ popoverPresentationController: UIPopoverPresentationController) {
self.view.endEditing(true)
}
override var shouldAutorotate : Bool {

override var shouldAutorotate: Bool {
return true
}
}

0 comments on commit 4da83f5

Please sign in to comment.