Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
attributes = {
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1030;
ORGANIZATIONNAME = "Daiki Okumura";
TargetAttributes = {
4F47CAAA1AE26BD100BF71E4 = {
Expand All @@ -184,7 +184,7 @@
};
buildConfigurationList = 4F47CAA61AE26BD100BF71E4 /* Build configuration list for PBXProject "DOAlertController-DEMO" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -274,18 +274,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = 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_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 Down Expand Up @@ -313,26 +322,35 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
4F47CAC91AE26BD100BF71E4 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = 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_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 @@ -352,7 +370,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -367,7 +385,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -382,7 +400,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "co.devlog.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont

// NotificationCenter
NotificationCenter.default.addObserver(self, selector: #selector(DOAlertController.handleAlertActionEnabledDidChangeNotification(_:)), name: NSNotification.Name(rawValue: DOAlertActionEnabledDidChangeNotification), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(DOAlertController.handleKeyboardWillShowNotification(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(DOAlertController.handleKeyboardWillHideNotification(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(DOAlertController.handleKeyboardWillShowNotification(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(DOAlertController.handleKeyboardWillHideNotification(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)

// Delegate
self.transitioningDelegate = self
Expand Down Expand Up @@ -304,7 +304,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
// Screen Size
var screenSize = presenting != nil ? presenting!.view.bounds.size : UIScreen.main.bounds.size
if ((UIDevice.current.systemVersion as NSString).floatValue < 8.0) {
if (UIInterfaceOrientationIsLandscape(currentOrientation())) {
if (currentOrientation().isLandscape) {
screenSize = CGSize(width: screenSize.height, height: screenSize.width)
}
}
Expand Down Expand Up @@ -534,8 +534,8 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
for button in buttons {
let action = actions[button.tag - 1] as! DOAlertAction
button.titleLabel?.font = buttonFont[action.style]
button.setTitleColor(buttonTextColor[action.style], for: UIControlState())
button.setBackgroundImage(createImageFromUIColor(buttonBgColor[action.style]!), for: UIControlState())
button.setTitleColor(buttonTextColor[action.style], for: UIControl.State())
button.setBackgroundImage(createImageFromUIColor(buttonBgColor[action.style]!), for: UIControl.State())
button.setBackgroundImage(createImageFromUIColor(buttonBgColorHighlighted[action.style]!), for: .highlighted)
button.setBackgroundImage(createImageFromUIColor(buttonBgColorHighlighted[action.style]!), for: .selected)
button.frame = CGRect(x: buttonPositionX, y: buttonAreaPositionY, width: buttonWidth, height: buttonHeight)
Expand All @@ -547,8 +547,8 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
let action = actions[button.tag - 1] as! DOAlertAction
if (action.style != DOAlertActionStyle.cancel) {
button.titleLabel?.font = buttonFont[action.style]
button.setTitleColor(buttonTextColor[action.style], for: UIControlState())
button.setBackgroundImage(createImageFromUIColor(buttonBgColor[action.style]!), for: UIControlState())
button.setTitleColor(buttonTextColor[action.style], for: UIControl.State())
button.setBackgroundImage(createImageFromUIColor(buttonBgColor[action.style]!), for: UIControl.State())
button.setBackgroundImage(createImageFromUIColor(buttonBgColorHighlighted[action.style]!), for: .highlighted)
button.setBackgroundImage(createImageFromUIColor(buttonBgColorHighlighted[action.style]!), for: .selected)
button.frame = CGRect(x: 0, y: buttonAreaPositionY, width: innerContentWidth, height: buttonHeight)
Expand All @@ -566,8 +566,8 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
let button = buttonAreaScrollView.viewWithTag(cancelButtonTag) as! UIButton
let action = actions[cancelButtonTag - 1] as! DOAlertAction
button.titleLabel?.font = buttonFont[action.style]
button.setTitleColor(buttonTextColor[action.style], for: UIControlState())
button.setBackgroundImage(createImageFromUIColor(buttonBgColor[action.style]!), for: UIControlState())
button.setTitleColor(buttonTextColor[action.style], for: UIControl.State())
button.setBackgroundImage(createImageFromUIColor(buttonBgColor[action.style]!), for: UIControl.State())
button.setBackgroundImage(createImageFromUIColor(buttonBgColorHighlighted[action.style]!), for: .highlighted)
button.setBackgroundImage(createImageFromUIColor(buttonBgColorHighlighted[action.style]!), for: .selected)
button.frame = CGRect(x: 0, y: buttonAreaPositionY, width: innerContentWidth, height: buttonHeight)
Expand Down Expand Up @@ -599,7 +599,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont

var screenSize = self.presentingViewController != nil ? self.presentingViewController!.view.bounds.size : UIScreen.main.bounds.size
if ((UIDevice.current.systemVersion as NSString).floatValue < 8.0) {
if (UIInterfaceOrientationIsLandscape(currentOrientation())) {
if (currentOrientation().isLandscape) {
screenSize = CGSize(width: screenSize.height, height: screenSize.width)
}
}
Expand Down Expand Up @@ -627,7 +627,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
}

// Button Tapped Action
func buttonTapped(_ sender: UIButton) {
@objc func buttonTapped(_ sender: UIButton) {
sender.isSelected = true
let action = actions[sender.tag - 1] as! DOAlertAction
if (action.handler != nil) {
Expand All @@ -637,7 +637,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
}

// Handle ContainerView tap gesture
func handleContainerViewTapGesture(_ sender: AnyObject) {
@objc func handleContainerViewTapGesture(_ sender: AnyObject) {
// cancel action
let action = actions[cancelButtonTag - 1] as! DOAlertAction
if (action.handler != nil) {
Expand All @@ -662,16 +662,16 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont

@objc func handleAlertActionEnabledDidChangeNotification(_ notification: Notification) {
for i in 0..<buttons.count {
buttons[i].isEnabled = actions[i].enabled
buttons[i].isEnabled = actions[i].isEnabled
}
}

func handleKeyboardWillShowNotification(_ notification: Notification) {
@objc func handleKeyboardWillShowNotification(_ notification: Notification) {
if let userInfo = notification.userInfo as? [String: NSValue],
let keyboardSize = userInfo[UIKeyboardFrameEndUserInfoKey]?.cgRectValue.size {
let keyboardSize = userInfo[UIResponder.keyboardFrameEndUserInfoKey]?.cgRectValue.size {
var _keyboardSize = keyboardSize
if ((UIDevice.current.systemVersion as NSString).floatValue < 8.0) {
if (UIInterfaceOrientationIsLandscape(currentOrientation())) {
if (currentOrientation().isLandscape) {
_keyboardSize = CGSize(width: _keyboardSize.height, height: _keyboardSize.width)
}
}
Expand All @@ -684,7 +684,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
}
}

func handleKeyboardWillHideNotification(_ notification: Notification) {
@objc func handleKeyboardWillHideNotification(_ notification: Notification) {
keyboardHeight = 0.0
reloadAlertViewHeight()
containerViewBottomSpaceConstraint?.constant = keyboardHeight
Expand Down Expand Up @@ -713,7 +713,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont
// Add Button
let button = UIButton()
button.layer.masksToBounds = true
button.setTitle(action.title, for: UIControlState())
button.setTitle(action.title, for: UIControl.State())
button.isEnabled = action.enabled
button.layer.cornerRadius = buttonCornerRadius
button.addTarget(self, action: #selector(DOAlertController.buttonTapped(_:)), for: .touchUpInside)
Expand All @@ -737,7 +737,7 @@ open class DOAlertController : UIViewController, UITextFieldDelegate, UIViewCont

let textField = UITextField()
textField.frame.size = CGSize(width: innerContentWidth, height: textFieldHeight)
textField.borderStyle = UITextBorderStyle.none
textField.borderStyle = UITextField.BorderStyle.none
textField.backgroundColor = textFieldBgColor
textField.delegate = self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,27 @@ class ViewController : UITableViewController, UITextFieldDelegate {
// Listen for changes to the text field's text so that we can toggle the current
// action's enabled property based on whether the user has entered a sufficiently
// secure entry.
NotificationCenter.default.addObserver(self, selector: #selector(ViewController.handleTextFieldTextDidChangeNotification(_:)), name: NSNotification.Name.UITextFieldTextDidChange, object: textField)
NotificationCenter.default.addObserver(self, selector: #selector(ViewController.handleTextFieldTextDidChangeNotification(_:)), name: UITextField.textDidChangeNotification, object: textField)

textField?.isSecureTextEntry = true
}

// Stop listening for text change notifications on the text field. This closure will be called in the two action handlers.
let removeTextFieldObserver: (Void) -> Void = {
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UITextFieldTextDidChange, object: alertController.textFields!.first)
let removeTextFieldObserver: () -> Void = {
NotificationCenter.default.removeObserver(self, name: UITextField.textDidChangeNotification, object: alertController.textFields!.first)
}

// Create the actions.
let cancelAction = DOAlertAction(title: cancelButtonTitle, style: .cancel) { action in
NSLog("The \"Secure Text Entry\" alert's cancel action occured.")

removeTextFieldObserver()
removeTextFieldObserver()
}

let otherAction = DOAlertAction(title: otherButtonTitle, style: .default) { action in
NSLog("The \"Secure Text Entry\" alert's other action occured.")

removeTextFieldObserver()
removeTextFieldObserver()
}

// The text field initially has no text in the text field, so we'll disable it.
Expand Down Expand Up @@ -242,7 +242,7 @@ class ViewController : UITableViewController, UITextFieldDelegate {
label.text = "ID"
label.font = UIFont(name: "GillSans-Bold", size: 15.0)
textField?.leftView = label
textField?.leftViewMode = UITextFieldViewMode.always
textField?.leftViewMode = UITextField.ViewMode.always

textField?.delegate = self
}
Expand All @@ -260,7 +260,7 @@ class ViewController : UITableViewController, UITextFieldDelegate {
label.text = "PASS"
label.font = UIFont(name: "GillSans-Bold", size: 15.0)
textField?.leftView = label
textField?.leftViewMode = UITextFieldViewMode.always
textField?.leftViewMode = UITextField.ViewMode.always

textField?.delegate = self
}
Expand Down Expand Up @@ -391,11 +391,11 @@ class ViewController : UITableViewController, UITextFieldDelegate {

// MARK: UITextFieldTextDidChangeNotification

func handleTextFieldTextDidChangeNotification(_ notification: Notification) {
@objc func handleTextFieldTextDidChangeNotification(_ notification: Notification) {
let textField = notification.object as! UITextField

// Enforce a minimum length of >= 5 characters for secure text alerts.
secureTextAlertAction!.enabled = textField.text!.characters.count >= 5
secureTextAlertAction!.enabled = textField.text!.count >= 5
}

// MARK: UITextFieldDelegate Methods
Expand Down
Loading