diff --git a/.gitignore b/.gitignore index 02c0875..7962b20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,48 @@ .DS_Store -/.build -/Packages -/*.xcodeproj +.Trashes +*.swp +*~.nib +DerivedData/ +build/ + +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore +Index + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +.build/ \ No newline at end of file diff --git a/PureExample/PureExample.xcodeproj/project.pbxproj b/PureExample/PureExample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..47028ef --- /dev/null +++ b/PureExample/PureExample.xcodeproj/project.pbxproj @@ -0,0 +1,485 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 3556F58523FDC36600C775E1 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3556F58423FDC36600C775E1 /* AppDelegate.swift */; }; + 3556F58723FDC36600C775E1 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3556F58623FDC36600C775E1 /* SceneDelegate.swift */; }; + 3556F58C23FDC36600C775E1 /* ListViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3556F58A23FDC36600C775E1 /* ListViewController.storyboard */; }; + 3556F58E23FDC36700C775E1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3556F58D23FDC36700C775E1 /* Assets.xcassets */; }; + 3556F59123FDC36700C775E1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3556F58F23FDC36700C775E1 /* LaunchScreen.storyboard */; }; + 3556F59A23FDC4B400C775E1 /* StoryboardLoadable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3556F59923FDC4B400C775E1 /* StoryboardLoadable.swift */; }; + 3556F59D23FDC4ED00C775E1 /* ListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3556F59C23FDC4ED00C775E1 /* ListViewController.swift */; }; + 356EC33F23FE8A0F00A63CB8 /* AppDependency.swift in Sources */ = {isa = PBXBuildFile; fileRef = 356EC33E23FE8A0F00A63CB8 /* AppDependency.swift */; }; + 356EC34323FE8A8800A63CB8 /* RemoteNotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 356EC34223FE8A8800A63CB8 /* RemoteNotificationService.swift */; }; + 356EC34523FE8AA700A63CB8 /* Networking.swift in Sources */ = {isa = PBXBuildFile; fileRef = 356EC34423FE8AA700A63CB8 /* Networking.swift */; }; + 3585C06C23FE9F9C005FC01A /* DetailViewController.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3585C06B23FE9F9C005FC01A /* DetailViewController.storyboard */; }; + 3585C06E23FE9FA7005FC01A /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3585C06D23FE9FA7005FC01A /* DetailViewController.swift */; }; + 3585C07023FEA010005FC01A /* Item.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3585C06F23FEA010005FC01A /* Item.swift */; }; + 35D1C53723FECE5D00BEC341 /* ImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35D1C53523FECE5C00BEC341 /* ImageCell.swift */; }; + 35D1C53823FECE5D00BEC341 /* ImageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 35D1C53623FECE5C00BEC341 /* ImageCell.xib */; }; + 35D1C53A23FECEAA00BEC341 /* ImageDownloaderType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35D1C53923FECEAA00BEC341 /* ImageDownloaderType.swift */; }; + 35D1C54123FED90300BEC341 /* ItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35D1C53F23FED90300BEC341 /* ItemCell.swift */; }; + 35D1C54223FED90300BEC341 /* ItemCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 35D1C54023FED90300BEC341 /* ItemCell.xib */; }; + 35D6A0A823FF2DF1006837D0 /* Pure in Frameworks */ = {isa = PBXBuildFile; productRef = 35D6A0A723FF2DF1006837D0 /* Pure */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 3556F58123FDC36600C775E1 /* PureExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PureExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 3556F58423FDC36600C775E1 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 3556F58623FDC36600C775E1 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 3556F58B23FDC36600C775E1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/ListViewController.storyboard; sourceTree = ""; }; + 3556F58D23FDC36700C775E1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 3556F59023FDC36700C775E1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 3556F59223FDC36700C775E1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3556F59923FDC4B400C775E1 /* StoryboardLoadable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryboardLoadable.swift; sourceTree = ""; }; + 3556F59C23FDC4ED00C775E1 /* ListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListViewController.swift; sourceTree = ""; }; + 356EC33E23FE8A0F00A63CB8 /* AppDependency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDependency.swift; sourceTree = ""; }; + 356EC34223FE8A8800A63CB8 /* RemoteNotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemoteNotificationService.swift; sourceTree = ""; }; + 356EC34423FE8AA700A63CB8 /* Networking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Networking.swift; sourceTree = ""; }; + 3585C06B23FE9F9C005FC01A /* DetailViewController.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = DetailViewController.storyboard; sourceTree = ""; }; + 3585C06D23FE9FA7005FC01A /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; + 3585C06F23FEA010005FC01A /* Item.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Item.swift; sourceTree = ""; }; + 35D1C53523FECE5C00BEC341 /* ImageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageCell.swift; sourceTree = ""; }; + 35D1C53623FECE5C00BEC341 /* ImageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ImageCell.xib; sourceTree = ""; }; + 35D1C53923FECEAA00BEC341 /* ImageDownloaderType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageDownloaderType.swift; sourceTree = ""; }; + 35D1C53F23FED90300BEC341 /* ItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemCell.swift; sourceTree = ""; }; + 35D1C54023FED90300BEC341 /* ItemCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ItemCell.xib; sourceTree = ""; }; + 35D6A0A523FF2DA8006837D0 /* Pure */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Pure; path = ..; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3556F57E23FDC36600C775E1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 35D6A0A823FF2DF1006837D0 /* Pure in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3556F57823FDC36600C775E1 = { + isa = PBXGroup; + children = ( + 35D6A0A523FF2DA8006837D0 /* Pure */, + 3556F58323FDC36600C775E1 /* PureExample */, + 3556F58223FDC36600C775E1 /* Products */, + 35D6A0A623FF2DF1006837D0 /* Frameworks */, + ); + sourceTree = ""; + }; + 3556F58223FDC36600C775E1 /* Products */ = { + isa = PBXGroup; + children = ( + 3556F58123FDC36600C775E1 /* PureExample.app */, + ); + name = Products; + sourceTree = ""; + }; + 3556F58323FDC36600C775E1 /* PureExample */ = { + isa = PBXGroup; + children = ( + 35D1C53223FECDE800BEC341 /* Views */, + 356EC34723FE8B0000A63CB8 /* Resources */, + 356EC34623FE8AF600A63CB8 /* Main */, + 356EC33D23FE89F800A63CB8 /* Services */, + 356EC33C23FE89E300A63CB8 /* Models */, + 3556F59B23FDC4DE00C775E1 /* ViewControllers */, + 3556F59823FDC4A000C775E1 /* Protocols */, + ); + path = PureExample; + sourceTree = ""; + }; + 3556F59823FDC4A000C775E1 /* Protocols */ = { + isa = PBXGroup; + children = ( + 3556F59923FDC4B400C775E1 /* StoryboardLoadable.swift */, + 35D1C53923FECEAA00BEC341 /* ImageDownloaderType.swift */, + ); + path = Protocols; + sourceTree = ""; + }; + 3556F59B23FDC4DE00C775E1 /* ViewControllers */ = { + isa = PBXGroup; + children = ( + 3585C07223FEA092005FC01A /* DetailViewController */, + 3585C07123FEA083005FC01A /* ListViewController */, + ); + path = ViewControllers; + sourceTree = ""; + }; + 356EC33C23FE89E300A63CB8 /* Models */ = { + isa = PBXGroup; + children = ( + 356EC33E23FE8A0F00A63CB8 /* AppDependency.swift */, + 3585C06F23FEA010005FC01A /* Item.swift */, + ); + path = Models; + sourceTree = ""; + }; + 356EC33D23FE89F800A63CB8 /* Services */ = { + isa = PBXGroup; + children = ( + 356EC34223FE8A8800A63CB8 /* RemoteNotificationService.swift */, + 356EC34423FE8AA700A63CB8 /* Networking.swift */, + ); + path = Services; + sourceTree = ""; + }; + 356EC34623FE8AF600A63CB8 /* Main */ = { + isa = PBXGroup; + children = ( + 3556F58423FDC36600C775E1 /* AppDelegate.swift */, + 3556F58623FDC36600C775E1 /* SceneDelegate.swift */, + ); + path = Main; + sourceTree = ""; + }; + 356EC34723FE8B0000A63CB8 /* Resources */ = { + isa = PBXGroup; + children = ( + 3556F58D23FDC36700C775E1 /* Assets.xcassets */, + 3556F58F23FDC36700C775E1 /* LaunchScreen.storyboard */, + 3556F59223FDC36700C775E1 /* Info.plist */, + ); + path = Resources; + sourceTree = ""; + }; + 3585C07123FEA083005FC01A /* ListViewController */ = { + isa = PBXGroup; + children = ( + 3556F58A23FDC36600C775E1 /* ListViewController.storyboard */, + 3556F59C23FDC4ED00C775E1 /* ListViewController.swift */, + ); + path = ListViewController; + sourceTree = ""; + }; + 3585C07223FEA092005FC01A /* DetailViewController */ = { + isa = PBXGroup; + children = ( + 3585C06B23FE9F9C005FC01A /* DetailViewController.storyboard */, + 3585C06D23FE9FA7005FC01A /* DetailViewController.swift */, + ); + path = DetailViewController; + sourceTree = ""; + }; + 35D1C53223FECDE800BEC341 /* Views */ = { + isa = PBXGroup; + children = ( + 35D1C53523FECE5C00BEC341 /* ImageCell.swift */, + 35D1C53623FECE5C00BEC341 /* ImageCell.xib */, + 35D1C53F23FED90300BEC341 /* ItemCell.swift */, + 35D1C54023FED90300BEC341 /* ItemCell.xib */, + ); + path = Views; + sourceTree = ""; + }; + 35D6A0A623FF2DF1006837D0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3556F58023FDC36600C775E1 /* PureExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3556F59523FDC36700C775E1 /* Build configuration list for PBXNativeTarget "PureExample" */; + buildPhases = ( + 3556F57D23FDC36600C775E1 /* Sources */, + 3556F57E23FDC36600C775E1 /* Frameworks */, + 3556F57F23FDC36600C775E1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PureExample; + packageProductDependencies = ( + 35D6A0A723FF2DF1006837D0 /* Pure */, + ); + productName = PureExample; + productReference = 3556F58123FDC36600C775E1 /* PureExample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3556F57923FDC36600C775E1 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1130; + LastUpgradeCheck = 1130; + ORGANIZATIONNAME = plum; + TargetAttributes = { + 3556F58023FDC36600C775E1 = { + CreatedOnToolsVersion = 11.3.1; + }; + }; + }; + buildConfigurationList = 3556F57C23FDC36600C775E1 /* Build configuration list for PBXProject "PureExample" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 3556F57823FDC36600C775E1; + packageReferences = ( + ); + productRefGroup = 3556F58223FDC36600C775E1 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3556F58023FDC36600C775E1 /* PureExample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3556F57F23FDC36600C775E1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3585C06C23FE9F9C005FC01A /* DetailViewController.storyboard in Resources */, + 3556F59123FDC36700C775E1 /* LaunchScreen.storyboard in Resources */, + 35D1C54223FED90300BEC341 /* ItemCell.xib in Resources */, + 35D1C53823FECE5D00BEC341 /* ImageCell.xib in Resources */, + 3556F58E23FDC36700C775E1 /* Assets.xcassets in Resources */, + 3556F58C23FDC36600C775E1 /* ListViewController.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3556F57D23FDC36600C775E1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 35D1C54123FED90300BEC341 /* ItemCell.swift in Sources */, + 356EC34323FE8A8800A63CB8 /* RemoteNotificationService.swift in Sources */, + 3585C07023FEA010005FC01A /* Item.swift in Sources */, + 3556F59A23FDC4B400C775E1 /* StoryboardLoadable.swift in Sources */, + 356EC33F23FE8A0F00A63CB8 /* AppDependency.swift in Sources */, + 35D1C53723FECE5D00BEC341 /* ImageCell.swift in Sources */, + 35D1C53A23FECEAA00BEC341 /* ImageDownloaderType.swift in Sources */, + 3556F58523FDC36600C775E1 /* AppDelegate.swift in Sources */, + 3556F59D23FDC4ED00C775E1 /* ListViewController.swift in Sources */, + 3556F58723FDC36600C775E1 /* SceneDelegate.swift in Sources */, + 356EC34523FE8AA700A63CB8 /* Networking.swift in Sources */, + 3585C06E23FE9FA7005FC01A /* DetailViewController.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 3556F58A23FDC36600C775E1 /* ListViewController.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3556F58B23FDC36600C775E1 /* Base */, + ); + name = ListViewController.storyboard; + sourceTree = ""; + }; + 3556F58F23FDC36700C775E1 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3556F59023FDC36700C775E1 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3556F59323FDC36700C775E1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 3556F59423FDC36700C775E1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 3556F59623FDC36700C775E1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = PureExample/Resources/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.plum.PureExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 3556F59723FDC36700C775E1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = PureExample/Resources/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.plum.PureExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3556F57C23FDC36600C775E1 /* Build configuration list for PBXProject "PureExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3556F59323FDC36700C775E1 /* Debug */, + 3556F59423FDC36700C775E1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3556F59523FDC36700C775E1 /* Build configuration list for PBXNativeTarget "PureExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3556F59623FDC36700C775E1 /* Debug */, + 3556F59723FDC36700C775E1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 35D6A0A723FF2DF1006837D0 /* Pure */ = { + isa = XCSwiftPackageProductDependency; + productName = Pure; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 3556F57923FDC36600C775E1 /* Project object */; +} diff --git a/PureExample/PureExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/PureExample/PureExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/PureExample/PureExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/PureExample/PureExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/PureExample/PureExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/PureExample/PureExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/PureExample/PureExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/PureExample/PureExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..6957b03 --- /dev/null +++ b/PureExample/PureExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,43 @@ +{ + "object": { + "pins": [ + { + "package": "CwlCatchException", + "repositoryURL": "https://github.com/mattgallagher/CwlCatchException.git", + "state": { + "branch": null, + "revision": "f809deb30dc5c9d9b78c872e553261a61177721a", + "version": "2.0.0" + } + }, + { + "package": "CwlPreconditionTesting", + "repositoryURL": "https://github.com/mattgallagher/CwlPreconditionTesting.git", + "state": { + "branch": null, + "revision": "ea422878db4e680069af320ac444183628360ab1", + "version": "2.0.0-beta.1" + } + }, + { + "package": "Nimble", + "repositoryURL": "https://github.com/Quick/Nimble.git", + "state": { + "branch": null, + "revision": "fc3cd1adf6961a3541679342d64fbbfd7a9f4ca7", + "version": null + } + }, + { + "package": "Quick", + "repositoryURL": "https://github.com/Quick/Quick.git", + "state": { + "branch": null, + "revision": "33682c2f6230c60614861dfc61df267e11a1602f", + "version": "2.2.0" + } + } + ] + }, + "version": 1 +} diff --git a/PureExample/PureExample/Main/AppDelegate.swift b/PureExample/PureExample/Main/AppDelegate.swift new file mode 100644 index 0000000..4008460 --- /dev/null +++ b/PureExample/PureExample/Main/AppDelegate.swift @@ -0,0 +1,32 @@ +// +// AppDelegate.swift +// PureExample +// +// Created by Łukasz Śliwiński on 19/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit +import UserNotifications + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + let dependency: AppDependency + + /// Called from the system (it's private: not accessible in the testing environment) + private override init() { + self.dependency = AppDependency.resolve() + super.init() + } + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } +} diff --git a/PureExample/PureExample/Main/SceneDelegate.swift b/PureExample/PureExample/Main/SceneDelegate.swift new file mode 100644 index 0000000..adfc0e8 --- /dev/null +++ b/PureExample/PureExample/Main/SceneDelegate.swift @@ -0,0 +1,33 @@ +// +// SceneDelegate.swift +// PureExample +// +// Created by Łukasz Śliwiński on 19/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + private var appDelegate: AppDelegate { + return UIApplication.shared.delegate as! AppDelegate + } + + var window: UIWindow? + + func scene( + _ scene: UIScene, + willConnectTo session: UISceneSession, + options connectionOptions: UIScene.ConnectionOptions + ) { + guard let scene = (scene as? UIWindowScene) else { return } + + self.window = UIWindow(windowScene: scene) + guard let window = self.window else { return } + + let factory = appDelegate.dependency.listViewControllerFactory + window.rootViewController = factory.create() + window.makeKeyAndVisible() + } +} diff --git a/PureExample/PureExample/Models/AppDependency.swift b/PureExample/PureExample/Models/AppDependency.swift new file mode 100644 index 0000000..5df7ca8 --- /dev/null +++ b/PureExample/PureExample/Models/AppDependency.swift @@ -0,0 +1,103 @@ +// +// AppDependency.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit +import UserNotifications +import Pure + +struct AppDependency { + let networking: Networking + let remoteNotificationService: RemoteNotificationService + let listViewControllerFactory: ListViewController.Factory +} + +extension AppDependency { + + static func resolve() -> AppDependency { + let networking = Networking() + let remoteNotificationService = RemoteNotificationService( + notificationCenter: UNUserNotificationCenter.current() + ) + + return AppDependency( + networking: networking, + remoteNotificationService: remoteNotificationService, + listViewControllerFactory: ListViewController.Factory( + dependency: .init( + networking: networking, + notificationsService: remoteNotificationService, + factory: DetailViewController.Factory( + dependency: .init( + networking: networking, + imageCellConfigurator: ImageCell.Configurator() + ) + ) + ) + ) + ) + } +} + +// MARK: - Pure Factory Module - + +// MARK: - ListViewController - + +extension ListViewController: FactoryModule { + struct Dependency { + let networking: Networking + let notificationsService: RemoteNotificationService + let factory: DetailViewController.Factory + } +} + +extension Factory where Module == ListViewController { + + func create() -> ListViewController { + let module = ListViewController.loadFromStoryboard() + module.networking = dependency.networking + module.notificationsService = dependency.notificationsService + module.factory = dependency.factory + return module + } +} + +// MARK: - DetailViewController - + +extension DetailViewController: FactoryModule { + struct Dependency { + let networking: Networking + let imageCellConfigurator: ImageCell.Configurator + } + + struct Payload { + let selectedItem: Item + } +} + +extension Factory where Module == DetailViewController { + + func create(payload: DetailViewController.Payload) -> DetailViewController { + let vc = DetailViewController.loadFromStoryboard() + vc.networking = dependency.networking + vc.imageCellConfigurator = dependency.imageCellConfigurator + vc.item = payload.selectedItem + return vc + } +} + +// MARK: - ImageCell - + +extension ImageCell: ConfiguratorModule { + struct Payload { + let image: UIImage + } + + func configure(dependency: Void, payload: ImageCell.Payload) { + self.imageView.image = payload.image + } +} diff --git a/PureExample/PureExample/Models/Item.swift b/PureExample/PureExample/Models/Item.swift new file mode 100644 index 0000000..9a17a6a --- /dev/null +++ b/PureExample/PureExample/Models/Item.swift @@ -0,0 +1,13 @@ +// +// Item.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import Foundation + +struct Item { + let name: String +} diff --git a/PureExample/PureExample/Protocols/ImageDownloaderType.swift b/PureExample/PureExample/Protocols/ImageDownloaderType.swift new file mode 100644 index 0000000..6a9d5bf --- /dev/null +++ b/PureExample/PureExample/Protocols/ImageDownloaderType.swift @@ -0,0 +1,13 @@ +// +// ImageDownloaderType.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import Foundation + +protocol ImageDownloaderType { + +} diff --git a/PureExample/PureExample/Protocols/StoryboardLoadable.swift b/PureExample/PureExample/Protocols/StoryboardLoadable.swift new file mode 100644 index 0000000..b1abbae --- /dev/null +++ b/PureExample/PureExample/Protocols/StoryboardLoadable.swift @@ -0,0 +1,31 @@ +// +// StoryboardLoadable.swift +// PureExample +// +// Created by Łukasz Śliwiński on 19/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit + +protocol StoryboardLoadable: class { + static var storyboardName: String { get } + static var controllerId: String { get } +} + +extension StoryboardLoadable where Self: UIViewController { + + static var storyboardName: String { + return String(describing: Self.self) + } + + static var controllerId: String { + return String(describing: Self.self) + } + + static func loadFromStoryboard() -> Self { + let bundle = Bundle(for: Self.self) + let storyboard = UIStoryboard(name: Self.storyboardName, bundle: bundle) + return storyboard.instantiateViewController(withIdentifier: Self.controllerId) as! Self + } +} diff --git a/PureExample/PureExample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d8db8d6 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_1.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_1.imageset/Contents.json new file mode 100644 index 0000000..a95398d --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_1.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_1.imageset/image_1.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_1.imageset/image_1.jpeg new file mode 100644 index 0000000..07abeed Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_1.imageset/image_1.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_10.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_10.imageset/Contents.json new file mode 100644 index 0000000..2633149 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_10.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_10.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_10.imageset/image_10.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_10.imageset/image_10.jpeg new file mode 100644 index 0000000..d4977eb Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_10.imageset/image_10.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_2.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_2.imageset/Contents.json new file mode 100644 index 0000000..a9d9523 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_2.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_2.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_2.imageset/image_2.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_2.imageset/image_2.jpeg new file mode 100644 index 0000000..aceeb18 Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_2.imageset/image_2.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_3.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_3.imageset/Contents.json new file mode 100644 index 0000000..5eab80f --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_3.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_3.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_3.imageset/image_3.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_3.imageset/image_3.jpeg new file mode 100644 index 0000000..6aafb7f Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_3.imageset/image_3.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_4.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_4.imageset/Contents.json new file mode 100644 index 0000000..3ea34a9 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_4.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_4.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_4.imageset/image_4.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_4.imageset/image_4.jpeg new file mode 100644 index 0000000..f98598c Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_4.imageset/image_4.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_5.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_5.imageset/Contents.json new file mode 100644 index 0000000..e8fb9a2 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_5.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_5.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_5.imageset/image_5.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_5.imageset/image_5.jpeg new file mode 100644 index 0000000..736c30a Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_5.imageset/image_5.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_6.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_6.imageset/Contents.json new file mode 100644 index 0000000..da8caca --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_6.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_6.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_6.imageset/image_6.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_6.imageset/image_6.jpeg new file mode 100644 index 0000000..19d21a1 Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_6.imageset/image_6.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_7.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_7.imageset/Contents.json new file mode 100644 index 0000000..b34a6eb --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_7.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_7.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_7.imageset/image_7.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_7.imageset/image_7.jpeg new file mode 100644 index 0000000..5eff31c Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_7.imageset/image_7.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_8.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_8.imageset/Contents.json new file mode 100644 index 0000000..9549103 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_8.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_8.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_8.imageset/image_8.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_8.imageset/image_8.jpeg new file mode 100644 index 0000000..0f1cbb2 Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_8.imageset/image_8.jpeg differ diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_9.imageset/Contents.json b/PureExample/PureExample/Resources/Assets.xcassets/image_9.imageset/Contents.json new file mode 100644 index 0000000..828fc08 --- /dev/null +++ b/PureExample/PureExample/Resources/Assets.xcassets/image_9.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "image_9.jpeg", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/PureExample/PureExample/Resources/Assets.xcassets/image_9.imageset/image_9.jpeg b/PureExample/PureExample/Resources/Assets.xcassets/image_9.imageset/image_9.jpeg new file mode 100644 index 0000000..dbd47bd Binary files /dev/null and b/PureExample/PureExample/Resources/Assets.xcassets/image_9.imageset/image_9.jpeg differ diff --git a/PureExample/PureExample/Resources/Base.lproj/LaunchScreen.storyboard b/PureExample/PureExample/Resources/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/PureExample/PureExample/Resources/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PureExample/PureExample/Resources/Info.plist b/PureExample/PureExample/Resources/Info.plist new file mode 100644 index 0000000..9742bf0 --- /dev/null +++ b/PureExample/PureExample/Resources/Info.plist @@ -0,0 +1,60 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + + + + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/PureExample/PureExample/Services/File.swift b/PureExample/PureExample/Services/File.swift new file mode 100644 index 0000000..fc6bd28 --- /dev/null +++ b/PureExample/PureExample/Services/File.swift @@ -0,0 +1,9 @@ +// +// File.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import Foundation diff --git a/PureExample/PureExample/Services/Networking.swift b/PureExample/PureExample/Services/Networking.swift new file mode 100644 index 0000000..6b051d3 --- /dev/null +++ b/PureExample/PureExample/Services/Networking.swift @@ -0,0 +1,33 @@ +// +// Networking.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit + +final class Networking { + + func loadItems(completion: @escaping ([Item]) -> Void) { + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) { + let items = (0..<10).map({ (index) in + Item(name: "Item \(index)") + }) + completion(items) + } + } + + func loadImages(for item: Item, completion: @escaping ([UIImage]) -> Void) { + let numberOfImages = Int.random(in: 5...10) + + let images = Array(1.. UIImage in + return UIImage(named: "image_\(index)")! + } + + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) { + completion(images) + } + } +} diff --git a/PureExample/PureExample/Services/RemoteNotificationService.swift b/PureExample/PureExample/Services/RemoteNotificationService.swift new file mode 100644 index 0000000..2edfc2a --- /dev/null +++ b/PureExample/PureExample/Services/RemoteNotificationService.swift @@ -0,0 +1,54 @@ +// +// RemoteNotificationService.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import Foundation +import UserNotifications + +final class RemoteNotificationService: NSObject { + + private let notificationCenter: UNUserNotificationCenter + + init(notificationCenter: UNUserNotificationCenter) { + self.notificationCenter = notificationCenter + super.init() + notificationCenter.delegate = self + } + + func requestAuthorization(completion: @escaping (Result) -> Void) { + notificationCenter.requestAuthorization( + options: [.alert, .sound], + completionHandler: { (granted, error) in + if let error = error { + completion(.failure(error)) + } else { + completion(.success(granted)) + } + }) + } +} + +extension RemoteNotificationService: UNUserNotificationCenterDelegate { + + func userNotificationCenter( + _ center: UNUserNotificationCenter, + didReceive response: UNNotificationResponse, + withCompletionHandler completionHandler: @escaping () -> Void + ) { + print("did receive notification \(response.notification.request.content.userInfo)") + completionHandler() + } + + // When the app in foreground + func userNotificationCenter( + _ center: UNUserNotificationCenter, + willPresent notification: UNNotification, + withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void + ) { + completionHandler([.alert, .sound]) + } +} diff --git a/PureExample/PureExample/ViewControllers/DetailViewController/DetailViewController.storyboard b/PureExample/PureExample/ViewControllers/DetailViewController/DetailViewController.storyboard new file mode 100644 index 0000000..92afc9b --- /dev/null +++ b/PureExample/PureExample/ViewControllers/DetailViewController/DetailViewController.storyboard @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PureExample/PureExample/ViewControllers/DetailViewController/DetailViewController.swift b/PureExample/PureExample/ViewControllers/DetailViewController/DetailViewController.swift new file mode 100644 index 0000000..3b40031 --- /dev/null +++ b/PureExample/PureExample/ViewControllers/DetailViewController/DetailViewController.swift @@ -0,0 +1,89 @@ +// +// DetailViewController.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit + +final class DetailViewController: UIViewController { + + // MARK: - Properties + + var networking: Networking! + var item: Item! + var imageCellConfigurator: ImageCell.Configurator! + var images: [UIImage] = [] + + // MARK: - IBOutlets + + @IBOutlet private weak var collectionView: UICollectionView! + + // MARK: - Life cycle + + override func viewDidLoad() { + super.viewDidLoad() + self.setupCollectionView() + self.loadImages() + } + + // MARK: - Private helpers + + private func setupCollectionView() { + self.collectionView.delegate = self + self.collectionView.dataSource = self + self.collectionView.register(UINib(nibName: "ImageCell", bundle: .main), forCellWithReuseIdentifier: "ImageCell") + + let size = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(1), + heightDimension: .absolute(200.0) + ) + let itemSize = NSCollectionLayoutSize( + widthDimension: .fractionalWidth(0.5), + heightDimension: .absolute(200.0) + ) + let item1 = NSCollectionLayoutItem(layoutSize: itemSize) + let item2 = NSCollectionLayoutItem(layoutSize: itemSize) + let group = NSCollectionLayoutGroup.horizontal(layoutSize: size, subitems: [item1, item2]) + let section = NSCollectionLayoutSection(group: group) + let layout = UICollectionViewCompositionalLayout(section: section) + self.collectionView.collectionViewLayout = layout + } + + private func loadImages() { + self.networking.loadImages(for: self.item, completion: { (images) in + self.images = images + self.collectionView.reloadData() + }) + } +} + +// MARK: - UICollectionViewDelegate - + +extension DetailViewController: UICollectionViewDelegate { + +} + +// MARK: - UICollectionViewDataSource - + +extension DetailViewController: UICollectionViewDataSource { + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return self.images.count + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ImageCell", for: indexPath) as? ImageCell else { + return UICollectionViewCell() + } + let image = self.images[indexPath.row] + self.imageCellConfigurator.configure(cell, payload: .init(image: image)) + return cell + } +} + +// MARK: - StoryboardLoadable - + +extension DetailViewController: StoryboardLoadable {} diff --git a/PureExample/PureExample/ViewControllers/ListViewController/Base.lproj/ListViewController.storyboard b/PureExample/PureExample/ViewControllers/ListViewController/Base.lproj/ListViewController.storyboard new file mode 100644 index 0000000..44fd01e --- /dev/null +++ b/PureExample/PureExample/ViewControllers/ListViewController/Base.lproj/ListViewController.storyboard @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PureExample/PureExample/ViewControllers/ListViewController/ListViewController.swift b/PureExample/PureExample/ViewControllers/ListViewController/ListViewController.swift new file mode 100644 index 0000000..1bfc5dc --- /dev/null +++ b/PureExample/PureExample/ViewControllers/ListViewController/ListViewController.swift @@ -0,0 +1,104 @@ +// +// ListViewController.swift +// PureExample +// +// Created by Łukasz Śliwiński on 19/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit + +final class ListViewController: UIViewController { + + // MARK: - Properties + + var networking: Networking! + var notificationsService: RemoteNotificationService! + var factory: DetailViewController.Factory! + var items: [Item] = [] + + // MARK: - IBOutlets + + @IBOutlet private weak var tableView: UITableView! + + // MARK: Life cycle + + override func viewDidLoad() { + super.viewDidLoad() + self.setupTableView() + self.requestAuthorization() + self.loadItems() + } + + // MARK: - Private Helpers + + private func setupTableView() { + self.tableView.delegate = self + self.tableView.dataSource = self + self.tableView.estimatedRowHeight = 44 + self.tableView.rowHeight = UITableView.automaticDimension + self.tableView.register(UINib(nibName: "ItemCell", bundle: .main), forCellReuseIdentifier: "ItemCell") + } + + private func requestAuthorization() { + self.notificationsService.requestAuthorization { (result) in + switch result { + case .success(let granted): + print("Notifications granted: \(granted)") + case .failure(let error): + print("Notifications authorization error: \(error)") + } + } + } + + private func loadItems() { + self.networking.loadItems { (items) in + self.items = items + self.tableView.reloadData() + } + } + + private func presentItemDetail(_ selectedItem: Item) { + let detailViewController = self.factory.create( + payload: DetailViewController.Payload(selectedItem: selectedItem) + ) + self.present(detailViewController, animated: true) + } +} + +// MARK: - UITableViewDelegate - + +extension ListViewController: UITableViewDelegate { + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let item = self.items[indexPath.row] + self.presentItemDetail(item) + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + return UITableView.automaticDimension + } +} + +// MARK: - UITableViewDataSource - + +extension ListViewController: UITableViewDataSource { + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return self.items.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + guard let cell = tableView.dequeueReusableCell(withIdentifier: "ItemCell", for: indexPath) as? ItemCell else { + return UITableViewCell() + } + let item = items[indexPath.row] + cell.label?.text = item.name + return cell + } +} + + +// MARK: - StoryboardLoadable - + +extension ListViewController: StoryboardLoadable {} diff --git a/PureExample/PureExample/Views/ImageCell.swift b/PureExample/PureExample/Views/ImageCell.swift new file mode 100644 index 0000000..e939a3e --- /dev/null +++ b/PureExample/PureExample/Views/ImageCell.swift @@ -0,0 +1,14 @@ +// +// ImageCell.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit + +final class ImageCell: UICollectionViewCell { + + @IBOutlet weak var imageView: UIImageView! +} diff --git a/PureExample/PureExample/Views/ImageCell.xib b/PureExample/PureExample/Views/ImageCell.xib new file mode 100644 index 0000000..3250910 --- /dev/null +++ b/PureExample/PureExample/Views/ImageCell.xib @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PureExample/PureExample/Views/ItemCell.swift b/PureExample/PureExample/Views/ItemCell.swift new file mode 100644 index 0000000..58f1697 --- /dev/null +++ b/PureExample/PureExample/Views/ItemCell.swift @@ -0,0 +1,13 @@ +// +// ItemCell.swift +// PureExample +// +// Created by Łukasz Śliwiński on 20/02/2020. +// Copyright © 2020 plum. All rights reserved. +// + +import UIKit + +class ItemCell: UITableViewCell { + @IBOutlet weak var label: UILabel! +} diff --git a/PureExample/PureExample/Views/ItemCell.xib b/PureExample/PureExample/Views/ItemCell.xib new file mode 100644 index 0000000..6b19561 --- /dev/null +++ b/PureExample/PureExample/Views/ItemCell.xib @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +