Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Swift 5, Remove Warring. #60

Open
wants to merge 12 commits into
base: new
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 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
29 changes: 21 additions & 8 deletions Alerts&Pickers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
365C130B224E93B70024D6A5 /* Alerts&Pickers.podspec in Resources */ = {isa = PBXBuildFile; fileRef = 365C130A224E93B70024D6A5 /* Alerts&Pickers.podspec */; };
FA005E922015D769001EA8C6 /* Contacts.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA005E912015D769001EA8C6 /* Contacts.swift */; };
FA005E942015E490001EA8C6 /* UISearchBar+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA005E932015E490001EA8C6 /* UISearchBar+Extensions.swift */; };
FA005E9620162BB5001EA8C6 /* Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA005E9520162BB5001EA8C6 /* Assets.swift */; };
Expand Down Expand Up @@ -73,6 +74,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
365C130A224E93B70024D6A5 /* Alerts&Pickers.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Alerts&Pickers.podspec"; sourceTree = SOURCE_ROOT; };
FA005E912015D769001EA8C6 /* Contacts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Contacts.swift; sourceTree = "<group>"; };
FA005E932015E490001EA8C6 /* UISearchBar+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISearchBar+Extensions.swift"; sourceTree = "<group>"; };
FA005E9520162BB5001EA8C6 /* Assets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Assets.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -243,6 +245,7 @@
FA3BB28A2008B46500E06F8F /* Resources */,
FA3BB2AA2008B46800E06F8F /* ViewController.swift */,
FA3BB2AB2008B46800E06F8F /* AppDelegate.swift */,
365C130A224E93B70024D6A5 /* Alerts&Pickers.podspec */,
);
path = Example;
sourceTree = "<group>";
Expand Down Expand Up @@ -513,11 +516,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "Supreme Apps";
TargetAttributes = {
FA3BB2722008B41B00E06F8F = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -549,6 +553,7 @@
FA3BB2CF2008B9FA00E06F8F /* LICENSE in Resources */,
FA3BB2BF2008B46900E06F8F /* Countries.bundle in Resources */,
FA3BB2AD2008B46800E06F8F /* LaunchScreen.storyboard in Resources */,
365C130B224E93B70024D6A5 /* Alerts&Pickers.podspec in Resources */,
FA3BB2AC2008B46800E06F8F /* Assets.xcassets in Resources */,
FA3BB2CD2008B98F00E06F8F /* Assets in Resources */,
FA3BB2892008B45600E06F8F /* README.md in Resources */,
Expand Down Expand Up @@ -649,13 +654,15 @@
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_DOCUMENTATION_COMMENTS = YES;
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;
Expand Down Expand Up @@ -685,7 +692,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = NO;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -707,13 +714,15 @@
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_DOCUMENTATION_COMMENTS = YES;
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;
Expand Down Expand Up @@ -748,13 +757,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = XL743FKK28;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/Example/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "AA.Alerts-Pickers";
PRODUCT_BUNDLE_IDENTIFIER = "persional.Alerts-Pickers";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -763,13 +774,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = XL743FKK28;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/Example/Resources/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "AA.Alerts-Pickers";
PRODUCT_BUNDLE_IDENTIFIER = "persional.Alerts-Pickers";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
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 = "0920"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,7 +26,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -46,7 +45,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,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 {
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = UINavigationController(rootViewController: ViewController())
window?.makeKeyAndVisible()
Expand Down
6 changes: 3 additions & 3 deletions Example/FlowLayouts/VegaScrollFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ open class VerticalScrollFlowLayout: UICollectionViewFlowLayout {

let touchLocation = collectionView!.panGestureRecognizer.location(in: collectionView)

dynamicAnimator.behaviors.flatMap { $0 as? UIAttachmentBehavior }.forEach { behavior in
dynamicAnimator.behaviors.compactMap { $0 as? UIAttachmentBehavior }.forEach { behavior in
let attrs = behavior.items.first as! UICollectionViewLayoutAttributes
attrs.center = getUpdatedBehaviorItemCenter(behavior: behavior, touchLocation: touchLocation)
self.dynamicAnimator.updateItem(usingCurrentState: attrs)
Expand Down Expand Up @@ -168,8 +168,8 @@ open class VerticalScrollFlowLayout: UICollectionViewFlowLayout {
}

private func getUpdatedBehaviorItemCenter(behavior: UIAttachmentBehavior,touchLocation: CGPoint) -> CGPoint {
let yDistanceFromTouch = fabs(touchLocation.y - behavior.anchorPoint.y)
let xDistanceFromTouch = fabs(touchLocation.x - behavior.anchorPoint.x)
let yDistanceFromTouch = abs(touchLocation.y - behavior.anchorPoint.y)
let xDistanceFromTouch = abs(touchLocation.x - behavior.anchorPoint.x)
let scrollResistance = (yDistanceFromTouch + xDistanceFromTouch) / (springHardness * 100)

let attrs = behavior.items.first as! UICollectionViewLayoutAttributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "iPad [email protected]",
"scale" : "2x"
},
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions Example/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) lets you make beautiful photos of your property or market items. It needs access to the Camera.</string>
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to the Contacts to let you find your friends.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>$(PRODUCT_NAME) lets you keep track of interesting places. It needs access to the GPS coordinates for your location.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to the Photo Library to let you add photos from your Photo Library.</string>
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) needs access to the Contacts to let you find your friends.</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
Expand Down
6 changes: 3 additions & 3 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ViewController: UIViewController {

// MARK: Properties

fileprivate var alertStyle: UIAlertControllerStyle = .actionSheet
fileprivate var alertStyle: UIAlertController.Style = .actionSheet

fileprivate lazy var segments: SegmentedControl = {
let styles: [String] = ["Alert", "ActionSheet"]
Expand All @@ -120,7 +120,7 @@ class ViewController: UIViewController {
$0.register(TypeOneCell.self, forCellWithReuseIdentifier: TypeOneCell.identifier)
$0.showsVerticalScrollIndicator = false
$0.showsHorizontalScrollIndicator = false
$0.decelerationRate = UIScrollViewDecelerationRateFast
$0.decelerationRate = UIScrollView.DecelerationRate.fast
//$0.contentInsetAdjustmentBehavior = .never
$0.bounces = true
$0.backgroundColor = .white
Expand Down Expand Up @@ -293,7 +293,7 @@ class ViewController: UIViewController {

let frameSizes: [CGFloat] = (150...300).map { CGFloat($0) }
let pickerViewValues: [[String]] = [frameSizes.map { Int($0).description }]
let pickerViewSelectedValue: PickerViewViewController.Index = (column: 0, row: frameSizes.index(of: 216) ?? 0)
let pickerViewSelectedValue: PickerViewViewController.Index = (column: 0, row: frameSizes.firstIndex(of: 216) ?? 0)

alert.addPickerView(values: pickerViewValues, initialSelection: pickerViewSelectedValue) { vc, picker, index, values in

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</div>

<p align="center">
<img src="https://img.shields.io/badge/Swift-4.0-orange.svg" alt="Swift 4.0"/>
<img src="https://img.shields.io/badge/Swift-4.0-orange.svg" alt="Swift 5.0"/>
<img src="https://img.shields.io/badge/platform-iOS-brightgreen.svg" alt="Platform: iOS"/>
<img src="https://img.shields.io/badge/Xcode-9%2B-brightgreen.svg" alt="XCode 9+"/>
<img src="https://img.shields.io/badge/iOS-11%2B-brightgreen.svg" alt="iOS 11"/>
Expand Down Expand Up @@ -454,7 +454,7 @@ Download and drop `/Source` folder in your project.

## Requirements

* Swift 4
* Swift 5
* iOS 11 or higher

## Authors
Expand Down
8 changes: 4 additions & 4 deletions Source/Extensions/Array+Extensions.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ extension Array where Element: Equatable {
public extension Array {

/// Random item from array.
public var randomItem: Element? {
var randomItem: Element? {
if self.isEmpty { return nil }
let index = Int(arc4random_uniform(UInt32(count)))
return self[index]
}

/// Shuffled version of array.
public var shuffled: [Element] {
var shuffled: [Element] {
var arr = self
for _ in 0..<10 {
arr.sort { (_,_) in arc4random() < arc4random() }
Expand All @@ -125,7 +125,7 @@ public extension Array {
}

/// Shuffle array.
public mutating func shuffle() {
mutating func shuffle() {
// https://gist.github.com/ijoshsmith/5e3c7d8c2099a3fe8dc3
for _ in 0..<10 {
sort { (_,_) in arc4random() < arc4random() }
Expand All @@ -136,7 +136,7 @@ public extension Array {
///
/// - Parameter index: index of element.
/// - Returns: optional element (if exists).
public func item(at index: Int) -> Element? {
func item(at index: Int) -> Element? {
guard index >= 0 && index < count else { return nil }
return self[index]
}
Expand Down
Empty file modified Source/Extensions/Common+Extensions.swift
100644 → 100755
Empty file.
Loading