Skip to content

Commit

Permalink
- Removed few unused compiler checks
Browse files Browse the repository at this point in the history
- updated placeholder textColor to match system placeholderText color
  • Loading branch information
hackiftekhar committed Feb 5, 2024
1 parent 6e7be69 commit 644ed11
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 88 deletions.
2 changes: 1 addition & 1 deletion IQKeyboardManager/IQTextView/IQTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ -(UILabel*)placeholderLabel
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000
if (@available(iOS 13.0, *))
{
_placeholderLabel.textColor = [UIColor systemGrayColor];
_placeholderLabel.textColor = [UIColor placeholderTextColor];
}
else
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,22 @@ internal struct IQRootControllerConfiguration {
beginSafeAreaInsets = rootController.view.safeAreaInsets

let interfaceOrientation: UIInterfaceOrientation
#if swift(>=5.1)
if #available(iOS 13, *) {
if let scene = rootController.view.window?.windowScene {
interfaceOrientation = scene.interfaceOrientation
} else {
interfaceOrientation = .unknown
}
if let scene = rootController.view.window?.windowScene {
interfaceOrientation = scene.interfaceOrientation
} else {
interfaceOrientation = UIApplication.shared.statusBarOrientation
interfaceOrientation = .unknown
}
#else
interfaceOrientation = UIApplication.shared.statusBarOrientation
#endif

beginOrientation = interfaceOrientation
}

var currentOrientation: UIInterfaceOrientation {
let interfaceOrientation: UIInterfaceOrientation
#if swift(>=5.1)
if #available(iOS 13, *) {
if let scene = rootController.view.window?.windowScene {
interfaceOrientation = scene.interfaceOrientation
} else {
interfaceOrientation = .unknown
}
if let scene = rootController.view.window?.windowScene {
interfaceOrientation = scene.interfaceOrientation
} else {
interfaceOrientation = UIApplication.shared.statusBarOrientation
interfaceOrientation = .unknown
}
#else
interfaceOrientation = UIApplication.shared.statusBarOrientation
#endif
return interfaceOrientation
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,7 @@ internal struct IQScrollViewConfiguration {

startingContentOffset = scrollView.contentOffset
startingContentInset = scrollView.contentInset

#if swift(>=5.1)
if #available(iOS 11.1, *) {
startingScrollIndicatorInsets = scrollView.verticalScrollIndicatorInsets
} else {
startingScrollIndicatorInsets = scrollView.scrollIndicatorInsets
}
#else
startingScrollIndicatorInsets = scrollView.scrollIndicatorInsets
#endif
startingScrollIndicatorInsets = scrollView.verticalScrollIndicatorInsets
}

var hasChanged: Bool {
Expand All @@ -74,21 +65,9 @@ internal struct IQScrollViewConfiguration {
success = true
}

#if swift(>=5.1)
if #available(iOS 11.1, *) {
if scrollView.verticalScrollIndicatorInsets != self.startingScrollIndicatorInsets {
scrollView.verticalScrollIndicatorInsets = self.startingScrollIndicatorInsets
}
} else {
if scrollView.scrollIndicatorInsets != self.startingScrollIndicatorInsets {
scrollView.scrollIndicatorInsets = self.startingScrollIndicatorInsets
}
}
#else
if scrollView.scrollIndicatorInsets != self.startingScrollIndicatorInsets {
scrollView.scrollIndicatorInsets = self.startingScrollIndicatorInsets
if scrollView.verticalScrollIndicatorInsets != self.startingScrollIndicatorInsets {
scrollView.verticalScrollIndicatorInsets = self.startingScrollIndicatorInsets
}
#endif

if canRestoreContentOffset,
scrollView.iq.restoreContentOffset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,7 @@ public extension IQKeyboardManager {
if let navigationController: UINavigationController = rootController.navigationController {
navigationBarAreaHeight = navigationController.navigationBar.frame.maxY
} else {
#if swift(>=5.1)
if #available(iOS 13, *) {
statusBarHeight = window.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
} else {
statusBarHeight = UIApplication.shared.statusBarFrame.height
}
#else
statusBarHeight = UIApplication.shared.statusBarFrame.height
#endif
statusBarHeight = window.windowScene?.statusBarManager?.statusBarFrame.height ?? 0
navigationBarAreaHeight = statusBarHeight
}

Expand Down Expand Up @@ -509,17 +501,7 @@ public extension IQKeyboardManager {
lastScrollView.contentInset = movedInsets
lastScrollView.layoutIfNeeded() // (Bug ID: #1996)

var newScrollIndicatorInset: UIEdgeInsets

#if swift(>=5.1)
if #available(iOS 11.1, *) {
newScrollIndicatorInset = lastScrollView.verticalScrollIndicatorInsets
} else {
newScrollIndicatorInset = lastScrollView.scrollIndicatorInsets
}
#else
newScrollIndicatorInset = lastScrollView.scrollIndicatorInsets
#endif
var newScrollIndicatorInset: UIEdgeInsets = lastScrollView.verticalScrollIndicatorInsets

newScrollIndicatorInset.bottom = bottomScrollIndicatorInset
lastScrollView.scrollIndicatorInsets = newScrollIndicatorInset
Expand Down
6 changes: 1 addition & 5 deletions IQKeyboardManagerSwift/IQTextView/IQTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ import UIKit
label.textAlignment = self.textAlignment
label.backgroundColor = UIColor.clear
label.isAccessibilityElement = false
#if swift(>=5.1)
label.textColor = UIColor.systemGray
#else
label.textColor = UIColor.lightText
#endif
label.textColor = UIColor.placeholderText
label.alpha = 0
self.addSubview(label)

Expand Down
8 changes: 0 additions & 8 deletions IQKeyboardManagerSwift/IQToolbar/IQTitleBarButtonItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ import UIKit
if let color: UIColor = selectableTitleColor {
titleButton?.setTitleColor(color, for: .normal)
} else {
#if swift(>=5.1)
titleButton?.setTitleColor(UIColor.systemBlue, for: .normal)
#else
titleButton?.setTitleColor(UIColor(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
#endif
}
}
}
Expand All @@ -97,11 +93,7 @@ import UIKit
titleButton?.isEnabled = false
titleButton?.titleLabel?.numberOfLines = 3
titleButton?.setTitleColor(UIColor.lightGray, for: .disabled)
#if swift(>=5.1)
titleButton?.setTitleColor(UIColor.systemBlue, for: .normal)
#else
titleButton?.setTitleColor(UIColor(red: 0.0, green: 0.5, blue: 1.0, alpha: 1), for: .normal)
#endif
titleButton?.backgroundColor = UIColor.clear
titleButton?.titleLabel?.textAlignment = .center
titleButton?.setTitle(title, for: .normal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@ public extension IQKeyboardManagerWrapper where Base: UIView {
return unwrappedToolbar
} else {

let width: CGFloat

if #available(iOS 13.0, *) {
width = base.window?.windowScene?.screen.bounds.width ?? 0
} else {
width = UIScreen.main.bounds.width
}
let width: CGFloat = base.window?.windowScene?.screen.bounds.width ?? 0

let frame = CGRect(origin: .zero, size: .init(width: width, height: 44))
let newToolbar = IQToolbar(frame: frame)
Expand Down
2 changes: 1 addition & 1 deletion IQKeyboardManagerSwift/LIsteners/Info/IQKeyboardInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public struct IQKeyboardInfo: Equatable {
self.name = name

let screenBounds: CGRect
if #available(iOS 13.0, *), let screen: UIScreen = notification?.object as? UIScreen {
if let screen: UIScreen = notification?.object as? UIScreen {
screenBounds = screen.bounds
} else {
screenBounds = UIScreen.main.bounds
Expand Down

0 comments on commit 644ed11

Please sign in to comment.