From 8c6f3a45ba92969c0fbca56427cefb1cad732126 Mon Sep 17 00:00:00 2001 From: MUISEROUX Fritzgerald Date: Thu, 26 Jan 2017 00:10:20 +0100 Subject: [PATCH] initial commit --- .gitignore | 1 + CustomLoader.xcodeproj/project.pbxproj | 446 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcschemes/CustomLoader.xcscheme | 101 ++++ CustomLoader/AppDelegate.swift | 46 ++ .../AppIcon.appiconset/Contents.json | 38 ++ .../Base.lproj/LaunchScreen.storyboard | 27 ++ CustomLoader/Base.lproj/Main.storyboard | 50 ++ CustomLoader/Info.plist | 38 ++ CustomLoader/ViewController.swift | 33 ++ CustomLoaderTests/CustomLoaderTests.swift | 36 ++ CustomLoaderTests/Info.plist | 22 + sources/LoadingView.swift | 74 +++ sources/ProgressBoxView.swift | 125 +++++ sources/ProgressRingView.swift | 155 ++++++ 15 files changed, 1199 insertions(+) create mode 100644 .gitignore create mode 100644 CustomLoader.xcodeproj/project.pbxproj create mode 100644 CustomLoader.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 CustomLoader.xcodeproj/xcshareddata/xcschemes/CustomLoader.xcscheme create mode 100644 CustomLoader/AppDelegate.swift create mode 100644 CustomLoader/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 CustomLoader/Base.lproj/LaunchScreen.storyboard create mode 100644 CustomLoader/Base.lproj/Main.storyboard create mode 100644 CustomLoader/Info.plist create mode 100644 CustomLoader/ViewController.swift create mode 100644 CustomLoaderTests/CustomLoaderTests.swift create mode 100644 CustomLoaderTests/Info.plist create mode 100644 sources/LoadingView.swift create mode 100644 sources/ProgressBoxView.swift create mode 100644 sources/ProgressRingView.swift diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c545112 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +xcuserdata/ diff --git a/CustomLoader.xcodeproj/project.pbxproj b/CustomLoader.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a263e1d --- /dev/null +++ b/CustomLoader.xcodeproj/project.pbxproj @@ -0,0 +1,446 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4CFF3DE11E36951A00F8CDBC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF3DE01E36951A00F8CDBC /* AppDelegate.swift */; }; + 4CFF3DE31E36951A00F8CDBC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF3DE21E36951A00F8CDBC /* ViewController.swift */; }; + 4CFF3DE61E36951A00F8CDBC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4CFF3DE41E36951A00F8CDBC /* Main.storyboard */; }; + 4CFF3DE81E36951A00F8CDBC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4CFF3DE71E36951A00F8CDBC /* Assets.xcassets */; }; + 4CFF3DEB1E36951A00F8CDBC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4CFF3DE91E36951A00F8CDBC /* LaunchScreen.storyboard */; }; + 4CFF3DF61E36951A00F8CDBC /* CustomLoaderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF3DF51E36951A00F8CDBC /* CustomLoaderTests.swift */; }; + 4CFF3E021E3695A700F8CDBC /* ProgressRingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF3E011E3695A700F8CDBC /* ProgressRingView.swift */; }; + 4CFF3E041E37331800F8CDBC /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF3E031E37331800F8CDBC /* LoadingView.swift */; }; + 4CFF3E061E37F24E00F8CDBC /* ProgressBoxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF3E051E37F24E00F8CDBC /* ProgressBoxView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 4CFF3DF21E36951A00F8CDBC /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 4CFF3DD51E36951A00F8CDBC /* Project object */; + proxyType = 1; + remoteGlobalIDString = 4CFF3DDC1E36951A00F8CDBC; + remoteInfo = CustomLoader; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 4CFF3DDD1E36951A00F8CDBC /* CustomLoader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CustomLoader.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 4CFF3DE01E36951A00F8CDBC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 4CFF3DE21E36951A00F8CDBC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 4CFF3DE51E36951A00F8CDBC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 4CFF3DE71E36951A00F8CDBC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 4CFF3DEA1E36951A00F8CDBC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 4CFF3DEC1E36951A00F8CDBC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4CFF3DF11E36951A00F8CDBC /* CustomLoaderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CustomLoaderTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 4CFF3DF51E36951A00F8CDBC /* CustomLoaderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomLoaderTests.swift; sourceTree = ""; }; + 4CFF3DF71E36951A00F8CDBC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 4CFF3E011E3695A700F8CDBC /* ProgressRingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressRingView.swift; sourceTree = ""; }; + 4CFF3E031E37331800F8CDBC /* LoadingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = ""; }; + 4CFF3E051E37F24E00F8CDBC /* ProgressBoxView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBoxView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4CFF3DDA1E36951A00F8CDBC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4CFF3DEE1E36951A00F8CDBC /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4CFF3DD41E36951A00F8CDBC = { + isa = PBXGroup; + children = ( + 4CFF3E001E36953F00F8CDBC /* Control */, + 4CFF3DDF1E36951A00F8CDBC /* CustomLoader */, + 4CFF3DF41E36951A00F8CDBC /* CustomLoaderTests */, + 4CFF3DDE1E36951A00F8CDBC /* Products */, + ); + sourceTree = ""; + }; + 4CFF3DDE1E36951A00F8CDBC /* Products */ = { + isa = PBXGroup; + children = ( + 4CFF3DDD1E36951A00F8CDBC /* CustomLoader.app */, + 4CFF3DF11E36951A00F8CDBC /* CustomLoaderTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 4CFF3DDF1E36951A00F8CDBC /* CustomLoader */ = { + isa = PBXGroup; + children = ( + 4CFF3DE01E36951A00F8CDBC /* AppDelegate.swift */, + 4CFF3DE21E36951A00F8CDBC /* ViewController.swift */, + 4CFF3DE41E36951A00F8CDBC /* Main.storyboard */, + 4CFF3DE71E36951A00F8CDBC /* Assets.xcassets */, + 4CFF3DE91E36951A00F8CDBC /* LaunchScreen.storyboard */, + 4CFF3DEC1E36951A00F8CDBC /* Info.plist */, + ); + path = CustomLoader; + sourceTree = ""; + }; + 4CFF3DF41E36951A00F8CDBC /* CustomLoaderTests */ = { + isa = PBXGroup; + children = ( + 4CFF3DF51E36951A00F8CDBC /* CustomLoaderTests.swift */, + 4CFF3DF71E36951A00F8CDBC /* Info.plist */, + ); + path = CustomLoaderTests; + sourceTree = ""; + }; + 4CFF3E001E36953F00F8CDBC /* Control */ = { + isa = PBXGroup; + children = ( + 4CFF3E011E3695A700F8CDBC /* ProgressRingView.swift */, + 4CFF3E031E37331800F8CDBC /* LoadingView.swift */, + 4CFF3E051E37F24E00F8CDBC /* ProgressBoxView.swift */, + ); + name = Control; + path = sources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4CFF3DDC1E36951A00F8CDBC /* CustomLoader */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4CFF3DFA1E36951A00F8CDBC /* Build configuration list for PBXNativeTarget "CustomLoader" */; + buildPhases = ( + 4CFF3DD91E36951A00F8CDBC /* Sources */, + 4CFF3DDA1E36951A00F8CDBC /* Frameworks */, + 4CFF3DDB1E36951A00F8CDBC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CustomLoader; + productName = CustomLoader; + productReference = 4CFF3DDD1E36951A00F8CDBC /* CustomLoader.app */; + productType = "com.apple.product-type.application"; + }; + 4CFF3DF01E36951A00F8CDBC /* CustomLoaderTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4CFF3DFD1E36951A00F8CDBC /* Build configuration list for PBXNativeTarget "CustomLoaderTests" */; + buildPhases = ( + 4CFF3DED1E36951A00F8CDBC /* Sources */, + 4CFF3DEE1E36951A00F8CDBC /* Frameworks */, + 4CFF3DEF1E36951A00F8CDBC /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 4CFF3DF31E36951A00F8CDBC /* PBXTargetDependency */, + ); + name = CustomLoaderTests; + productName = CustomLoaderTests; + productReference = 4CFF3DF11E36951A00F8CDBC /* CustomLoaderTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4CFF3DD51E36951A00F8CDBC /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0820; + LastUpgradeCheck = 0820; + ORGANIZATIONNAME = "fritzgerald muiseroux"; + TargetAttributes = { + 4CFF3DDC1E36951A00F8CDBC = { + CreatedOnToolsVersion = 8.2.1; + DevelopmentTeam = M9ZSW7KS3F; + ProvisioningStyle = Automatic; + }; + 4CFF3DF01E36951A00F8CDBC = { + CreatedOnToolsVersion = 8.2.1; + DevelopmentTeam = M9ZSW7KS3F; + ProvisioningStyle = Automatic; + TestTargetID = 4CFF3DDC1E36951A00F8CDBC; + }; + }; + }; + buildConfigurationList = 4CFF3DD81E36951A00F8CDBC /* Build configuration list for PBXProject "CustomLoader" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 4CFF3DD41E36951A00F8CDBC; + productRefGroup = 4CFF3DDE1E36951A00F8CDBC /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4CFF3DDC1E36951A00F8CDBC /* CustomLoader */, + 4CFF3DF01E36951A00F8CDBC /* CustomLoaderTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 4CFF3DDB1E36951A00F8CDBC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4CFF3DEB1E36951A00F8CDBC /* LaunchScreen.storyboard in Resources */, + 4CFF3DE81E36951A00F8CDBC /* Assets.xcassets in Resources */, + 4CFF3DE61E36951A00F8CDBC /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4CFF3DEF1E36951A00F8CDBC /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 4CFF3DD91E36951A00F8CDBC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4CFF3E021E3695A700F8CDBC /* ProgressRingView.swift in Sources */, + 4CFF3E041E37331800F8CDBC /* LoadingView.swift in Sources */, + 4CFF3DE31E36951A00F8CDBC /* ViewController.swift in Sources */, + 4CFF3DE11E36951A00F8CDBC /* AppDelegate.swift in Sources */, + 4CFF3E061E37F24E00F8CDBC /* ProgressBoxView.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 4CFF3DED1E36951A00F8CDBC /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4CFF3DF61E36951A00F8CDBC /* CustomLoaderTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 4CFF3DF31E36951A00F8CDBC /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 4CFF3DDC1E36951A00F8CDBC /* CustomLoader */; + targetProxy = 4CFF3DF21E36951A00F8CDBC /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 4CFF3DE41E36951A00F8CDBC /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 4CFF3DE51E36951A00F8CDBC /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 4CFF3DE91E36951A00F8CDBC /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 4CFF3DEA1E36951A00F8CDBC /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 4CFF3DF81E36951A00F8CDBC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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 = 10.2; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 4CFF3DF91E36951A00F8CDBC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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 = 10.2; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 4CFF3DFB1E36951A00F8CDBC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = M9ZSW7KS3F; + INFOPLIST_FILE = CustomLoader/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fitjilab.CustomLoader; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 4CFF3DFC1E36951A00F8CDBC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = M9ZSW7KS3F; + INFOPLIST_FILE = CustomLoader/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fitjilab.CustomLoader; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; + 4CFF3DFE1E36951A00F8CDBC /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = M9ZSW7KS3F; + INFOPLIST_FILE = CustomLoaderTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fitjilab.CustomLoaderTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CustomLoader.app/CustomLoader"; + }; + name = Debug; + }; + 4CFF3DFF1E36951A00F8CDBC /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = M9ZSW7KS3F; + INFOPLIST_FILE = CustomLoaderTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.fitjilab.CustomLoaderTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CustomLoader.app/CustomLoader"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4CFF3DD81E36951A00F8CDBC /* Build configuration list for PBXProject "CustomLoader" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4CFF3DF81E36951A00F8CDBC /* Debug */, + 4CFF3DF91E36951A00F8CDBC /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4CFF3DFA1E36951A00F8CDBC /* Build configuration list for PBXNativeTarget "CustomLoader" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4CFF3DFB1E36951A00F8CDBC /* Debug */, + 4CFF3DFC1E36951A00F8CDBC /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; + 4CFF3DFD1E36951A00F8CDBC /* Build configuration list for PBXNativeTarget "CustomLoaderTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4CFF3DFE1E36951A00F8CDBC /* Debug */, + 4CFF3DFF1E36951A00F8CDBC /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4CFF3DD51E36951A00F8CDBC /* Project object */; +} diff --git a/CustomLoader.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/CustomLoader.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..567f165 --- /dev/null +++ b/CustomLoader.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/CustomLoader.xcodeproj/xcshareddata/xcschemes/CustomLoader.xcscheme b/CustomLoader.xcodeproj/xcshareddata/xcschemes/CustomLoader.xcscheme new file mode 100644 index 0000000..b2e3bbc --- /dev/null +++ b/CustomLoader.xcodeproj/xcshareddata/xcschemes/CustomLoader.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CustomLoader/AppDelegate.swift b/CustomLoader/AppDelegate.swift new file mode 100644 index 0000000..c3b79c4 --- /dev/null +++ b/CustomLoader/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// CustomLoader +// +// Created by fritzgerald muiseroux on 23/01/2017. +// Copyright © 2017 fritzgerald muiseroux. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/CustomLoader/Assets.xcassets/AppIcon.appiconset/Contents.json b/CustomLoader/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..118c98f --- /dev/null +++ b/CustomLoader/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,38 @@ +{ + "images" : [ + { + "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" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/CustomLoader/Base.lproj/LaunchScreen.storyboard b/CustomLoader/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/CustomLoader/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CustomLoader/Base.lproj/Main.storyboard b/CustomLoader/Base.lproj/Main.storyboard new file mode 100644 index 0000000..95d5efe --- /dev/null +++ b/CustomLoader/Base.lproj/Main.storyboard @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CustomLoader/Info.plist b/CustomLoader/Info.plist new file mode 100644 index 0000000..38e98af --- /dev/null +++ b/CustomLoader/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/CustomLoader/ViewController.swift b/CustomLoader/ViewController.swift new file mode 100644 index 0000000..15d8ec9 --- /dev/null +++ b/CustomLoader/ViewController.swift @@ -0,0 +1,33 @@ +// +// ViewController.swift +// CustomLoader +// +// Created by fritzgerald muiseroux on 23/01/2017. +// Copyright © 2017 fritzgerald muiseroux. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + var loader: LoadingView? + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + } + + @IBAction func showLoader(sender: Any) { + + loader = LoadingView.show(inView: view, box: .standard) { _ in + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { + self.loader!.removeFromSuperview(animated: true) + } + } + } +} + diff --git a/CustomLoaderTests/CustomLoaderTests.swift b/CustomLoaderTests/CustomLoaderTests.swift new file mode 100644 index 0000000..5c090e6 --- /dev/null +++ b/CustomLoaderTests/CustomLoaderTests.swift @@ -0,0 +1,36 @@ +// +// CustomLoaderTests.swift +// CustomLoaderTests +// +// Created by fritzgerald muiseroux on 23/01/2017. +// Copyright © 2017 fritzgerald muiseroux. All rights reserved. +// + +import XCTest +@testable import CustomLoader + +class CustomLoaderTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/CustomLoaderTests/Info.plist b/CustomLoaderTests/Info.plist new file mode 100644 index 0000000..6c6c23c --- /dev/null +++ b/CustomLoaderTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/sources/LoadingView.swift b/sources/LoadingView.swift new file mode 100644 index 0000000..b490894 --- /dev/null +++ b/sources/LoadingView.swift @@ -0,0 +1,74 @@ +// +// LoadingView.swift +// CustomLoader +// +// Created by fritzgerald muiseroux on 24/01/2017. +// Copyright © 2017 fritzgerald muiseroux. All rights reserved. +// + +import UIKit + +class LoadingView: UIView { + let loaderView: UIView + + init(loaderView theView: UIView) { + loaderView = theView + super.init(frame: CGRect.zero) + + theView.translatesAutoresizingMaskIntoConstraints = false + addSubview(theView) + + let centerXContraint = NSLayoutConstraint(item: theView, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0) + let centerYContraint = NSLayoutConstraint(item: theView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0) + addConstraints([centerXContraint, centerYContraint]) + } + + func removeFromSuperview(animated: Bool, completion: ((Bool) -> Void)? = nil) { + UIView.animate(withDuration: 0.3, animations: { + self.alpha = 0 + }, completion: { finished in + if finished { + self.removeFromSuperview() + } + if let completion = completion { + completion(finished) + } + }) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + + class func show(inView view:UIView, withProgressRing ringView: ProgressRingView, animated: Bool = true, completion: ((Bool) -> Void)? = nil) -> LoadingView { + + let loadingView = LoadingView(loaderView: ringView) + show(inView: view, loadingView: loadingView, animated: animated, completion: completion) + + return loadingView + } + + class func show(inView view: UIView, box: ProgressBoxView, animated: Bool = true, completion: ((Bool) -> Void)? = nil) -> LoadingView { + + let loadingView = LoadingView(loaderView: box) + show(inView: view, loadingView: loadingView, animated: animated, completion: completion) + + return loadingView + } + + class func show(inView view: UIView, loadingView: UIView, animated: Bool = true, completion: ((Bool) -> Void)? = nil) { + loadingView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin,] + loadingView.frame = view.bounds + view.addSubview(loadingView) + + if animated { + loadingView.alpha = 0 + UIView.animate(withDuration: 0.3, animations: { + loadingView.alpha = 1.0 + }, completion: completion) + } else if let completion = completion { + completion(true) + } + } +} diff --git a/sources/ProgressBoxView.swift b/sources/ProgressBoxView.swift new file mode 100644 index 0000000..609b61b --- /dev/null +++ b/sources/ProgressBoxView.swift @@ -0,0 +1,125 @@ +// +// ProgressBoxView.swift +// CustomLoader +// +// Created by fritzgerald muiseroux on 24/01/2017. +// Copyright © 2017 fritzgerald muiseroux. All rights reserved. +// + +import UIKit + +class ProgressBoxView: UIView { + + var loaderView: UIView! + var contentView: UIView! + let label = UILabel() + let label2 = UILabel() + + init(loader: UIView) { + super.init(frame: CGRect.zero) + loaderView = loader + initializeStyle() + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func initializeStyle() { + + contentView = UIView() + contentView.translatesAutoresizingMaskIntoConstraints = false + addSubview(contentView) + + + label.standardStyle(withFont: UIFont.boldSystemFont(ofSize: 15)) + label2.standardStyle(withFont: UIFont.boldSystemFont(ofSize: 12)) + + contentView.stackViews([loaderView , label, label2]) + + let centerYConstraint = NSLayoutConstraint(item: contentView, attribute: .centerY, relatedBy: .equal, toItem: self, attribute: .centerY, multiplier: 1.0, constant: 0) + let centerXConstraint = NSLayoutConstraint(item: contentView, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0) + let vContraints = NSLayoutConstraint.constraints(withVisualFormat: "V:|-[view]-|", options: .directionLeadingToTrailing, metrics: nil, views: ["view": contentView]) + let hContraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|-[view]-|", options: .directionLeadingToTrailing, metrics: nil, views: ["view": contentView]) + + addConstraints(vContraints) + addConstraints(hContraints) + addConstraints([centerYConstraint, centerXConstraint]) + + layer.cornerRadius = 10 + } + + override var intrinsicContentSize: CGSize { + return CGSize(width: 100, height: 100) + } +} + +extension ProgressBoxView { + static var standard: ProgressBoxView { + let view = ProgressBoxView(loader: ProgressRingView.light) + view.backgroundColor = UIColor.lightGray + return view + } +} + +class SpaceView : UIView { + + override init(frame: CGRect) { + super.init(frame: frame) + addConstraint(NSLayoutConstraint(item: self, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .width, multiplier: 1.0, constant: frame.width)) + addConstraint(NSLayoutConstraint(item: self, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .height, multiplier: 1.0, constant: frame.height)) + backgroundColor = UIColor.clear + } + + required init?(coder aDecoder: NSCoder) { + fatalError("[SpaceView init:coder:] not implemented") + } + +} + +extension UILabel { + + func standardStyle(withFont font: UIFont) { + self.font = font + self.textColor = UIColor.white + self.numberOfLines = 0 + self.textAlignment = .center + } +} + +extension UIView { + + func stackViews(_ views:[UIView]) { + + var lastView: UIView? = nil + var stackConstraints = [NSLayoutConstraint]() + + views.forEach({ view in + view.translatesAutoresizingMaskIntoConstraints = false + self.addSubview(view) + }) + + + views.forEach { view in + if let lastView = lastView { + let topConstraint = NSLayoutConstraint(item: view, attribute: .top, relatedBy: .equal, toItem: lastView, attribute: .bottom, multiplier: 1.0, constant: 0) + stackConstraints.append(topConstraint) + } else { + let topConstraint = NSLayoutConstraint(item: view, attribute: .top, relatedBy: .equal, toItem: self, attribute: .topMargin, multiplier: 1.0, constant: 0) + stackConstraints.append(topConstraint) + } + let centerXConstraint = NSLayoutConstraint(item: view, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0) + stackConstraints.append(centerXConstraint) + + let horizontalCOnstraints = NSLayoutConstraint.constraints(withVisualFormat: "H:|->=0-[view]->=0-|", options: .directionLeadingToTrailing, metrics: nil, views: ["view": view]) + stackConstraints.append(contentsOf: horizontalCOnstraints) + lastView = view + } + + if let lastView = lastView { + let bottom = NSLayoutConstraint(item: lastView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottomMargin, multiplier: 1.0, constant: 0) + stackConstraints.append(bottom) + } + self.addConstraints(stackConstraints) + } +} diff --git a/sources/ProgressRingView.swift b/sources/ProgressRingView.swift new file mode 100644 index 0000000..a610e24 --- /dev/null +++ b/sources/ProgressRingView.swift @@ -0,0 +1,155 @@ +// +// LoadingIndicatorView.swift +// CustomLoader +// +// Created by fritzgerald muiseroux on 23/01/2017. +// Copyright © 2017 fritzgerald muiseroux. All rights reserved. +// + +import UIKit + +@IBDesignable +class ProgressRingView: UIView { + + var addedLayer = [CALayer]() + + private var _innerColor: UIColor = UIColor.clear + @IBInspectable + var innerColor: UIColor { + get { return _innerColor } + set { + _innerColor = newValue + setNeedsLayout() + } + } + + private var _outterColor: UIColor = UIColor.clear + @IBInspectable + var outterColor: UIColor { + get { return _outterColor } + set { + _outterColor = newValue + setNeedsLayout() + } + } + + private var _lineWidth: CGFloat = 3.0 + @IBInspectable + var lineWidth: CGFloat { + get { return _lineWidth } + set { + _lineWidth = newValue + setNeedsLayout() + } + } + + override init(frame: CGRect) { + super.init(frame: frame) + initialize() + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + initialize() + } + + func circleLayer(color: UIColor, scale: CGFloat = 1.0) -> CALayer { + + let shapeLayer = CAShapeLayer(circleInFrame: bounds, scale:scale, maxAngle: M_PI) + shapeLayer.fillColor = UIColor.clear.cgColor + shapeLayer.strokeColor = color.cgColor + shapeLayer.lineWidth = lineWidth + + layer.addSublayer(shapeLayer) + return shapeLayer + } + + func initialize() { + + let theLayer = circleLayer(color: outterColor) + layer.addSublayer(theLayer) + theLayer.addRotationAnimation(clockwise: true) + + let theLayer2 = circleLayer(color: innerColor, scale: 0.7) + layer.addSublayer(theLayer2) + theLayer2.addRotationAnimation(clockwise: false) + + addedLayer.append(theLayer) + addedLayer.append(theLayer2) + } + + override func layoutSubviews() { + super.layoutSubviews() + + addedLayer.forEach { subLayer in + subLayer.removeFromSuperlayer() + } + addedLayer.removeAll() + initialize() + } + + override var intrinsicContentSize: CGSize { + return CGSize(width: 40, height: 40) + } +} + +extension ProgressRingView { + + static var light: ProgressRingView { + let view = ProgressRingView() + view.outterColor = .white + view.innerColor = .darkGray + return view + } + + static var dark: ProgressRingView { + let view = ProgressRingView() + view.outterColor = .black + view.innerColor = .darkGray + return view + } +} + +extension CAShapeLayer { + + convenience init(circleInFrame drawingFrame: CGRect, + scale: CGFloat = 1.0, + maxAngle: Double = M_PI * 2, + clockwise: Bool = true) { + self.init() + var diameter = drawingFrame.width + if drawingFrame.width > drawingFrame.height { + diameter = drawingFrame.height + } + let center = CGPoint(x: drawingFrame.width / 2.0, y: drawingFrame.height / 2.0) + let circlePath = UIBezierPath(arcCenter: center, + radius: (diameter * scale) / 2.0, + startAngle: CGFloat(0), + endAngle:CGFloat(maxAngle), + clockwise: clockwise) + path = circlePath.cgPath + frame = drawingFrame + } +} + +extension CALayer { + + /// Rotate forever around the Z axis + func addRotationAnimation(clockwise: Bool) { + + let rotation = CABasicAnimation(keyPath: "transform.rotation.z") + rotation.fromValue = 0 + rotation.toValue = M_PI + if clockwise { + rotation.toValue = -M_PI + } + rotation.isCumulative = true + rotation.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionLinear) + rotation.duration = 0.75 + rotation.isAdditive = true + rotation.fillMode = kCAFilterLinear + rotation.repeatCount = Float.greatestFiniteMagnitude; + + self.add(rotation, forKey: "rotation") + } +}