diff --git a/Experiences.xcodeproj/project.pbxproj b/Experiences.xcodeproj/project.pbxproj new file mode 100644 index 00000000..832bef87 --- /dev/null +++ b/Experiences.xcodeproj/project.pbxproj @@ -0,0 +1,366 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 61A9EDD32562681700BF6849 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61A9EDD22562681700BF6849 /* AppDelegate.swift */; }; + 61A9EDD52562681700BF6849 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61A9EDD42562681700BF6849 /* SceneDelegate.swift */; }; + 61A9EDD72562681700BF6849 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61A9EDD62562681700BF6849 /* ViewController.swift */; }; + 61A9EDDA2562681700BF6849 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 61A9EDD82562681700BF6849 /* Main.storyboard */; }; + 61A9EDDC2562681700BF6849 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 61A9EDDB2562681700BF6849 /* Assets.xcassets */; }; + 61A9EDDF2562681700BF6849 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 61A9EDDD2562681700BF6849 /* LaunchScreen.storyboard */; }; + 61EA774B25627B5B00D03AD1 /* ExperienceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61EA774A25627B5B00D03AD1 /* ExperienceViewController.swift */; }; + 61EA774E25627D5100D03AD1 /* Experience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61EA774D25627D5100D03AD1 /* Experience.swift */; }; + 61EA775325627D6200D03AD1 /* ExperienceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61EA775225627D6200D03AD1 /* ExperienceController.swift */; }; + 61EA775625628FB600D03AD1 /* UIImage+Ratio.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61EA775525628FB600D03AD1 /* UIImage+Ratio.swift */; }; + 61EA775B256290B100D03AD1 /* UIViewController+InformationalAlert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61EA775A256290B100D03AD1 /* UIViewController+InformationalAlert.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 61A9EDCF2562681700BF6849 /* Experiences.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Experiences.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 61A9EDD22562681700BF6849 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 61A9EDD42562681700BF6849 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 61A9EDD62562681700BF6849 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 61A9EDD92562681700BF6849 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 61A9EDDB2562681700BF6849 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 61A9EDDE2562681700BF6849 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 61A9EDE02562681700BF6849 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 61EA774A25627B5B00D03AD1 /* ExperienceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExperienceViewController.swift; sourceTree = ""; }; + 61EA774D25627D5100D03AD1 /* Experience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Experience.swift; sourceTree = ""; }; + 61EA775225627D6200D03AD1 /* ExperienceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExperienceController.swift; sourceTree = ""; }; + 61EA775525628FB600D03AD1 /* UIImage+Ratio.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Ratio.swift"; sourceTree = ""; }; + 61EA775A256290B100D03AD1 /* UIViewController+InformationalAlert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+InformationalAlert.swift"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 61A9EDCC2562681700BF6849 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 61A9EDC62562681700BF6849 = { + isa = PBXGroup; + children = ( + 61A9EDD12562681700BF6849 /* Experiences */, + 61A9EDD02562681700BF6849 /* Products */, + ); + sourceTree = ""; + }; + 61A9EDD02562681700BF6849 /* Products */ = { + isa = PBXGroup; + children = ( + 61A9EDCF2562681700BF6849 /* Experiences.app */, + ); + name = Products; + sourceTree = ""; + }; + 61A9EDD12562681700BF6849 /* Experiences */ = { + isa = PBXGroup; + children = ( + 61A9EDD22562681700BF6849 /* AppDelegate.swift */, + 61A9EDD42562681700BF6849 /* SceneDelegate.swift */, + 61A9EDD62562681700BF6849 /* ViewController.swift */, + 61EA774A25627B5B00D03AD1 /* ExperienceViewController.swift */, + 61EA774D25627D5100D03AD1 /* Experience.swift */, + 61EA775225627D6200D03AD1 /* ExperienceController.swift */, + 61EA775525628FB600D03AD1 /* UIImage+Ratio.swift */, + 61EA775A256290B100D03AD1 /* UIViewController+InformationalAlert.swift */, + 61A9EDD82562681700BF6849 /* Main.storyboard */, + 61A9EDDB2562681700BF6849 /* Assets.xcassets */, + 61A9EDDD2562681700BF6849 /* LaunchScreen.storyboard */, + 61A9EDE02562681700BF6849 /* Info.plist */, + ); + path = Experiences; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 61A9EDCE2562681700BF6849 /* Experiences */ = { + isa = PBXNativeTarget; + buildConfigurationList = 61A9EDE32562681700BF6849 /* Build configuration list for PBXNativeTarget "Experiences" */; + buildPhases = ( + 61A9EDCB2562681700BF6849 /* Sources */, + 61A9EDCC2562681700BF6849 /* Frameworks */, + 61A9EDCD2562681700BF6849 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Experiences; + productName = Experiences; + productReference = 61A9EDCF2562681700BF6849 /* Experiences.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 61A9EDC72562681700BF6849 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1220; + LastUpgradeCheck = 1220; + TargetAttributes = { + 61A9EDCE2562681700BF6849 = { + CreatedOnToolsVersion = 12.2; + }; + }; + }; + buildConfigurationList = 61A9EDCA2562681700BF6849 /* Build configuration list for PBXProject "Experiences" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 61A9EDC62562681700BF6849; + productRefGroup = 61A9EDD02562681700BF6849 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 61A9EDCE2562681700BF6849 /* Experiences */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 61A9EDCD2562681700BF6849 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 61A9EDDF2562681700BF6849 /* LaunchScreen.storyboard in Resources */, + 61A9EDDC2562681700BF6849 /* Assets.xcassets in Resources */, + 61A9EDDA2562681700BF6849 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 61A9EDCB2562681700BF6849 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 61EA774B25627B5B00D03AD1 /* ExperienceViewController.swift in Sources */, + 61A9EDD72562681700BF6849 /* ViewController.swift in Sources */, + 61A9EDD32562681700BF6849 /* AppDelegate.swift in Sources */, + 61EA775625628FB600D03AD1 /* UIImage+Ratio.swift in Sources */, + 61EA775325627D6200D03AD1 /* ExperienceController.swift in Sources */, + 61EA774E25627D5100D03AD1 /* Experience.swift in Sources */, + 61A9EDD52562681700BF6849 /* SceneDelegate.swift in Sources */, + 61EA775B256290B100D03AD1 /* UIViewController+InformationalAlert.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 61A9EDD82562681700BF6849 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 61A9EDD92562681700BF6849 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 61A9EDDD2562681700BF6849 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 61A9EDDE2562681700BF6849 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 61A9EDE12562681700BF6849 /* 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + 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 = 14.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; + }; + 61A9EDE22562681700BF6849 /* 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + 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 = 14.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; + }; + 61A9EDE42562681700BF6849 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 5Z7LY99W88; + INFOPLIST_FILE = Experiences/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.omihek.Experiences; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 61A9EDE52562681700BF6849 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 5Z7LY99W88; + INFOPLIST_FILE = Experiences/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.omihek.Experiences; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 61A9EDCA2562681700BF6849 /* Build configuration list for PBXProject "Experiences" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 61A9EDE12562681700BF6849 /* Debug */, + 61A9EDE22562681700BF6849 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 61A9EDE32562681700BF6849 /* Build configuration list for PBXNativeTarget "Experiences" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 61A9EDE42562681700BF6849 /* Debug */, + 61A9EDE52562681700BF6849 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 61A9EDC72562681700BF6849 /* Project object */; +} diff --git a/Experiences/AppDelegate.swift b/Experiences/AppDelegate.swift new file mode 100644 index 00000000..c776ed09 --- /dev/null +++ b/Experiences/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +import UIKit + +@main +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/Experiences/Assets.xcassets/AccentColor.colorset/Contents.json b/Experiences/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/Experiences/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experiences/Assets.xcassets/AppIcon.appiconset/Contents.json b/Experiences/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/Experiences/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experiences/Assets.xcassets/Contents.json b/Experiences/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Experiences/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experiences/Base.lproj/LaunchScreen.storyboard b/Experiences/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/Experiences/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Experiences/Base.lproj/Main.storyboard b/Experiences/Base.lproj/Main.storyboard new file mode 100644 index 00000000..2be0c332 --- /dev/null +++ b/Experiences/Base.lproj/Main.storyboard @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Experiences/Experience.swift b/Experiences/Experience.swift new file mode 100644 index 00000000..9618c367 --- /dev/null +++ b/Experiences/Experience.swift @@ -0,0 +1,32 @@ +// +// Experience.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +import Foundation +import UIKit +import MapKit + +class Experience: NSObject, MKAnnotation { + + var id: String + var expTitle: String + var image: UIImage? + var ratio: CGFloat? + var recording: URL? + let timestamp: Date + var coordinate: CLLocationCoordinate2D + + + init(expTitle: String, image: UIImage? = nil, ratio: CGFloat?, recording: URL? = nil, timestamp: Date = Date(), coordinate: CLLocationCoordinate2D) { + self.id = UUID().uuidString + self.expTitle = expTitle + self.image = image + self.ratio = ratio + self.recording = recording + self.timestamp = timestamp + self.coordinate = coordinate + } +} diff --git a/Experiences/ExperienceController.swift b/Experiences/ExperienceController.swift new file mode 100644 index 00000000..078985b6 --- /dev/null +++ b/Experiences/ExperienceController.swift @@ -0,0 +1,22 @@ +// +// ExperienceController.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +import Foundation +import UIKit +import MapKit + +class ExperienceController { + + var experiences: [Experience] = [] + + func createExperience(with title: String, image: UIImage?, ratio: CGFloat?, recording: URL?, geotag: CLLocationCoordinate2D) { + + let experience = Experience(expTitle: title, image: image, ratio: ratio, recording: recording, coordinate: geotag) + + experiences.append(experience) + } +} diff --git a/Experiences/ExperienceViewController.swift b/Experiences/ExperienceViewController.swift new file mode 100644 index 00000000..9d4ec3eb --- /dev/null +++ b/Experiences/ExperienceViewController.swift @@ -0,0 +1,286 @@ +// +// ExperienceViewController.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +import UIKit +import CoreImage +import CoreImage.CIFilterBuiltins +import Photos +import AVFoundation + +protocol AddExperienceDelegate { + func expCreated() +} + +class ExperienceViewController: UIViewController { + + @IBOutlet weak var saveButton: UIBarButtonItem! + @IBOutlet weak var titleTextField: UITextField! + @IBOutlet weak var imageView: UIImageView! + @IBOutlet weak var addImageButton: UIButton! + @IBOutlet weak var recordButton: UIButton! + + var delegate: AddExperienceDelegate? + + var expController: ExperienceController! + var expTitle = "No Title" + var expImage: UIImage? + + var currentLocation: CLLocationCoordinate2D? + let locationManager = CLLocationManager() + + var recordingURL: URL? + var audioRecorder: AVAudioRecorder? + + private let context = CIContext() + private let vintageFilter = CIFilter.photoEffectInstant() + + var originalImage: UIImage? { + didSet { + guard let originalImage = originalImage else { + scaledImage = nil + return + } + + var scaledSize = imageView.bounds.size + let scale = imageView.contentScaleFactor + + 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() + } + } + + override func viewDidLoad() { + super.viewDidLoad() + + locationManager.requestWhenInUseAuthorization() + + if CLLocationManager.locationServicesEnabled() { + locationManager.delegate = self + locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters + locationManager.startUpdatingLocation() + } + } + + private func presentImagePickerController() { + + guard UIImagePickerController.isSourceTypeAvailable(.photoLibrary) else { + presentInformationalAlertController(title: "Error", message: "The photo library is unavailable") + return + } + + DispatchQueue.main.async { + let imagePicker = UIImagePickerController() + imagePicker.delegate = self + imagePicker.sourceType = .photoLibrary + + self.present(imagePicker, animated: true, completion: nil) + } + } + + private func image(byFiltering inputImage: CIImage) -> UIImage? { + vintageFilter.inputImage = inputImage + + guard let outputImage = vintageFilter.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 + } + } + + var isRecording: Bool { + audioRecorder?.isRecording ?? false + } + + func createNewRecordingURL() -> URL { + let documents = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + + let name = ISO8601DateFormatter.string(from: Date(), timeZone: .current, formatOptions: .withInternetDateTime) + let file = documents.appendingPathComponent(name, isDirectory: false).appendingPathExtension("caf") + + print("recording URL: \(file)") + + return file + } + + func requestPermissionOrStartRecording() { + switch AVAudioSession.sharedInstance().recordPermission { + case .undetermined: + AVAudioSession.sharedInstance().requestRecordPermission { granted in + guard granted == true else { + print("We need microphone access") + return + } + + print("Recording permission has been granted!") + } + case .denied: + print("Microphone access has been blocked.") + + let alertController = UIAlertController(title: "Microphone Access Denied", message: "Please allow this app to access your Microphone.", preferredStyle: .alert) + + alertController.addAction(UIAlertAction(title: "Open Settings", style: .default) { (_) in + UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!) + }) + + alertController.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil)) + + present(alertController, animated: true, completion: nil) + case .granted: + startRecording() + @unknown default: + break + } + } + + func prepareAudioSession() throws { + let session = AVAudioSession.sharedInstance() + try session.setCategory(.playAndRecord, options: [.defaultToSpeaker]) + try session.setActive(true, options: []) + } + + func startRecording() { + do { + try prepareAudioSession() + } catch { + print("Cannot record audio: \(error)") + return + } + + recordButton.setTitle("Stop Recording", for: []) + + recordingURL = createNewRecordingURL() + + let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 1)! + + do { + audioRecorder = try AVAudioRecorder(url: recordingURL!, format: format) + audioRecorder?.delegate = self + audioRecorder?.isMeteringEnabled = true + audioRecorder?.record() + } catch { + preconditionFailure("The audio recorder could not be created with \(recordingURL!) and \(format)") + } + } + + func stopRecording() { + audioRecorder?.stop() + recordButton.setTitle("Record", for: []) + } + + @IBAction func saveExperience(_ sender: Any) { + if let title = titleTextField.text, + !title.isEmpty { + expTitle = title + } + + if let image = imageView.image { + expImage = image + } + + expController.createExperience(with: expTitle, image: expImage, ratio: expImage?.ratio, recording: recordingURL, geotag: currentLocation!) + delegate?.expCreated() + + self.dismiss(animated: true, completion: nil) + } + + @IBAction func addImage(_ sender: Any) { + let authorizationStatus = PHPhotoLibrary.authorizationStatus() + + switch authorizationStatus { + case .authorized: + presentImagePickerController() + case .notDetermined: + + PHPhotoLibrary.requestAuthorization { (status) in + + guard status == .authorized else { + NSLog("User did not authorize access to the photo library") + self.presentInformationalAlertController(title: "Error", message: "In order to access the photo library, you must allow this application access to it.") + return + } + + self.presentImagePickerController() + } + + case .denied: + self.presentInformationalAlertController(title: "Error", message: "In order to access the photo library, you must allow this application access to it.") + case .restricted: + self.presentInformationalAlertController(title: "Error", message: "Unable to access the photo library. Your device's restrictions do not allow access.") + default: + break + } + presentImagePickerController() + } + + @IBAction func recordAudio(_ sender: Any) { + if isRecording { + stopRecording() + } else { + requestPermissionOrStartRecording() + } + } +} + + +extension ExperienceViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { + + addImageButton.setTitle("", for: []) + + picker.dismiss(animated: true, completion: nil) + + guard let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage else { return } + + imageView.image = image + + originalImage = imageView.image + } + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { + picker.dismiss(animated: true, completion: nil) + } +} + + +extension ExperienceViewController: AVAudioRecorderDelegate { + func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: Error?) { + if let error = error { + print("Audio Recording Error: \(error)") + } + } +} + + +extension ExperienceViewController: CLLocationManagerDelegate { + func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { + guard let locValue: CLLocationCoordinate2D = manager.location?.coordinate else { return } + + currentLocation = locValue + } +} diff --git a/Experiences/Info.plist b/Experiences/Info.plist new file mode 100644 index 00000000..31679369 --- /dev/null +++ b/Experiences/Info.plist @@ -0,0 +1,72 @@ + + + + + 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 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + NSLocationWhenInUseUsageDescription + $(PRODUCT_NAME) needs your location to tag your experiences. + NSPhotoLibraryUsageDescription + $(PRODUCT_NAME) needs permission to access your photo library. + NSMicrophoneUsageDescription + $(PRODUCT_NAME) needs permission to use your microphone to record audio. + + diff --git a/Experiences/SceneDelegate.swift b/Experiences/SceneDelegate.swift new file mode 100644 index 00000000..1fac3265 --- /dev/null +++ b/Experiences/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +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 necessarily 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/Experiences/UIImage+Ratio.swift b/Experiences/UIImage+Ratio.swift new file mode 100644 index 00000000..8a7ff2a7 --- /dev/null +++ b/Experiences/UIImage+Ratio.swift @@ -0,0 +1,41 @@ +// +// UIImage+Ratio.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +import Foundation +import UIKit + +extension UIImage { + var ratio: CGFloat { + return size.height / size.width + } + + /// 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/Experiences/UIViewController+InformationalAlert.swift b/Experiences/UIViewController+InformationalAlert.swift new file mode 100644 index 00000000..8016f5a8 --- /dev/null +++ b/Experiences/UIViewController+InformationalAlert.swift @@ -0,0 +1,21 @@ +// +// UIViewController+InformationalAlert.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +import Foundation +import UIKit + +extension UIViewController { + + func presentInformationalAlertController(title: String?, message: String?, dismissActionCompletion: ((UIAlertAction) -> Void)? = nil, completion: (() -> Void)? = nil) { + let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) + let dismissAction = UIAlertAction(title: "Dismiss", style: .cancel, handler: dismissActionCompletion) + + alertController.addAction(dismissAction) + + present(alertController, animated: true, completion: completion) + } +} diff --git a/Experiences/ViewController.swift b/Experiences/ViewController.swift new file mode 100644 index 00000000..f463360c --- /dev/null +++ b/Experiences/ViewController.swift @@ -0,0 +1,70 @@ +// +// ViewController.swift +// Experiences +// +// Created by Kenneth Jones on 11/16/20. +// + +import UIKit +import MapKit + +enum ReuseIdentifier { + static let expAnnotation = "ExperienceAnnotationView" + static let addExpSegue = "AddExperienceSegue" +} + +class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { + + @IBOutlet weak var mapView: MKMapView! + @IBOutlet weak var addExperienceButton: UIButton! + + private var userTrackingButton: MKUserTrackingButton! + private let locationManager = CLLocationManager() + + var expController = ExperienceController() + + override func viewDidLoad() { + super.viewDidLoad() + + addExperienceButton.backgroundColor = UIColor(hue: 190/360, saturation: 70/100, brightness: 80/100, alpha: 1.0) + addExperienceButton.tintColor = .white + addExperienceButton.layer.cornerRadius = 8.0 + + locationManager.requestWhenInUseAuthorization() + + userTrackingButton = MKUserTrackingButton(mapView: mapView) + userTrackingButton.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(userTrackingButton) + + NSLayoutConstraint.activate([ + userTrackingButton.leadingAnchor.constraint(equalTo: mapView.leadingAnchor, constant: 20), + mapView.bottomAnchor.constraint(equalTo: userTrackingButton.bottomAnchor, constant: 20) + ]) + + if CLLocationManager.locationServicesEnabled() { + locationManager.delegate = self + locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters + locationManager.startUpdatingLocation() + } + + mapView.register(MKMarkerAnnotationView.self, forAnnotationViewWithReuseIdentifier: ReuseIdentifier.expAnnotation) + + mapView.addAnnotations(expController.experiences) + } + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == ReuseIdentifier.addExpSegue { + let destinationVC = segue.destination as? ExperienceViewController + destinationVC?.expController = expController + destinationVC?.delegate = self + } + } +} + + +extension ViewController: AddExperienceDelegate { + func expCreated() { + mapView.removeAnnotations(mapView.annotations) + mapView.addAnnotations(expController.experiences) + } +}