Skip to content

Commit

Permalink
Remove CocoaPods, Update to latest RMActionController
Browse files Browse the repository at this point in the history
Updating to latest RMActionController makes RMDateSelectionController compatible with Swift 3.
  • Loading branch information
CooperRS committed Oct 30, 2016
1 parent 4235c5f commit f638e83
Show file tree
Hide file tree
Showing 11 changed files with 443 additions and 304 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Extern/RMActionController"]
path = Extern/RMActionController
url = [email protected]:CooperRS/RMActionController.git
1 change: 1 addition & 0 deletions Extern/RMActionController
Submodule RMActionController added at d4ecf3
6 changes: 0 additions & 6 deletions Podfile

This file was deleted.

17 changes: 0 additions & 17 deletions Podfile.lock

This file was deleted.

598 changes: 376 additions & 222 deletions RMDateSelectionViewController-Demo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0800"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0800"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>Launch Screen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIMainStoryboardFile~ipad</key>
Expand Down
82 changes: 35 additions & 47 deletions RMDateSelectionViewController-SwiftDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,101 +19,89 @@ class ViewController: UITableViewController {

// MARK: Actions
func openDateSelectionViewController() {
var style = RMActionControllerStyle.White
if self.blackSwitch.on {
style = RMActionControllerStyle.Black
var style = RMActionControllerStyle.white
if self.blackSwitch.isOn {
style = RMActionControllerStyle.black
}

let selectAction = RMAction(title: "Select", style: RMActionStyle.Done) { controller in
if let dateController = controller as? RMDateSelectionViewController {
print("Successfully selected date: ", dateController.datePicker.date);
}
let selectAction = RMAction<UIDatePicker>(title: "Select", style: RMActionStyle.done) { controller in
print("Successfully selected date: ", controller.contentView.date);
}

let cancelAction = RMAction(title: "Cancel", style: RMActionStyle.Cancel) { _ in
let cancelAction = RMAction<UIDatePicker>(title: "Cancel", style: RMActionStyle.cancel) { _ in
print("Date selection was canceled")
}

let actionController = RMDateSelectionViewController(style: style, title: "Test", message: "This is a test message.\nPlease choose a date and press 'Select' or 'Cancel'.", selectAction: selectAction, andCancelAction: cancelAction)!;
let actionController = RMDateSelectionViewController(style: style, title: "Test", message: "This is a test message.\nPlease choose a date and press 'Select' or 'Cancel'.", select: selectAction, andCancel: cancelAction)!;

let in15MinAction = RMAction(title: "15 Min", style: .Additional) { controller -> Void in
if let dateController = controller as? RMDateSelectionViewController {
dateController.datePicker.date = NSDate(timeIntervalSinceNow: 15*60);
print("15 Min button tapped");
}
let in15MinAction = RMAction<UIDatePicker>(title: "15 Min", style: .additional) { controller -> Void in
controller.contentView.date = Date(timeIntervalSinceNow: 15*60);
print("15 Min button tapped");
}
in15MinAction!.dismissesActionController = false;

let in30MinAction = RMAction(title: "30 Min", style: .Additional) { controller -> Void in
if let dateController = controller as? RMDateSelectionViewController {
dateController.datePicker.date = NSDate(timeIntervalSinceNow: 30*60);
print("30 Min button tapped");
}
let in30MinAction = RMAction<UIDatePicker>(title: "30 Min", style: .additional) { controller -> Void in
controller.contentView.date = Date(timeIntervalSinceNow: 30*60);
print("30 Min button tapped");
}
in30MinAction!.dismissesActionController = false;

let in45MinAction = RMAction(title: "45 Min", style: .Additional) { controller -> Void in
if let dateController = controller as? RMDateSelectionViewController {
dateController.datePicker.date = NSDate(timeIntervalSinceNow: 45*60);
print("45 Min button tapped");
}
let in45MinAction = RMAction<UIDatePicker>(title: "45 Min", style: .additional) { controller -> Void in
controller.contentView.date = Date(timeIntervalSinceNow: 45*60);
print("45 Min button tapped");
}
in45MinAction!.dismissesActionController = false;

let in60MinAction = RMAction(title: "60 Min", style: .Additional) { controller -> Void in
if let dateController = controller as? RMDateSelectionViewController {
dateController.datePicker.date = NSDate(timeIntervalSinceNow: 60*60);
print("60 Min button tapped");
}
let in60MinAction = RMAction<UIDatePicker>(title: "60 Min", style: .additional) { controller -> Void in
controller.contentView.date = Date(timeIntervalSinceNow: 60*60);
print("60 Min button tapped");
}
in60MinAction!.dismissesActionController = false;

let groupedAction = RMGroupedAction(style: .Additional, andActions: [in15MinAction!, in30MinAction!, in45MinAction!, in60MinAction!]);
let groupedAction = RMGroupedAction<UIDatePicker>(style: .additional, andActions: [in15MinAction!, in30MinAction!, in45MinAction!, in60MinAction!]);
actionController.addAction(groupedAction!);

let nowAction = RMAction(title: "Now", style: .Additional) { controller -> Void in
if let dateController = controller as? RMDateSelectionViewController {
dateController.datePicker.date = NSDate();
print("Now button tapped");
}
let nowAction = RMAction<UIDatePicker>(title: "Now", style: .additional) { controller -> Void in
controller.contentView.date = Date();
print("Now button tapped");
}
nowAction!.dismissesActionController = false;

actionController.addAction(nowAction!);

//You can enable or disable blur, bouncing and motion effects
actionController.disableBouncingEffects = !self.bouncingSwitch.on
actionController.disableMotionEffects = !self.motionSwitch.on
actionController.disableBlurEffects = !self.blurSwitch.on
actionController.disableBouncingEffects = !self.bouncingSwitch.isOn
actionController.disableMotionEffects = !self.motionSwitch.isOn
actionController.disableBlurEffects = !self.blurSwitch.isOn

//You can access the actual UIDatePicker via the datePicker property
actionController.datePicker.datePickerMode = .DateAndTime;
actionController.datePicker.datePickerMode = .dateAndTime;
actionController.datePicker.minuteInterval = 5;
actionController.datePicker.date = NSDate(timeIntervalSinceReferenceDate: 0);
actionController.datePicker.date = Date(timeIntervalSinceReferenceDate: 0);

//On the iPad we want to show the date selection view controller within a popover. Fortunately, we can use iOS 8 API for this! :)
//(Of course only if we are running on iOS 8 or later)
if actionController.respondsToSelector(Selector("popoverPresentationController:")) && UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad {
if actionController.responds(to: Selector(("popoverPresentationController:"))) && UIDevice.current.userInterfaceIdiom == .pad {
//First we set the modal presentation style to the popover style
actionController.modalPresentationStyle = UIModalPresentationStyle.Popover
actionController.modalPresentationStyle = UIModalPresentationStyle.popover

//Then we tell the popover presentation controller, where the popover should appear
if let popoverPresentationController = actionController.popoverPresentationController {
popoverPresentationController.sourceView = self.tableView
popoverPresentationController.sourceRect = self.tableView.rectForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0))
popoverPresentationController.sourceRect = self.tableView.rectForRow(at: IndexPath.init(row: 0, section: 0))
}
}

//Now just present the date selection controller using the standard iOS presentation method
presentViewController(actionController, animated: true, completion: nil)
present(actionController, animated: true, completion: nil)
}

// MARK: UITableView Delegates
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if indexPath.section == 0 && indexPath.row == 0 {
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath as NSIndexPath).section == 0 && (indexPath as NSIndexPath).row == 0 {
openDateSelectionViewController()
}
tableView.deselectRowAtIndexPath(indexPath, animated: true)
tableView.deselectRow(at: indexPath, animated: true)
}

}
Expand Down
24 changes: 24 additions & 0 deletions RMDateSelectionViewController/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

0 comments on commit f638e83

Please sign in to comment.