Skip to content
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
16 changes: 11 additions & 5 deletions LambdaTimeline.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
1AC9C5CE254B86BD00CDD572 /* ImageFilterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AC9C5CD254B86BD00CDD572 /* ImageFilterViewController.swift */; };
4646377C216FDE4B00E7FF73 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4646377B216FDE4B00E7FF73 /* AppDelegate.swift */; };
46463783216FDE4C00E7FF73 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46463782216FDE4C00E7FF73 /* Assets.xcassets */; };
46463786216FDE4C00E7FF73 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 46463784216FDE4C00E7FF73 /* LaunchScreen.storyboard */; };
Expand All @@ -25,6 +26,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1AC9C5CD254B86BD00CDD572 /* ImageFilterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageFilterViewController.swift; sourceTree = "<group>"; };
46463778216FDE4B00E7FF73 /* LambdaTimeline.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LambdaTimeline.app; sourceTree = BUILT_PRODUCTS_DIR; };
4646377B216FDE4B00E7FF73 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
46463782216FDE4C00E7FF73 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -128,6 +130,7 @@
46A0366921700F5100E7FF73 /* PostsCollectionViewController.swift */,
46CFE6F421707D0000E7FF73 /* ImagePostViewController.swift */,
46D571F72173FC2700E7FF73 /* ImagePostDetailTableViewController.swift */,
1AC9C5CD254B86BD00CDD572 /* ImageFilterViewController.swift */,
);
path = "View Controllers";
sourceTree = "<group>";
Expand Down Expand Up @@ -185,7 +188,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1000;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1200;
ORGANIZATIONNAME = "Lambda School";
TargetAttributes = {
46463777216FDE4B00E7FF73 = {
Expand Down Expand Up @@ -232,6 +235,7 @@
files = (
46A0366D2170158900E7FF73 /* SignInViewController.swift in Sources */,
46CFE6F92170862C00E7FF73 /* ShiftableViewController.swift in Sources */,
1AC9C5CE254B86BD00CDD572 /* ImageFilterViewController.swift in Sources */,
4646377C216FDE4B00E7FF73 /* AppDelegate.swift in Sources */,
46CFE6F521707D0000E7FF73 /* ImagePostViewController.swift in Sources */,
46463790216FFD1B00E7FF73 /* Post.swift in Sources */,
Expand Down Expand Up @@ -285,6 +289,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -310,7 +315,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -346,6 +351,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -365,7 +371,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand All @@ -382,7 +388,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/LambdaTimeline/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -401,7 +407,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = "$(SRCROOT)/LambdaTimeline/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
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 = "1130"
LastUpgradeVersion = "1200"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
29 changes: 29 additions & 0 deletions LambdaTimeline/Helpers/Extensions/UIImage+Ratio.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,32 @@ extension UIImage {
return size.height / size.width
}
}

extension UIImage {

/// Resize the image to a max dimension from size parameter
func imageByScaling(toSize size: CGSize) -> UIImage? {
guard size.width > 0 && size.height > 0 else { return nil }

let originalAspectRatio = self.size.width/self.size.height
var correctedSize = size

if correctedSize.width > correctedSize.width*originalAspectRatio {
correctedSize.width = correctedSize.width*originalAspectRatio
} else {
correctedSize.height = correctedSize.height/originalAspectRatio
}

return UIGraphicsImageRenderer(size: correctedSize, format: imageRendererFormat).image { context in
draw(in: CGRect(origin: .zero, size: correctedSize))
}
}

/// Renders the image if the pixel data was rotated due to orientation of camera
var flattened: UIImage {
if imageOrientation == .up { return self }
return UIGraphicsImageRenderer(size: size, format: imageRendererFormat).image { context in
draw(at: .zero)
}
}
}
Loading