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

Swift 5 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
27 changes: 23 additions & 4 deletions AKPFlowLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Arseniy Kuznetsov";
TargetAttributes = {
57FA3EB51D0D877E00EFD324 = {
Expand All @@ -188,10 +188,11 @@
};
buildConfigurationList = 57FA3EB01D0D877E00EFD324 /* Build configuration list for PBXProject "AKPFlowLayout" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 57FA3EAC1D0D877E00EFD324;
productRefGroup = 57FA3EB71D0D877E00EFD324 /* Products */;
Expand Down Expand Up @@ -256,19 +257,28 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = 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 @@ -307,19 +317,28 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = 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 @@ -366,7 +385,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -387,7 +406,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.akpw.AKPFlowLayout;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
};
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 = "0800"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
12 changes: 6 additions & 6 deletions AKPFlowLayout/AKPFlowLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public final class AKPFlowLayout: UICollectionViewFlowLayout {
for idx in customSectionHeadersIdxs {
let indexPath = IndexPath(item: 0, section: idx)
if let attributes = super.layoutAttributesForSupplementaryView(
ofKind: UICollectionElementKindSectionHeader,
ofKind: UICollectionView.elementKindSectionHeader,
at: indexPath) as? AKPFlowLayoutAttributes {
layoutAttributes.append(attributes)
}
}
// for section headers, need to adjust their attributes
for attributes in layoutAttributes where
attributes.representedElementKind == UICollectionElementKindSectionHeader {
attributes.representedElementKind == UICollectionView.elementKindSectionHeader {
(attributes.frame, attributes.zIndex) = adjustLayoutAttributes(forSectionAttributes: attributes)
}
return layoutAttributes
Expand Down Expand Up @@ -118,7 +118,7 @@ public final class AKPFlowLayout: UICollectionViewFlowLayout {
// then invalidate
let invalidatedIdxPaths = sectionIdxPaths.map { IndexPath(item: 0, section: $0) }
invalidationContext.invalidateSupplementaryElements(
ofKind: UICollectionElementKindSectionHeader, at: invalidatedIdxPaths )
ofKind: UICollectionView.elementKindSectionHeader, at: invalidatedIdxPaths )
}
return invalidationContext
}
Expand Down Expand Up @@ -169,7 +169,7 @@ extension AKPFlowLayout {

// remove the sections that should already be taken care of by UICollectionViewFlowLayout
for attributes in layoutAttributes
where attributes.representedElementKind == UICollectionElementKindSectionHeader {
where attributes.representedElementKind == UICollectionView.elementKindSectionHeader {
sectionIdxs.remove((attributes.indexPath as NSIndexPath).section)
}
return sectionIdxs
Expand Down Expand Up @@ -207,7 +207,7 @@ extension AKPFlowLayout {
// Stretchy header
if firstSectionHeight - offset < firsSectionMaximumStretchHeight {
sectionFrame.size.height = firstSectionHeight - offset
sectionHeadersLayoutAttributes.stretchFactor = fabs(offset)
sectionHeadersLayoutAttributes.stretchFactor = abs(offset)
previousStretchFactor = sectionHeadersLayoutAttributes.stretchFactor
} else {
// need to limit the stretch
Expand Down Expand Up @@ -297,7 +297,7 @@ extension AKPFlowLayout {
private extension AKPFlowLayoutAttributes {
// Determines if element is a section, or is a cell in a section with custom header
func visibleSectionHeader(_ sectionsShouldPin: Bool) -> Bool {
let isHeader = representedElementKind == UICollectionElementKindSectionHeader
let isHeader = representedElementKind == UICollectionView.elementKindSectionHeader
let isCellInPinnedSection = sectionsShouldPin && ( representedElementCategory == .cell )
return isCellInPinnedSection || isHeader
}
Expand Down