diff --git a/Experience/Experience.xcodeproj/project.pbxproj b/Experience/Experience.xcodeproj/project.pbxproj new file mode 100644 index 00000000..a7fc5ef4 --- /dev/null +++ b/Experience/Experience.xcodeproj/project.pbxproj @@ -0,0 +1,398 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 223BEEE825577BED002685E3 /* UIImage+Scaling.swift in Sources */ = {isa = PBXBuildFile; fileRef = 223BEEE725577BED002685E3 /* UIImage+Scaling.swift */; }; + 2295A6B92557023E006ABB74 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2295A6B82557023E006ABB74 /* AppDelegate.swift */; }; + 2295A6BB2557023E006ABB74 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2295A6BA2557023E006ABB74 /* SceneDelegate.swift */; }; + 2295A6BD2557023E006ABB74 /* PostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2295A6BC2557023E006ABB74 /* PostViewController.swift */; }; + 2295A6C02557023E006ABB74 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2295A6BE2557023E006ABB74 /* Main.storyboard */; }; + 2295A6C22557023F006ABB74 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2295A6C12557023F006ABB74 /* Assets.xcassets */; }; + 2295A6C52557023F006ABB74 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2295A6C32557023F006ABB74 /* LaunchScreen.storyboard */; }; + 2295A6D625571A5F006ABB74 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2295A6D525571A5F006ABB74 /* MapsViewController.swift */; }; + 229E045D255A2D9500E3536E /* Post.swift in Sources */ = {isa = PBXBuildFile; fileRef = 229E045C255A2D9500E3536E /* Post.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 223BEEE725577BED002685E3 /* UIImage+Scaling.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Scaling.swift"; sourceTree = ""; }; + 2295A6B52557023E006ABB74 /* Experience.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Experience.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 2295A6B82557023E006ABB74 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 2295A6BA2557023E006ABB74 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 2295A6BC2557023E006ABB74 /* PostViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostViewController.swift; sourceTree = ""; }; + 2295A6BF2557023E006ABB74 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 2295A6C12557023F006ABB74 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 2295A6C42557023F006ABB74 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 2295A6C62557023F006ABB74 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 2295A6D525571A5F006ABB74 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = ""; }; + 229E045C255A2D9500E3536E /* Post.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Post.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 2295A6B22557023E006ABB74 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 223BEEE625577B71002685E3 /* Helper */ = { + isa = PBXGroup; + children = ( + 223BEEE725577BED002685E3 /* UIImage+Scaling.swift */, + ); + path = Helper; + sourceTree = ""; + }; + 2295A6AC2557023E006ABB74 = { + isa = PBXGroup; + children = ( + 2295A6B72557023E006ABB74 /* Experience */, + 2295A6B62557023E006ABB74 /* Products */, + ); + sourceTree = ""; + }; + 2295A6B62557023E006ABB74 /* Products */ = { + isa = PBXGroup; + children = ( + 2295A6B52557023E006ABB74 /* Experience.app */, + ); + name = Products; + sourceTree = ""; + }; + 2295A6B72557023E006ABB74 /* Experience */ = { + isa = PBXGroup; + children = ( + 223BEEE625577B71002685E3 /* Helper */, + 2295A6D425571A1D006ABB74 /* Model */, + 2295A6D325571A06006ABB74 /* Views */, + 2295A6D1255719FB006ABB74 /* View Controllers */, + 2295A6D0255719E2006ABB74 /* Resources */, + 2295A6C62557023F006ABB74 /* Info.plist */, + ); + path = Experience; + sourceTree = ""; + }; + 2295A6D0255719E2006ABB74 /* Resources */ = { + isa = PBXGroup; + children = ( + 2295A6B82557023E006ABB74 /* AppDelegate.swift */, + 2295A6BA2557023E006ABB74 /* SceneDelegate.swift */, + 2295A6C12557023F006ABB74 /* Assets.xcassets */, + ); + path = Resources; + sourceTree = ""; + }; + 2295A6D1255719FB006ABB74 /* View Controllers */ = { + isa = PBXGroup; + children = ( + 2295A6BC2557023E006ABB74 /* PostViewController.swift */, + 2295A6D525571A5F006ABB74 /* MapsViewController.swift */, + ); + path = "View Controllers"; + sourceTree = ""; + }; + 2295A6D325571A06006ABB74 /* Views */ = { + isa = PBXGroup; + children = ( + 2295A6BE2557023E006ABB74 /* Main.storyboard */, + 2295A6C32557023F006ABB74 /* LaunchScreen.storyboard */, + ); + path = Views; + sourceTree = ""; + }; + 2295A6D425571A1D006ABB74 /* Model */ = { + isa = PBXGroup; + children = ( + 229E045C255A2D9500E3536E /* Post.swift */, + ); + path = Model; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 2295A6B42557023E006ABB74 /* Experience */ = { + isa = PBXNativeTarget; + buildConfigurationList = 2295A6C92557023F006ABB74 /* Build configuration list for PBXNativeTarget "Experience" */; + buildPhases = ( + 2295A6B12557023E006ABB74 /* Sources */, + 2295A6B22557023E006ABB74 /* Frameworks */, + 2295A6B32557023E006ABB74 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Experience; + productName = Experience; + productReference = 2295A6B52557023E006ABB74 /* Experience.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 2295A6AD2557023E006ABB74 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1210; + LastUpgradeCheck = 1210; + TargetAttributes = { + 2295A6B42557023E006ABB74 = { + CreatedOnToolsVersion = 12.1; + }; + }; + }; + buildConfigurationList = 2295A6B02557023E006ABB74 /* Build configuration list for PBXProject "Experience" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 2295A6AC2557023E006ABB74; + productRefGroup = 2295A6B62557023E006ABB74 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 2295A6B42557023E006ABB74 /* Experience */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 2295A6B32557023E006ABB74 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2295A6C52557023F006ABB74 /* LaunchScreen.storyboard in Resources */, + 2295A6C22557023F006ABB74 /* Assets.xcassets in Resources */, + 2295A6C02557023E006ABB74 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 2295A6B12557023E006ABB74 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2295A6BD2557023E006ABB74 /* PostViewController.swift in Sources */, + 2295A6B92557023E006ABB74 /* AppDelegate.swift in Sources */, + 2295A6BB2557023E006ABB74 /* SceneDelegate.swift in Sources */, + 229E045D255A2D9500E3536E /* Post.swift in Sources */, + 223BEEE825577BED002685E3 /* UIImage+Scaling.swift in Sources */, + 2295A6D625571A5F006ABB74 /* MapsViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 2295A6BE2557023E006ABB74 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2295A6BF2557023E006ABB74 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 2295A6C32557023F006ABB74 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 2295A6C42557023F006ABB74 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 2295A6C72557023F006ABB74 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + 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; + }; + 2295A6C82557023F006ABB74 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.1; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 2295A6CA2557023F006ABB74 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 4JH2MBZ5K9; + INFOPLIST_FILE = Experience/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = samsDevsLife.Experience; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 2295A6CB2557023F006ABB74 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 4JH2MBZ5K9; + INFOPLIST_FILE = Experience/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = samsDevsLife.Experience; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 2295A6B02557023E006ABB74 /* Build configuration list for PBXProject "Experience" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2295A6C72557023F006ABB74 /* Debug */, + 2295A6C82557023F006ABB74 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 2295A6C92557023F006ABB74 /* Build configuration list for PBXNativeTarget "Experience" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 2295A6CA2557023F006ABB74 /* Debug */, + 2295A6CB2557023F006ABB74 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 2295A6AD2557023E006ABB74 /* Project object */; +} diff --git a/Experience/Experience/Helper/UIImage+Scaling.swift b/Experience/Experience/Helper/UIImage+Scaling.swift new file mode 100644 index 00000000..8750a3d1 --- /dev/null +++ b/Experience/Experience/Helper/UIImage+Scaling.swift @@ -0,0 +1,37 @@ +// +// UIImage+Scaling.swift +// Experience +// +// Created by Sammy Alvarado on 11/7/20. +// + +import UIKit + +extension UIImage { + + /// Resize the image to a max dimension from size parameter + func imageByScaling(toSize size: CGSize) -> UIImage? { + guard size.width > 0 && size.height > 0 else { return nil } + + let originalAspectRatio = self.size.width/self.size.height + var correctedSize = size + + if correctedSize.width > correctedSize.width*originalAspectRatio { + correctedSize.width = correctedSize.width*originalAspectRatio + } else { + correctedSize.height = correctedSize.height/originalAspectRatio + } + + return UIGraphicsImageRenderer(size: correctedSize, format: imageRendererFormat).image { context in + draw(in: CGRect(origin: .zero, size: correctedSize)) + } + } + + /// Renders the image if the pixel data was rotated due to orientation of camera + var flattened: UIImage { + if imageOrientation == .up { return self } + return UIGraphicsImageRenderer(size: size, format: imageRendererFormat).image { context in + draw(at: .zero) + } + } +} diff --git a/Experience/Experience/Info.plist b/Experience/Experience/Info.plist new file mode 100644 index 00000000..c2ae71a4 --- /dev/null +++ b/Experience/Experience/Info.plist @@ -0,0 +1,72 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSPhotoLibraryUsageDescription + $(PRODUCT_NAME) needs to access pictures for new post + NSLocationWhenInUseUsageDescription + $(PRODUCT_NAME)need to access current location for new post + NSMicrophoneUsageDescription + $(PRODUCT_NAME)need to access audio mic for new post + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Experience/Experience/Model/Post.swift b/Experience/Experience/Model/Post.swift new file mode 100644 index 00000000..dee96869 --- /dev/null +++ b/Experience/Experience/Model/Post.swift @@ -0,0 +1,33 @@ +// +// post.swift +// Experience +// +// Created by Sammy Alvarado on 11/9/20. +// + +import UIKit +import MapKit + +class Post: NSObject { + + let image: UIImage? + let titleName: String + let latitude: Double + let longitude: Double + + init(titleName: String, image: UIImage, latitude: Double, longitude: Double) { + self.titleName = titleName + self.image = image + self.latitude = latitude + self.longitude = longitude + } +} + +extension Post: MKAnnotation { + var coordinate: CLLocationCoordinate2D { + CLLocationCoordinate2D(latitude: latitude, longitude: longitude) + + } + var title: String? { titleName } +} + diff --git a/Experience/Experience/Resources/AppDelegate.swift b/Experience/Experience/Resources/AppDelegate.swift new file mode 100644 index 00000000..15b331ac --- /dev/null +++ b/Experience/Experience/Resources/AppDelegate.swift @@ -0,0 +1,36 @@ +// +// AppDelegate.swift +// Experience +// +// Created by Sammy Alvarado on 11/7/20. +// + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/Experience/Experience/Resources/Assets.xcassets/1024.imageset/1024.png b/Experience/Experience/Resources/Assets.xcassets/1024.imageset/1024.png new file mode 100644 index 00000000..add104c4 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/1024.imageset/1024.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/1024.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/1024.imageset/Contents.json new file mode 100644 index 00000000..94202f55 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/1024.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "1024.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/114.imageset/114.png b/Experience/Experience/Resources/Assets.xcassets/114.imageset/114.png new file mode 100644 index 00000000..ed0a5a9a Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/114.imageset/114.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/114.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/114.imageset/Contents.json new file mode 100644 index 00000000..76639ea2 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/114.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "114.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/120.imageset/120.png b/Experience/Experience/Resources/Assets.xcassets/120.imageset/120.png new file mode 100644 index 00000000..370da232 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/120.imageset/120.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/120.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/120.imageset/Contents.json new file mode 100644 index 00000000..b81f9a5e --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/120.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "120.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg.png b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg.png new file mode 100644 index 00000000..ccf65bf5 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg@2x.png b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg@2x.png new file mode 100644 index 00000000..332b687d Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg@2x.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg@3x.png b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg@3x.png new file mode 100644 index 00000000..fcd13b09 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/1200px-Tomboy_logo.svg@3x.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/Contents.json new file mode 100644 index 00000000..59becb52 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/1200px-Tomboy_logo.svg.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "1200px-Tomboy_logo.svg.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "1200px-Tomboy_logo.svg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "1200px-Tomboy_logo.svg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/180.imageset/180.png b/Experience/Experience/Resources/Assets.xcassets/180.imageset/180.png new file mode 100644 index 00000000..348e84ce Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/180.imageset/180.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/180.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/180.imageset/Contents.json new file mode 100644 index 00000000..96fa8191 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/180.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "180.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/29.imageset/29.png b/Experience/Experience/Resources/Assets.xcassets/29.imageset/29.png new file mode 100644 index 00000000..2b8c4e5a Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/29.imageset/29.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/29.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/29.imageset/Contents.json new file mode 100644 index 00000000..5a742fde --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/29.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "29.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/40.imageset/40.png b/Experience/Experience/Resources/Assets.xcassets/40.imageset/40.png new file mode 100644 index 00000000..a3e9069e Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/40.imageset/40.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/40.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/40.imageset/Contents.json new file mode 100644 index 00000000..35a59638 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/40.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "40.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/57.imageset/57.png b/Experience/Experience/Resources/Assets.xcassets/57.imageset/57.png new file mode 100644 index 00000000..5d6ef35e Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/57.imageset/57.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/57.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/57.imageset/Contents.json new file mode 100644 index 00000000..fac19b4d --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/57.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "57.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/58.imageset/58.png b/Experience/Experience/Resources/Assets.xcassets/58.imageset/58.png new file mode 100644 index 00000000..3cd61824 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/58.imageset/58.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/58.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/58.imageset/Contents.json new file mode 100644 index 00000000..e9e5d138 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/58.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "58.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/60.imageset/60.png b/Experience/Experience/Resources/Assets.xcassets/60.imageset/60.png new file mode 100644 index 00000000..ebad3ae9 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/60.imageset/60.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/60.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/60.imageset/Contents.json new file mode 100644 index 00000000..85717beb --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/60.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "60.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/80.imageset/80.png b/Experience/Experience/Resources/Assets.xcassets/80.imageset/80.png new file mode 100644 index 00000000..0dc4794c Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/80.imageset/80.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/80.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/80.imageset/Contents.json new file mode 100644 index 00000000..e565d1a9 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/80.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "80.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/87.imageset/87.png b/Experience/Experience/Resources/Assets.xcassets/87.imageset/87.png new file mode 100644 index 00000000..a08a0871 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/87.imageset/87.png differ diff --git a/Experience/Experience/Resources/Assets.xcassets/87.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/87.imageset/Contents.json new file mode 100644 index 00000000..ba6b40e3 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/87.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "87.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/AccentColor.colorset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 00000000..eb878970 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/Experience/Experience/Resources/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/Experience/Experience/Resources/Assets.xcassets/Contents.json b/Experience/Experience/Resources/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/Record.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/Record.imageset/Contents.json new file mode 100644 index 00000000..122fd799 --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/Record.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Record.pdf", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/Record.imageset/Record.pdf b/Experience/Experience/Resources/Assets.xcassets/Record.imageset/Record.pdf new file mode 100644 index 00000000..f4b07935 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/Record.imageset/Record.pdf differ diff --git a/Experience/Experience/Resources/Assets.xcassets/Stop.imageset/Contents.json b/Experience/Experience/Resources/Assets.xcassets/Stop.imageset/Contents.json new file mode 100644 index 00000000..7b724bde --- /dev/null +++ b/Experience/Experience/Resources/Assets.xcassets/Stop.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "Stop.pdf", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Experience/Experience/Resources/Assets.xcassets/Stop.imageset/Stop.pdf b/Experience/Experience/Resources/Assets.xcassets/Stop.imageset/Stop.pdf new file mode 100644 index 00000000..7aee81c0 Binary files /dev/null and b/Experience/Experience/Resources/Assets.xcassets/Stop.imageset/Stop.pdf differ diff --git a/Experience/Experience/Resources/SceneDelegate.swift b/Experience/Experience/Resources/SceneDelegate.swift new file mode 100644 index 00000000..3bbf3fb5 --- /dev/null +++ b/Experience/Experience/Resources/SceneDelegate.swift @@ -0,0 +1,52 @@ +// +// SceneDelegate.swift +// Experience +// +// Created by Sammy Alvarado on 11/7/20. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/Experience/Experience/View Controllers/MapsViewController.swift b/Experience/Experience/View Controllers/MapsViewController.swift new file mode 100644 index 00000000..40812a79 --- /dev/null +++ b/Experience/Experience/View Controllers/MapsViewController.swift @@ -0,0 +1,116 @@ +// +// MapsViewController.swift +// Experience +// +// Created by Sammy Alvarado on 11/7/20. +// + +import UIKit +import MapKit + +class MapsViewController: UIViewController { + @IBOutlet weak var addNotesButton: UIButton! + @IBOutlet weak var mapView: MKMapView! + + var posts: [Post] = [] + + private var userTrackingButton: MKUserTrackingButton! + private var locationManager = CLLocationManager() +// var currentLoc: CLLocation! + + + override func viewDidLoad() { + super.viewDidLoad() + configureMapView() + mapView.delegate = self + +// locationManager.requestWhenInUseAuthorization() +// locationManager.desiredAccuracy = kCLLocationAccuracyBest +// locationManager.distanceFilter = kCLDistanceFilterNone +// locationManager.distanceFilter = kCLLocationAccuracyNearestTenMeters +// locationManager.startUpdatingLocation() + + mapView.showsUserLocation = true + + userTrackingButton = MKUserTrackingButton(mapView: mapView) + userTrackingButton.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(userTrackingButton) + + NSLayoutConstraint.activate([ + userTrackingButton.leadingAnchor.constraint(equalTo: mapView.leadingAnchor, constant: 20), + mapView.bottomAnchor.constraint(equalTo: userTrackingButton.bottomAnchor, constant: 80) + ]) + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(true) + mapView.addAnnotations(posts) + determineMyCurrentLocation() + } + + func determineMyCurrentLocation() { + locationManager = CLLocationManager() + locationManager.delegate = self + locationManager.desiredAccuracy = kCLLocationAccuracyBest + locationManager.requestAlwaysAuthorization() + + if CLLocationManager.locationServicesEnabled() { + locationManager.startUpdatingLocation() + } + } + + func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { + let userLocation:CLLocation = locations[0] as CLLocation + + // Call stopUpdatingLocation() to stop listening for location updates, + // other wise this function will be called every time when user location changes. + + // manager.stopUpdatingLocation() + + print("user latitude = \(userLocation.coordinate.latitude)") + print("user longitude = \(userLocation.coordinate.longitude)") + } + + // MARK: - Navigation + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + switch segue.identifier { + case "NewPost": + if let navigationVC = segue.destination as? UINavigationController { + let newPostVC = navigationVC.topViewController as! PostViewController + newPostVC.post = posts + newPostVC.postDelegate = self + } + default: + break + } + } +} + +extension MapsViewController: MKMapViewDelegate, CLLocationManagerDelegate { + func mapViewDidChangeVisibleRegion(_ mapView: MKMapView) { + } + + private func configureMapView() { + mapView.register(MKMarkerAnnotationView.self, forAnnotationViewWithReuseIdentifier: .annotationReuseIdentifier) + mapView.addAnnotations(posts) + } + + func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { + + guard let post = annotation as? Post else { return nil } + let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: .annotationReuseIdentifier, for: post) as! MKMarkerAnnotationView + + annotationView.glyphImage = #imageLiteral(resourceName: "87") + + annotationView.canShowCallout = true + annotationView.rightCalloutAccessoryView = UIButton(type: .detailDisclosure) + return annotationView + } +} + +extension MapsViewController: PostDelegate { + func getPost(post: Post) { + posts.append(post) + } + +} diff --git a/Experience/Experience/View Controllers/PostViewController.swift b/Experience/Experience/View Controllers/PostViewController.swift new file mode 100644 index 00000000..d686aeac --- /dev/null +++ b/Experience/Experience/View Controllers/PostViewController.swift @@ -0,0 +1,278 @@ +// +// ViewController.swift +// Experience +// +// Created by Sammy Alvarado on 11/7/20. +// + +import UIKit +import CoreImage +import CoreImage.CIFilterBuiltins +import Photos +import AVFoundation +import MapKit +import CoreLocation + +extension String { + static let annotationReuseIdentifier = "Experiences" +} + +protocol PostDelegate { + func getPost(post: Post) +} + +class PostViewController: UIViewController { + // MARK: OUTLETS For Photos + @IBOutlet weak var titleTextField: UITextField! + @IBOutlet weak var posterImageView: UIImageView! + + // MARK: OUTLETS For Audio + @IBOutlet weak var recordButton: UIButton! + + // MARK: PROPERTIES -- Audio + var post: [Post] = [] + var postDelegate: PostDelegate? + var audioRecorder: AVAudioRecorder? + var audioPlayer: AVAudioPlayer? + var recordingURL: URL? + private let locationManager = CLLocationManager() + + var originalImage: UIImage? { + didSet { + guard let originalImage = originalImage else { + scaledImage = nil + return + } + + var scaledSize = posterImageView.bounds.size + let scale = posterImageView.contentScaleFactor + + scaledSize.width *= scale + scaledSize.height *= scale + + guard let scaledUIImage = originalImage.imageByScaling(toSize: scaledSize) else { + scaledImage = nil + return + } + + scaledImage = CIImage(image: scaledUIImage) + } + } + + var scaledImage: CIImage? { + didSet { + updateImage() + } + } + + override func viewDidLoad() { + super.viewDidLoad() + originalImage = posterImageView.image + recordButton.titleLabel?.text = "Record" + updateViews() + } + + func prepareAudioSession() throws { + let session = AVAudioSession.sharedInstance() + try session.setCategory(.playAndRecord, options: [.defaultToSpeaker]) + try session.setActive(true, options: []) + } + + var isRecording: Bool { + audioRecorder?.isRecording ?? false + } + + func createNewRecordingURL() -> URL { + let documents = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! + + let name = ISO8601DateFormatter.string(from: Date(), timeZone: .current, formatOptions: .withInternetDateTime) + let file = documents.appendingPathComponent(name, isDirectory: false).appendingPathExtension("caf") + + return file + } + + func requestPermissionOrStartRecording() { + switch AVAudioSession.sharedInstance().recordPermission { + case .undetermined: + AVAudioSession.sharedInstance().requestRecordPermission { granted in + guard granted == true else { + print("We need microphone access") + return + } + + print("Recording permission has been granted!") + + } + case .denied: + print("Microphone access has been blocked.") + + let alertController = UIAlertController(title: "Microphone Access Denied", message: "Please allow this app to access your Microphone.", preferredStyle: .alert) + + alertController.addAction(UIAlertAction(title: "Open Settings", style: .default) { (_) in + UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!) + }) + + alertController.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil)) + + present(alertController, animated: true, completion: nil) + case .granted: + startRecording() + @unknown default: + break + } + } + + func startRecording() { + do { + try prepareAudioSession() + } catch { + print("Cannot record audio: \(error)") + return + } + + recordingURL = createNewRecordingURL() + + let format = AVAudioFormat(standardFormatWithSampleRate: 44_100, channels: 1)! + + do { + audioRecorder = try AVAudioRecorder(url: recordingURL!, format: format) + audioRecorder?.delegate = self + audioRecorder?.isMeteringEnabled = true + audioRecorder?.record() + + } catch { + preconditionFailure("The audio recorder could not be created with \(recordingURL!) and \(format)") + } + } + + func stopRecording() { + audioRecorder?.stop() + } + + func updateViews() { + recordButton.setTitle(isRecording.self ? "Stop Recording" : "Record", for: .normal) + + if isRecording { + stopRecording() + } else { + requestPermissionOrStartRecording() + } + } + + private func imagePickerAction() { + let alert = UIAlertController() + + let photoLibraryAction = UIAlertAction(title: "Choose from Library", style: .default) { (action) in + self.imagePickerController(sourceType: .photoLibrary) + } + + let cameraAction = UIAlertAction(title: "Camera", style: .default) { (action) in + self.imagePickerController(sourceType: .camera) + } + + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + + alert.addAction(photoLibraryAction) + alert.addAction(cameraAction) + alert.addAction(cancelAction) + + self.present(alert, animated: true) + + } + + private func imagePickerController(sourceType: UIImagePickerController.SourceType) { + guard UIImagePickerController.isSourceTypeAvailable(.photoLibrary) else { + print("The photo library is not available.") + return + } + + let imagePicker = UIImagePickerController() + imagePicker.sourceType = sourceType + imagePicker.delegate = self + + present(imagePicker, animated: true, completion: nil) + } + + private func image(byFiltering inputImage: CIImage) -> UIImage? { + guard let currentCGImage = inputImage.cgImage else { return nil } + let currentCIImage = CIImage(cgImage: currentCGImage) + + let filter = CIFilter(name: "CIColorMonochrome") + filter?.setValue(currentCIImage, forKey: "inputImage") + + filter?.setValue(1.0, forKey: "inputIntensity") + guard let outputImage = filter?.outputImage else { return nil } + + let context = CIContext() + + let cgimg = context.createCGImage(outputImage, from: outputImage.extent)! + let processedImage = UIImage(cgImage: cgimg) + + return processedImage + } + + func updateImage() { + if let scaledImage = scaledImage { + posterImageView.image = image(byFiltering: scaledImage) + } else { + posterImageView.image = nil + } + } + + // MARK: ACTIONS For Photos + @IBAction func addImageTapped(_ sender: UIButton) { + imagePickerAction() + } + + // MARK: ACTIONS For Record + + @IBAction func recordButtonWasTapped(_ sender: UIButton) { + updateViews() + + } + + @IBAction func saveButtonTapped(_ sender: UIBarButtonItem) { + let location = locationManager.location?.coordinate + + let newPost = Post(titleName: titleTextField.text ?? "", image: originalImage ?? #imageLiteral(resourceName: "120"), latitude: location!.latitude, longitude: location!.longitude) + postDelegate?.getPost(post: newPost) + + navigationController?.dismiss(animated: true, completion: nil) + } +} + + // MARK: EXTENSIONS +extension PostViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { + + func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) { + + if let image = info[.editedImage] as? UIImage { + originalImage = image + } else if let image = info[.originalImage] as? UIImage { + originalImage = image + } + + picker.dismiss(animated: true, completion: nil) + } + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { + picker.dismiss(animated: true, completion: nil) + } +} + +extension PostViewController: AVAudioRecorderDelegate { + + func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder, successfully flag: Bool) { + if let recordingURL = recordingURL { + audioPlayer = try? AVAudioPlayer(contentsOf: recordingURL) + } + recordingURL = nil + } + + func audioRecorderEncodeErrorDidOccur(_ recorder: AVAudioRecorder, error: Error?) { + if let error = error { + print("Audio Recorder Error: \(error)") + } + } + +} diff --git a/Experience/Experience/Views/Base.lproj/LaunchScreen.storyboard b/Experience/Experience/Views/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/Experience/Experience/Views/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Experience/Experience/Views/Base.lproj/Main.storyboard b/Experience/Experience/Views/Base.lproj/Main.storyboard new file mode 100644 index 00000000..30da9a26 --- /dev/null +++ b/Experience/Experience/Views/Base.lproj/Main.storyboard @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +