diff --git a/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.pbxproj b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.pbxproj new file mode 100644 index 00000000..d7218a9b --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.pbxproj @@ -0,0 +1,421 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 3C40CF24250EB6BA00458186 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF23250EB6BA00458186 /* AppDelegate.swift */; }; + 3C40CF26250EB6BA00458186 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF25250EB6BA00458186 /* SceneDelegate.swift */; }; + 3C40CF2B250EB6BA00458186 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C40CF29250EB6BA00458186 /* Main.storyboard */; }; + 3C40CF2D250EB6BB00458186 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3C40CF2C250EB6BB00458186 /* Assets.xcassets */; }; + 3C40CF30250EB6BB00458186 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3C40CF2E250EB6BB00458186 /* LaunchScreen.storyboard */; }; + 3C40CF3B250EB7C900458186 /* Experience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF3A250EB7C900458186 /* Experience.swift */; }; + 3C40CF3D250EC15400458186 /* TabViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF3C250EC15400458186 /* TabViewController.swift */; }; + 3C40CF3F250EC1EC00458186 /* ExperienceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF3E250EC1EC00458186 /* ExperienceController.swift */; }; + 3C40CF43250EC31A00458186 /* ExperienceTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF42250EC31A00458186 /* ExperienceTableViewController.swift */; }; + 3C40CF45250EC37D00458186 /* MapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF44250EC37D00458186 /* MapViewController.swift */; }; + 3C40CF47250ECB5600458186 /* AudioViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF46250ECB5600458186 /* AudioViewController.swift */; }; + 3C40CF49250ECB6400458186 /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF48250ECB6400458186 /* ImageViewController.swift */; }; + 3C40CF4B250ED21C00458186 /* AudioPlayerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF4A250ED21C00458186 /* AudioPlayerController.swift */; }; + 3C40CF4D250ED25A00458186 /* AudioRecorderController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF4C250ED25A00458186 /* AudioRecorderController.swift */; }; + 3C40CF50250EDCBE00458186 /* UIImage+Scaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF4F250EDCBE00458186 /* UIImage+Scaling.swift */; }; + 3C40CF52250EDCF900458186 /* Experience+MKAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF51250EDCF900458186 /* Experience+MKAnnotation.swift */; }; + 3C40CF54250EE4E700458186 /* LocationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF53250EE4E700458186 /* LocationHelper.swift */; }; + 3C40CF56250EE54C00458186 /* Alerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C40CF55250EE54C00458186 /* Alerts.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 3C40CF20250EB6BA00458186 /* ExperiencesChallenge.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExperiencesChallenge.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 3C40CF23250EB6BA00458186 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 3C40CF25250EB6BA00458186 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 3C40CF2A250EB6BA00458186 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 3C40CF2C250EB6BB00458186 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 3C40CF2F250EB6BB00458186 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 3C40CF31250EB6BB00458186 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3C40CF3A250EB7C900458186 /* Experience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Experience.swift; sourceTree = ""; }; + 3C40CF3C250EC15400458186 /* TabViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabViewController.swift; sourceTree = ""; }; + 3C40CF3E250EC1EC00458186 /* ExperienceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExperienceController.swift; sourceTree = ""; }; + 3C40CF42250EC31A00458186 /* ExperienceTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExperienceTableViewController.swift; sourceTree = ""; }; + 3C40CF44250EC37D00458186 /* MapViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapViewController.swift; sourceTree = ""; }; + 3C40CF46250ECB5600458186 /* AudioViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioViewController.swift; sourceTree = ""; }; + 3C40CF48250ECB6400458186 /* ImageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = ""; }; + 3C40CF4A250ED21C00458186 /* AudioPlayerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioPlayerController.swift; sourceTree = ""; }; + 3C40CF4C250ED25A00458186 /* AudioRecorderController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecorderController.swift; sourceTree = ""; }; + 3C40CF4F250EDCBE00458186 /* UIImage+Scaling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Scaling.swift"; sourceTree = ""; }; + 3C40CF51250EDCF900458186 /* Experience+MKAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Experience+MKAnnotation.swift"; sourceTree = ""; }; + 3C40CF53250EE4E700458186 /* LocationHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationHelper.swift; sourceTree = ""; }; + 3C40CF55250EE54C00458186 /* Alerts.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alerts.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3C40CF1D250EB6BA00458186 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3C40CF17250EB6BA00458186 = { + isa = PBXGroup; + children = ( + 3C40CF22250EB6BA00458186 /* ExperiencesChallenge */, + 3C40CF21250EB6BA00458186 /* Products */, + ); + sourceTree = ""; + }; + 3C40CF21250EB6BA00458186 /* Products */ = { + isa = PBXGroup; + children = ( + 3C40CF20250EB6BA00458186 /* ExperiencesChallenge.app */, + ); + name = Products; + sourceTree = ""; + }; + 3C40CF22250EB6BA00458186 /* ExperiencesChallenge */ = { + isa = PBXGroup; + children = ( + 3C40CF4E250EDCA300458186 /* Helpers */, + 3C40CF39250EB70000458186 /* View Controllers */, + 3C40CF38250EB6F500458186 /* Controllers */, + 3C40CF37250EB6EC00458186 /* Model */, + 3C40CF23250EB6BA00458186 /* AppDelegate.swift */, + 3C40CF25250EB6BA00458186 /* SceneDelegate.swift */, + 3C40CF29250EB6BA00458186 /* Main.storyboard */, + 3C40CF2C250EB6BB00458186 /* Assets.xcassets */, + 3C40CF2E250EB6BB00458186 /* LaunchScreen.storyboard */, + 3C40CF31250EB6BB00458186 /* Info.plist */, + ); + path = ExperiencesChallenge; + sourceTree = ""; + }; + 3C40CF37250EB6EC00458186 /* Model */ = { + isa = PBXGroup; + children = ( + 3C40CF3A250EB7C900458186 /* Experience.swift */, + ); + path = Model; + sourceTree = ""; + }; + 3C40CF38250EB6F500458186 /* Controllers */ = { + isa = PBXGroup; + children = ( + 3C40CF3E250EC1EC00458186 /* ExperienceController.swift */, + 3C40CF4A250ED21C00458186 /* AudioPlayerController.swift */, + 3C40CF4C250ED25A00458186 /* AudioRecorderController.swift */, + ); + path = Controllers; + sourceTree = ""; + }; + 3C40CF39250EB70000458186 /* View Controllers */ = { + isa = PBXGroup; + children = ( + 3C40CF3C250EC15400458186 /* TabViewController.swift */, + 3C40CF42250EC31A00458186 /* ExperienceTableViewController.swift */, + 3C40CF44250EC37D00458186 /* MapViewController.swift */, + 3C40CF46250ECB5600458186 /* AudioViewController.swift */, + 3C40CF48250ECB6400458186 /* ImageViewController.swift */, + ); + path = "View Controllers"; + sourceTree = ""; + }; + 3C40CF4E250EDCA300458186 /* Helpers */ = { + isa = PBXGroup; + children = ( + 3C40CF4F250EDCBE00458186 /* UIImage+Scaling.swift */, + 3C40CF51250EDCF900458186 /* Experience+MKAnnotation.swift */, + 3C40CF53250EE4E700458186 /* LocationHelper.swift */, + 3C40CF55250EE54C00458186 /* Alerts.swift */, + ); + path = Helpers; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3C40CF1F250EB6BA00458186 /* ExperiencesChallenge */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3C40CF34250EB6BB00458186 /* Build configuration list for PBXNativeTarget "ExperiencesChallenge" */; + buildPhases = ( + 3C40CF1C250EB6BA00458186 /* Sources */, + 3C40CF1D250EB6BA00458186 /* Frameworks */, + 3C40CF1E250EB6BA00458186 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ExperiencesChallenge; + productName = ExperiencesChallenge; + productReference = 3C40CF20250EB6BA00458186 /* ExperiencesChallenge.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3C40CF18250EB6BA00458186 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1170; + LastUpgradeCheck = 1170; + ORGANIZATIONNAME = "Ian French"; + TargetAttributes = { + 3C40CF1F250EB6BA00458186 = { + CreatedOnToolsVersion = 11.7; + }; + }; + }; + buildConfigurationList = 3C40CF1B250EB6BA00458186 /* Build configuration list for PBXProject "ExperiencesChallenge" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 3C40CF17250EB6BA00458186; + productRefGroup = 3C40CF21250EB6BA00458186 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3C40CF1F250EB6BA00458186 /* ExperiencesChallenge */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3C40CF1E250EB6BA00458186 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3C40CF30250EB6BB00458186 /* LaunchScreen.storyboard in Resources */, + 3C40CF2D250EB6BB00458186 /* Assets.xcassets in Resources */, + 3C40CF2B250EB6BA00458186 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3C40CF1C250EB6BA00458186 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3C40CF24250EB6BA00458186 /* AppDelegate.swift in Sources */, + 3C40CF56250EE54C00458186 /* Alerts.swift in Sources */, + 3C40CF49250ECB6400458186 /* ImageViewController.swift in Sources */, + 3C40CF4B250ED21C00458186 /* AudioPlayerController.swift in Sources */, + 3C40CF52250EDCF900458186 /* Experience+MKAnnotation.swift in Sources */, + 3C40CF50250EDCBE00458186 /* UIImage+Scaling.swift in Sources */, + 3C40CF4D250ED25A00458186 /* AudioRecorderController.swift in Sources */, + 3C40CF26250EB6BA00458186 /* SceneDelegate.swift in Sources */, + 3C40CF3F250EC1EC00458186 /* ExperienceController.swift in Sources */, + 3C40CF54250EE4E700458186 /* LocationHelper.swift in Sources */, + 3C40CF3D250EC15400458186 /* TabViewController.swift in Sources */, + 3C40CF47250ECB5600458186 /* AudioViewController.swift in Sources */, + 3C40CF43250EC31A00458186 /* ExperienceTableViewController.swift in Sources */, + 3C40CF3B250EB7C900458186 /* Experience.swift in Sources */, + 3C40CF45250EC37D00458186 /* MapViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 3C40CF29250EB6BA00458186 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3C40CF2A250EB6BA00458186 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 3C40CF2E250EB6BB00458186 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3C40CF2F250EB6BB00458186 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3C40CF32250EB6BB00458186 /* 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.7; + 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; + }; + 3C40CF33250EB6BB00458186 /* 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.7; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 3C40CF35250EB6BB00458186 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = ExperiencesChallenge/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "Cygnus-Enterprises.ExperiencesChallenge"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 3C40CF36250EB6BB00458186 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = ExperiencesChallenge/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "Cygnus-Enterprises.ExperiencesChallenge"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3C40CF1B250EB6BA00458186 /* Build configuration list for PBXProject "ExperiencesChallenge" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3C40CF32250EB6BB00458186 /* Debug */, + 3C40CF33250EB6BB00458186 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3C40CF34250EB6BB00458186 /* Build configuration list for PBXNativeTarget "ExperiencesChallenge" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3C40CF35250EB6BB00458186 /* Debug */, + 3C40CF36250EB6BB00458186 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3C40CF18250EB6BA00458186 /* Project object */; +} diff --git a/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..a03c62a6 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/xcuserdata/Ian.xcuserdatad/UserInterfaceState.xcuserstate b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/xcuserdata/Ian.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..06b5b7af Binary files /dev/null and b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/project.xcworkspace/xcuserdata/Ian.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/xcuserdata/Ian.xcuserdatad/xcschemes/xcschememanagement.plist b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/xcuserdata/Ian.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..492c8c02 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge.xcodeproj/xcuserdata/Ian.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + ExperiencesChallenge.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/ExperiencesChallenge/ExperiencesChallenge/AppDelegate.swift b/ExperiencesChallenge/ExperiencesChallenge/AppDelegate.swift new file mode 100644 index 00000000..04b083a8 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/AppDelegate.swift @@ -0,0 +1,37 @@ +// +// AppDelegate.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. 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/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/AppIcon.appiconset/Contents.json b/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/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/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Contents.json b/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Unknown.imageset/Contents.json b/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Unknown.imageset/Contents.json new file mode 100644 index 00000000..42378de7 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Unknown.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Unknown.jpeg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Unknown.imageset/Unknown.jpeg b/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Unknown.imageset/Unknown.jpeg new file mode 100644 index 00000000..c840763a Binary files /dev/null and b/ExperiencesChallenge/ExperiencesChallenge/Assets.xcassets/Unknown.imageset/Unknown.jpeg differ diff --git a/ExperiencesChallenge/ExperiencesChallenge/Base.lproj/LaunchScreen.storyboard b/ExperiencesChallenge/ExperiencesChallenge/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ExperiencesChallenge/ExperiencesChallenge/Base.lproj/Main.storyboard b/ExperiencesChallenge/ExperiencesChallenge/Base.lproj/Main.storyboard new file mode 100644 index 00000000..7741773b --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Base.lproj/Main.storyboard @@ -0,0 +1,404 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ExperiencesChallenge/ExperiencesChallenge/Controllers/AudioPlayerController.swift b/ExperiencesChallenge/ExperiencesChallenge/Controllers/AudioPlayerController.swift new file mode 100644 index 00000000..1c576da6 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Controllers/AudioPlayerController.swift @@ -0,0 +1,66 @@ +// +// AudioPlayerController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + + +import Foundation +import AVFoundation + +class AudioPlayerController: NSObject { + + var audioPlayer: AVAudioPlayer? + var timer: Timer? + + var isPlaying: Bool { + audioPlayer?.isPlaying ?? false + } + + func loadAudio(url: URL) { + do { + audioPlayer = try AVAudioPlayer(contentsOf: url) + } catch { + print("Error loading in audio") + } + } + + private func play() { + audioPlayer?.play() + startTimer() + } + + private func pause() { + audioPlayer?.pause() + cancelTimer() + } + + func playPause() { + if isPlaying { + pause() + } else { + play() + } + } + + private func startTimer() { + cancelTimer() + timer = Timer.scheduledTimer(timeInterval: 0.03, + target: self, + selector: #selector(updateTimer(timer:)), + userInfo: nil, + repeats: true) + } + + @objc private func updateTimer(timer: Timer) { + + } + + private func cancelTimer() { + timer?.invalidate() + timer = nil + } +} + diff --git a/ExperiencesChallenge/ExperiencesChallenge/Controllers/AudioRecorderController.swift b/ExperiencesChallenge/ExperiencesChallenge/Controllers/AudioRecorderController.swift new file mode 100644 index 00000000..c16e201a --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Controllers/AudioRecorderController.swift @@ -0,0 +1,67 @@ +// +// AudioRecorderController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + + + +import Foundation +import AVFoundation + +class AudioRecorderController: NSObject { + + + var audioRecorder: AVAudioRecorder? + var recordingURL: URL? + + var isRecording: Bool { + return audioRecorder?.isRecording ?? false + } + + func record() { + 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).appendingPathExtension("caf") + recordingURL = file + + print("record: \(file)") + + + let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 1)! + + audioRecorder = try! AVAudioRecorder(url: file, format: format) + audioRecorder?.delegate = self + audioRecorder?.record() + } + + func stop() { + audioRecorder?.stop() + audioRecorder = nil + } + + func recordToggle() { + if isRecording { + stop() + } else { + record() + } + } +} + +extension AudioRecorderController: AVAudioRecorderDelegate { + func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: Error?) { + if let error = error { + print("Audio recorder error: \(error)") + } + } + + func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder, successfully flag: Bool) { + + print("Finished Recording") + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/Controllers/ExperienceController.swift b/ExperiencesChallenge/ExperiencesChallenge/Controllers/ExperienceController.swift new file mode 100644 index 00000000..36533d12 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Controllers/ExperienceController.swift @@ -0,0 +1,23 @@ +// +// ExperienceController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + + +import Foundation +import MapKit + +class ExperienceController { + + var experiences = [Experience]() + + func createPost(with title: String, ofType mediaType: MediaType, location geotag: CLLocationCoordinate2D?) { + let experience = Experience(title: title, mediaType: mediaType, geotag: geotag) + experiences.append(experience) + } + + +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/Helpers/Alerts.swift b/ExperiencesChallenge/ExperiencesChallenge/Helpers/Alerts.swift new file mode 100644 index 00000000..b8c38f1f --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Helpers/Alerts.swift @@ -0,0 +1,21 @@ +// +// Alerts.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +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/ExperiencesChallenge/ExperiencesChallenge/Helpers/Experience+MKAnnotation.swift b/ExperiencesChallenge/ExperiencesChallenge/Helpers/Experience+MKAnnotation.swift new file mode 100644 index 00000000..cb654228 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Helpers/Experience+MKAnnotation.swift @@ -0,0 +1,20 @@ +// +// Experience+MKAnnotation.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +import MapKit + +extension Experience: MKAnnotation { + var coordinate: CLLocationCoordinate2D { + guard let geotag = geotag else { return CLLocationCoordinate2D() } + return CLLocationCoordinate2D(latitude: geotag.latitude, longitude: geotag.longitude) + } + + var title: String? { + experienceTitle + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/Helpers/LocationHelper.swift b/ExperiencesChallenge/ExperiencesChallenge/Helpers/LocationHelper.swift new file mode 100644 index 00000000..5781dfde --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Helpers/LocationHelper.swift @@ -0,0 +1,60 @@ +// +// LocationHelper.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +import MapKit + +class LocationHelper: NSObject { + + static let shared = LocationHelper() + + private let locationManager = CLLocationManager() + var group: DispatchGroup? + + override init() { + super.init() + locationManager.delegate = self + + requestLocationAuthorization() + } + + func requestLocationAuthorization() { + + switch CLLocationManager.authorizationStatus() { + case .authorizedWhenInUse: + return + case .notDetermined: + locationManager.requestWhenInUseAuthorization() + default: + break + } + } + + func getCurrentLocation(completion: @escaping (CLLocationCoordinate2D?) -> Void) { + requestLocationAuthorization() + + group = DispatchGroup() + group?.enter() + locationManager.requestLocation() + group?.notify(queue: .main) { + let coordinate = self.locationManager.location?.coordinate + + self.group = nil + completion(coordinate) + } + } +} + +extension LocationHelper: CLLocationManagerDelegate { + func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { + group?.leave() + } + + func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { + print("Failed getting location \(error)") + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/Helpers/UIImage+Scaling.swift b/ExperiencesChallenge/ExperiencesChallenge/Helpers/UIImage+Scaling.swift new file mode 100644 index 00000000..fc9a3340 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Helpers/UIImage+Scaling.swift @@ -0,0 +1,40 @@ +// +// UIImage+Scaling.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + + +import UIKit +import ImageIO + +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/ExperiencesChallenge/ExperiencesChallenge/Info.plist b/ExperiencesChallenge/ExperiencesChallenge/Info.plist new file mode 100644 index 00000000..9146aa84 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Info.plist @@ -0,0 +1,72 @@ + + + + + NSLocationWhenInUseUsageDescription + + NSMicrophoneUsageDescription + + NSPhotoLibraryUsageDescription + + LSApplicationCategoryType + + 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 + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/ExperiencesChallenge/ExperiencesChallenge/Model/AudioVisualizer.swift b/ExperiencesChallenge/ExperiencesChallenge/Model/AudioVisualizer.swift new file mode 100644 index 00000000..c0e4ba18 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Model/AudioVisualizer.swift @@ -0,0 +1,277 @@ +// +// AudioVisualizer.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + + +import UIKit + +@IBDesignable +public class AudioVisualizer: UIView { + + // MARK: IBInspectable Properties + + /// The width of a bar in points. + @IBInspectable public var barWidth: CGFloat = 10 { + didSet { + updateBars() + } + } + + /// The corner radius of a bar in points. If less than `0`, then it will default to half of the width of the bar. + @IBInspectable public var barCornerRadius: CGFloat = -1 { + didSet { + updateBars() + } + } + + /// The spacing between bars in points. + @IBInspectable public var barSpacing: CGFloat = 4 { + didSet { + updateBars() + } + } + + /// The color of a bar. + @IBInspectable public var barColor: UIColor = .systemGray { + didSet { + for bar in bars { + bar.backgroundColor = barColor + } + } + } + + /// The amount of time before a bar decays into the adjacent spot + @IBInspectable public var decaySpeed: Double = 0.01 { + didSet { + decayTimer?.invalidate() + decayTimer = nil + } + } + + /// The fraction the newest value will decay by if not updated by the time a decay starts + @IBInspectable public var decayAmount: Double = 0.8 + + // MARK: Internal Properties + + private var bars = [UIView]() + private var values = [Double]() + + private weak var decayTimer: Timer? + private var newestValue: Double = 0 + + // MARK: - Object Lifecycle + + override init(frame: CGRect) { + super.init(frame: frame) + + initialSetup() + } + + required init?(coder: NSCoder) { + super.init(coder: coder) + + initialSetup() + } + + func initialSetup() { + // Pre-fill values for Interface Builder preview + #if TARGET_INTERFACE_BUILDER + values = [ + 0.19767167952644904, + 0.30975147553721694, + 0.2717680681330001, + 0.25914398105158504, + 0.3413322535900626, + 0.311223010327166, + 0.3302641160440099, + 0.303853272136915, + 0.2659123465612464, + 0.2860924489760262, + 0.26477145407733543, + 0.23180693200970012, + 0.24445487891619533, + 0.21484121767935302, + 0.19688917099112885, + 0.19020094289324854, + 0.17402194532721785, + 0.1600055988294578, + 0.15120753744055154, + 0.13789741397752767, + 0.13231033268544698, + 0.1270923459375989, + 0.1121238175344413, + 0.12400069790665748, + 0.24978783142512598, + 0.233063298365594, + 0.5375441947045457, + 0.47456518731446534, + 0.5236630241490436, + 0.4692151822551929, + 0.4255172022748686, + 0.46023063710569184, + 0.42934908823397355, + 0.37221041959882545, + 0.4685050055667653, + 0.4209394065681193, + 0.46643118034506187, + 0.4292307341708633, + 0.3814422662003417, + 0.4386719969186142, + 0.3956598546828729 + ] + #endif + + // Build the inner bars + self.updateBars() + } + + deinit { + // Invalidate the timer if it is still active + decayTimer?.invalidate() + } + + // MARK: - Layout + override public func layoutSubviews() { + updateBars() + } + + private func updateBars() { + // Clean up old bars + for bar in bars { + bar.removeFromSuperview() + } + + var newBars = [UIView]() + + + // Make sure the width of a bar and spacing is greater than 0, and that the available width is also greater than 0 + guard round(barWidth) > 0, barSpacing >= 0, bounds.width > 0, bounds.height > 0 else { + // Not enough information to create a single bar, so bail early + bars = [] + return + } + + // Calculate number of bars we will be able to display + var numberOfBarsToCreate = Int(bounds.width/(barWidth + barSpacing)) + + // Helper function for creating bars + func createBar(_ positionFromCenter: Int) { + let bar = UIView(frame: frame(forBar: positionFromCenter)) + bar.backgroundColor = barColor + bar.layer.cornerRadius = (barCornerRadius < 0 || barCornerRadius > barWidth/2) ? floor(barWidth/3) : barCornerRadius + + numberOfBarsToCreate -= 1 + newBars.append(bar) + self.addSubview(bar) + } + + // Create the center bar + createBar(0) + + // Keep creating bars in pairs until there is no more room + var position = 1 + while numberOfBarsToCreate > 0 { + // Create the symmetric pairs of bars starting from the center + createBar(-position) + createBar(position) + + position += 1 + } + + bars = newBars + } + + /// Calculate the frame of a particular bar + /// - Parameter positionFromCenter: The distance of the bar from the center (which is 0) + private func frame(forBar positionFromCenter: Int) -> CGRect { + let valueIndex = Int(positionFromCenter.magnitude) + + return frame(forBar: positionFromCenter, value: (valueIndex < values.count) ? values[valueIndex] : 0) + } + + /// Calculate the frame of a particular bar, specifying a value + /// - Parameter positionFromCenter: The distance of the bar from the center (which is 0) + private func frame(forBar positionFromCenter: Int, value: Double) -> CGRect { + let maxValue = (1 - CGFloat(positionFromCenter.magnitude)*(barWidth + barSpacing)/bounds.width/2)*bounds.height/2 + let height = CGFloat(value)*maxValue + + return CGRect(x: floor(bounds.width/2) + CGFloat(positionFromCenter)*(barWidth + barSpacing) - barWidth/2, y: floor(bounds.height/2) - height, width: barWidth, height: height*2) + } + + // MARK: - Animation + + /// Start the decay timer, but only if if hasn't been created yet + private func startTimer() { + guard decayTimer == nil else { return } + + decayTimer = Timer.scheduledTimer(withTimeInterval: decaySpeed, repeats: true) { [weak self] (_) in + guard let self = self else { return } + + self.decayNewestValue() + } + } + + private func decayNewestValue() { + values.insert(newestValue, at: 0) + + // Trim the end of the values array if there are too many for the number of bars + let currentCount = values.count + let maxCount = (bars.count + 1)/2 + /* + Note that the amount of bars will always be either 0, or an odd number (since the bars are counted in pairs after the first central bar), so we chose a "transformation" (a mathematical function) that satisfies this: value index = floor((bar index + 1)/2) + + Bar index: 0 1 2 3 4 5 6 7 8 9 ... + (valid bar index): 0 1 - 3 - 5 - 7 - 9 ... + Value index: 0 1 1 2 2 3 3 4 4 5 ... + + */ + if currentCount > maxCount { + values.removeSubrange(maxCount ..< currentCount) + } + + // Update the frames of each bar + for (positionFromCenter, value) in values.enumerated() { + if positionFromCenter == 0 { + bars[0].frame = frame(forBar: positionFromCenter, value: value) + } else { + bars[positionFromCenter*2 - 1].frame = frame(forBar: -positionFromCenter, value: value) + bars[positionFromCenter*2].frame = frame(forBar: positionFromCenter, value: value) + } + } + + // Decay the newest value + newestValue = newestValue*decayAmount + + // Check if the values are empty + let totalValue = values.reduce(0.0) { $0 + $1 } + if totalValue <= 0.000001 { + // Note that total value may never reach 0, but this is small enough to clear everything out + decayTimer?.invalidate() + decayTimer = nil + } + } + + // MARK: - Public Methods + + /// Add a value to the visualizer. Be sure to call `AVAudioPlayer.isMeteringEnabled = true`, and `AVAudioPlayer.updateMeters()` before every call to `AVAudioPlayer.averagePower(forChannel: 0)` + /// - Parameter decibelValue: The value you would get out of `AVAudioPlayer.averagePower(forChannel: 0)` + public func addValue(decibelValue: Float) { + addValue(decibelValue: Double(decibelValue)) + } + + /// Add a value to the visualizer. Be sure to call `AVAudioPlayer.isMeteringEnabled = true`, and `AVAudioPlayer.updateMeters()` before every call to `AVAudioPlayer.averagePower(forChannel: 0)` + /// - Parameter decibelValue: The value you would get out of `AVAudioPlayer.averagePower(forChannel: 0)` + public func addValue(decibelValue: Double) { + let normalizedValue = __exp10(decibelValue/20) + + newestValue = normalizedValue + + startTimer() + } + +} + diff --git a/ExperiencesChallenge/ExperiencesChallenge/Model/Experience.swift b/ExperiencesChallenge/ExperiencesChallenge/Model/Experience.swift new file mode 100644 index 00000000..1c19d4ea --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/Model/Experience.swift @@ -0,0 +1,30 @@ +// +// Experience.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +import Foundation +import MapKit + +enum MediaType: String { + case image + case audio + +} + +class Experience: NSObject { + + var experienceTitle: String? + let mediaType: MediaType + var geotag: CLLocationCoordinate2D? + + init(title: String?, mediaType: MediaType, geotag: CLLocationCoordinate2D?) { + self.experienceTitle = title + self.mediaType = mediaType + self.geotag = geotag + } +} + diff --git a/ExperiencesChallenge/ExperiencesChallenge/SceneDelegate.swift b/ExperiencesChallenge/ExperiencesChallenge/SceneDelegate.swift new file mode 100644 index 00000000..d9c4759c --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/SceneDelegate.swift @@ -0,0 +1,53 @@ +// +// SceneDelegate.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. 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/ExperiencesChallenge/ExperiencesChallenge/View Controllers/AudioViewController.swift b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/AudioViewController.swift new file mode 100644 index 00000000..1a9a4361 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/AudioViewController.swift @@ -0,0 +1,131 @@ +// +// AudioViewController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + + +import UIKit +import AVFoundation + +protocol AudioViewControllerDelegate { + func saveAudioButtonTapped() +} + +class AudioViewController: UIViewController { + + var experienceController: ExperienceController? + + let audioPlayerController = AudioPlayerController() + let audioRecorderController = AudioRecorderController() + var audioData: Data? + var delegate: AudioViewControllerDelegate? + + @IBOutlet weak var cancelButton: UIBarButtonItem! + + @IBOutlet weak var playbackRecordingButton: UIButton! + @IBOutlet weak var timeLabel: UILabel! + @IBOutlet weak var timeRemainingLabel: UILabel! + @IBOutlet weak var timerSlider: UISlider! + @IBOutlet weak var recordAudioButton: UIButton! + @IBOutlet weak var saveAudioButton: UIButton! + + private lazy var timeIntervalFormatter: DateComponentsFormatter = { + + let formatting = DateComponentsFormatter() + formatting.unitsStyle = .positional // 00:00 mm:ss + formatting.zeroFormattingBehavior = .pad + formatting.allowedUnits = [.minute, .second] + return formatting + }() + + override func viewDidLoad() { + super.viewDidLoad() + timeLabel.font = UIFont.monospacedDigitSystemFont(ofSize: timeLabel.font.pointSize, + weight: .regular) + timeRemainingLabel.font = UIFont.monospacedDigitSystemFont(ofSize: timeRemainingLabel.font.pointSize, + weight: .regular) + updateViews() + + } + + private func updateViews() { + let playButtonTitle = audioPlayerController.isPlaying ? "Pause" : "Playback Recording" + playbackRecordingButton.setTitle(playButtonTitle, for: .normal) + + let elapsedTime = audioPlayerController.audioPlayer?.currentTime ?? 0 + let duration = audioPlayerController.audioPlayer?.duration ?? 0 + timeLabel.text = timeIntervalFormatter.string(from: elapsedTime) + + timerSlider.minimumValue = 0 + timerSlider.maximumValue = Float(duration) + timerSlider.value = Float(elapsedTime) + + let recordButtonTitle = audioRecorderController.isRecording ? "Stop" : "Start Recording" + recordAudioButton.setTitle(recordButtonTitle, for: .normal) + + let timeRemaining = duration - elapsedTime + timeRemainingLabel.text = timeIntervalFormatter.string(from: timeRemaining) + } + + func playbackAudioRecording() { + guard let recordURL = audioRecorderController.recordingURL else { return } + do { + audioData = try Data(contentsOf: recordURL) + audioPlayerController.loadAudio(url: recordURL) + audioPlayerController.audioPlayer?.delegate = self + saveAudioButton.isEnabled = true + saveAudioButton.tintColor = UIColor.link + } catch { + print("Cannot create audio data") + return + } + audioPlayerController.playPause() + } + + private func addAudio() { + view.endEditing(true) + + guard let _ = audioData else { return } + let title = "Audio Entry" + self.experienceController?.createPost(with: title, ofType: .audio, location: nil) + delegate?.saveAudioButtonTapped() + dismiss(animated: true, completion: nil) + } + + + @IBAction func recordAudioTapped(_ sender: Any) { + audioRecorderController.recordToggle() + updateViews() + } + + @IBAction func saveAudioButtonTapped(_ sender: Any) { + addAudio() + } + + @IBAction func cancelButtonTapped(_ sender: Any) { + dismiss(animated: true, completion: nil) + } + + @IBAction func playbackRecordingTapped(_ sender: Any) { + playbackAudioRecording() + updateViews() + } +} + + +extension AudioViewController: AVAudioPlayerDelegate { + + func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) { + updateViews() + print("Audio file has finished playing") + } + + func audioPlayerDecodeErrorDidOccur(_ player: AVAudioPlayer, error: Error?) { + if let error = error { + print("Audio Player error: \(error)") + } + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/View Controllers/ExperienceTableViewController.swift b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/ExperienceTableViewController.swift new file mode 100644 index 00000000..de0715e8 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/ExperienceTableViewController.swift @@ -0,0 +1,99 @@ +// +// ExperienceTableViewController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +import UIKit + +class ExperienceTableViewController: UITableViewController { + + + @IBOutlet weak var addExperienceButton: UIBarButtonItem! + + var experienceController: ExperienceController? + + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + tableView.reloadData() + } + + override func viewDidLoad() { + super.viewDidLoad() + } + + @IBAction func addExperienceButtonTapped(_ sender: UIBarButtonItem) { + addExperience() + } + + + private func addExperience() { + let alert = UIAlertController(title: "New Experience", message: "What kind of experience are you adding?", preferredStyle: .actionSheet) + + let addImageAction = UIAlertAction(title: "Image", style: .default) { (_) in + self.performSegue(withIdentifier: "imageSegue", sender: nil) + } + + let addAudioAction = UIAlertAction(title: "Audio", style: .default) { (_) in + self.performSegue(withIdentifier: "audioSegue", sender: nil) + } + + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + + alert.addAction(addImageAction) + alert.addAction(addAudioAction) + alert.addAction(cancelAction) + + self.present(alert, animated: true, completion: nil) + } + + // MARK: - Table view data source + + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return experienceController?.experiences.count ?? 0 + } + + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "ExpCell", for: indexPath) + + cell.textLabel?.text = experienceController?.experiences[indexPath.row].title + cell.detailTextLabel?.text = experienceController?.experiences[indexPath.row].mediaType.rawValue + + return cell + } + + // MARK: - Navigation + + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + switch segue.identifier { + case "imageSegue": + if let destinationVC = segue.destination as? ImageViewController { + destinationVC.experienceController = self.experienceController + destinationVC.delegate = self + } + case "audioSegue": + if let destinationVC = segue.destination as? AudioViewController { + destinationVC.experienceController = self.experienceController + destinationVC.delegate = self + } + + default: + return + } + } + } + +extension ExperienceTableViewController: ImageViewControllerDelegate, AudioViewControllerDelegate { + + func saveImageButtonTapped() { + tableView.reloadData() + } + + func saveAudioButtonTapped() { + tableView.reloadData() + } + + } diff --git a/ExperiencesChallenge/ExperiencesChallenge/View Controllers/ImageViewController.swift b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/ImageViewController.swift new file mode 100644 index 00000000..b8414279 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/ImageViewController.swift @@ -0,0 +1,216 @@ +// +// ImageViewController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + + +import UIKit +import CoreImage +import CoreImage.CIFilterBuiltins +import Photos + +protocol ImageViewControllerDelegate { + func saveImageButtonTapped() +} + +class ImageViewController: UIViewController { + + var experienceController: ExperienceController? + var imageData: Data? + var delegate: ImageViewControllerDelegate? + + private var chromeFilter = CIFilter(name: "CIPhotoEffectChrome") + let context = CIContext(options: nil) + + // MARK: IBOutlets + + @IBOutlet weak var saveImageButton: UIBarButtonItem! + @IBOutlet weak var filterStackview: UIStackView! + @IBOutlet weak var imageView: UIImageView! + @IBOutlet weak var cancelButton: UIBarButtonItem! + @IBOutlet weak var addLocationSwitch: UISwitch! + @IBOutlet weak var chromeSwitch: UISwitch! + @IBOutlet weak var chooseImageButton: UIButton! + @IBOutlet weak var titleTextField: UITextField! + @IBOutlet weak var imageHeight: NSLayoutConstraint! + + + override func viewDidLoad() { + super.viewDidLoad() + saveImageButton.isEnabled = false + saveImageButton.tintColor = UIColor.gray + + setImageViewHeight(with: 1.0) + updateViews() + + } + + func setImageViewHeight(with aspectRatio: CGFloat) { + + imageHeight.constant = imageView.frame.size.width * aspectRatio + view.layoutSubviews() + } + + func updateViews() { + + guard let imageData = imageData, + let image = UIImage(data: imageData) else { + title = "New Image" + filterStackview.isHidden = true + return + } + + let ratio = image.size.height / image.size.width + setImageViewHeight(with: ratio) + + imageView.image = image + + chooseImageButton.setTitle("", for: []) + } + + private func scaleImage(_ image: UIImage) -> UIImage { + + var scaledSize = imageView.bounds.size + + let scale = UIScreen.main.scale + scaledSize = CGSize(width: scaledSize.width * scale, height: scaledSize.height * scale) + + return image.imageByScaling(toSize: scaledSize) ?? UIImage() + } + + 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 addImage() { + view.endEditing(true) + + guard let title = titleTextField.text, + !title.isEmpty else { + presentInformationalAlertController(title: "Uh-oh", message: "Make sure that you add a caption before posting.") + return + } + + if addLocationSwitch.isOn { + LocationHelper.shared.getCurrentLocation { (coordinate) in + self.experienceController?.createPost(with: title, ofType: .image, location: coordinate) + self.delegate?.saveImageButtonTapped() + self.dismiss(animated: true) {} + } + } else { + self.experienceController?.createPost(with: title, ofType: .image, location: nil) + delegate?.saveImageButtonTapped() + self.dismiss(animated: true, completion: nil) + } + } + + private func selectImage() { + 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.") + + @unknown default: + fatalError() + } + presentImagePickerController() + } + + private func chromeEffectImage(_ image: UIImage) -> UIImage { + guard let cgImage = image.cgImage, + let chromeEffect = chromeFilter + else { return image} + let ciImage = CIImage(cgImage: cgImage) + + chromeEffect.setValue(ciImage, forKey: "inputImage") + guard let outputCIImage = chromeEffect.outputImage else { return image } + + guard let outputCGImage = context.createCGImage(outputCIImage, from: CGRect(origin: CGPoint.zero, size: image.size)) else { return image } + + return UIImage(cgImage: outputCGImage) + } + + private func chromeImage() { + guard let image = imageView.image else { return } + let scaledImage = scaleImage(image) + + imageView.image = chromeEffectImage(scaledImage) + } + + // MARK: - IBActions + + @IBAction func saveImageButtonTapped(_ sender: Any) { + addImage() + } + + @IBAction func selectImageButtonTapped(_ sender: Any) { + selectImage() + } + + @IBAction func chromeSwitchChanged(_ sender: Any) { + chromeImage() + } + + + @IBAction func cancelButtonTapped(_ sender: Any) { + dismiss(animated: true, completion: nil) + } + + +} + +extension ImageViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { + + chooseImageButton.setTitle("", for: []) + + picker.dismiss(animated: true, completion: nil) + + guard let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage else { return } + + imageView.image = image + + filterStackview.isHidden = false + + saveImageButton.isEnabled = true + saveImageButton.tintColor = UIColor.link + + let ratio = image.size.height / image.size.width + setImageViewHeight(with: ratio) + } + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { + picker.dismiss(animated: true, completion: nil) + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/View Controllers/MapViewController.swift b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/MapViewController.swift new file mode 100644 index 00000000..03d64fd0 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/MapViewController.swift @@ -0,0 +1,67 @@ +// +// MapViewController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +import UIKit +import MapKit + +class MapViewController: UIViewController { + + + @IBOutlet weak var mapView: MKMapView! + + var location: CLLocationCoordinate2D? + + var experienceController: ExperienceController? + override func viewDidLoad() { + super.viewDidLoad() + + mapView.register(MKAnnotationView.self, forAnnotationViewWithReuseIdentifier: .annotationReuseIdentifier) + mapView.delegate = self + fetchExperiences() + } + + func setPinUsingMKPointAnnotation(location: CLLocationCoordinate2D){ + let annotation = MKPointAnnotation() + annotation.coordinate = location + let coordinateRegion = MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 200, longitudinalMeters: 200) + mapView.setRegion(coordinateRegion, animated: true) + mapView.addAnnotation(annotation) + } + + private func fetchExperiences() { + guard let experiences = experienceController?.experiences else { return } + + DispatchQueue.main.async { + self.mapView.addAnnotations(experiences) + + guard let entry = experiences.first else { return } + + let span = MKCoordinateSpan(latitudeDelta: 2, longitudeDelta: 2) + let region = MKCoordinateRegion(center: entry.coordinate, span: span) + self.mapView.setRegion(region, animated: true) + } + } +} +extension String { + static let annotationReuseIdentifier = "EntryView" +} + +extension MapViewController: MKMapViewDelegate { + + func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { + + guard let _ = annotation as? Experience else { + fatalError("Only Experiences are supported") + } + guard let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: .annotationReuseIdentifier) as? MKMarkerAnnotationView else { + fatalError("Missing map annotation view") + } + return annotationView + } +} + diff --git a/ExperiencesChallenge/ExperiencesChallenge/View Controllers/TabViewController.swift b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/TabViewController.swift new file mode 100644 index 00000000..5c6f8361 --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/View Controllers/TabViewController.swift @@ -0,0 +1,31 @@ +// +// TabViewController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +import UIKit + +class TabViewController: UITabBarController { + + let experienceController = ExperienceController() + + override func viewDidLoad() { + super.viewDidLoad() + setupVCs() + } + + private func setupVCs() { + guard let tabViewControllers = self.viewControllers else { return } + if let navController = tabViewControllers[0] as? UINavigationController, + let experienceTVC = navController.topViewController as? ExperienceTableViewController { + experienceTVC.experienceController = self.experienceController + } + if let mapVC = tabViewControllers[1] as? MapViewController { + mapVC.experienceController = self.experienceController + + } + } +} diff --git a/ExperiencesChallenge/ExperiencesChallenge/ViewController.swift b/ExperiencesChallenge/ExperiencesChallenge/ViewController.swift new file mode 100644 index 00000000..7a7b1c2f --- /dev/null +++ b/ExperiencesChallenge/ExperiencesChallenge/ViewController.swift @@ -0,0 +1,20 @@ +// +// ViewController.swift +// ExperiencesChallenge +// +// Created by Ian French on 9/13/20. +// Copyright © 2020 Ian French. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} +