Skip to content

Commit

Permalink
Merge pull request #66 from xmartlabs/swift4
Browse files Browse the repository at this point in the history
Swift4
  • Loading branch information
Martin Barreto authored Oct 9, 2017
2 parents f518329 + 694468c commit 43d79a2
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.0
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: objective-c
osx_image: xcode8
osx_image: xcode9
env:
- DESTINATION="OS=10.0,name=iPhone 6s" SCHEME="XLActionController" SDK=iphonesimulator10.0
- DESTINATION="OS=11.0,name=iPhone 7" SCHEME="XLActionController" SDK=iphonesimulator
before_install:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
script:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

All notable changes to this project will be documented in this file.

### master branch
### [4.0.0](https://github.com/xmartlabs/XLActionController/releases/tag/4.0.0)

* Support for Swift 4.
* Added customizable background color to the Skype action controller, [PR #52](https://github.com/xmartlabs/XLActionController/pull/52)
* Using status bar style from settings in iOS 10, [PR #53](https://github.com/xmartlabs/XLActionController/pull/53)

Expand Down
31 changes: 24 additions & 7 deletions Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
28B3B8631BFA7EEC007337A2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
28B3B8651BFA7EEC007337A2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
28B3B86A1BFA7EEC007337A2 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
28B3B8701BFA7EEC007337A2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = Example/UITests/Info.plist; sourceTree = "<group>"; };
28B3B8701BFA7EEC007337A2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
28B3B8791BFA8566007337A2 /* PeriscopeExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PeriscopeExampleViewController.swift; sourceTree = "<group>"; };
28B3B87A1BFA8566007337A2 /* SpotifyExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpotifyExampleViewController.swift; sourceTree = "<group>"; };
28B3B87B1BFA8566007337A2 /* TweetbotExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TweetbotExampleViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -198,7 +198,7 @@
28B3B8701BFA7EEC007337A2 /* Info.plist */,
);
name = UITests;
path = ExampleUITests;
path = Example/UITests;
sourceTree = "<group>";
};
28B3B8841BFA858D007337A2 /* Products */ = {
Expand Down Expand Up @@ -258,12 +258,13 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = Xmartlabs;
TargetAttributes = {
28B3B8551BFA7EEC007337A2 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
ProvisioningStyle = Manual;
};
28B3B8691BFA7EEC007337A2 = {
CreatedOnToolsVersion = 7.1;
Expand Down Expand Up @@ -430,14 +431,20 @@
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_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_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 @@ -476,14 +483,20 @@
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_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_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 @@ -512,27 +525,31 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_SWIFT_FLAGS = "-DXLACTIONCONTROLLER_EXAMPLE";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
28B3B8751BFA7EEC007337A2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Manual;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Example/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_SWIFT_FLAGS = "-DXLACTIONCONTROLLER_EXAMPLE";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -546,7 +563,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = Example;
USES_XCTRUNNER = YES;
};
Expand All @@ -561,7 +578,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.ExampleUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = Example;
USES_XCTRUNNER = YES;
};
Expand Down
4 changes: 3 additions & 1 deletion Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
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/CustomActionControllers/Skype.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ open class SkypeCell: UICollectionViewCell {

open class SkypeActionController: ActionController<SkypeCell, String, UICollectionReusableView, Void, UICollectionReusableView, Void> {

open var backgroundColor: UIColor = UIColor(colorLiteralRed: 18/255.0, green: 165/255.0, blue: 244/255.0, alpha: 1.0)
open var backgroundColor: UIColor = UIColor(red: 18/255.0, green: 165/255.0, blue: 244/255.0, alpha: 1.0)

fileprivate var contextView: ContextView!
fileprivate var normalAnimationRect: UIView!
Expand Down
2 changes: 1 addition & 1 deletion Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>4.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 XMARTLABS (http://xmartlabs.com)
Copyright (c) 2017 XMARTLABS (http://xmartlabs.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<p align="left">
<a href="https://travis-ci.org/xmartlabs/XLActionController"><img src="https://travis-ci.org/xmartlabs/XLActionController.svg?branch=master" alt="Build status" /></a>
<img src="https://img.shields.io/badge/platform-iOS-blue.svg?style=flat" alt="Platform iOS" />
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/swift3-compatible-4BC51D.svg?style=flat" alt="Swift 3 compatible" /></a>
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/swift4-compatible-4BC51D.svg?style=flat" alt="Swift 4 compatible" /></a>
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat" alt="Carthage compatible" /></a>
<a href="https://cocoapods.org/pods/XLActionController"><img src="https://img.shields.io/badge/pod-3.0.1-blue.svg" alt="CocoaPods compatible" /></a>
<a href="https://cocoapods.org/pods/XLActionController"><img src="https://img.shields.io/cocoapods/v/XLActionController.svg" alt="CocoaPods compatible" /></a>
<a href="https://raw.githubusercontent.com/xmartlabs/XLActionController/master/LICENSE"><img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License: MIT" /></a>
<a href="https://codebeat.co/projects/github-com-xmartlabs-xlactioncontroller"><img alt="codebeat badge" src="https://codebeat.co/badges/24f48197-136d-44cc-b072-6703644d13b6" /></a>
</p>
Expand Down Expand Up @@ -387,9 +387,9 @@ After the dismissal animation completes, `dismissView` calls `onDidDismissView`

## Requirements

* iOS 8.0+
* Xcode 8.0+
* Swift 3
* iOS 9.0+
* Xcode 9.0+
* Swift 4

## Getting involved

Expand All @@ -411,7 +411,7 @@ Specify XLActionController into your project's Podfile:

```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
platform :ios, '9.0'
use_frameworks!

target '<Your App Target>' do
Expand Down Expand Up @@ -442,7 +442,7 @@ dependency manager for Cocoa.
Specify XLActionController into your project's Carthage:

```
github "xmartlabs/XLActionController" ~> 3.0
github "xmartlabs/XLActionController" ~> 4.0
```

### Manually as Embedded Framework
Expand Down
6 changes: 3 additions & 3 deletions Source/ActionController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,15 @@ open class ActionController<ActionViewType: UICollectionViewCell, ActionDataType

// MARK: - Event handlers

func cancelButtonDidTouch(_ sender: UIButton) {
@objc func cancelButtonDidTouch(_ sender: UIButton) {
self.dismiss()
}

func tapGestureDidRecognize(_ gesture: UITapGestureRecognizer) {
@objc func tapGestureDidRecognize(_ gesture: UITapGestureRecognizer) {
self.dismiss()
}

func swipeGestureDidRecognize(_ gesture: UISwipeGestureRecognizer) {
@objc func swipeGestureDidRecognize(_ gesture: UISwipeGestureRecognizer) {
self.dismiss()
}

Expand Down
23 changes: 20 additions & 3 deletions Source/DynamicCollectionViewFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ open class DynamicCollectionViewFlowLayout: UICollectionViewFlowLayout {

return top
}

private func isRTL(for view: UIView) -> Bool {
if #available(iOS 9.0, *) {
return UIView.userInterfaceLayoutDirection(for: view.semanticContentAttribute) == .rightToLeft
} else {
return UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft
}
}

@discardableResult
func setupAttributesForIndexPath(_ indexPath: IndexPath?) -> UICollectionViewLayoutAttributes? {
guard let indexPath = indexPath, let animator = dynamicAnimator, let collectionView = collectionView else {
Expand All @@ -148,15 +157,23 @@ open class DynamicCollectionViewFlowLayout: UICollectionViewFlowLayout {
var initialFrame = CGRect(x: 0, y: originY + frame.origin.y, width: collectionItemSize.width, height: collectionItemSize.height)

// Calculate x position depending on alignment value
var translationX: CGFloat

let collectionViewContentWidth = collectionView.bounds.size.width - collectionView.contentInset.left - collectionView.contentInset.right
let rightMargin = (collectionViewContentWidth - frame.size.width)
let leftMargin = CGFloat(0.0)

var translationX: CGFloat
switch itemsAligment {
case .center:
translationX = (collectionViewContentWidth - frame.size.width) * 0.5
case .fill, .left:
translationX = 0.0
translationX = leftMargin
case .right:
translationX = (collectionViewContentWidth - frame.size.width)
translationX = rightMargin
case .leading:
translationX = isRTL(for: collectionView) ? rightMargin : leftMargin
case .trailing:
translationX = isRTL(for: collectionView) ? leftMargin : rightMargin
}

frame.origin.x = translationX
Expand Down
2 changes: 1 addition & 1 deletion Source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>4.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
6 changes: 3 additions & 3 deletions XLActionController.podspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Pod::Spec.new do |spec|
spec.name = 'XLActionController'
spec.version = '3.0.1'
spec.version = '4.0.0'
spec.license = 'MIT'
spec.summary = 'Fully customizable and extensible action sheet controller written in Swift 3'
spec.summary = 'Fully customizable and extensible action sheet controller written in Swift'
spec.homepage = 'https://github.com/xmartlabs/XLActionController'
spec.social_media_url = 'http://twitter.com/xmartlabs'
spec.authors = { 'Miguel Revetria' => '[email protected]', 'Martin Barreto' => '[email protected]' }
spec.source = { :git => 'https://github.com/xmartlabs/XLActionController.git', :tag => spec.version }
spec.ios.deployment_target = '8.0'
spec.ios.deployment_target = '9.0'
spec.ios.frameworks = 'UIKit', 'Foundation', 'CoreGraphics'
spec.requires_arc = true

Expand Down
Loading

0 comments on commit 43d79a2

Please sign in to comment.