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

Update DatePickerDialog.swift #90

Open
wants to merge 8 commits into
base: master
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
11 changes: 7 additions & 4 deletions DatePickerDialog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -458,20 +459,21 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = squimer.DatePickerDialog;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.3;
};
name = Debug;
};
Expand All @@ -480,19 +482,20 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Sources/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = squimer.DatePickerDialog;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.3;
};
name = Release;
};
Expand Down
16 changes: 8 additions & 8 deletions Sources/DatePickerDialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ open class DatePickerDialog: UIView {

// MARK: - Variables
private var defaultDate: Date?
private var datePickerMode: UIDatePickerMode?
private var datePickerMode: UIDatePicker.Mode?
private var callback: DatePickerCallback?
var showCancelButton: Bool = false
var locale: Locale?
Expand Down Expand Up @@ -73,7 +73,7 @@ open class DatePickerDialog: UIView {
/// Handle device orientation changes
@objc func deviceOrientationDidChange(_ notification: Notification) {
self.frame = UIScreen.main.bounds
let dialogSize = CGSize(width: 300, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight)
let dialogSize = CGSize(width: UIScreen.main.bounds.size.width - 10, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight)
dialogView.frame = CGRect(x: (UIScreen.main.bounds.size.width - dialogSize.width) / 2,
y: (UIScreen.main.bounds.size.height - dialogSize.height) / 2,
width: dialogSize.width,
Expand All @@ -86,7 +86,7 @@ open class DatePickerDialog: UIView {
cancelButtonTitle: String = "Cancel",
defaultDate: Date = Date(),
minimumDate: Date? = nil, maximumDate: Date? = nil,
datePickerMode: UIDatePickerMode = .dateAndTime,
datePickerMode: UIDatePicker.Mode = .dateAndTime,
callback: @escaping DatePickerCallback) {
self.titleLabel.text = title
self.doneButton.setTitle(doneButtonTitle, for: .normal)
Expand All @@ -96,7 +96,7 @@ open class DatePickerDialog: UIView {
self.datePickerMode = datePickerMode
self.callback = callback
self.defaultDate = defaultDate
self.datePicker.datePickerMode = self.datePickerMode ?? UIDatePickerMode.date
self.datePicker.datePickerMode = self.datePickerMode ?? UIDatePicker.Mode.date
self.datePicker.date = self.defaultDate ?? Date()
self.datePicker.maximumDate = maximumDate
self.datePicker.minimumDate = minimumDate
Expand All @@ -107,12 +107,12 @@ open class DatePickerDialog: UIView {
guard let appDelegate = UIApplication.shared.delegate else { fatalError() }
guard let window = appDelegate.window else { fatalError() }
window?.addSubview(self)
window?.bringSubview(toFront: self)
window?.bringSubviewToFront(self)
window?.endEditing(true)

NotificationCenter.default.addObserver(self,
selector: .deviceOrientationDidChange,
name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
name: UIDevice.orientationDidChangeNotification, object: nil)

/* Anim */
UIView.animate(
Expand Down Expand Up @@ -159,7 +159,7 @@ open class DatePickerDialog: UIView {
/// Creates the container view here: create the dialog, then add the custom content and buttons
private func createContainerView() -> UIView {
let screenSize = UIScreen.main.bounds.size
let dialogSize = CGSize(width: 300, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight)
let dialogSize = CGSize(width: UIScreen.main.bounds.size.width - 10, height: 230 + kDefaultButtonHeight + kDefaultButtonSpacerHeight)

// For the black background
self.frame = CGRect(x: 0, y: 0, width: screenSize.width, height: screenSize.height)
Expand Down Expand Up @@ -220,7 +220,7 @@ open class DatePickerDialog: UIView {
let datePicker = UIDatePicker(frame: CGRect(x: 0, y: 30, width: 0, height: 0))
datePicker.setValue(self.textColor, forKeyPath: "textColor")
datePicker.autoresizingMask = .flexibleRightMargin
datePicker.frame.size.width = 300
datePicker.frame.size.width = UIScreen.main.bounds.size.width - 10
datePicker.frame.size.height = 216
return datePicker
}
Expand Down