2 Commits

Author SHA1 Message Date
Ryan Nystrom 846252cc15 pin modal size to inset container 2019-10-09 12:41:09 -04:00
Bart Jochems 6bae31e2be Swift 5 support (#51)
* Swift 5 support

* Update tests and travis configuration

* Update swift version in podspec
2019-06-03 09:21:15 -07:00
6 changed files with 27 additions and 21 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
language: swift
osx_image: xcode9.3
osx_image: xcode10.2
script:
- xcodebuild clean -project ContextMenu.xcodeproj -scheme ContextMenu -destination "platform=iOS Simulator,name=iPhone X,OS=11.3" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet
- xcodebuild clean -project ContextMenu.xcodeproj -scheme ContextMenu -destination "platform=iOS Simulator,name=iPhone X,OS=12.2" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet
+1 -1
View File
@@ -8,5 +8,5 @@ Pod::Spec.new do |spec|
spec.source = { :git => 'https://github.com/GitHawkApp/ContextMenu.git', :tag => spec.version.to_s }
spec.source_files = 'ContextMenu/*.swift'
spec.platform = :ios, '9.0'
spec.swift_version = '4.2'
spec.swift_version = '5.0'
end
+6 -6
View File
@@ -208,12 +208,12 @@
TargetAttributes = {
2971CE712054539900342296 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 0920;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
2991418320BC757000B63A3B = {
CreatedOnToolsVersion = 9.3;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
@@ -437,7 +437,7 @@
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -461,7 +461,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
@@ -479,7 +479,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.whoisryannystrom.ContextMenuTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -497,7 +497,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.whoisryannystrom.ContextMenuTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
@@ -10,7 +10,7 @@ import Foundation
public extension ContextMenu {
/// Haptic Feedback types.
public enum HapticFeedbackStyle: Int {
enum HapticFeedbackStyle: Int {
case light, medium, heavy
}
@@ -58,7 +58,12 @@ class ContextMenuPresentationController: UIPresentationController {
override var frameOfPresentedViewInContainerView: CGRect {
guard let containerBounds = containerView?.bounds else { return .zero }
let size = presentedViewController.preferredContentSize
var size = presentedViewController.preferredContentSize
// cap size to inset container bounds
size.width = min(containerBounds.width - 2 * item.options.containerStyle.edgePadding, size.width)
size.height = min(containerBounds.height - 2 * item.options.containerStyle.edgePadding, size.height)
let frame: CGRect
if let corner = preferredSourceViewCorner {
let minPadding = item.options.containerStyle.edgePadding
+11 -10
View File
@@ -12,19 +12,20 @@ import XCTest
class CGRect_AreaTests: XCTestCase {
let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
func test_whenCornersHavePadding() {
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 10, y: 10), position: .topLeft)), 100)
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 90, y: 10), position: .topRight)), 100)
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 90, y: 90), position: .bottomRight)), 100)
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 10, y: 90), position: .bottomLeft)), 100)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 10, y: 10, width: 0, height: 0), position: .topLeft)), 100)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 90, y: 10, width: 0, height: 0), position: .topRight)), 100)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 90, y: 90, width: 0, height: 0), position: .bottomRight)), 100)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 10, y: 90, width: 0, height: 0), position: .bottomLeft)), 100)
}
func test_whenCornersHaveNoPadding() {
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 0, y: 0), position: .topLeft)), 0)
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 100, y: 0), position: .topRight)), 0)
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 100, y: 100), position: .bottomRight)), 0)
XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 00, y: 100), position: .bottomLeft)), 0)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 0, y: 0, width: rect.width, height: rect.height), position: .topLeft)), 0)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 100, y: 0, width: rect.width, height: rect.height), position: .topRight)), 0)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 100, y: 100, width: rect.width, height: rect.height), position: .bottomRight)), 0)
XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 0, y: 100, width: rect.width, height: rect.height), position: .bottomLeft)), 0)
}
}