Skip to content

Commit

Permalink
Merge pull request #85 from rayhannabi/release/0.6.7
Browse files Browse the repository at this point in the history
Release/0.6.7
  • Loading branch information
rayhannabi authored Oct 24, 2019
2 parents 6852845 + 96a1d39 commit 7971f70
Show file tree
Hide file tree
Showing 33 changed files with 1,093 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
os: osx
language: objective-c
osx_image: xcode10.3
osx_image: xcode11
xcode_project: RNAlertController.xcodeproj
xcode_scheme: RNAlertController
xcode_sdk: iphonesimulator12.4
xcode_destination: platform=iOS Simulator,OS=12.4,name=iPhone Xs
xcode_sdk: iphonesimulator13.0
xcode_destination: platform=iOS Simulator,OS=13.0,name=iPhone Xs

git:
depth: 1
Expand Down
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"
spec.version = "0.6.7"
spec.summary = "Custom Alert Framework for iOS"

spec.description = <<-DESC
Expand Down
16 changes: 8 additions & 8 deletions RNAlertController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,15 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 681;
CURRENT_PROJECT_VERSION = 682;
DEVELOPMENT_TEAM = PCH85ZHVFN;
INFOPLIST_FILE = "$(SRCROOT)/RNAlertControllerExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.6;
MARKETING_VERSION = 0.6.7;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -555,15 +555,15 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 681;
CURRENT_PROJECT_VERSION = 682;
DEVELOPMENT_TEAM = PCH85ZHVFN;
INFOPLIST_FILE = "$(SRCROOT)/RNAlertControllerExample/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.6.6;
MARKETING_VERSION = 0.6.7;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -702,7 +702,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1005;
CURRENT_PROJECT_VERSION = 1006;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = PCH85ZHVFN;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -716,7 +716,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.6.6;
MARKETING_VERSION = 0.6.7;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertController;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -734,7 +734,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1005;
CURRENT_PROJECT_VERSION = 1006;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = PCH85ZHVFN;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -748,7 +748,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.6.6;
MARKETING_VERSION = 0.6.7;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertController;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
19 changes: 15 additions & 4 deletions RNAlertControllerExample/Controllers/OtherViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ class OtherViewController: UIViewController {
private var selectedDate: Date?

@IBAction private func didTapAlert(_ sender: Any) {
let message = """
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)
let text = "The word Kashmir was derived from the ancient Sanskrit language and was referred to as káśmīra."
let attText = NSMutableAttributedString(string: text,
attributes: [.font : UIFont.alertMessageFont ])
attText.addAttribute(.font,
value: UIFont.alertMessageFontBold,
range: NSRange(text.range(of: "Kashmir")!, in: text))
attText.addAttribute(.font,
value: UIFont.alertMessageFontItalic,
range: NSRange(text.range(of: "Sanskrit")!, in: text))
attText.addAttribute(.font,
value: UIFont.alertMessageFontBold,
range: NSRange(text.range(of: "káśmīra")!, in: text))

RNAlertController(title: "Kashmir Valley", message: nil)
.setAttributedTextForMessage(attText)
.setBannerImage(UIImage(named: "crop")!)
.addOkButton()
.present()
Expand Down
2 changes: 1 addition & 1 deletion RNAlertControllerExample/Controllers/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ViewController: UIViewController {
.addOkButton(action: {
self.customAlertFull()
})
.addButton(title: "Cancel")
.addButton(title: "Request Help", type: .cancel)
.present()
}

Expand Down
22 changes: 15 additions & 7 deletions Source/Extensions/UIFont+Extra.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,30 @@

import UIKit

extension UIFont {
public extension UIFont {

class var alertTitleFont: UIFont {
static var alertTitleFont: UIFont {
return self.systemFont(ofSize: 18, weight: .semibold)
}

class var alertMessageFont: UIFont {
static var alertMessageFont: UIFont {
return self.systemFont(ofSize: 14, weight: .regular)
}

class var alertButtonFontRegular: UIFont {
return self.systemFont(ofSize: 17, weight: .regular)
static var alertMessageFontBold: UIFont {
return self.systemFont(ofSize: 14, weight: .bold)
}

class var alertButtonFontBold: UIFont {
return self.systemFont(ofSize: 17, weight: .semibold)
static var alertMessageFontItalic: UIFont {
return self.italicSystemFont(ofSize: 14)
}

static var alertButtonFontRegular: UIFont {
return self.systemFont(ofSize: 16, weight: .regular)
}

static var alertButtonFontBold: UIFont {
return self.systemFont(ofSize: 16, weight: .semibold)
}

}
9 changes: 9 additions & 0 deletions Source/RNAlertController+API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public extension RNAlertController {
return self
}

/// Sets attributed text for the message.
///
/// When set, message text will use attributed text instead of regular text.
/// - Parameter attributedText: Attributed string to set.
@discardableResult func setAttributedTextForMessage(_ attributedText: NSAttributedString?) -> RNAlertController {
self.attributedMessage = attributedText
return self
}

/// Adds an **OK** button to the alert.
///
/// - Parameter action: Block to run when the button is pressed (i.e. touchUpInside event).
Expand Down
45 changes: 25 additions & 20 deletions Source/RNAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ import UIKit
/// An object that provides RNAlertController.
@objcMembers public final class RNAlertController: UIViewController {

var titleText : String?
var messageText : String?
var buttons : [AlertButton]?
var image : UIImage?
var pickerData : [String]?
var pickerAction : AlertPickerAction?
var selectedPickerRow : Int?
var alertURL : AlertURL?
var alertDatePicker : AlertDatePicker?
var message : String?
var attributedMessage : NSAttributedString?
var buttons : [AlertButton]?
var image : UIImage?
var pickerData : [String]?
var pickerAction : AlertPickerAction?
var selectedPickerRow : Int?
var alertURL : AlertURL?
var alertDatePicker : AlertDatePicker?

private var alertWindow : UIWindow?
private var originalWindow : UIWindow?
private var container : AlertContainerView!
private var alertBodyBackground : UIView!
private var container : AlertContainerView!

private override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
Expand All @@ -44,9 +44,9 @@ import UIKit
/// - message: Message body of the alert
public convenience init(title: String?, message: String?) {
self.init(nibName: nil, bundle: nil)
buttons = [AlertButton]()
titleText = title
messageText = message
self.title = title
self.message = message
buttons = []
}

public override func viewDidLoad() {
Expand Down Expand Up @@ -114,9 +114,9 @@ private extension RNAlertController {
let screenWidth = UIScreen.main.bounds.width
let screenHeight = UIScreen.main.bounds.height
if screenWidth < screenHeight {
containerWidth = screenWidth * (alertDatePicker == nil ? 0.725 : 0.8)
containerWidth = screenWidth * (alertDatePicker == nil ? 0.73 : 0.8)
} else {
containerWidth = screenHeight * (alertDatePicker == nil ? 0.725 : 0.8)
containerWidth = screenHeight * (alertDatePicker == nil ? 0.73 : 0.8)
}
NSLayoutConstraint.activate([
container.centerXAnchor.constraint(equalTo: view.centerXAnchor),
Expand All @@ -128,15 +128,20 @@ private extension RNAlertController {
}

func createTitleLabel() -> AlertLabel? {
guard let title = titleText else { return nil }
guard let title = title else { return nil }
let titleLabel = AlertLabel(text: title, type: .title)
return titleLabel
}

func createMessageLabel() -> AlertLabel? {
guard let message = messageText else { return nil }
let labelType: AlertLabelType = titleText == nil ? .title : .message
let messageLabel = AlertLabel(text: message, type: labelType)
let labelType: AlertLabelType = title == nil ? .title : .message
var messageLabel = AlertLabel()
if let message = message {
messageLabel = AlertLabel(text: message, type: labelType)
}
if let attributedMessage = attributedMessage {
messageLabel = AlertLabel(attributedText: attributedMessage)
}
return messageLabel
}

Expand Down Expand Up @@ -204,7 +209,7 @@ private extension RNAlertController {
alertBody.axis = .vertical
alertBody.distribution = .fill
alertBody.alignment = .fill
alertBody.spacing = 0.5
alertBody.spacing = 0.25

container.contentView.addSubview(alertBody)
NSLayoutConstraint.activate([
Expand Down
2 changes: 1 addition & 1 deletion Source/Views/AlertButtonStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class AlertButtonStackView: UIStackView {
distribution = .fillEqually
alignment = .fill
axis = .horizontal
spacing = 0.5
spacing = 0.25
}

required init(coder: NSCoder) {
Expand Down
3 changes: 1 addition & 2 deletions Source/Views/AlertLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ class AlertLabel: UILabel {
setFont(for: type)
}

convenience init(attributedText: NSAttributedString, type: AlertLabelType) {
convenience init(attributedText: NSAttributedString) {
self.init(frame: .zero)
self.attributedText = attributedText
setFont(for: type)
}

override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
Expand Down
8 changes: 8 additions & 0 deletions docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Extensions/UIFont.html">UIFont</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
Expand Down
8 changes: 8 additions & 0 deletions docs/Classes/AlertPickerRow.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Extensions/UIFont.html">UIFont</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
Expand Down
57 changes: 57 additions & 0 deletions docs/Classes/RNAlertController.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="../Extensions/UIFont.html">UIFont</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="../Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
Expand Down Expand Up @@ -408,6 +416,55 @@ <h4>Return Value</h4>
</section>
</div>
</li>
<li class="item">
<div>
<code>
<a name="/c:@CM@RNAlertController@objc(cs)RNAlertController(im)setAttributedTextForMessage:"></a>
<a name="//apple_ref/swift/Method/setAttributedTextForMessage(_:)" class="dashAnchor"></a>
<a class="token" href="#/c:@CM@RNAlertController@objc(cs)RNAlertController(im)setAttributedTextForMessage:">setAttributedTextForMessage(_:)</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">
<p>Sets attributed text for the message.</p>

<p>When set, message text will use attributed text instead of regular text.</p>

</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">@discardableResult</span>
<span class="kd">func</span> <span class="nf">setAttributedTextForMessage</span><span class="p">(</span><span class="n">_</span> <span class="nv">attributedText</span><span class="p">:</span> <span class="kt">NSAttributedString</span><span class="p">?)</span> <span class="o">-&gt;</span> <span class="kt">RNAlertController</span></code></pre>

</div>
</div>
<div>
<h4>Parameters</h4>
<table class="graybox">
<tbody>
<tr>
<td>
<code>
<em>attributedText</em>
</code>
</td>
<td>
<div>
<p>Attributed string to set.</p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</div>
</li>
<li class="item">
<div>
<code>
Expand Down
Loading

0 comments on commit 7971f70

Please sign in to comment.