Skip to content

Commit

Permalink
Merge pull request #91 from rayhannabi/release/0.6.9
Browse files Browse the repository at this point in the history
Release/0.6.9
  • Loading branch information
rayhannabi committed Dec 5, 2019
2 parents 42d74c8 + 6894c74 commit 91fe07d
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 16 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.8"
spec.version = "0.6.9"
spec.summary = "Custom Alert Framework for iOS"

spec.description = <<-DESC
Expand Down
20 changes: 12 additions & 8 deletions RNAlertController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
E85EC3DE2293F6FA00C7B417 /* AlertURLButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = E85EC3DD2293F6FA00C7B417 /* AlertURLButton.swift */; };
E8722543234B14E10054A937 /* AlertDatePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8722542234B14E10054A937 /* AlertDatePicker.swift */; };
E88841062366F90E00CFF2AA /* AlertBannerPosition.swift in Sources */ = {isa = PBXBuildFile; fileRef = E88841052366F90E00CFF2AA /* AlertBannerPosition.swift */; };
E896FF022398ED930003CCD0 /* AlertMessageTextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E896FF012398ED930003CCD0 /* AlertMessageTextView.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 @@ -108,6 +109,7 @@
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>"; };
E88841052366F90E00CFF2AA /* AlertBannerPosition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertBannerPosition.swift; sourceTree = "<group>"; };
E896FF012398ED930003CCD0 /* AlertMessageTextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertMessageTextView.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 @@ -174,6 +176,7 @@
E8722542234B14E10054A937 /* AlertDatePicker.swift */,
E8CE528E227B07D200466CAF /* AlertImageView.swift */,
E8ECFADB22772EFB00D4BA3F /* AlertLabel.swift */,
E896FF012398ED930003CCD0 /* AlertMessageTextView.swift */,
E8CE5294227C506000466CAF /* AlertPickerView.swift */,
E8CE5290227B092400466CAF /* AlertStackView.swift */,
E85EC3DD2293F6FA00C7B417 /* AlertURLButton.swift */,
Expand Down Expand Up @@ -465,6 +468,7 @@
E8722543234B14E10054A937 /* AlertDatePicker.swift in Sources */,
E88841062366F90E00CFF2AA /* AlertBannerPosition.swift in Sources */,
E8FEEE2623104A9F00A155E2 /* UIColor+Extra.swift in Sources */,
E896FF022398ED930003CCD0 /* AlertMessageTextView.swift in Sources */,
E8CE5293227B0FD400466CAF /* AlertContainerView.swift in Sources */,
E8ECFAE222772EFC00D4BA3F /* UIFont+Extra.swift in Sources */,
E8CE5295227C506000466CAF /* AlertPickerView.swift in Sources */,
Expand Down Expand Up @@ -569,15 +573,15 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 670;
CURRENT_PROJECT_VERSION = 671;
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.8;
MARKETING_VERSION = 0.6.9;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -591,15 +595,15 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 670;
CURRENT_PROJECT_VERSION = 671;
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.8;
MARKETING_VERSION = 0.6.9;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertControllerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -738,7 +742,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1010;
CURRENT_PROJECT_VERSION = 1011;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = PCH85ZHVFN;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -752,7 +756,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.6.8;
MARKETING_VERSION = 0.6.9;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertController;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -770,7 +774,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1010;
CURRENT_PROJECT_VERSION = 1011;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = PCH85ZHVFN;
DYLIB_COMPATIBILITY_VERSION = 1;
Expand All @@ -784,7 +788,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 0.6.8;
MARKETING_VERSION = 0.6.9;
PRODUCT_BUNDLE_IDENTIFIER = com.rayhan.ios.RNAlertController;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class OtherViewController: UIViewController {
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,
attText.addAttribute(.link,
value: URL(string: "https://www.google.com/search?q=Kashmir")!,
range: NSRange(text.range(of: "Kashmir")!, in: text))
attText.addAttribute(.font,
value: UIFont.alertMessageFontItalic,
Expand Down
19 changes: 14 additions & 5 deletions Source/RNAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,16 @@ private extension RNAlertController {
if let message = message {
messageLabel = AlertLabel(text: message, type: labelType)
}
if let attributedMessage = attributedMessage {
messageLabel = AlertLabel(attributedText: attributedMessage)
}
return messageLabel
}

func createAttributedMessageView() -> AlertMessageTextView? {
guard let attributedMessage = attributedMessage else { return nil }
let messageTextView = AlertMessageTextView()
messageTextView.setAttributedTextWithCenterAlignment(attributedMessage)
return messageTextView
}

func createImageView() -> AlertImageView? {
guard let image = image else { return nil }
guard let position = imagePosition else { return nil }
Expand Down Expand Up @@ -199,11 +203,16 @@ private extension RNAlertController {
var alertStackItems = [UIView]()
let titleLabel = createTitleLabel()
let messageLabel = createMessageLabel()
let messageTextView = createAttributedMessageView()
if titleLabel != nil {
alertStackItems.append(titleLabel!)
}
if messageLabel != nil {
alertStackItems.append(messageLabel!)
if messageTextView != nil {
alertStackItems.append(messageTextView!)
} else {
if messageLabel != nil {
alertStackItems.append(messageLabel!)
}
}
let alertStackView = AlertStackView(arrangedSubviews: alertStackItems)
return alertStackView
Expand Down
52 changes: 52 additions & 0 deletions Source/Views/AlertMessageTextView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// AlertMessageTextView.swift
// RNAlertController
//
// Created by Rayhan Nabi on 5/12/19.
// Copyright © 2019 Rayhan Nabi. All rights reserved.
//

import UIKit

class AlertMessageTextView: UITextView {

convenience init() {
self.init(frame: .zero)
translatesAutoresizingMaskIntoConstraints = false
backgroundColor = .clear
textAlignment = .center
setEditableProperties()
setLinkAttributes()
}

func setAttributedTextWithCenterAlignment(_ attributedText: NSAttributedString) {
let mutableAttributedText = NSMutableAttributedString(attributedString: attributedText)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
mutableAttributedText.addAttribute(.paragraphStyle,
value: paragraphStyle,
range: NSRange(location: 0, length: attributedText.string.count))
self.attributedText = mutableAttributedText
}

private func setLinkAttributes() {
let linkAttributes: [NSAttributedString.Key : Any] = [
.foregroundColor: UIColor.alertButtonTextRegular,
.underlineColor: UIColor.alertButtonTextRegular,
.underlineStyle: NSUnderlineStyle.single.rawValue
]
linkTextAttributes = linkAttributes
}

private func setEditableProperties() {
isScrollEnabled = false
isEditable = false
showsHorizontalScrollIndicator = false
showsVerticalScrollIndicator = false
bounces = false
bouncesZoom = false
dataDetectorTypes = .all
delaysContentTouches = false
}

}
Binary file modified docs/docsets/RNAlertController.tgz
Binary file not shown.

0 comments on commit 91fe07d

Please sign in to comment.