Skip to content

Commit

Permalink
Merge pull request #77 from rayhannabi/release/0.6.6.beta.2
Browse files Browse the repository at this point in the history
Release/0.6.6.beta.2
  • Loading branch information
rayhannabi committed Oct 7, 2019
2 parents 254fe00 + 117bf81 commit 6e8d870
Show file tree
Hide file tree
Showing 31 changed files with 430 additions and 79 deletions.
2 changes: 1 addition & 1 deletion RNAlertController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Pod::Spec.new do |spec|

spec.name = "RNAlertController"
spec.version = "0.6.6.beta.1"
spec.version = "0.6.6.beta.2"
spec.summary = "Custom Alert Framework for iOS"

spec.description = <<-DESC
Expand Down
51 changes: 9 additions & 42 deletions RNAlertController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
E85086C6231E65F800F0D6B3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E85086AF231E649700F0D6B3 /* Main.storyboard */; };
E85086C7231E670200F0D6B3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E85086B7231E649700F0D6B3 /* Assets.xcassets */; };
E85EC3DE2293F6FA00C7B417 /* AlertURLButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = E85EC3DD2293F6FA00C7B417 /* AlertURLButton.swift */; };
E8722543234B14E10054A937 /* AlertDatePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8722542234B14E10054A937 /* AlertDatePicker.swift */; };
E8CE528F227B07D200466CAF /* AlertImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8CE528E227B07D200466CAF /* AlertImageView.swift */; };
E8CE5291227B092400466CAF /* AlertStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8CE5290227B092400466CAF /* AlertStackView.swift */; };
E8CE5293227B0FD400466CAF /* AlertContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8CE5292227B0FD400466CAF /* AlertContainerView.swift */; };
Expand Down Expand Up @@ -92,6 +93,7 @@
E85086BA231E649700F0D6B3 /* UIView+Corner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Corner.swift"; sourceTree = "<group>"; };
E85086CC231E6BBA00F0D6B3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E85EC3DD2293F6FA00C7B417 /* AlertURLButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertURLButton.swift; sourceTree = "<group>"; };
E8722542234B14E10054A937 /* AlertDatePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertDatePicker.swift; sourceTree = "<group>"; };
E8CE528E227B07D200466CAF /* AlertImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertImageView.swift; sourceTree = "<group>"; };
E8CE5290227B092400466CAF /* AlertStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertStackView.swift; sourceTree = "<group>"; };
E8CE5292227B0FD400466CAF /* AlertContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertContainerView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -152,10 +154,11 @@
E813210D231E7343007BD8F7 /* Views */ = {
isa = PBXGroup;
children = (
E8ECFADC22772EFB00D4BA3F /* AlertButton.swift */,
E8FEEE232310409200A155E2 /* AlertActionButton.swift */,
E8ECFADC22772EFB00D4BA3F /* AlertButton.swift */,
E8ECFADE22772EFB00D4BA3F /* AlertButtonStackView.swift */,
E8CE5292227B0FD400466CAF /* AlertContainerView.swift */,
E8722542234B14E10054A937 /* AlertDatePicker.swift */,
E8CE528E227B07D200466CAF /* AlertImageView.swift */,
E8ECFADB22772EFB00D4BA3F /* AlertLabel.swift */,
E8CE5294227C506000466CAF /* AlertPickerView.swift */,
Expand Down Expand Up @@ -298,7 +301,6 @@
E8508697231E647600F0D6B3 /* Frameworks */,
E8508698231E647600F0D6B3 /* Resources */,
E85086C4231E656C00F0D6B3 /* Embed Frameworks */,
E8F6B2EB233E4C8F006A03F4 /* ShellScript */,
);
buildRules = (
);
Expand All @@ -318,7 +320,6 @@
E8ECFAC722772ED000D4BA3F /* Sources */,
E8ECFAC822772ED000D4BA3F /* Frameworks */,
E8ECFAC922772ED000D4BA3F /* Resources */,
E8F6B2EA233E4C77006A03F4 /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -400,43 +401,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
E8F6B2EA233E4C77006A03F4 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "buildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"${INFOPLIST_FILE}\")\nbuildNumber=$(($buildNumber + 1))\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"${INFOPLIST_FILE}\"\n";
};
E8F6B2EB233E4C8F006A03F4 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "buildNumber=$(/usr/libexec/PlistBuddy -c \"Print CFBundleVersion\" \"${INFOPLIST_FILE}\")\nbuildNumber=$(($buildNumber + 1))\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $buildNumber\" \"${INFOPLIST_FILE}\"\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
E8508671231E5F2100F0D6B3 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -466,6 +430,7 @@
E8ECFAE422772EFC00D4BA3F /* AlertButton.swift in Sources */,
E8ECFAE122772EFC00D4BA3F /* UIButton+Action.swift in Sources */,
E85EC3DE2293F6FA00C7B417 /* AlertURLButton.swift in Sources */,
E8722543234B14E10054A937 /* AlertDatePicker.swift in Sources */,
E8FEEE2623104A9F00A155E2 /* UIColor+Extra.swift in Sources */,
E8CE5293227B0FD400466CAF /* AlertContainerView.swift in Sources */,
E8ECFAE222772EFC00D4BA3F /* UIFont+Extra.swift in Sources */,
Expand Down Expand Up @@ -568,6 +533,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 676;
DEVELOPMENT_TEAM = PCH85ZHVFN;
INFOPLIST_FILE = "$(SRCROOT)/RNAlertControllerExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
Expand All @@ -589,6 +555,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 676;
DEVELOPMENT_TEAM = PCH85ZHVFN;
INFOPLIST_FILE = "$(SRCROOT)/RNAlertControllerExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
Expand Down Expand Up @@ -735,7 +702,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1001;
CURRENT_PROJECT_VERSION = 1002;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = PCH85ZHVFN;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand Down Expand Up @@ -767,7 +734,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1001;
CURRENT_PROJECT_VERSION = 1002;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = PCH85ZHVFN;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class OtherViewController: UIViewController {
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
"""
RNAlertController(title: "Kashmir Valley", message: message)
.setBannerImage(UIImage(named: "crop")!)
.setDatePicker(mode: .date, date: nil, selectionAction: { date in
print(date)
})
.addOkButton()
.present()
}
Expand Down
2 changes: 1 addition & 1 deletion RNAlertControllerExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>675</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
17 changes: 17 additions & 0 deletions Source/RNAlertController+API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,21 @@ public extension RNAlertController {
return self
}

/// Sets a date picker with a selected date.
///
/// A date picker is placed under the message body.
/// - Parameters:
/// - mode: `UIDatePicker.Mode` describing the mode displayed the date picker.
/// - date: `Date` to set. If passed `nil`, current date is used.
/// - selectionAction: Block to execute when date is selected.
/// - Returns: `RNAlertController` instance.
@discardableResult
func setDatePicker(mode: UIDatePicker.Mode,
date: Date? = nil,
selectionAction: AlertDatePickerAction? = nil) -> RNAlertController {
alertDatePicker = AlertDatePicker(datePickerMode: mode, selectedDate: date)
alertDatePicker?.action = selectionAction
return self
}

}
11 changes: 9 additions & 2 deletions Source/RNAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import UIKit
var pickerAction : AlertPickerAction?
var selectedPickerRow : Int?
var alertURL : AlertURL?
var alertDatePicker : AlertDatePicker?

private var alertWindow : UIWindow?
private var originalWindow : UIWindow?
Expand Down Expand Up @@ -62,6 +63,9 @@ import UIKit

public override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
if (alertDatePicker != nil) {
alertDatePicker!.action?(alertDatePicker!.date)
}
originalWindow?.makeKeyAndVisible()
alertWindow?.isHidden = true
alertWindow = nil
Expand Down Expand Up @@ -105,9 +109,9 @@ private extension RNAlertController {
let screenWidth = UIScreen.main.bounds.width
let screenHeight = UIScreen.main.bounds.height
if screenWidth < screenHeight {
containerWidth = screenWidth * 0.725
containerWidth = screenWidth * (alertDatePicker == nil ? 0.725 : 0.8)
} else {
containerWidth = screenHeight * 0.725
containerWidth = screenHeight * (alertDatePicker == nil ? 0.725 : 0.8)
}
NSLayoutConstraint.activate([
container.centerXAnchor.constraint(equalTo: view.centerXAnchor),
Expand Down Expand Up @@ -168,6 +172,9 @@ private extension RNAlertController {
if urlView != nil {
extraStackItems.append(urlView!)
}
if alertDatePicker != nil {
extraStackItems.append(alertDatePicker!)
}
let extraStackView = AlertStackView(arrangedSubviews: extraStackItems)
return extraStackView
}
Expand Down
26 changes: 26 additions & 0 deletions Source/Views/AlertDatePicker.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// AlertDatePicker.swift
// RNAlertController
//
// Created by Rayhan on 7/10/19.
// Copyright © 2019 Rayhan Nabi. All rights reserved.
//

import UIKit

/// Action block to perform when a date is selected.
public typealias AlertDatePickerAction = (Date) -> Void

class AlertDatePicker: UIDatePicker {

var action: AlertDatePickerAction?

convenience init(datePickerMode: UIDatePicker.Mode,
selectedDate: Date? = nil) {
self.init(frame: .zero)
self.datePickerMode = datePickerMode
self.date = selectedDate ?? Date()
translatesAutoresizingMaskIntoConstraints = false
}

}
5 changes: 4 additions & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<li class="nav-group-task">
<a href="Typealiases.html#/s:17RNAlertController11AlertActiona">AlertAction</a>
</li>
<li class="nav-group-task">
<a href="Typealiases.html#/s:17RNAlertController21AlertDatePickerActiona">AlertDatePickerAction</a>
</li>
<li class="nav-group-task">
<a href="Typealiases.html#/s:17RNAlertController17AlertPickerActiona">AlertPickerAction</a>
</li>
Expand Down Expand Up @@ -137,7 +140,7 @@ <h4>Declaration</h4>
</section>
<section id="footer">
<p>Copyright © Rayhan Nabi 2019, published under <a class="link" href="https://github.com/rayhannabi/RNAlertController/blob/master/LICENSE" target="_blank" rel="external">MIT License</a></p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
Expand Down
5 changes: 4 additions & 1 deletion docs/Classes/AlertPickerRow.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
<li class="nav-group-task">
<a href="../Typealiases.html#/s:17RNAlertController11AlertActiona">AlertAction</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:17RNAlertController21AlertDatePickerActiona">AlertDatePickerAction</a>
</li>
<li class="nav-group-task">
<a href="../Typealiases.html#/s:17RNAlertController17AlertPickerActiona">AlertPickerAction</a>
</li>
Expand Down Expand Up @@ -136,7 +139,7 @@ <h4>Declaration</h4>
</section>
<section id="footer">
<p>Copyright © Rayhan Nabi 2019, published under <a class="link" href="https://github.com/rayhannabi/RNAlertController/blob/master/LICENSE" target="_blank" rel="external">MIT License</a></p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.10.0</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
Expand Down
Loading

0 comments on commit 6e8d870

Please sign in to comment.