Skip to content

Commit

Permalink
Updated to Swift 5
Browse files Browse the repository at this point in the history
  • Loading branch information
vdeep committed Jun 20, 2019
1 parent 09241b2 commit bb52a4e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
18 changes: 12 additions & 6 deletions FMPhotoPicker/FMPhotoPicker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -437,16 +437,17 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 0920;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Tribal Media House";
TargetAttributes = {
CEE50D0820196DF9005AE708 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 0920;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
CEE50D1120196DF9005AE708 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
Expand All @@ -457,6 +458,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = CEE50CFF20196DF9005AE708;
productRefGroup = CEE50D0A20196DF9005AE708 /* Products */;
Expand Down Expand Up @@ -581,13 +583,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 @@ -641,13 +645,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 @@ -698,7 +704,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -720,7 +726,7 @@
PRODUCT_BUNDLE_IDENTIFIER = jp.co.tribalmedia.FMPhotoPicker;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -734,7 +740,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = jp.co.tribalmedia.FMPhotoPickerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -748,7 +754,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = jp.co.tribalmedia.FMPhotoPickerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
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 = "1020"
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>
<TestableReference
Expand Down Expand Up @@ -56,7 +55,6 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ class FMPhotosDataSource {
}

public func setSeletedForPhoto(atIndex index: Int) {
if self.selectedPhotoIndexes.index(where: { $0 == index }) == nil {
if self.selectedPhotoIndexes.firstIndex(where: { $0 == index }) == nil {
self.selectedPhotoIndexes.append(index)
}
}

public func unsetSeclectedForPhoto(atIndex index: Int) {
if let indexInSelectedIndex = self.selectedPhotoIndexes.index(where: { $0 == index }) {
if let indexInSelectedIndex = self.selectedPhotoIndexes.firstIndex(where: { $0 == index }) {
self.selectedPhotoIndexes.remove(at: indexInSelectedIndex)
}
}

public func selectedIndexOfPhoto(atIndex index: Int) -> Int? {
return self.selectedPhotoIndexes.index(where: { $0 == index })
return self.selectedPhotoIndexes.firstIndex(where: { $0 == index })
}

public func numberOfSelectedPhoto() -> Int {
Expand Down Expand Up @@ -70,7 +70,7 @@ class FMPhotosDataSource {
}

public func index(ofPhoto photo: FMPhotoAsset) -> Int? {
return self.photoAssets.index(where: { $0 === photo })
return self.photoAssets.firstIndex(where: { $0 === photo })
}

public func contains(photo: FMPhotoAsset) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class FMPhotoPickerBatchSelector: NSObject {

var result = [PanSelection]()
for index in fromIndex...toIndex {
let found = self.panSelections.index(where: { $0.indexPath.item == index })
let found = self.panSelections.firstIndex(where: { $0.indexPath.item == index })
if let found = found {
result.append(self.panSelections[found])
}
Expand All @@ -198,7 +198,7 @@ class FMPhotoPickerBatchSelector: NSObject {
*/
private func removeFromPrevSection(panSelectionsTobeReset: [PanSelection]) {
panSelectionsTobeReset.forEach { panSelection in
if let found = self.panSelections.index(where: { $0.indexPath == panSelection.indexPath }) {
if let found = self.panSelections.firstIndex(where: { $0.indexPath == panSelection.indexPath }) {
self.panSelections.remove(at: found)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,18 @@ public class FMImageEditorViewController: UIViewController {

// MARK: - Logics
private func contentFrameCrop() -> CGRect {
let frameWidth: CGFloat = view.bounds.width - 2 * kContentFrameSpacing
var frameHeight: CGFloat = view.bounds.height
frameHeight -= transparentViewHeightConstraint.constant
frameHeight -= bottomMenuContainer.frame.height
frameHeight -= subMenuContainer.frame.height
frameHeight -= unsafeAreaBottomViewHeightConstraint.constant
frameHeight -= 2 * kContentFrameSpacing

return CGRect(x: kContentFrameSpacing,
y: kContentFrameSpacing + transparentViewHeightConstraint.constant,
width: view.bounds.width - 2 * kContentFrameSpacing,
height: view.bounds.height - transparentViewHeightConstraint.constant - bottomMenuContainer.frame.height - subMenuContainer.frame.height - unsafeAreaBottomViewHeightConstraint.constant - 2 * kContentFrameSpacing)
width: frameWidth,
height: frameHeight)
}

private func contentFrameFilter() -> CGRect {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ extension FMCropMenuView: UICollectionViewDelegate {
cell.setSelected()

if let prevCropItem = prevCropItem,
let prevRow = cropItems.index(where: { $0.identifier() == prevCropItem.identifier() }) {
let prevRow = cropItems.firstIndex(where: { $0.identifier() == prevCropItem.identifier() }) {
collectionView.reloadItems(at: [IndexPath(row: prevRow, section: 1)])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FMFiltersMenuView: UIView {

super.init(frame: .zero)

if let index = self.availableFilters.index(where: { return $0.filterName() == appliedFilter?.filterName() }) {
if let index = self.availableFilters.firstIndex(where: { return $0.filterName() == appliedFilter?.filterName() }) {
self.selectedCellIndex = index
}

Expand Down

0 comments on commit bb52a4e

Please sign in to comment.