diff --git a/Experiences/Experiences.xcodeproj/project.pbxproj b/Experiences/Experiences.xcodeproj/project.pbxproj new file mode 100644 index 00000000..fc92a894 --- /dev/null +++ b/Experiences/Experiences.xcodeproj/project.pbxproj @@ -0,0 +1,399 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + B4D62AF124B8F90D00E9DE58 /* CameraView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D62AF024B8F90D00E9DE58 /* CameraView.swift */; }; + B4D62AF324B8F95700E9DE58 /* CameraPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D62AF224B8F95700E9DE58 /* CameraPreviewView.swift */; }; + B4D62AF524B8F99700E9DE58 /* VideoPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D62AF424B8F99700E9DE58 /* VideoPlayerView.swift */; }; + B4D62AF724B8FA2600E9DE58 /* AddExperienceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D62AF624B8FA2600E9DE58 /* AddExperienceViewController.swift */; }; + B4D62AF924B8FB7900E9DE58 /* CameraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4D62AF824B8FB7900E9DE58 /* CameraViewController.swift */; }; + B4DB474324B8BD3F00CF0574 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DB474224B8BD3F00CF0574 /* AppDelegate.swift */; }; + B4DB474524B8BD3F00CF0574 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DB474424B8BD3F00CF0574 /* SceneDelegate.swift */; }; + B4DB474A24B8BD3F00CF0574 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B4DB474824B8BD3F00CF0574 /* Main.storyboard */; }; + B4DB474C24B8BD4400CF0574 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4DB474B24B8BD4400CF0574 /* Assets.xcassets */; }; + B4DB474F24B8BD4500CF0574 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B4DB474D24B8BD4500CF0574 /* LaunchScreen.storyboard */; }; + B4DB475724B8C0FC00CF0574 /* Experience.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DB475624B8C0FC00CF0574 /* Experience.swift */; }; + B4DB475924B8C28B00CF0574 /* ExperienceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DB475824B8C28B00CF0574 /* ExperienceController.swift */; }; + B4DB475B24B8C5E900CF0574 /* UIImage+Scaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DB475A24B8C5E900CF0574 /* UIImage+Scaling.swift */; }; + B4DB475D24B8C66D00CF0574 /* MapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4DB475C24B8C66D00CF0574 /* MapViewController.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B4D62AF024B8F90D00E9DE58 /* CameraView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraView.swift; sourceTree = ""; }; + B4D62AF224B8F95700E9DE58 /* CameraPreviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraPreviewView.swift; sourceTree = ""; }; + B4D62AF424B8F99700E9DE58 /* VideoPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerView.swift; sourceTree = ""; }; + B4D62AF624B8FA2600E9DE58 /* AddExperienceViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddExperienceViewController.swift; sourceTree = ""; }; + B4D62AF824B8FB7900E9DE58 /* CameraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraViewController.swift; sourceTree = ""; }; + B4DB473F24B8BD3F00CF0574 /* Experiences.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Experiences.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B4DB474224B8BD3F00CF0574 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + B4DB474424B8BD3F00CF0574 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + B4DB474924B8BD3F00CF0574 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + B4DB474B24B8BD4400CF0574 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + B4DB474E24B8BD4500CF0574 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + B4DB475024B8BD4500CF0574 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B4DB475624B8C0FC00CF0574 /* Experience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Experience.swift; sourceTree = ""; }; + B4DB475824B8C28B00CF0574 /* ExperienceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExperienceController.swift; sourceTree = ""; }; + B4DB475A24B8C5E900CF0574 /* UIImage+Scaling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Scaling.swift"; sourceTree = ""; }; + B4DB475C24B8C66D00CF0574 /* MapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewController.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B4DB473C24B8BD3F00CF0574 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B4D62AFA24B9011600E9DE58 /* View Controllers */ = { + isa = PBXGroup; + children = ( + B4D62AF824B8FB7900E9DE58 /* CameraViewController.swift */, + B4DB475C24B8C66D00CF0574 /* MapViewController.swift */, + B4D62AF624B8FA2600E9DE58 /* AddExperienceViewController.swift */, + ); + path = "View Controllers"; + sourceTree = ""; + }; + B4D62AFB24B9014300E9DE58 /* Views */ = { + isa = PBXGroup; + children = ( + B4DB474D24B8BD4500CF0574 /* LaunchScreen.storyboard */, + B4DB474824B8BD3F00CF0574 /* Main.storyboard */, + B4D62AF424B8F99700E9DE58 /* VideoPlayerView.swift */, + B4D62AF024B8F90D00E9DE58 /* CameraView.swift */, + B4D62AF224B8F95700E9DE58 /* CameraPreviewView.swift */, + ); + path = Views; + sourceTree = ""; + }; + B4D62AFC24B9016200E9DE58 /* Controller */ = { + isa = PBXGroup; + children = ( + B4DB475624B8C0FC00CF0574 /* Experience.swift */, + B4DB475824B8C28B00CF0574 /* ExperienceController.swift */, + B4DB475A24B8C5E900CF0574 /* UIImage+Scaling.swift */, + ); + path = Controller; + sourceTree = ""; + }; + B4DB473624B8BD3F00CF0574 = { + isa = PBXGroup; + children = ( + B4DB474124B8BD3F00CF0574 /* Experiences */, + B4DB474024B8BD3F00CF0574 /* Products */, + ); + sourceTree = ""; + }; + B4DB474024B8BD3F00CF0574 /* Products */ = { + isa = PBXGroup; + children = ( + B4DB473F24B8BD3F00CF0574 /* Experiences.app */, + ); + name = Products; + sourceTree = ""; + }; + B4DB474124B8BD3F00CF0574 /* Experiences */ = { + isa = PBXGroup; + children = ( + B4DB474224B8BD3F00CF0574 /* AppDelegate.swift */, + B4DB474424B8BD3F00CF0574 /* SceneDelegate.swift */, + B4D62AFC24B9016200E9DE58 /* Controller */, + B4D62AFA24B9011600E9DE58 /* View Controllers */, + B4D62AFB24B9014300E9DE58 /* Views */, + B4DB474B24B8BD4400CF0574 /* Assets.xcassets */, + B4DB475024B8BD4500CF0574 /* Info.plist */, + ); + path = Experiences; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B4DB473E24B8BD3F00CF0574 /* Experiences */ = { + isa = PBXNativeTarget; + buildConfigurationList = B4DB475324B8BD4500CF0574 /* Build configuration list for PBXNativeTarget "Experiences" */; + buildPhases = ( + B4DB473B24B8BD3F00CF0574 /* Sources */, + B4DB473C24B8BD3F00CF0574 /* Frameworks */, + B4DB473D24B8BD3F00CF0574 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Experiences; + productName = Experiences; + productReference = B4DB473F24B8BD3F00CF0574 /* Experiences.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B4DB473724B8BD3F00CF0574 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1150; + LastUpgradeCheck = 1150; + ORGANIZATIONNAME = "Nonye Ezekwo"; + TargetAttributes = { + B4DB473E24B8BD3F00CF0574 = { + CreatedOnToolsVersion = 11.5; + }; + }; + }; + buildConfigurationList = B4DB473A24B8BD3F00CF0574 /* Build configuration list for PBXProject "Experiences" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B4DB473624B8BD3F00CF0574; + productRefGroup = B4DB474024B8BD3F00CF0574 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B4DB473E24B8BD3F00CF0574 /* Experiences */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B4DB473D24B8BD3F00CF0574 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B4DB474F24B8BD4500CF0574 /* LaunchScreen.storyboard in Resources */, + B4DB474C24B8BD4400CF0574 /* Assets.xcassets in Resources */, + B4DB474A24B8BD3F00CF0574 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B4DB473B24B8BD3F00CF0574 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B4DB474324B8BD3F00CF0574 /* AppDelegate.swift in Sources */, + B4D62AF124B8F90D00E9DE58 /* CameraView.swift in Sources */, + B4DB474524B8BD3F00CF0574 /* SceneDelegate.swift in Sources */, + B4DB475B24B8C5E900CF0574 /* UIImage+Scaling.swift in Sources */, + B4DB475724B8C0FC00CF0574 /* Experience.swift in Sources */, + B4DB475924B8C28B00CF0574 /* ExperienceController.swift in Sources */, + B4D62AF324B8F95700E9DE58 /* CameraPreviewView.swift in Sources */, + B4DB475D24B8C66D00CF0574 /* MapViewController.swift in Sources */, + B4D62AF924B8FB7900E9DE58 /* CameraViewController.swift in Sources */, + B4D62AF724B8FA2600E9DE58 /* AddExperienceViewController.swift in Sources */, + B4D62AF524B8F99700E9DE58 /* VideoPlayerView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + B4DB474824B8BD3F00CF0574 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B4DB474924B8BD3F00CF0574 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + B4DB474D24B8BD4500CF0574 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B4DB474E24B8BD4500CF0574 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + B4DB475124B8BD4500CF0574 /* 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.5; + 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; + }; + B4DB475224B8BD4500CF0574 /* 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.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + B4DB475424B8BD4500CF0574 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = JKA99996Q5; + INFOPLIST_FILE = Experiences/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.nonye.CocoaHealth; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + B4DB475524B8BD4500CF0574 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = JKA99996Q5; + INFOPLIST_FILE = Experiences/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.nonye.CocoaHealth; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B4DB473A24B8BD3F00CF0574 /* Build configuration list for PBXProject "Experiences" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B4DB475124B8BD4500CF0574 /* Debug */, + B4DB475224B8BD4500CF0574 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B4DB475324B8BD4500CF0574 /* Build configuration list for PBXNativeTarget "Experiences" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B4DB475424B8BD4500CF0574 /* Debug */, + B4DB475524B8BD4500CF0574 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B4DB473724B8BD3F00CF0574 /* Project object */; +} diff --git a/Experiences/Experiences/AppDelegate.swift b/Experiences/Experiences/AppDelegate.swift new file mode 100644 index 00000000..1f8a5485 --- /dev/null +++ b/Experiences/Experiences/AppDelegate.swift @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. 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/Experiences/Experiences/Assets.xcassets/AppIcon.appiconset/Contents.json b/Experiences/Experiences/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/Experiences/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/Experiences/Assets.xcassets/Contents.json b/Experiences/Experiences/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Experiences/Experiences/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experiences/Experiences/Controller/Experience.swift b/Experiences/Experiences/Controller/Experience.swift new file mode 100644 index 00000000..656eb8fe --- /dev/null +++ b/Experiences/Experiences/Controller/Experience.swift @@ -0,0 +1,27 @@ +// +// Experience.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import Foundation +import MapKit +import CoreLocation + +class Experience: NSObject, MKAnnotation { + var coordinate: CLLocationCoordinate2D + var experienceTitle: String? + var image: UIImage? + var audio: URL? + var video: URL? + + init(coordinate: CLLocationCoordinate2D, title: String?, image: UIImage?, audio: URL?, video: URL?) { + self.coordinate = coordinate + self.experienceTitle = title + self.image = image + self.audio = audio + self.video = video + } +} diff --git a/Experiences/Experiences/Controller/ExperienceController.swift b/Experiences/Experiences/Controller/ExperienceController.swift new file mode 100644 index 00000000..4c95fa40 --- /dev/null +++ b/Experiences/Experiences/Controller/ExperienceController.swift @@ -0,0 +1,32 @@ +// +// ExperienceController.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import Foundation +import MapKit +import CoreLocation + +class ExperienceController { + + var experiences: [Experience] = [] + var experience: Experience? + + func createExperience(coordinate: CLLocationCoordinate2D, + title: String?, + image: UIImage?, + audio: URL?, + video: URL?) { + + let newExperience = Experience(coordinate: coordinate, + title: title, + image: image, + audio: audio, + video: video) + experiences.append(newExperience) + experience = newExperience + } +} diff --git a/Experiences/Experiences/Controller/UIImage+Scaling.swift b/Experiences/Experiences/Controller/UIImage+Scaling.swift new file mode 100644 index 00000000..f524f7b2 --- /dev/null +++ b/Experiences/Experiences/Controller/UIImage+Scaling.swift @@ -0,0 +1,41 @@ +// +// UIImage+Scaling.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import UIKit +import AVFoundation +import CoreImage +import CoreImage.CIFilterBuiltins +import Photos + +extension UIImage { + 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/Experiences/Info.plist b/Experiences/Experiences/Info.plist new file mode 100644 index 00000000..22a6a56c --- /dev/null +++ b/Experiences/Experiences/Info.plist @@ -0,0 +1,78 @@ + + + + + NSLocationWhenInUseUsageDescription + $(PRODUCT_NAME) uses location to show views on map. + 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 + + NSCameraUsageDescription + $(PRODUCT_NAME) uses the camera to take photos and videos. + NSLocationAlwaysAndWhenInUseUsageDescription + $(PRODUCT_NAME) uses location to show views on map. + NSLocationUsageDescription + $(PRODUCT_NAME) uses location to show views on map. + NSMicrophoneUsageDescription + $(PRODUCT_NAME) uses the microphone to record audio + NSPhotoLibraryAddUsageDescription + $(PRODUCT_NAME) needs access to library to add filtered photos. + NSPhotoLibraryUsageDescription + $(PRODUCT_NAME) needs access to photo library to save photos + 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/Experiences/Experiences/SceneDelegate.swift b/Experiences/Experiences/SceneDelegate.swift new file mode 100644 index 00000000..4c653c18 --- /dev/null +++ b/Experiences/Experiences/SceneDelegate.swift @@ -0,0 +1,53 @@ +// +// SceneDelegate.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. 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/Experiences/Experiences/View Controllers/AddExperienceViewController.swift b/Experiences/Experiences/View Controllers/AddExperienceViewController.swift new file mode 100644 index 00000000..edd5bbda --- /dev/null +++ b/Experiences/Experiences/View Controllers/AddExperienceViewController.swift @@ -0,0 +1,289 @@ +// +// AddExperienceViewController.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import UIKit +import Photos +import AVFoundation + +class AddExperienceViewController: UIViewController { + // MARK: PROPERTIES + + private let context = CIContext(options: nil) + + var experienceController: ExperienceController? + var coordinate: CLLocationCoordinate2D? + + let imageFilter = CIFilter(name: "CIPhotoEffectInstant")! + var posterImage: UIImage? + + var recordingURL: URL? + var audioRecorder: AVAudioRecorder? + + // MARK: - OUTLETS + + @IBOutlet var titleTextField: UITextField! + @IBOutlet var addImage: UIButton! + @IBOutlet var recordButton: UIButton! + @IBOutlet var playButton: UIButton! + @IBOutlet var imageView: UIImageView! + + override func viewDidLoad() { + super.viewDidLoad() + audioRecorder?.delegate = self + hideKeyboardOnTap() + updateViews() + try? prepareAudioSession() + + } + + func updateViews() { + playButton.isSelected = isPlaying + + } + var originalImage: UIImage? { + didSet { + updateImage() + } + } + + func updateImage() { + if let originalImage = originalImage { + + var scaledSize = imageView.bounds.size + let scale = UIScreen.main.scale + scaledSize = CGSize(width: scaledSize.width * scale, height: scaledSize.height * scale) + + imageView.image = image(byFiltering: originalImage.imageByScaling(toSize: scaledSize)!) + + } else { + imageView.image = nil + } + } + + private func image(byFiltering image: UIImage) -> UIImage { + guard let cgImage = image.cgImage else { return image } + let ciImage = CIImage(cgImage: cgImage) + imageFilter.setValue(ciImage, forKey: "inputImage") + + guard let outputCIImage = imageFilter.outputImage else { return image } + + guard let outputCGImage = context.createCGImage(outputCIImage, from: outputCIImage.extent) else { return image } + + return UIImage(cgImage: outputCGImage) + } + + + // MARK: - Audio Methods + + func prepareAudioSession() throws { + let session = AVAudioSession.sharedInstance() + try session.setCategory(.playAndRecord, options: [.defaultToSpeaker]) + try session.setActive(true, options: []) + } + + func loadAudio() { + let songURL = createNewRecordingURL() + audioPlayer = try? AVAudioPlayer(contentsOf: songURL) + } + + var isPlaying: Bool { + return audioPlayer?.isPlaying ?? false + } + + var audioPlayer: AVAudioPlayer? { + didSet { + audioPlayer?.delegate = self + } + } + + func togglePlayback() { + if isPlaying { + pause() + } else { + play() + } + } + + func play() { + audioPlayer?.play() + updateViews() + } + + func pause() { + audioPlayer?.pause() + updateViews() + } + + var isRecording: Bool { + return audioRecorder?.isRecording ?? false + } + + func toggleRecording() { + if isRecording { + stopRecording() + } else { + requestPermissionOrStartRecording() + + } + } + + private func createNewRecordingURL() -> URL { + let documents = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true) + 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 access to the microphone to record a note.") + return + } + } + case .denied: + print("Microphone access has been denied.") + + 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 startRecording() { + let recordingURL = createNewRecordingURL() + + //44,1000 hertz = 44.1 kHZ = FM / CD Audio Quality + let audioFormat = AVAudioFormat(standardFormatWithSampleRate: 44.1, channels: 1)! + + audioRecorder = try? AVAudioRecorder(url: recordingURL, format: audioFormat) + audioRecorder?.delegate = self + audioRecorder?.record() + self.recordingURL = recordingURL + updateViews() + } + + func stopRecording() { + audioRecorder?.stop() + updateViews() + } + + // MARK: - ACTIONS + + @IBAction func addPosterImageButtonPressed(_ sender: Any) { + guard UIImagePickerController.isSourceTypeAvailable(.photoLibrary) else { + print("The photo library is unavailable") + return + } + let imagePicker = UIImagePickerController() + imagePicker.sourceType = .photoLibrary + imagePicker.delegate = self + present(imagePicker, animated: true, completion: nil) + } + + @IBAction func recordButtonPressed(_ sender: Any) { + toggleRecording() + } + + @IBAction func playButtonPressed(_ sender: Any) { + togglePlayback() + } + + // MARK: - Navigation + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "RecordSegue" { + guard let videoVC = segue.destination as? CameraViewController else { return } + videoVC.experienceController = experienceController + videoVC.coordinate = coordinate + videoVC.experienceTitle = titleTextField.text + videoVC.image = originalImage + videoVC.audio = recordingURL + } + } + +} + +// MARK: - EXTENSION + +extension AddExperienceViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { + if let image = info[.originalImage] as? UIImage { + originalImage = image + addImage.isHidden = true + picker.dismiss(animated: true, completion: nil) + } + } + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { + picker.dismiss(animated: true, completion: nil) + } +} + +extension AddExperienceViewController: AVAudioRecorderDelegate { + + func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder, successfully flag: Bool) { + guard let recordingURL = recordingURL else { return } + print("Finished recording: \(recordingURL.path)") + audioPlayer = try? AVAudioPlayer(contentsOf: recordingURL) + updateViews() + } + + func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: Error?) { + if let error = error { + print("Error recording: \(error)") + } + updateViews() + } +} + +extension AddExperienceViewController: AVAudioPlayerDelegate { + func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) { + DispatchQueue.main.async { + self.updateViews() + } + } + + func audioPlayerDecodeErrorDidOccur(_ player: AVAudioPlayer, error: Error?) { + if let error = error { + print(error) + } + DispatchQueue.main.async { + self.updateViews() + } + } +} + +extension UIViewController { + internal func hideKeyboardOnTap() { + let tap = UITapGestureRecognizer(target: self, action: #selector(self.hideKeyboard)) + tap.cancelsTouchesInView = false + self.view.addGestureRecognizer(tap) + } + + @objc private func hideKeyboard() { + self.view.endEditing(true) + } +} + diff --git a/Experiences/Experiences/View Controllers/CameraViewController.swift b/Experiences/Experiences/View Controllers/CameraViewController.swift new file mode 100644 index 00000000..3f4e6cd5 --- /dev/null +++ b/Experiences/Experiences/View Controllers/CameraViewController.swift @@ -0,0 +1,197 @@ +// +// CameraViewController.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import UIKit +import AVFoundation +import CoreLocation + +class CameraViewController: UIViewController { + + // MARK: - PROPERTIES + var experienceController: ExperienceController? + + lazy private var captureSession = AVCaptureSession() + lazy private var fileOutput = AVCaptureMovieFileOutput() + + private var player: AVPlayer! + private var playerView: VideoPlayerView! + + var coordinate: CLLocationCoordinate2D? + var experienceTitle: String? + var image: UIImage? + var audio: URL? + var video: URL? + + // MARK: - Outlets + @IBOutlet var recordButton: UIButton! + @IBOutlet var cameraView: CameraPreviewView! + + override func viewDidLoad() { + super.viewDidLoad() + cameraView.videoPlayerView.videoGravity = .resizeAspectFill + setUpCaptureSession() + } + + @objc func handleTapGesture(_ tapGesture: UITapGestureRecognizer) { + if let player = player { + player.seek(to: CMTime.zero) + player.play() + } + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + captureSession.startRunning() + } + + override func viewDidDisappear(_ animated: Bool) { + super.viewDidDisappear(animated) + captureSession.stopRunning() + } + + private func updateViews() { + recordButton.isSelected = fileOutput.isRecording + } + + private func setUpCaptureSession() { + + captureSession.beginConfiguration() + + let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture(_:))) + view.addGestureRecognizer(tapGesture) + + let camera = bestCamera() + guard let cameraInput = try? AVCaptureDeviceInput(device: camera), + captureSession.canAddInput(cameraInput) else { + fatalError("Future - do something better than crashing") + } + captureSession.addInput(cameraInput) + + let microphone = bestAudio() + guard let audioInput = try? AVCaptureDeviceInput(device: microphone), + captureSession.canAddInput(audioInput) else { + fatalError("Can't create and add input from microphone") + } + captureSession.addInput(audioInput) + + if captureSession.canSetSessionPreset(.hd1920x1080) { + captureSession.sessionPreset = .hd1920x1080 + } + + guard captureSession.canAddOutput(fileOutput) else { + fatalError("Cannot add movie recording") + } + captureSession.addOutput(fileOutput) + + captureSession.commitConfiguration() + cameraView.session = captureSession + } + + private func bestCamera() -> AVCaptureDevice { + if let ultraWideCamera = AVCaptureDevice.default(.builtInUltraWideCamera, for: .video, position: .back) { + return ultraWideCamera + } + + if let wideAngleCamera = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) { + return wideAngleCamera + } + + fatalError("No camera available, are you on a simulator?") // TODO: show UI instead of a fatal error + } + + private func bestAudio() -> AVCaptureDevice { + if let device = AVCaptureDevice.default(for: .audio) { + return device + } + fatalError("No audio") + } + + private func toggleRecording() { + if fileOutput.isRecording { + fileOutput.stopRecording() + updateViews() + } else { + fileOutput.startRecording(to: newRecordingURL(), recordingDelegate: self) + updateViews() + } + } + + private func newRecordingURL() -> URL { + let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + + let formatter = ISO8601DateFormatter() + formatter.formatOptions = [.withInternetDateTime] + + let name = formatter.string(from: Date()) + let fileURL = documentsDirectory.appendingPathComponent(name).appendingPathExtension("mov") + return fileURL + } + + private func playMovie(url: URL) { + let player = AVPlayer(url: url) + + if playerView == nil { + // setup view + let playerView = VideoPlayerView() + playerView.player = player + + // customize the frame + var frame = view.bounds + frame.size.height = frame.size.height / 4 + frame.size.width = frame.size.width / 4 + frame.origin.y = view.layoutMargins.top + + playerView.frame = frame + + view.addSubview(playerView) + self.playerView = playerView + } + player.play() + self.player = player + } + + // MARK: - ACTIONS + + @IBAction func recordButtonPressed(_ sender: Any) { + toggleRecording() + } + @IBAction func saveButtonPressed(_ sender: Any) { + guard let experienceController = experienceController, + let coordinate = coordinate, + let title = experienceTitle, + let image = image, + let audio = audio, + let video = video else { return } + experienceController.createExperience(coordinate: coordinate, title: title, image: image, audio: audio, video: video) + navigationController?.popToRootViewController(animated: true) + } +} + +// MARK: - EXTENSION + +extension CameraViewController: AVCaptureFileOutputRecordingDelegate { + func fileOutput(_ output: AVCaptureFileOutput, didStartRecordingTo fileURL: URL, from connections: [AVCaptureConnection]) { + print("didStartRecording: \(fileURL)") + + updateViews() + } + + func fileOutput(_ output: AVCaptureFileOutput, didFinishRecordingTo outputFileURL: URL, from connections: [AVCaptureConnection], error: Error?) { + if let error = error { + print("Error saving movie: \(error)") + return + } + DispatchQueue.main.async { + self.playMovie(url: outputFileURL) + self.video = outputFileURL + } + updateViews() + } +} + + diff --git a/Experiences/Experiences/View Controllers/MapViewController.swift b/Experiences/Experiences/View Controllers/MapViewController.swift new file mode 100644 index 00000000..23f0c2b8 --- /dev/null +++ b/Experiences/Experiences/View Controllers/MapViewController.swift @@ -0,0 +1,90 @@ +// +// MapViewController.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import UIKit +import MapKit + +class MapViewController: UIViewController { + // MARK: - PROPERTIES + let experienceController = ExperienceController() + let locationManager = CLLocationManager() + var coordinate: CLLocationCoordinate2D? + + // MARK: - OUTLETS + @IBOutlet var mapView: MKMapView! + + override func viewDidLoad() { + super.viewDidLoad() + mapView.register(MKMarkerAnnotationView.self, forAnnotationViewWithReuseIdentifier: "MapView") + self.locationManager.requestAlwaysAuthorization() + if CLLocationManager.locationServicesEnabled() { + locationManager.delegate = self + locationManager.desiredAccuracy = kCLLocationAccuracyBest + locationManager.startUpdatingLocation() + } + mapView.delegate = self + mapView.mapType = .standard + mapView.isZoomEnabled = true + mapView.isScrollEnabled = true + if let userLocation = mapView.userLocation.location?.coordinate { + mapView.setCenter(userLocation, animated: true) + } + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(true) + addAnnotation() + } + + // MARK: - Methods + func addAnnotation() { + let myPin = MKPointAnnotation() + if let myCoordinate = experienceController.experience?.coordinate { + myPin.coordinate = myCoordinate + } + if let annotationText = experienceController.experience?.experienceTitle { + myPin.title = annotationText + } + mapView.addAnnotation(myPin) + } + + // MARK: - Navigation + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + if segue.identifier == "AddExperience" { + guard let newExperienceVC = segue.destination as? AddExperienceViewController else { return } + newExperienceVC.experienceController = experienceController + newExperienceVC.coordinate = coordinate + } + } +} + +// MARK: - Extensions + +extension MapViewController: MKMapViewDelegate, CLLocationManagerDelegate { + + func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { + guard let experience = annotation as? Experience else { return nil } + let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "MapView", for: experience) as! MKMarkerAnnotationView + annotationView.glyphText = experience.experienceTitle + annotationView.glyphTintColor = .systemBlue + annotationView.titleVisibility = .visible + return annotationView + } + + func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { + let locValue:CLLocationCoordinate2D = manager.location!.coordinate + mapView.mapType = MKMapType.standard + let span = MKCoordinateSpan(latitudeDelta: 0.25, longitudeDelta: 0.25) + let region = MKCoordinateRegion(center: locValue, span: span) + mapView.setRegion(region, animated: true) + let annotation = MKPointAnnotation() + annotation.coordinate = locValue + coordinate = annotation.coordinate + } +} diff --git a/Experiences/Experiences/Views/Base.lproj/LaunchScreen.storyboard b/Experiences/Experiences/Views/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/Experiences/Experiences/Views/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Experiences/Experiences/Views/Base.lproj/Main.storyboard b/Experiences/Experiences/Views/Base.lproj/Main.storyboard new file mode 100644 index 00000000..a5bcd677 --- /dev/null +++ b/Experiences/Experiences/Views/Base.lproj/Main.storyboard @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Experiences/Experiences/Views/CameraPreviewView.swift b/Experiences/Experiences/Views/CameraPreviewView.swift new file mode 100644 index 00000000..601a08c2 --- /dev/null +++ b/Experiences/Experiences/Views/CameraPreviewView.swift @@ -0,0 +1,26 @@ +// +// CameraPreviewView.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import UIKit +import AVFoundation + +class CameraPreviewView: UIView { + + override class var layerClass: AnyClass { + return AVCaptureVideoPreviewLayer.self + } + + var videoPlayerView: AVCaptureVideoPreviewLayer { + return layer as! AVCaptureVideoPreviewLayer + } + + var session: AVCaptureSession? { + get { return videoPlayerView.session } + set { videoPlayerView.session = newValue } + } +} diff --git a/Experiences/Experiences/Views/CameraView.swift b/Experiences/Experiences/Views/CameraView.swift new file mode 100644 index 00000000..9e9a8845 --- /dev/null +++ b/Experiences/Experiences/Views/CameraView.swift @@ -0,0 +1,25 @@ +// +// CameraView.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import UIKit +import AVFoundation + +class CameraView: UIView { + override class var layerClass: AnyClass { + return AVCaptureVideoPreviewLayer.self + } + + var videoPlayerView: AVCaptureVideoPreviewLayer { + return layer as! AVCaptureVideoPreviewLayer + } + + var session: AVCaptureSession? { + get { return videoPlayerView.session } + set { videoPlayerView.session = newValue } + } +} diff --git a/Experiences/Experiences/Views/VideoPlayerView.swift b/Experiences/Experiences/Views/VideoPlayerView.swift new file mode 100644 index 00000000..a511165f --- /dev/null +++ b/Experiences/Experiences/Views/VideoPlayerView.swift @@ -0,0 +1,27 @@ +// +// VideoPlayerView.swift +// Experiences +// +// Created by Nonye on 7/10/20. +// Copyright © 2020 Nonye Ezekwo. All rights reserved. +// + +import UIKit +import AVFoundation + +class VideoPlayerView: UIView { + + override class var layerClass: AnyClass { + return AVPlayerLayer.self + } + + var videoPlayerLayer: AVPlayerLayer { + return layer as! AVPlayerLayer + } + + var player: AVPlayer? { + get { return videoPlayerLayer.player } + set { videoPlayerLayer.player = newValue } + } +} +