diff --git a/QuantiSpaceX.xcodeproj/project.pbxproj b/QuantiSpaceX.xcodeproj/project.pbxproj new file mode 100644 index 000000000..cc7acdc4d --- /dev/null +++ b/QuantiSpaceX.xcodeproj/project.pbxproj @@ -0,0 +1,379 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 77; + objects = { + +/* Begin PBXBuildFile section */ + 70092C152D1E0CA100774A37 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 70092C142D1E0CA100774A37 /* Alamofire */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 70092BF72D1E065500774A37 /* QuantiSpaceX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuantiSpaceX.app; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ + 70D368992D5F9E230027F78E /* Exceptions for "QuantiSpaceX" folder in "QuantiSpaceX" target */ = { + isa = PBXFileSystemSynchronizedBuildFileExceptionSet; + membershipExceptions = ( + Info.plist, + ); + target = 70092BF62D1E065500774A37 /* QuantiSpaceX */; + }; +/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ + +/* Begin PBXFileSystemSynchronizedRootGroup section */ + 70D3685F2D52AD4F0027F78E /* QuantiSpaceX */ = { + isa = PBXFileSystemSynchronizedRootGroup; + exceptions = ( + 70D368992D5F9E230027F78E /* Exceptions for "QuantiSpaceX" folder in "QuantiSpaceX" target */, + ); + path = QuantiSpaceX; + sourceTree = ""; + }; +/* End PBXFileSystemSynchronizedRootGroup section */ + +/* Begin PBXFrameworksBuildPhase section */ + 70092BF42D1E065500774A37 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 70092C152D1E0CA100774A37 /* Alamofire in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 70092BEE2D1E065500774A37 = { + isa = PBXGroup; + children = ( + 70D3685F2D52AD4F0027F78E /* QuantiSpaceX */, + 70092BF82D1E065500774A37 /* Products */, + ); + sourceTree = ""; + }; + 70092BF82D1E065500774A37 /* Products */ = { + isa = PBXGroup; + children = ( + 70092BF72D1E065500774A37 /* QuantiSpaceX.app */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 70092BF62D1E065500774A37 /* QuantiSpaceX */ = { + isa = PBXNativeTarget; + buildConfigurationList = 70092C052D1E065700774A37 /* Build configuration list for PBXNativeTarget "QuantiSpaceX" */; + buildPhases = ( + 70092BF32D1E065500774A37 /* Sources */, + 70092BF42D1E065500774A37 /* Frameworks */, + 70092BF52D1E065500774A37 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + fileSystemSynchronizedGroups = ( + 70D3685F2D52AD4F0027F78E /* QuantiSpaceX */, + ); + name = QuantiSpaceX; + packageProductDependencies = ( + 70092C142D1E0CA100774A37 /* Alamofire */, + ); + productName = QuantiSpaceX; + productReference = 70092BF72D1E065500774A37 /* QuantiSpaceX.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 70092BEF2D1E065500774A37 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1620; + LastUpgradeCheck = 1620; + TargetAttributes = { + 70092BF62D1E065500774A37 = { + CreatedOnToolsVersion = 16.2; + }; + }; + }; + buildConfigurationList = 70092BF22D1E065500774A37 /* Build configuration list for PBXProject "QuantiSpaceX" */; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + cs, + ); + mainGroup = 70092BEE2D1E065500774A37; + minimizedProjectReferenceProxies = 1; + packageReferences = ( + 70092C132D1E0CA100774A37 /* XCRemoteSwiftPackageReference "Alamofire" */, + ); + preferredProjectObjectVersion = 77; + productRefGroup = 70092BF82D1E065500774A37 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 70092BF62D1E065500774A37 /* QuantiSpaceX */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 70092BF52D1E065500774A37 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 70092BF32D1E065500774A37 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 70092C032D1E065700774A37 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 70092C042D1E065700774A37 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + 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; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + 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 = 18.2; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_EMIT_LOC_STRINGS = YES; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 70092C062D1E065700774A37 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"QuantiSpaceX/Preview Content\""; + DEVELOPMENT_TEAM = 5Q8R423CHJ; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = QuantiSpaceX/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = QuantiSpaceX; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education"; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = com.project.petr.sample.spacex; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 70092C072D1E065700774A37 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"QuantiSpaceX/Preview Content\""; + DEVELOPMENT_TEAM = 5Q8R423CHJ; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = QuantiSpaceX/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = QuantiSpaceX; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.education"; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0.0; + PRODUCT_BUNDLE_IDENTIFIER = com.project.petr.sample.spacex; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 70092BF22D1E065500774A37 /* Build configuration list for PBXProject "QuantiSpaceX" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 70092C032D1E065700774A37 /* Debug */, + 70092C042D1E065700774A37 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 70092C052D1E065700774A37 /* Build configuration list for PBXNativeTarget "QuantiSpaceX" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 70092C062D1E065700774A37 /* Debug */, + 70092C072D1E065700774A37 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 70092C132D1E0CA100774A37 /* XCRemoteSwiftPackageReference "Alamofire" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Alamofire/Alamofire.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.10.2; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 70092C142D1E0CA100774A37 /* Alamofire */ = { + isa = XCSwiftPackageProductDependency; + package = 70092C132D1E0CA100774A37 /* XCRemoteSwiftPackageReference "Alamofire" */; + productName = Alamofire; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 70092BEF2D1E065500774A37 /* Project object */; +} diff --git a/QuantiSpaceX.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/QuantiSpaceX.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/QuantiSpaceX.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/QuantiSpaceX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/QuantiSpaceX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..8c6ea5840 --- /dev/null +++ b/QuantiSpaceX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "e8f130fe30ac6cdc940ef06ee1e8535e9f46ffee6aeead1722b9525562f6ce08", + "pins" : [ + { + "identity" : "alamofire", + "kind" : "remoteSourceControl", + "location" : "https://github.com/Alamofire/Alamofire.git", + "state" : { + "revision" : "513364f870f6bfc468f9d2ff0a95caccc10044c5", + "version" : "5.10.2" + } + } + ], + "version" : 3 +} diff --git a/QuantiSpaceX.xcodeproj/project.xcworkspace/xcuserdata/petrzacek.xcuserdatad/UserInterfaceState.xcuserstate b/QuantiSpaceX.xcodeproj/project.xcworkspace/xcuserdata/petrzacek.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 000000000..ff6c88656 Binary files /dev/null and b/QuantiSpaceX.xcodeproj/project.xcworkspace/xcuserdata/petrzacek.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/QuantiSpaceX.xcodeproj/xcshareddata/xcschemes/QuantiSpaceX.xcscheme b/QuantiSpaceX.xcodeproj/xcshareddata/xcschemes/QuantiSpaceX.xcscheme new file mode 100644 index 000000000..6fb1d0c2b --- /dev/null +++ b/QuantiSpaceX.xcodeproj/xcshareddata/xcschemes/QuantiSpaceX.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QuantiSpaceX.xcodeproj/xcuserdata/petrzacek.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/QuantiSpaceX.xcodeproj/xcuserdata/petrzacek.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 000000000..f76bcbf5a --- /dev/null +++ b/QuantiSpaceX.xcodeproj/xcuserdata/petrzacek.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/QuantiSpaceX.xcodeproj/xcuserdata/petrzacek.xcuserdatad/xcschemes/xcschememanagement.plist b/QuantiSpaceX.xcodeproj/xcuserdata/petrzacek.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 000000000..23e94ea6b --- /dev/null +++ b/QuantiSpaceX.xcodeproj/xcuserdata/petrzacek.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + QuantiSpaceX.xcscheme_^#shared#^_ + + orderHint + 0 + + + SuppressBuildableAutocreation + + 70092BF62D1E065500774A37 + + primary + + + + + diff --git a/QuantiSpaceX/API/APIClient.swift b/QuantiSpaceX/API/APIClient.swift new file mode 100644 index 000000000..81a41774a --- /dev/null +++ b/QuantiSpaceX/API/APIClient.swift @@ -0,0 +1,64 @@ +// +// APIClient.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 26.12.2024. +// + +import Foundation +import Alamofire + +class APIClient: APIClientProtocol { + + let decoder = JSONDecoder() + // MARK: - Properties + private let rootUrl: String = "https://api.spacexdata.com/v4" + + enum ApiPath { + case getRockets + var path: String { + get { + switch (self) { + case .getRockets: return "/rockets" + } + } + } + } + + + // MARK: - Functions + func getAllRockets(completion: @escaping ([RocketList]?, Error?) -> Void) { + AF.request( + rootUrl + ApiPath.getRockets.path, + method: .get, + parameters: nil + ) + .validate() + .responseJSON { response in + switch response.result { + case .success(_): +// Debug API +// guard let responseData = response.data else { return } +// print("JSON String: \(String(data: responseData, encoding: .utf8))") + guard let data = response.data, + let rocketList = try? self.decoder.decode([RocketList].self, from: data) else { + print("error") + completion( + nil, + QuantiSpaceXError.unknown + ) + return + } +// for rocket in rocketList { +// print("Rocket Name: \(rocket.name)") +// } + completion(rocketList, nil) + + case .failure(let error): + completion(nil, error) + return + + } + } + } +} diff --git a/QuantiSpaceX/API/APIClientProtocol.swift b/QuantiSpaceX/API/APIClientProtocol.swift new file mode 100644 index 000000000..2c5c168cd --- /dev/null +++ b/QuantiSpaceX/API/APIClientProtocol.swift @@ -0,0 +1,14 @@ +// +// APIClientProtocol.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 26.12.2024. +// + +import Foundation + +protocol APIClientProtocol { + + func getAllRockets(completion: @escaping ([RocketList]?, Error?) -> ()) + +} diff --git a/QuantiSpaceX/API/Mock/MockAPIClient.swift b/QuantiSpaceX/API/Mock/MockAPIClient.swift new file mode 100644 index 000000000..f12e1e86e --- /dev/null +++ b/QuantiSpaceX/API/Mock/MockAPIClient.swift @@ -0,0 +1,18 @@ +// +// MockAPIClient.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 14.02.2025. +// + +import Foundation + +class MockAPIClient: APIClientProtocol { + func getAllRockets(completion: @escaping ([RocketList]?, (any Error)?) -> ()) { + completion([RocketList(height: Height(meters: 10,feet: 15), diameter: Diameter(meters: 30,feet: 70), mass: Mass(kg: 8000,lb: 900000), first_stage: FirstStage(thrust_sea_level:ThrustSeaLevel(kn: 30, lbf: 500),thrust_vacuum: ThrustVacuum(kn: 60, lbf: 100), reusable: true, engines: 2, burn_time_sec: 20), second_stage: SecondStage(burn_time_sec: 800000), engines: Engines(isp: Isp(sea_level: 8000, vacuum: 70),engine_loss_max: 20,propellant_1: "one",propellant_2: "two", thrust_to_weight: 600000), landing_legs: LandingLegs(number: 9, material: "Titanium"), payload_weights: [PayloadWeight(id: "57681", kg: 8000, lb: 2000)], flickr_images: ["https://fastly.picsum.photos/id/864/200/300.jpg?hmac=pHxnt4rXpNHIqBRpVSe-yL_pDtdwDfasgfub8GwI5mw", "https://fastly.picsum.photos/id/950/200/300.jpg?hmac=EEKbkKLpjWodOy9F68WA1hJkukq9UBUCIREC8fDW44U"], name: "Rocket East One", type: "Runnning", active: false, stages: 5, boosters: 12, cost_per_launch: 12000000, success_rate_pct: 12.5, first_flight: "15th of January 1975", country: "Czech", company: "Petronium", wikipedia: "none", description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse bibendum ac nibh eget sagittis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Proin ornare eleifend nunc, vitae volutpat dui aliquet eu. Integer sed vestibulum turpis. Vestibulum vulputate tortor sem, quis eleifend justo auctor at. Nam congue blandit tellus, vel fermentum risus lacinia et. Etiam ex metus, ullamcorper ac interdum ut, tempor non magna. Vestibulum dui tellus, fermentum nec urna ultrices, hendrerit euismod diam. Nullam et justo et justo fringilla mollis.", id: "54678"), RocketList(height: Height(meters: 20000,feet: 2000000), diameter: Diameter(meters: 300000,feet: 7055555), mass: Mass(kg: 800000,lb: 2000), first_stage: FirstStage(thrust_sea_level:ThrustSeaLevel(kn: 230, lbf: 1500),thrust_vacuum: ThrustVacuum(kn: 160, lbf: 10220), reusable: true, engines: 12, burn_time_sec: 22220), second_stage: SecondStage(burn_time_sec: 80022000), engines: Engines(isp: Isp(sea_level: 80020, vacuum: 720),engine_loss_max: 220,propellant_1: "seven",propellant_2: "three", thrust_to_weight: 6020000), landing_legs: LandingLegs(number: 22, material: "Iron"), payload_weights: [PayloadWeight(id: "57682", kg: 800220, lb: 200220)], flickr_images: ["https://fastly.picsum.photos/id/864/200/300.jpg?hmac=pHxnt4rXpNHIqBRpVSe-yL_pDtdwDfasgfub8GwI5mw", "https://fastly.picsum.photos/id/950/200/300.jpg?hmac=EEKbkKLpjWodOy9F68WA1hJkukq9UBUCIREC8fDW44U"], name: "Bark Bark", type: "Runnning", active: false, stages: 5, boosters: 12, cost_per_launch: 12000000, success_rate_pct: 12.5, first_flight: "11th of March 1900", country: "Russia", company: "Lajka's Revange", wikipedia: "none", description: "Aliquam consectetur auctor varius. Ut a risus ac dolor commodo varius ut id eros. Maecenas ut nulla placerat, pretium tellus tempus, porttitor est. Vivamus sit amet malesuada ligula. Vivamus sed sem mi. Integer semper dictum venenatis. Morbi vel urna mi.", id: "54679"), RocketList(height: Height(meters: 20000,feet: 2000000), diameter: Diameter(meters: 200000,feet: 7055555), mass: Mass(kg: 800000,lb: 2000), first_stage: FirstStage(thrust_sea_level:ThrustSeaLevel(kn: 230, lbf: 1500),thrust_vacuum: ThrustVacuum(kn: 160, lbf: 10220), reusable: true, engines: 53, burn_time_sec: 22220), second_stage: SecondStage(burn_time_sec: 80022000), engines: Engines(isp: Isp(sea_level: 80020, vacuum: 720),engine_loss_max: 220,propellant_1: "seven",propellant_2: "three", thrust_to_weight: 6020000), landing_legs: LandingLegs(number: 22, material: "Iron"), payload_weights: [PayloadWeight(id: "57682", kg: 800220, lb: 200220)], flickr_images: ["https://fastly.picsum.photos/id/864/200/300.jpg?hmac=pHxnt4rXpNHIqBRpVSe-yL_pDtdwDfasgfub8GwI5mw", "https://fastly.picsum.photos/id/950/200/300.jpg?hmac=EEKbkKLpjWodOy9F68WA1hJkukq9UBUCIREC8fDW44U"], name: "Przyjaciel Bobr", type: "Runnning", active: true, stages: 22, boosters: 4, cost_per_launch: 90000000, success_rate_pct: 100, first_flight: "6th of September 2016", country: "Poland", company: "Bobr Enterprises", wikipedia: "none", description: "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam nec sem vestibulum, lobortis mauris non, malesuada sem. Phasellus eget velit suscipit, blandit mauris a, convallis leo. Morbi at pulvinar elit. Nulla facilisi. Pellentesque pharetra neque mauris, a tristique diam maximus quis. Nullam volutpat lacus metus, et porttitor mi dignissim id. Sed facilisis sit amet nunc et lacinia. Suspendisse semper metus ac felis facilisis ultricies. Donec non lacus vitae tellus malesuada tempus. Phasellus imperdiet mauris at aliquam convallis.", id: "54679") + ], nil) + } + func getRocketList () -> RocketList { + return RocketList(height: Height(meters: 20000,feet: 2000000), diameter: Diameter(meters: 200000,feet: 7055555), mass: Mass(kg: 800000,lb: 2000), first_stage: FirstStage(thrust_sea_level:ThrustSeaLevel(kn: 230, lbf: 1500),thrust_vacuum: ThrustVacuum(kn: 160, lbf: 10220), reusable: true, engines: 53, burn_time_sec: 22220), second_stage: SecondStage(burn_time_sec: 80022000), engines: Engines(isp: Isp(sea_level: 80020, vacuum: 720),engine_loss_max: 220,propellant_1: "seven",propellant_2: "three", thrust_to_weight: 6020000), landing_legs: LandingLegs(number: 22, material: "Iron"), payload_weights: [PayloadWeight(id: "57682", kg: 800220, lb: 200220)], flickr_images: ["https://fastly.picsum.photos/id/864/200/300.jpg?hmac=pHxnt4rXpNHIqBRpVSe-yL_pDtdwDfasgfub8GwI5mw", "https://fastly.picsum.photos/id/950/200/300.jpg?hmac=EEKbkKLpjWodOy9F68WA1hJkukq9UBUCIREC8fDW44U"], name: "Przyjaciel Bobr", type: "Runnning", active: true, stages: 22, boosters: 4, cost_per_launch: 90000000, success_rate_pct: 100, first_flight: "6th of September 2016", country: "Poland", company: "Bobr Enterprises", wikipedia: "none", description: "Aliquam erat volutpat. Donec lobortis ultricies libero, nec hendrerit nisi posuere eget. Ut ut erat et urna tristique consectetur ut non lacus. Donec tincidunt vulputate ligula sit amet molestie. Duis eleifend quam sodales eleifend consequat. Vivamus congue maximus sagittis. Etiam ultricies est tellus, a viverra diam egestas nec.", id: "54679") + } +} diff --git a/QuantiSpaceX/AcelerometerGyroscope/AcelerometerGyroscope.swift b/QuantiSpaceX/AcelerometerGyroscope/AcelerometerGyroscope.swift new file mode 100644 index 000000000..282fd88db --- /dev/null +++ b/QuantiSpaceX/AcelerometerGyroscope/AcelerometerGyroscope.swift @@ -0,0 +1,62 @@ +// +// AcelerometerGyroscope.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 27.12.2024. +// + +import Foundation +import CoreMotion + +class AcelerometerGyroscope: ObservableObject { + + let motion = CMMotionManager() + var timer = Timer() + var GyroVar = 0 + var gyroData: CMGyroData? + + func startGyros(completion: @escaping (Bool) -> ()) { + if motion.isGyroAvailable { + self.motion.gyroUpdateInterval = 1.0 / 60.0 + self.motion.startGyroUpdates() + + // Configure a timer to fetch the accelerometer data. + + self.timer = Timer(fire: Date(), interval: (1.0/60.0), + + repeats: true, block: { (timer) in +// Get the gyro data. + if let data = self.motion.gyroData { + let x = data.rotationRate.x + let y = data.rotationRate.y + let z = data.rotationRate.z +// print("gyro works \nx: \(x)\ny: \(y)\nz: \(z)\n") + if x > 1 { + print("X is greater than 1") + completion(true) + } + if y > 1 { + print("Y is greater than 1") + } + if z > 1 { + print("Z is greater than 1") + } + // Use the gyroscope data in your app. + } + }) + + // Add the timer to the current run loop. + RunLoop.current.add(self.timer, forMode: RunLoop.Mode.default) + } + } + + + func stopGyros() { + print("stop") + if self.timer != nil { + self.timer.invalidate() + self.motion.stopGyroUpdates() + } + } + +} diff --git a/QuantiSpaceX/Assets.xcassets/AccentColor.colorset/Contents.json b/QuantiSpaceX/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..eb8789700 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/AppIcon.appiconset/AppIcon.PNG b/QuantiSpaceX/Assets.xcassets/AppIcon.appiconset/AppIcon.PNG new file mode 100644 index 000000000..e84562b7a Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/AppIcon.appiconset/AppIcon.PNG differ diff --git a/QuantiSpaceX/Assets.xcassets/AppIcon.appiconset/Contents.json b/QuantiSpaceX/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d388e03eb --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,14 @@ +{ + "images" : [ + { + "filename" : "AppIcon.PNG", + "idiom" : "universal", + "platform" : "ios", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn.png b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn.png new file mode 100644 index 000000000..74b9053c4 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn.svg b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn.svg new file mode 100644 index 000000000..a6fdf6744 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn.svg @@ -0,0 +1,3 @@ + + + diff --git a/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn@2x.png b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn@2x.png new file mode 100644 index 000000000..ffc767ae9 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn@2x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn@3x.png b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn@3x.png new file mode 100644 index 000000000..a442ee53e Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Burn@3x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Burn.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Contents.json new file mode 100644 index 000000000..c73725304 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Burn.imageset/Contents.json @@ -0,0 +1,29 @@ +{ + "images" : [ + { + "filename" : "Burn.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Burn@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Burn@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "filename" : "Burn.svg", + "idiom" : "universal", + "scale" : "1x", + "unassigned" : true + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Contents.json b/QuantiSpaceX/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Engine.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Contents.json new file mode 100644 index 000000000..78aca26bf --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Contents.json @@ -0,0 +1,29 @@ +{ + "images" : [ + { + "filename" : "Engine.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Engine@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Engine@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "filename" : "Engine.svg", + "idiom" : "universal", + "scale" : "1x", + "unassigned" : true + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine.png b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine.png new file mode 100644 index 000000000..767e39f69 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine.svg b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine.svg new file mode 100644 index 000000000..698a1bdae --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine.svg @@ -0,0 +1,3 @@ + + + diff --git a/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine@2x.png b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine@2x.png new file mode 100644 index 000000000..4dd0bf35e Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine@2x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine@3x.png b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine@3x.png new file mode 100644 index 000000000..994363f98 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Engine.imageset/Engine@3x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Contents.json new file mode 100644 index 000000000..3a96c4057 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Contents.json @@ -0,0 +1,29 @@ +{ + "images" : [ + { + "filename" : "Fuel.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Fuel@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Fuel@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "filename" : "Fuel.svg", + "idiom" : "universal", + "scale" : "1x", + "unassigned" : true + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel.png b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel.png new file mode 100644 index 000000000..640975228 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel.svg b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel.svg new file mode 100644 index 000000000..4b70f96bd --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel@2x.png b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel@2x.png new file mode 100644 index 000000000..70fb205d0 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel@2x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel@3x.png b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel@3x.png new file mode 100644 index 000000000..c5e4b6d63 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Fuel.imageset/Fuel@3x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Contents.json new file mode 100644 index 000000000..86186dc51 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Contents.json @@ -0,0 +1,29 @@ +{ + "images" : [ + { + "filename" : "Reusable.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Reusable@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Reusable@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "filename" : "Reusable.svg", + "idiom" : "universal", + "scale" : "1x", + "unassigned" : true + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable.png b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable.png new file mode 100644 index 000000000..d017686c0 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable.svg b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable.svg new file mode 100644 index 000000000..57a719aa6 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable@2x.png b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable@2x.png new file mode 100644 index 000000000..edc000ec5 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable@2x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable@3x.png b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable@3x.png new file mode 100644 index 000000000..18b15e881 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Reusable.imageset/Reusable@3x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Contents.json new file mode 100644 index 000000000..8278716f7 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Contents.json @@ -0,0 +1,29 @@ +{ + "images" : [ + { + "filename" : "Rocket Flying.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Rocket Flying@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Rocket Flying@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "filename" : "Rocket Flying.svg", + "idiom" : "universal", + "scale" : "1x", + "unassigned" : true + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying.png b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying.png new file mode 100644 index 000000000..a4912c5d0 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying.svg b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying.svg new file mode 100644 index 000000000..e67a55f12 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying@2x.png b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying@2x.png new file mode 100644 index 000000000..b543f04b9 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying@2x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying@3x.png b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying@3x.png new file mode 100644 index 000000000..060f4e0e6 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket Flying.imageset/Rocket Flying@3x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Contents.json new file mode 100644 index 000000000..a0469a339 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Contents.json @@ -0,0 +1,29 @@ +{ + "images" : [ + { + "filename" : "Rocket Idle.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Rocket Idle@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Rocket Idle@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "filename" : "Rocket Idle.svg", + "idiom" : "universal", + "scale" : "1x", + "unassigned" : true + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle.png b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle.png new file mode 100644 index 000000000..258b0c669 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle.svg b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle.svg new file mode 100644 index 000000000..d4637f9fe --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle@2x.png b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle@2x.png new file mode 100644 index 000000000..e6e054072 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle@2x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle@3x.png b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle@3x.png new file mode 100644 index 000000000..e82c14ce1 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket Idle.imageset/Rocket Idle@3x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Contents.json new file mode 100644 index 000000000..e5ab3ce2d --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Contents.json @@ -0,0 +1,29 @@ +{ + "images" : [ + { + "filename" : "Rocket.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Rocket@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Rocket@3x.png", + "idiom" : "universal", + "scale" : "3x" + }, + { + "filename" : "Rocket.svg", + "idiom" : "universal", + "scale" : "1x", + "unassigned" : true + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket.png b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket.png new file mode 100644 index 000000000..f3d4129b8 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket.svg b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket.svg new file mode 100644 index 000000000..9dd9228b5 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket@2x.png b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket@2x.png new file mode 100644 index 000000000..9647e3306 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket@2x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket@3x.png b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket@3x.png new file mode 100644 index 000000000..514bd9785 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/Rocket.imageset/Rocket@3x.png differ diff --git a/QuantiSpaceX/Assets.xcassets/rocketError.imageset/Contents.json b/QuantiSpaceX/Assets.xcassets/rocketError.imageset/Contents.json new file mode 100644 index 000000000..3c34f39c6 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/rocketError.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "rocketError.PNG", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/rocketError.imageset/rocketError.PNG b/QuantiSpaceX/Assets.xcassets/rocketError.imageset/rocketError.PNG new file mode 100644 index 000000000..1854c1850 Binary files /dev/null and b/QuantiSpaceX/Assets.xcassets/rocketError.imageset/rocketError.PNG differ diff --git a/QuantiSpaceX/Assets.xcassets/rocketPink.colorset/Contents.json b/QuantiSpaceX/Assets.xcassets/rocketPink.colorset/Contents.json new file mode 100644 index 000000000..65ae7e3a3 --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/rocketPink.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "112", + "green" : "54", + "red" : "236" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Assets.xcassets/smokewhite.colorset/Contents.json b/QuantiSpaceX/Assets.xcassets/smokewhite.colorset/Contents.json new file mode 100644 index 000000000..7f8b3705b --- /dev/null +++ b/QuantiSpaceX/Assets.xcassets/smokewhite.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF5", + "green" : "0xF5", + "red" : "0xF5" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "23", + "green" : "21", + "red" : "21" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/QuantiSpaceX/Helpers/QuantiSpaceXError.swift b/QuantiSpaceX/Helpers/QuantiSpaceXError.swift new file mode 100644 index 000000000..25daa4a53 --- /dev/null +++ b/QuantiSpaceX/Helpers/QuantiSpaceXError.swift @@ -0,0 +1,20 @@ +// +// QuantiSpaceXError.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 27.12.2024. +// + +import Foundation + +enum QuantiSpaceXError: LocalizedError, Equatable { + + case unknown + + var errorDescription: String? { + switch self { + case .unknown: return "Unknown error has occured." + } + } + +} diff --git a/QuantiSpaceX/Info.plist b/QuantiSpaceX/Info.plist new file mode 100644 index 000000000..ede6aa67f --- /dev/null +++ b/QuantiSpaceX/Info.plist @@ -0,0 +1,10 @@ + + + + + INIntentsSupported + + Intent + + + diff --git a/QuantiSpaceX/Localizable/Localizable.xcstrings b/QuantiSpaceX/Localizable/Localizable.xcstrings new file mode 100644 index 000000000..ff7fc0c1d --- /dev/null +++ b/QuantiSpaceX/Localizable/Localizable.xcstrings @@ -0,0 +1,120 @@ +{ + "sourceLanguage" : "en", + "strings" : { + "%@ second%@ burn time" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "%1$@ sekund čas spalování" + } + }, + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "%1$@ second%2$@ burn time" + } + } + } + }, + "%@ ton%@ of fuel" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "%1$@ tun paliva" + } + }, + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "%1$@ ton%2$@ of fuel" + } + } + } + }, + "%lld engine%@" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "%1$lld motor%2$@" + } + }, + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "%1$lld engine%2$@" + } + } + } + }, + "first flight: %@" : { + + }, + "Launch" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Vyslat" + } + } + } + }, + "Launch succesful!" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Odpálení bylo úspěšné!" + } + } + } + }, + "Move your phone up\nto launch the rocket" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Pohněte s telefonem nahoru, aby raketa odletěla" + } + } + } + }, + "Overview" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Přehled" + } + } + } + }, + "Parameters" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Parametry" + } + } + } + }, + "Photos" : { + "localizations" : { + "cs" : { + "stringUnit" : { + "state" : "translated", + "value" : "Fotografie" + } + } + } + }, + "Rockets" : { + + } + }, + "version" : "1.0" +} \ No newline at end of file diff --git a/QuantiSpaceX/MainViewModel/MainViewModel.swift b/QuantiSpaceX/MainViewModel/MainViewModel.swift new file mode 100644 index 000000000..d2005e6e4 --- /dev/null +++ b/QuantiSpaceX/MainViewModel/MainViewModel.swift @@ -0,0 +1,29 @@ +// +// MainViewModel.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 26.12.2024. +// + +import Foundation + +class MainViewModel: ObservableObject { + + @Published var rocketModel = RocketModel() + @Published var currentRocketDetailList: RocketList? + + var apiClient: APIClientProtocol + + init( apiClient: APIClientProtocol) { + self.apiClient = apiClient + self.downloadRocketsData() + } + + func downloadRocketsData(completion: (()->())? = nil) { + apiClient.getAllRockets() { allRockets, error in + self.rocketModel.rocketList = allRockets + + } + } + +} diff --git a/QuantiSpaceX/Navigation/Header.swift b/QuantiSpaceX/Navigation/Header.swift new file mode 100644 index 000000000..f587c0b6b --- /dev/null +++ b/QuantiSpaceX/Navigation/Header.swift @@ -0,0 +1,51 @@ +// +// File.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 20.02.2025. +// + +import SwiftUI + +struct Header: View { + @EnvironmentObject var navigationStateViewModel: NavigationStateViewModel + var headerTitle: String + var backToView: DifferentViews = .HomeView + var showLaunchButton: Bool = true + var backText: String = "Rockets" + + var body: some View { + VStack { + ZStack { + ZStack { + HStack (spacing: 0) { + Image(systemName: "chevron.backward") + .font(.system(size: 25)) + .fontWeight(.medium) + + Text(backText) + } + }.padding(.leading, 20) + .foregroundStyle(.link) + .onTapGesture { + navigationStateViewModel.onViewChanged(newView: backToView) + } + Spacer() + HStack { + Text(headerTitle) + } + Spacer() + if showLaunchButton { + HStack { + Text("Launch") + }.padding(.trailing, 20) + .foregroundStyle(.link) + .onTapGesture { + navigationStateViewModel.onViewChanged(newView: .LaunchView) + } + } + + }.padding() + }.background(Color.init(.systemGray6)) + } +} diff --git a/QuantiSpaceX/Navigation/NavigationStateViewModel.swift b/QuantiSpaceX/Navigation/NavigationStateViewModel.swift new file mode 100644 index 000000000..737a87853 --- /dev/null +++ b/QuantiSpaceX/Navigation/NavigationStateViewModel.swift @@ -0,0 +1,22 @@ +// +// NavigationStateViewModel.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 20.02.2025. +// + +import Foundation + +class NavigationStateViewModel: ObservableObject { + @Published var currentView = DifferentViews.HomeView + + func onViewChanged(newView: DifferentViews) { + self.currentView = newView + } +} + +enum DifferentViews { + case HomeView + case DetailView + case LaunchView +} diff --git a/QuantiSpaceX/Navigation/NavigationView.swift b/QuantiSpaceX/Navigation/NavigationView.swift new file mode 100644 index 000000000..457ca541c --- /dev/null +++ b/QuantiSpaceX/Navigation/NavigationView.swift @@ -0,0 +1,37 @@ +// +// MainView.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 26.12.2024. +// + +import SwiftUI + +struct NavigationView: View { + @EnvironmentObject var navigationStateViewModel: NavigationStateViewModel + @ObservedObject var viewModel: MainViewModel + + init( + viewModel: MainViewModel + ) { + self.viewModel = viewModel + } + + var body: some View { + ZStack(alignment: .leading) { + switch navigationStateViewModel.currentView { + case .HomeView: + RocketListView(viewModel: viewModel) + case .DetailView: + if let rocketListData = viewModel.currentRocketDetailList { + RocketDetailView(rocketList: rocketListData) + } else { + ProgressView() + } + case .LaunchView: + RocketLaunchView() + } + } + } +} + diff --git a/QuantiSpaceX/NetworkMonitor/NetworkMonitor.swift b/QuantiSpaceX/NetworkMonitor/NetworkMonitor.swift new file mode 100644 index 000000000..2c94895c3 --- /dev/null +++ b/QuantiSpaceX/NetworkMonitor/NetworkMonitor.swift @@ -0,0 +1,66 @@ +// +// NetworkMonitor.swift +// QuantiSpaceX +// +// Created by Petr Žáček on 27.12.2024. +// + +import Foundation +import Network +import SwiftUI + +enum NetworkStatus { + case online + case offline +} + +class NetworkMonitor: ObservableObject { + + // Singleton access + static let shared = NetworkMonitor() + + private let monitor: NWPathMonitor + private var callbacks: [Int: (Bool) -> ()] = [:] + @Published private(set) var wasOnline = false + @Published private(set) var currentStatus: NetworkStatus = .offline + + private init() { + monitor = NWPathMonitor() + monitor.pathUpdateHandler = { path in + if path.status == .satisfied { + print("We are online") + self.wasOnline = true + self.currentStatus = .online + self.performWaitingCallbacks() + } else { + print("We are offline") + self.currentStatus = .offline + } + } + monitor.start(queue: DispatchQueue.main) + } + + private func performWaitingCallbacks() { + callbacks.keys.forEach { id in + self.callbacks[id]?(true) + self.callbacks.removeValue(forKey: id) + } + } + + func performWhenNetworkIsAvailable( + _ block: @escaping (Bool) -> (), + timeout: TimeInterval = 30.0 + ) { + if self.currentStatus == .online { + block(true) + } else { + let randomId = Int.random(in: Int.min..