diff --git a/ImageFilterEditor/.gitignore b/ImageFilterEditor/.gitignore new file mode 100644 index 00000000..312d1f65 --- /dev/null +++ b/ImageFilterEditor/.gitignore @@ -0,0 +1,68 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output diff --git a/ImageFilterEditor/PhotoFilter.xcodeproj/project.pbxproj b/ImageFilterEditor/PhotoFilter.xcodeproj/project.pbxproj new file mode 100644 index 00000000..cd1e983f --- /dev/null +++ b/ImageFilterEditor/PhotoFilter.xcodeproj/project.pbxproj @@ -0,0 +1,345 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + BD99071423957038009F7CDB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD99071323957038009F7CDB /* AppDelegate.swift */; }; + BD99071623957038009F7CDB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD99071523957038009F7CDB /* SceneDelegate.swift */; }; + BD99071D2395703C009F7CDB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BD99071C2395703C009F7CDB /* Assets.xcassets */; }; + BD9907202395703C009F7CDB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BD99071E2395703C009F7CDB /* LaunchScreen.storyboard */; }; + BD99072A23957067009F7CDB /* PhotoFilterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD99072723957067009F7CDB /* PhotoFilterViewController.swift */; }; + BD99072B23957067009F7CDB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BD99072823957067009F7CDB /* Main.storyboard */; }; + BD99072C23957067009F7CDB /* UIImage+Scaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD99072923957067009F7CDB /* UIImage+Scaling.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 87D7160924FF4C1B00087439 /* PhotoFilter.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PhotoFilter.entitlements; sourceTree = ""; }; + BD99071023957038009F7CDB /* PhotoFilter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PhotoFilter.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BD99071323957038009F7CDB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + BD99071523957038009F7CDB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + BD99071C2395703C009F7CDB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + BD99071F2395703C009F7CDB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + BD9907212395703C009F7CDB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BD99072723957067009F7CDB /* PhotoFilterViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhotoFilterViewController.swift; sourceTree = ""; }; + BD99072823957067009F7CDB /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; + BD99072923957067009F7CDB /* UIImage+Scaling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIImage+Scaling.swift"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + BD99070D23957038009F7CDB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + BD99070723957038009F7CDB = { + isa = PBXGroup; + children = ( + BD99071223957038009F7CDB /* PhotoFilter */, + BD99071123957038009F7CDB /* Products */, + ); + sourceTree = ""; + }; + BD99071123957038009F7CDB /* Products */ = { + isa = PBXGroup; + children = ( + BD99071023957038009F7CDB /* PhotoFilter.app */, + ); + name = Products; + sourceTree = ""; + }; + BD99071223957038009F7CDB /* PhotoFilter */ = { + isa = PBXGroup; + children = ( + 87D7160924FF4C1B00087439 /* PhotoFilter.entitlements */, + BD99071323957038009F7CDB /* AppDelegate.swift */, + BD99071523957038009F7CDB /* SceneDelegate.swift */, + BD99072823957067009F7CDB /* Main.storyboard */, + BD99072723957067009F7CDB /* PhotoFilterViewController.swift */, + BD99072923957067009F7CDB /* UIImage+Scaling.swift */, + BD99071C2395703C009F7CDB /* Assets.xcassets */, + BD99071E2395703C009F7CDB /* LaunchScreen.storyboard */, + BD9907212395703C009F7CDB /* Info.plist */, + ); + path = PhotoFilter; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + BD99070F23957038009F7CDB /* PhotoFilter */ = { + isa = PBXNativeTarget; + buildConfigurationList = BD9907242395703C009F7CDB /* Build configuration list for PBXNativeTarget "PhotoFilter" */; + buildPhases = ( + BD99070C23957038009F7CDB /* Sources */, + BD99070D23957038009F7CDB /* Frameworks */, + BD99070E23957038009F7CDB /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PhotoFilter; + productName = PhotoFilter; + productReference = BD99071023957038009F7CDB /* PhotoFilter.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + BD99070823957038009F7CDB /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1120; + LastUpgradeCheck = 1120; + ORGANIZATIONNAME = "Lambda, Inc"; + TargetAttributes = { + BD99070F23957038009F7CDB = { + CreatedOnToolsVersion = 11.2.1; + }; + }; + }; + buildConfigurationList = BD99070B23957038009F7CDB /* Build configuration list for PBXProject "PhotoFilter" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = BD99070723957038009F7CDB; + productRefGroup = BD99071123957038009F7CDB /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + BD99070F23957038009F7CDB /* PhotoFilter */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + BD99070E23957038009F7CDB /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BD99072B23957067009F7CDB /* Main.storyboard in Resources */, + BD9907202395703C009F7CDB /* LaunchScreen.storyboard in Resources */, + BD99071D2395703C009F7CDB /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + BD99070C23957038009F7CDB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BD99072A23957067009F7CDB /* PhotoFilterViewController.swift in Sources */, + BD99072C23957067009F7CDB /* UIImage+Scaling.swift in Sources */, + BD99071423957038009F7CDB /* AppDelegate.swift in Sources */, + BD99071623957038009F7CDB /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + BD99071E2395703C009F7CDB /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + BD99071F2395703C009F7CDB /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + BD9907222395703C009F7CDB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = 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_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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + BD9907232395703C009F7CDB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = 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_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; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + BD9907252395703C009F7CDB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = PhotoFilter/PhotoFilter.entitlements; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = VXUQXR6S56; + INFOPLIST_FILE = PhotoFilter/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.lambdaschool.PhotoFilter; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + BD9907262395703C009F7CDB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = PhotoFilter/PhotoFilter.entitlements; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = VXUQXR6S56; + INFOPLIST_FILE = PhotoFilter/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.lambdaschool.PhotoFilter; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + BD99070B23957038009F7CDB /* Build configuration list for PBXProject "PhotoFilter" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BD9907222395703C009F7CDB /* Debug */, + BD9907232395703C009F7CDB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + BD9907242395703C009F7CDB /* Build configuration list for PBXNativeTarget "PhotoFilter" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BD9907252395703C009F7CDB /* Debug */, + BD9907262395703C009F7CDB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = BD99070823957038009F7CDB /* Project object */; +} diff --git a/ImageFilterEditor/PhotoFilter/AppDelegate.swift b/ImageFilterEditor/PhotoFilter/AppDelegate.swift new file mode 100644 index 00000000..418e3485 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/AppDelegate.swift @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// PhotoFilter +// +// Created by Paul Solt on 12/2/19. +// Copyright © 2019 Lambda, Inc. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/ImageFilterEditor/PhotoFilter/Assets.xcassets/AppIcon.appiconset/Contents.json b/ImageFilterEditor/PhotoFilter/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d8db8d65 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ImageFilterEditor/PhotoFilter/Assets.xcassets/Contents.json b/ImageFilterEditor/PhotoFilter/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ImageFilterEditor/PhotoFilter/Assets.xcassets/small.imageset/Contents.json b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small.imageset/Contents.json new file mode 100644 index 00000000..38469ef9 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "small.jpeg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ImageFilterEditor/PhotoFilter/Assets.xcassets/small.imageset/small.jpeg b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small.imageset/small.jpeg new file mode 100644 index 00000000..85a8a393 Binary files /dev/null and b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small.imageset/small.jpeg differ diff --git a/ImageFilterEditor/PhotoFilter/Assets.xcassets/small2.imageset/Contents.json b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small2.imageset/Contents.json new file mode 100644 index 00000000..48f3d6b6 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "small2.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ImageFilterEditor/PhotoFilter/Assets.xcassets/small2.imageset/small2.jpg b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small2.imageset/small2.jpg new file mode 100644 index 00000000..11c516c4 Binary files /dev/null and b/ImageFilterEditor/PhotoFilter/Assets.xcassets/small2.imageset/small2.jpg differ diff --git a/ImageFilterEditor/PhotoFilter/Base.lproj/LaunchScreen.storyboard b/ImageFilterEditor/PhotoFilter/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ImageFilterEditor/PhotoFilter/Info.plist b/ImageFilterEditor/PhotoFilter/Info.plist new file mode 100644 index 00000000..aef051bd --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/Info.plist @@ -0,0 +1,68 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSPhotoLibraryUsageDescription + $(PRODUCT_NAME) needs access to your library to filter images. + NSPhotoLibraryAddUsageDescription + $(PRODUCT_NAME) needs access to your library to save filtered images. + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/ImageFilterEditor/PhotoFilter/Main.storyboard b/ImageFilterEditor/PhotoFilter/Main.storyboard new file mode 100644 index 00000000..3e0d2ddd --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/Main.storyboard @@ -0,0 +1,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ImageFilterEditor/PhotoFilter/PhotoFilter.entitlements b/ImageFilterEditor/PhotoFilter/PhotoFilter.entitlements new file mode 100644 index 00000000..8f330422 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/PhotoFilter.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + com.apple.security.personal-information.photos-library + + + diff --git a/ImageFilterEditor/PhotoFilter/PhotoFilterViewController.swift b/ImageFilterEditor/PhotoFilter/PhotoFilterViewController.swift new file mode 100644 index 00000000..8e280b54 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/PhotoFilterViewController.swift @@ -0,0 +1,173 @@ +import UIKit +import CoreImage +import CoreImage.CIFilterBuiltins +import Photos + +class PhotoFilterViewController: UIViewController { + + @IBOutlet weak var brightnessSlider: UISlider! + @IBOutlet weak var contrastSlider: UISlider! + @IBOutlet weak var saturationSlider: UISlider! + @IBOutlet weak var blurSlider: UISlider! + @IBOutlet weak var imageView: UIImageView! + + var originalImage: UIImage? { + didSet { + guard let originalImage = originalImage else { + scaledImage = nil + return + } + + var scaledSize = imageView.bounds.size +// let scale: CGFloat = 0.5 + let scale = imageView.contentScaleFactor // UIScreen.main.scale + +// scaledSize = CGSize(width: scaledSize.width*scale, +// height: scaledSize.height*scale) + + scaledSize.width *= scale + scaledSize.height *= scale + + guard let scaledUIImage = originalImage.imageByScaling(toSize: scaledSize) else { + scaledImage = nil + return + } + + scaledImage = CIImage(image: scaledUIImage) + } + } + + var scaledImage: CIImage? { + didSet { + updateImage() + } + } + + private let context = CIContext() + private let colorControlsFilter = CIFilter.colorControls() + private let blurFilter = CIFilter.gaussianBlur() + + override func viewDidLoad() { + super.viewDidLoad() + +// let filter = CIFilter.gaussianBlur() +// let filter2 = CIFilter(name: "CIColorControls") +// +// print(filter.attributes) + + originalImage = imageView.image + } + + private func presentImagePickerController() { + guard UIImagePickerController.isSourceTypeAvailable(.photoLibrary) else { + print("The photo library is not available.") + return + } + + let imagePicker = UIImagePickerController() + imagePicker.sourceType = .photoLibrary + imagePicker.delegate = self + + present(imagePicker, animated: true, completion: nil) + } + + private func image(byFiltering inputImage: CIImage) -> UIImage? { + colorControlsFilter.inputImage = inputImage + colorControlsFilter.saturation = saturationSlider.value + colorControlsFilter.brightness = brightnessSlider.value + colorControlsFilter.contrast = contrastSlider.value + + blurFilter.inputImage = colorControlsFilter.outputImage?.clampedToExtent() + blurFilter.radius = blurSlider.value + + guard let outputImage = blurFilter.outputImage else { return nil } + + guard let renderedCGImage = context.createCGImage(outputImage, from: inputImage.extent) else { return nil } + + return UIImage(cgImage: renderedCGImage) + } + + private func updateImage() { + if let scaledImage = scaledImage { + imageView.image = image(byFiltering: scaledImage) + } else { + imageView.image = nil + } + } + + // MARK: Actions + + @IBAction func choosePhotoButtonPressed(_ sender: Any) { + presentImagePickerController() + } + + @IBAction func savePhotoButtonPressed(_ sender: UIButton) { + guard + let originalImage = originalImage?.flattened, + let ciImage = CIImage(image: originalImage) + else { return } + + guard let processedImage = image(byFiltering: ciImage) else { return } + + PHPhotoLibrary.shared().performChanges({ + PHAssetChangeRequest.creationRequestForAsset(from: processedImage) + }) { (success, error) in + if let error = error { + print("Error saving photo: \(error)") + return + } + + DispatchQueue.main.async { + self.presentSuccessfulSaveAlert() + } + } + } + + private func presentSuccessfulSaveAlert() { + let alert = UIAlertController(title: "Photo Saved!", message: "The photo has been saved to your Photo Library!", preferredStyle: .alert) + + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) + + present(alert, animated: true, completion: nil) + } + + + // MARK: Slider events + + @IBAction func brightnessChanged(_ sender: UISlider) { + updateImage() + } + + @IBAction func contrastChanged(_ sender: Any) { + updateImage() + } + + @IBAction func saturationChanged(_ sender: Any) { + updateImage() + } + + @IBAction func blurChanged(_ sender: Any) { + updateImage() + } +} + + +extension PhotoFilterViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { + + if let image = info[.editedImage] as? UIImage { + originalImage = image + } else if let image = info[.originalImage] as? UIImage { + originalImage = image + } + + picker.dismiss(animated: true, completion: nil) + } + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { + picker.dismiss(animated: true, completion: nil) + } + +} + diff --git a/ImageFilterEditor/PhotoFilter/SceneDelegate.swift b/ImageFilterEditor/PhotoFilter/SceneDelegate.swift new file mode 100644 index 00000000..1529c968 --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/SceneDelegate.swift @@ -0,0 +1,53 @@ +// +// SceneDelegate.swift +// PhotoFilter +// +// Created by Paul Solt on 12/2/19. +// Copyright © 2019 Lambda, Inc. All rights reserved. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/ImageFilterEditor/PhotoFilter/UIImage+Scaling.swift b/ImageFilterEditor/PhotoFilter/UIImage+Scaling.swift new file mode 100644 index 00000000..c9ee898f --- /dev/null +++ b/ImageFilterEditor/PhotoFilter/UIImage+Scaling.swift @@ -0,0 +1,38 @@ +// +// UIImage+Scaling.swift +// iOS8-PhotoFilter +// +// Created by Paul Solt on 9/30/19. +// Copyright © 2019 Lambda, Inc. All rights reserved. +// + +import UIKit + +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) + } + } +} diff --git a/ImageFilterEditor/README.md b/ImageFilterEditor/README.md new file mode 100644 index 00000000..7ab5cf24 --- /dev/null +++ b/ImageFilterEditor/README.md @@ -0,0 +1,2 @@ +# ios-guided-project-core-image-starter +Photo Filter Starter Project for Core Image diff --git a/LambdaTimeline/Views/ImagePostCollectionViewCell.swift b/LambdaTimeline/Views/ImagePostCollectionViewCell.swift index 3841cf65..121029ea 100644 --- a/LambdaTimeline/Views/ImagePostCollectionViewCell.swift +++ b/LambdaTimeline/Views/ImagePostCollectionViewCell.swift @@ -8,6 +8,8 @@ import UIKit +// Part 2 firebase + class ImagePostCollectionViewCell: UICollectionViewCell { override func layoutSubviews() {