Skip to content

Commit

Permalink
Merge pull request #1990 from hackiftekhar/config_method
Browse files Browse the repository at this point in the history
- New config method to divide responsibilities in more better way.
- This needs many changes before ready for the production, but we need to do it since it's better way than previous approach.
- The Objective-C version currently does not support this feature, and also I'm not planning to do it in Objective-C version in near future. If someone is interested making a Pull Request, then it's super awesome!
  • Loading branch information
hackiftekhar authored Oct 19, 2023
2 parents c00b1ae + a2e6943 commit e0880d8
Show file tree
Hide file tree
Showing 66 changed files with 3,453 additions and 2,834 deletions.
7 changes: 0 additions & 7 deletions Demo/Swift_Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}

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.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/Cell/ColorTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2016 Iftekhar. All rights reserved.
//

import UIKit

class ColorTableViewCell: UITableViewCell {

@IBOutlet var labelTitle: UILabel!
Expand Down
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/Cell/NavigationTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2015 Iftekhar. All rights reserved.
//

import UIKit

class NavigationTableViewCell: UITableViewCell {

@IBOutlet var labelTitle: UILabel!
Expand Down
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/Cell/OptionTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2015 Iftekhar. All rights reserved.
//

import UIKit

class OptionTableViewCell: UITableViewCell {

@IBOutlet var labelOption: UILabel!
Expand Down
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/Cell/StepperTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2015 Iftekhar. All rights reserved.
//

import UIKit

class StepperTableViewCell: UITableViewCell {

@IBOutlet var labelTitle: UILabel!
Expand Down
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/Cell/SwitchTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2015 Iftekhar. All rights reserved.
//

import UIKit

class SwitchTableViewCell: UITableViewCell {

@IBOutlet var labelTitle: UILabel!
Expand Down
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/Cell/TextFieldTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2016 Iftekhar. All rights reserved.
//

import UIKit

class TextFieldTableViewCell: UITableViewCell {

@IBOutlet var labelTitle: UILabel!
Expand Down
11 changes: 7 additions & 4 deletions Demo/Swift_Demo/Storyboard/Base.lproj/General.storyboard
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina5_9" orientation="portrait" appearance="dark"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -162,7 +162,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="63Q-wt-23t">
<rect key="frame" x="0.0" y="596" width="375" height="91"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" tag="108" contentMode="scaleToFill" text="Can resign on touching outside" translatesAutoresizingMaskIntoConstraints="NO" id="wIC-LZ-asw">
<textView clipsSubviews="YES" multipleTouchEnabled="YES" tag="108" contentMode="scaleToFill" text="Can resign on touching outside" translatesAutoresizingMaskIntoConstraints="NO" id="wIC-LZ-asw" customClass="IQTextView" customModule="IQKeyboardManagerSwift">
<rect key="frame" x="20" y="28" width="335" height="35"/>
<color key="backgroundColor" systemColor="systemGray5Color"/>
<color key="tintColor" red="0.2440839877768155" green="0.0" blue="0.47692340353260865" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
Expand All @@ -172,6 +172,9 @@
<color key="textColor" systemColor="labelColor"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="placeholder" value="enableMode = .disabled"/>
</userDefinedRuntimeAttributes>
</textView>
</subviews>
<constraints>
Expand Down Expand Up @@ -645,7 +648,7 @@
<resources>
<image name="settings" width="25" height="25"/>
<systemColor name="labelColor">
<color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand Down
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/ViewController/BaseTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ extension BaseTableViewController {
navController.navigationBar.titleTextAttributes = self.navigationController?.navigationBar.titleTextAttributes
navController.modalPresentationStyle = style
if style == .popover {
let heightWidth = max(UIScreen.main.bounds.width, UIScreen.main.bounds.height)
navController.preferredContentSize = CGSize(width: heightWidth, height: heightWidth)
navController.popoverPresentationController?.barButtonItem = sender
navController.popoverPresentationController?.delegate = self
}
Expand Down
20 changes: 10 additions & 10 deletions Demo/Swift_Demo/ViewController/ManualToolbarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ class ManualToolbarViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()

textField1.addPreviousNextDoneOnKeyboardWithTarget(self, previousAction: #selector(self.previousAction(_:)), nextAction: #selector(self.nextAction(_:)), doneAction: #selector(self.doneAction(_:)), shouldShowPlaceholder: true)
textField1.keyboardToolbar.previousBarButton.isEnabled = false
textField1.keyboardToolbar.nextBarButton.isEnabled = true
textField1.iq.addPreviousNextDone(target: self, previousAction: #selector(self.previousAction(_:)), nextAction: #selector(self.nextAction(_:)), doneAction: #selector(self.doneAction(_:)), showPlaceholder: true)
textField1.iq.toolbar.previousBarButton.isEnabled = false
textField1.iq.toolbar.nextBarButton.isEnabled = true

textField2.addPreviousNextDoneOnKeyboardWithTarget(self, previousAction: #selector(self.previousAction(_:)), nextAction: #selector(self.nextAction(_:)), doneAction: #selector(self.doneAction(_:)), shouldShowPlaceholder: true)
textField2.keyboardToolbar.previousBarButton.isEnabled = true
textField2.keyboardToolbar.nextBarButton.isEnabled = false
textField2.iq.addPreviousNextDone(target: self, previousAction: #selector(self.previousAction(_:)), nextAction: #selector(self.nextAction(_:)), doneAction: #selector(self.doneAction(_:)), showPlaceholder: true)
textField2.iq.toolbar.previousBarButton.isEnabled = true
textField2.iq.toolbar.nextBarButton.isEnabled = false

textView3.addPreviousNextDoneOnKeyboardWithTarget(self, previousAction: #selector(self.previousAction(_:)), nextAction: #selector(self.nextAction(_:)), doneAction: #selector(self.doneAction(_:)), shouldShowPlaceholder: true)
textView3.iq.addPreviousNextDone(target: self, previousAction: #selector(self.previousAction(_:)), nextAction: #selector(self.nextAction(_:)), doneAction: #selector(self.doneAction(_:)), showPlaceholder: true)

textField4.keyboardToolbar.titleBarButton.setTarget(self, action: #selector(self.titleAction(_:)))
textField4.toolbarPlaceholder = "Saved Passwords"
textField4.addDoneOnKeyboardWithTarget(self, action: #selector(self.doneAction(_:)), shouldShowPlaceholder: true)
textField4.iq.toolbar.titleBarButton.setTarget(self, action: #selector(self.titleAction(_:)))
textField4.iq.placeholder = "Saved Passwords"
textField4.iq.addDone(target: self, action: #selector(self.doneAction(_:)), showPlaceholder: true)

textField5.inputAccessoryView = UIView()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NavigationBarViewController: BaseViewController, UITextFieldDelegate {
override func viewDidLoad() {
super.viewDidLoad()

textField3.toolbarPlaceholder = "This is the customised placeholder title for displaying as toolbar title"
textField3.iq.placeholder = "This is the customised placeholder title for displaying as toolbar title"

returnKeyHandler = IQKeyboardReturnKeyHandler(controller: self)
returnKeyHandler.lastTextFieldReturnKeyType = UIReturnKeyType.done
Expand All @@ -40,7 +40,7 @@ class NavigationBarViewController: BaseViewController, UITextFieldDelegate {
}

@IBAction func shouldHideTitle(_ sender: UISwitch!) {
textField2.shouldHideToolbarPlaceholder = !textField2.shouldHideToolbarPlaceholder
textField2.iq.hidePlaceholder = !textField2.iq.hidePlaceholder
}

func textFieldShouldReturn(_ textField: UITextField) -> Bool {
Expand Down
2 changes: 2 additions & 0 deletions Demo/Swift_Demo/ViewController/OptionsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright (c) 2015 Iftekhar. All rights reserved.
//

import UIKit

protocol OptionsViewControllerDelegate: AnyObject {

func optionsViewController(_ controller: OptionsViewController, index: NSInteger)
Expand Down
Loading

0 comments on commit e0880d8

Please sign in to comment.