Skip to content

Commit

Permalink
Update swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaJiang14 committed Sep 28, 2019
1 parent 013ba0d commit 56562c4
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# SJDatePicker
DatePicker for swift 3, using **UIPresentationController** and **UIViewControllerAnimatedTransitioning**.
DatePicker for swift 5, using **UIPresentationController** and **UIViewControllerAnimatedTransitioning**.


## Example
Just run the example project, or clone the repo.


## Requirements
* Xcode 8 or above
* iOS 10
* Swift 3
* Xcode 10 or above
* iOS 11
* Swift 5

![GITHUB](https://github.com/SabrinaJiang14/SJDatePicker/blob/master/Example/demo.gif "demo")

Expand Down
30 changes: 24 additions & 6 deletions SJDatePicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = Sabrina;
TargetAttributes = {
71F93C761E9D477A00FF18AA = {
Expand All @@ -122,7 +122,7 @@
};
buildConfigurationList = 71F93C721E9D477A00FF18AA /* Build configuration list for PBXProject "SJDatePicker" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -190,20 +190,29 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -226,7 +235,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -239,20 +248,29 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -269,7 +287,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.2;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -289,7 +307,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -304,7 +322,7 @@
PRODUCT_BUNDLE_IDENTIFIER = tw.sabrina.SJDatePicker;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
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>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion SJDatePicker/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
7 changes: 4 additions & 3 deletions SJDatePicker/SJDatePicker/CustomPresentationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CustomPresentationController: UIPresentationController {
static let viewLeftPadding:CGFloat = 0
static let viewTopPadding:CGFloat = 170
static let viewHeight:CGFloat = 261
static let buttonTopPadding:CGFloat = 50
static let buttonTopPadding:CGFloat = 80
static let buttonHeight:CGFloat = 40


Expand Down Expand Up @@ -65,13 +65,14 @@ class CustomPresentationController: UIPresentationController {

var frame = containerView.bounds
frame = frame.insetBy(dx: CustomPresentationController.viewLeftPadding, dy: CustomPresentationController.viewTopPadding)
frame.origin.y = containerView.bounds.size.height - CustomPresentationController.viewHeight - CustomPresentationController.buttonTopPadding - CustomPresentationController.viewLeftPadding
frame.origin.y = containerView.bounds.size.height - CustomPresentationController.viewHeight - CustomPresentationController.buttonTopPadding - CustomPresentationController.viewLeftPadding - containerView.safeAreaInsets.bottom + 12

frame.size.height = CustomPresentationController.viewHeight + CustomPresentationController.buttonTopPadding

return frame
}

func dismissSelf(){
@objc func dismissSelf(){
self.presentedViewController.dismiss(animated: true, completion: nil)
}

Expand Down
12 changes: 6 additions & 6 deletions SJDatePicker/SJDatePicker/PresentedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ enum dateformat:String{
class PresentedViewController: UIViewController {

public var buttonColor:UIColor = UIColor.blue
public var pickerMode:UIDatePickerMode = .dateAndTime
public var pickerMode:UIDatePicker.Mode = .dateAndTime
public var minimumDate:Date? = nil
public var maximumDate:Date? = nil
public var returnDateFormat:dateformat = .yyyy_To_ss
public var titleString:String? = nil

fileprivate var picker:UIDatePicker = UIDatePicker.init()
fileprivate var confirmButton:UIButton = UIButton.init()
fileprivate var picker:UIDatePicker = UIDatePicker()
fileprivate var confirmButton:UIButton = UIButton()
fileprivate let cornerRadius:CGFloat = 7.5
fileprivate let highlightedView:UIView = UIView.init()
fileprivate let highlightedView:UIView = UIView()
fileprivate let pickerHeight:CGFloat = 216
fileprivate let pickerWidth:CGFloat = UIScreen.main.bounds.size.width - 10

Expand All @@ -45,7 +45,7 @@ class PresentedViewController: UIViewController {

// Do any additional setup after loading the view.
if titleString != nil {
let titleLabel:UILabel = UILabel.init(frame: CGRect(x: 5, y: 0, width: pickerWidth, height: 40))
let titleLabel:UILabel = UILabel(frame: CGRect(x: 5, y: 0, width: pickerWidth, height: 40))
titleLabel.backgroundColor = UIColor.white
titleLabel.layer.cornerRadius = cornerRadius
titleLabel.layer.masksToBounds = true
Expand Down Expand Up @@ -114,7 +114,7 @@ class PresentedViewController: UIViewController {
self.transitioningDelegate = self
}

func confirmButton_Click(){
@objc func confirmButton_Click(){
if block != nil {
self.dismiss(animated: true, completion: nil)
let df:DateFormatter = DateFormatter.init()
Expand Down

0 comments on commit 56562c4

Please sign in to comment.