Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix date picker bug forr iOS 14 #112

Open
wants to merge 1 commit into
base: new
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Alerts&Pickers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = XL743FKK28;
DEVELOPMENT_TEAM = AJLMAG95WU;
INFOPLIST_FILE = "$(SRCROOT)/Example/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "AA.Alerts-Pickers";
Expand All @@ -764,7 +764,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = XL743FKK28;
DEVELOPMENT_TEAM = AJLMAG95WU;
INFOPLIST_FILE = "$(SRCROOT)/Example/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "AA.Alerts-Pickers";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Source/Extensions/String+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension String {
subscript (r: Range<Int>) -> String {
let start = index(startIndex, offsetBy: r.lowerBound)
let end = index(startIndex, offsetBy: r.upperBound)
return String(self[Range(start ..< end)])
return String(self[start ..< end])
}

var containsAlphabets: Bool {
Expand Down
6 changes: 3 additions & 3 deletions Source/Extensions/UISegmentedControl+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import UIKit
public extension UISegmentedControl {

/// Font of titles
public func title(font: UIFont) {
func title(font: UIFont) {
let attributes: [NSAttributedStringKey: Any] = [.font: font]
setTitleTextAttributes(attributes, for: UIControlState())
//setNeedsDisplay()
//layoutIfNeeded()
}

/// Segments titles.
public var segmentTitles: [String?] {
var segmentTitles: [String?] {
get {
var titles: [String?] = []
var i = 0
Expand All @@ -30,7 +30,7 @@ public extension UISegmentedControl {
}

/// Segments images.
public var segmentImages: [UIImage?] {
var segmentImages: [UIImage?] {
get {
var images: [UIImage?] = []
var i = 0
Expand Down
34 changes: 33 additions & 1 deletion Source/Pickers/Date/DatePickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,30 @@ extension UIAlertController {
/// - minimumDate: minimum date of date picker
/// - maximumDate: maximum date of date picker
/// - action: an action for datePicker value change
@available(iOS 13.4, *)
func addDatePicker(mode: UIDatePickerMode, date: Date?, minimumDate: Date? = nil, maximumDate: Date? = nil, style: UIDatePickerStyle = .wheels, action: DatePickerViewController.Action?) {
let datePicker = DatePickerViewController(mode: mode, date: date, minimumDate: minimumDate, maximumDate: maximumDate,style: style ,action: action)

set(vc: datePicker, height: 217)
}


/// Add a date picker
///
/// - Parameters:
/// - mode: date picker mode
/// - date: selected date of date picker
/// - minimumDate: minimum date of date picker
/// - maximumDate: maximum date of date picker
/// - action: an action for datePicker value change
///
func addDatePicker(mode: UIDatePickerMode, date: Date?, minimumDate: Date? = nil, maximumDate: Date? = nil, action: DatePickerViewController.Action?) {
let datePicker = DatePickerViewController(mode: mode, date: date, minimumDate: minimumDate, maximumDate: maximumDate, action: action)
let datePicker = DatePickerViewController(mode: mode, date: date, minimumDate: minimumDate, maximumDate: maximumDate ,action: action)

set(vc: datePicker, height: 217)
}


}

final class DatePickerViewController: UIViewController {
Expand All @@ -28,6 +47,19 @@ final class DatePickerViewController: UIViewController {
return $0
}(UIDatePicker())


@available(iOS 13.4, *)
required init(mode: UIDatePickerMode, date: Date? = nil, minimumDate: Date? = nil, maximumDate: Date? = nil,style: UIDatePickerStyle, action: Action?) {
super.init(nibName: nil, bundle: nil)
datePicker.datePickerMode = mode
datePicker.date = date ?? Date()
datePicker.minimumDate = minimumDate
datePicker.maximumDate = maximumDate
datePicker.preferredDatePickerStyle = style
self.action = action
}


required init(mode: UIDatePickerMode, date: Date? = nil, minimumDate: Date? = nil, maximumDate: Date? = nil, action: Action?) {
super.init(nibName: nil, bundle: nil)
datePicker.datePickerMode = mode
Expand Down
4 changes: 2 additions & 2 deletions Source/Pickers/Location/Managers/SearchHistoryManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ struct SearchHistoryManager {

func history() -> [Location] {
let history = defaults.object(forKey: HistoryKey) as? [NSDictionary] ?? []
return history.flatMap(Location.fromDefaultsDic)
return history.compactMap(Location.fromDefaultsDic)
}

func addToHistory(_ location: Location) {
guard let dic = location.toDefaultsDic() else { return }

var history = defaults.object(forKey: HistoryKey) as? [NSDictionary] ?? []
let historyNames = history.flatMap { $0[LocationDicKeys.name] as? String }
let historyNames = history.compactMap { $0[LocationDicKeys.name] as? String }
let alreadyInHistory = location.name.flatMap(historyNames.contains) ?? false
if !alreadyInHistory {
history.insert(dic, at: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ final class PhotoLibraryPickerViewController: UIViewController {
self.alertController?.dismiss(animated: true)
}
alert.show()
case .limited:
break
}
}

Expand Down
3 changes: 3 additions & 0 deletions Source/Pickers/Telegram/TelegramPickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ final class TelegramPickerViewController: UIViewController {
self.alertController?.dismiss(animated: true)
}
alert.show()
case .limited:
break
}

}

func fetchPhotos(completionHandler: @escaping ([PHAsset]) -> ()) {
Expand Down