diff --git a/iOS/ProgressKit/BaseView.swift b/iOS/ProgressKit/BaseView.swift new file mode 100644 index 0000000..2c55630 --- /dev/null +++ b/iOS/ProgressKit/BaseView.swift @@ -0,0 +1,59 @@ +// +// BaseView.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 04/10/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit +@IBDesignable +open class BaseView : UIView { + + override public init(frame frameRect: CGRect) { + super.init(frame: frameRect) + self.configureLayers() + } + + required public init?(coder: NSCoder) { + super.init(coder: coder) + //self.configureLayers() + } + + /// Configure the Layers + func configureLayers() { + //self.wantsLayer = true + notifyViewRedesigned() + } + + @IBInspectable open var background: UIColor = UIColor(red: 88.3 / 256, green: 104.4 / 256, blue: 118.5 / 256, alpha: 1.0) { + didSet { + self.notifyViewRedesigned() + } + } + + @IBInspectable open var foreground: UIColor = UIColor(red: 66.3 / 256, green: 173.7 / 256, blue: 106.4 / 256, alpha: 1.0) { + didSet { + self.notifyViewRedesigned() + } + } + + @IBInspectable open var cornerRadius: CGFloat = 5.0 { + didSet { + self.notifyViewRedesigned() + } + } + + /// Call when any IBInspectable variable is changed + func notifyViewRedesigned() { + self.layer.backgroundColor = background.cgColor + self.layer.cornerRadius = cornerRadius + } + + override open func layoutSubviews() { + super.layoutSubviews() + //self.frame will be correct here + configureLayers() + } +} diff --git a/iOS/ProgressKit/ProgressKit.xcodeproj/project.pbxproj b/iOS/ProgressKit/ProgressKit.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c18ed20 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit.xcodeproj/project.pbxproj @@ -0,0 +1,373 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 3D451CC01D9B128A002371F2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CBF1D9B128A002371F2 /* AppDelegate.swift */; }; + 3D451CC21D9B128A002371F2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CC11D9B128A002371F2 /* ViewController.swift */; }; + 3D451CC51D9B128A002371F2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3D451CC31D9B128A002371F2 /* Main.storyboard */; }; + 3D451CC71D9B128A002371F2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3D451CC61D9B128A002371F2 /* Assets.xcassets */; }; + 3D451CCA1D9B128A002371F2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3D451CC81D9B128A002371F2 /* LaunchScreen.storyboard */; }; + 3D451CDD1D9B12C0002371F2 /* CircularProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CD21D9B12C0002371F2 /* CircularProgressView.swift */; }; + 3D451CDE1D9B12C0002371F2 /* DeterminateAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CD31D9B12C0002371F2 /* DeterminateAnimation.swift */; }; + 3D451CDF1D9B12C0002371F2 /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CD41D9B12C0002371F2 /* ProgressBar.swift */; }; + 3D451CE01D9B12C0002371F2 /* Crawler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CD61D9B12C0002371F2 /* Crawler.swift */; }; + 3D451CE11D9B12C0002371F2 /* IndeterminateAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CD71D9B12C0002371F2 /* IndeterminateAnimation.swift */; }; + 3D451CE21D9B12C0002371F2 /* MaterialProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CD81D9B12C0002371F2 /* MaterialProgress.swift */; }; + 3D451CE31D9B12C0002371F2 /* Rainbow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CD91D9B12C0002371F2 /* Rainbow.swift */; }; + 3D451CE41D9B12C0002371F2 /* RotatingArc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CDA1D9B12C0002371F2 /* RotatingArc.swift */; }; + 3D451CE51D9B12C0002371F2 /* ShootingStars.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CDB1D9B12C0002371F2 /* ShootingStars.swift */; }; + 3D451CE61D9B12C0002371F2 /* Spinner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CDC1D9B12C0002371F2 /* Spinner.swift */; }; + 3D451CEA1D9B131F002371F2 /* ProgressUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CE91D9B131F002371F2 /* ProgressUtils.swift */; }; + 3D451CEC1D9B1329002371F2 /* BaseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D451CEB1D9B1329002371F2 /* BaseView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 3D451CBC1D9B128A002371F2 /* ProgressKit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ProgressKit.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 3D451CBF1D9B128A002371F2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 3D451CC11D9B128A002371F2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 3D451CC41D9B128A002371F2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 3D451CC61D9B128A002371F2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 3D451CC91D9B128A002371F2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 3D451CCB1D9B128A002371F2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3D451CD21D9B12C0002371F2 /* CircularProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularProgressView.swift; sourceTree = ""; }; + 3D451CD31D9B12C0002371F2 /* DeterminateAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeterminateAnimation.swift; sourceTree = ""; }; + 3D451CD41D9B12C0002371F2 /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = ""; }; + 3D451CD61D9B12C0002371F2 /* Crawler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Crawler.swift; sourceTree = ""; }; + 3D451CD71D9B12C0002371F2 /* IndeterminateAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndeterminateAnimation.swift; sourceTree = ""; }; + 3D451CD81D9B12C0002371F2 /* MaterialProgress.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MaterialProgress.swift; sourceTree = ""; }; + 3D451CD91D9B12C0002371F2 /* Rainbow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Rainbow.swift; sourceTree = ""; }; + 3D451CDA1D9B12C0002371F2 /* RotatingArc.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RotatingArc.swift; sourceTree = ""; }; + 3D451CDB1D9B12C0002371F2 /* ShootingStars.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShootingStars.swift; sourceTree = ""; }; + 3D451CDC1D9B12C0002371F2 /* Spinner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Spinner.swift; sourceTree = ""; }; + 3D451CE91D9B131F002371F2 /* ProgressUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressUtils.swift; sourceTree = ""; }; + 3D451CEB1D9B1329002371F2 /* BaseView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3D451CB91D9B128A002371F2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3D451CB31D9B128A002371F2 = { + isa = PBXGroup; + children = ( + 3D451CE91D9B131F002371F2 /* ProgressUtils.swift */, + 3D451CEB1D9B1329002371F2 /* BaseView.swift */, + 3D451CD11D9B12C0002371F2 /* Determinate */, + 3D451CD51D9B12C0002371F2 /* InDeterminate */, + 3D451CBE1D9B128A002371F2 /* ProgressKit */, + 3D451CBD1D9B128A002371F2 /* Products */, + ); + sourceTree = ""; + }; + 3D451CBD1D9B128A002371F2 /* Products */ = { + isa = PBXGroup; + children = ( + 3D451CBC1D9B128A002371F2 /* ProgressKit.app */, + ); + name = Products; + sourceTree = ""; + }; + 3D451CBE1D9B128A002371F2 /* ProgressKit */ = { + isa = PBXGroup; + children = ( + 3D451CBF1D9B128A002371F2 /* AppDelegate.swift */, + 3D451CC11D9B128A002371F2 /* ViewController.swift */, + 3D451CC31D9B128A002371F2 /* Main.storyboard */, + 3D451CC61D9B128A002371F2 /* Assets.xcassets */, + 3D451CC81D9B128A002371F2 /* LaunchScreen.storyboard */, + 3D451CCB1D9B128A002371F2 /* Info.plist */, + ); + path = ProgressKit; + sourceTree = ""; + }; + 3D451CD11D9B12C0002371F2 /* Determinate */ = { + isa = PBXGroup; + children = ( + 3D451CD21D9B12C0002371F2 /* CircularProgressView.swift */, + 3D451CD31D9B12C0002371F2 /* DeterminateAnimation.swift */, + 3D451CD41D9B12C0002371F2 /* ProgressBar.swift */, + ); + name = Determinate; + path = ProgressKit/Determinate; + sourceTree = ""; + }; + 3D451CD51D9B12C0002371F2 /* InDeterminate */ = { + isa = PBXGroup; + children = ( + 3D451CD61D9B12C0002371F2 /* Crawler.swift */, + 3D451CD71D9B12C0002371F2 /* IndeterminateAnimation.swift */, + 3D451CD81D9B12C0002371F2 /* MaterialProgress.swift */, + 3D451CD91D9B12C0002371F2 /* Rainbow.swift */, + 3D451CDA1D9B12C0002371F2 /* RotatingArc.swift */, + 3D451CDB1D9B12C0002371F2 /* ShootingStars.swift */, + 3D451CDC1D9B12C0002371F2 /* Spinner.swift */, + ); + name = InDeterminate; + path = ProgressKit/InDeterminate; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3D451CBB1D9B128A002371F2 /* ProgressKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3D451CCE1D9B128A002371F2 /* Build configuration list for PBXNativeTarget "ProgressKit" */; + buildPhases = ( + 3D451CB81D9B128A002371F2 /* Sources */, + 3D451CB91D9B128A002371F2 /* Frameworks */, + 3D451CBA1D9B128A002371F2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = ProgressKit; + productName = ProgressKit; + productReference = 3D451CBC1D9B128A002371F2 /* ProgressKit.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3D451CB41D9B128A002371F2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0800; + LastUpgradeCheck = 0800; + ORGANIZATIONNAME = BinaryBoy; + TargetAttributes = { + 3D451CBB1D9B128A002371F2 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = LXW484D3N9; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 3D451CB71D9B128A002371F2 /* Build configuration list for PBXProject "ProgressKit" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 3D451CB31D9B128A002371F2; + productRefGroup = 3D451CBD1D9B128A002371F2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3D451CBB1D9B128A002371F2 /* ProgressKit */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3D451CBA1D9B128A002371F2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3D451CCA1D9B128A002371F2 /* LaunchScreen.storyboard in Resources */, + 3D451CC71D9B128A002371F2 /* Assets.xcassets in Resources */, + 3D451CC51D9B128A002371F2 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3D451CB81D9B128A002371F2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3D451CE41D9B12C0002371F2 /* RotatingArc.swift in Sources */, + 3D451CEA1D9B131F002371F2 /* ProgressUtils.swift in Sources */, + 3D451CE31D9B12C0002371F2 /* Rainbow.swift in Sources */, + 3D451CE01D9B12C0002371F2 /* Crawler.swift in Sources */, + 3D451CC21D9B128A002371F2 /* ViewController.swift in Sources */, + 3D451CE11D9B12C0002371F2 /* IndeterminateAnimation.swift in Sources */, + 3D451CDD1D9B12C0002371F2 /* CircularProgressView.swift in Sources */, + 3D451CC01D9B128A002371F2 /* AppDelegate.swift in Sources */, + 3D451CE61D9B12C0002371F2 /* Spinner.swift in Sources */, + 3D451CE21D9B12C0002371F2 /* MaterialProgress.swift in Sources */, + 3D451CDF1D9B12C0002371F2 /* ProgressBar.swift in Sources */, + 3D451CEC1D9B1329002371F2 /* BaseView.swift in Sources */, + 3D451CDE1D9B12C0002371F2 /* DeterminateAnimation.swift in Sources */, + 3D451CE51D9B12C0002371F2 /* ShootingStars.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 3D451CC31D9B128A002371F2 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3D451CC41D9B128A002371F2 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 3D451CC81D9B128A002371F2 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3D451CC91D9B128A002371F2 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3D451CCC1D9B128A002371F2 /* 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_MOVES = 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.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 3D451CCD1D9B128A002371F2 /* 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_MOVES = 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.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 3D451CCF1D9B128A002371F2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = LXW484D3N9; + INFOPLIST_FILE = ProgressKit/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = dimo.hamdy.ProgressKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 3D451CD01D9B128A002371F2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = LXW484D3N9; + INFOPLIST_FILE = ProgressKit/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = dimo.hamdy.ProgressKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3D451CB71D9B128A002371F2 /* Build configuration list for PBXProject "ProgressKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3D451CCC1D9B128A002371F2 /* Debug */, + 3D451CCD1D9B128A002371F2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3D451CCE1D9B128A002371F2 /* Build configuration list for PBXNativeTarget "ProgressKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3D451CCF1D9B128A002371F2 /* Debug */, + 3D451CD01D9B128A002371F2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3D451CB41D9B128A002371F2 /* Project object */; +} diff --git a/iOS/ProgressKit/ProgressKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/iOS/ProgressKit/ProgressKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ad780a9 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/iOS/ProgressKit/ProgressKit/AppDelegate.swift b/iOS/ProgressKit/ProgressKit/AppDelegate.swift new file mode 100644 index 0000000..a5d7b33 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// ProgressKit-iOS +// +// Created by BinaryBoy on 9/27/16. +// Copyright © 2016 Kauntey Suryawanshi. 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/iOS/ProgressKit/ProgressKit/Assets.xcassets/AppIcon.appiconset/Contents.json b/iOS/ProgressKit/ProgressKit/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..b8236c6 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,48 @@ +{ + "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" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS/ProgressKit/ProgressKit/Base.lproj/LaunchScreen.storyboard b/iOS/ProgressKit/ProgressKit/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/ProgressKit/ProgressKit/Base.lproj/Main.storyboard b/iOS/ProgressKit/ProgressKit/Base.lproj/Main.storyboard new file mode 100644 index 0000000..ea99803 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/Base.lproj/Main.storyboard @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iOS/ProgressKit/ProgressKit/Determinate/CircularProgressView.swift b/iOS/ProgressKit/ProgressKit/Determinate/CircularProgressView.swift new file mode 100644 index 0000000..9a91caf --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/Determinate/CircularProgressView.swift @@ -0,0 +1,104 @@ +// +// CircularView.swift +// Animo +// +// Created by Kauntey Suryawanshi on 29/06/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +@IBDesignable +open class CircularProgressView: DeterminateAnimation { + + var backgroundCircle = CAShapeLayer() + var progressLayer = CAShapeLayer() + var percentLabelLayer = CATextLayer() + + @IBInspectable open var strokeWidth: CGFloat = -1 { + didSet { + notifyViewRedesigned() + } + } + + @IBInspectable open var showPercent: Bool = true { + didSet { + notifyViewRedesigned() + } + } + + override func notifyViewRedesigned() { + super.notifyViewRedesigned() + backgroundCircle.lineWidth = self.strokeWidth / 2 + progressLayer.lineWidth = strokeWidth + percentLabelLayer.isHidden = !showPercent + + backgroundCircle.strokeColor = foreground.withAlphaComponent(0.5).cgColor + progressLayer.strokeColor = foreground.cgColor + percentLabelLayer.foregroundColor = foreground.cgColor + } + + override func updateProgress() { + CATransaction.begin() + if animated { + CATransaction.setAnimationDuration(0.5) + } else { + CATransaction.setDisableActions(true) + } + let timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) + CATransaction.setAnimationTimingFunction(timing) + progressLayer.strokeEnd = max(0, min(progress, 1)) + percentLabelLayer.string = "\(Int(progress * 100))%" + CATransaction.commit() + } + + override func configureLayers() { + super.configureLayers() + let rect = self.bounds + let radius = (rect.width / 2) * 0.75 + let strokeScalingFactor = CGFloat(0.05) + + + // Add background Circle + do { + backgroundCircle.frame = rect + backgroundCircle.lineWidth = strokeWidth == -1 ? (rect.width * strokeScalingFactor / 2) : strokeWidth / 2 + + backgroundCircle.strokeColor = foreground.withAlphaComponent(0.5).cgColor + backgroundCircle.fillColor = UIColor.clear.cgColor + let backgroundPath = UIBezierPath() + backgroundPath.addArc(withCenter: rect.mid, radius: radius, startAngle: 0, endAngle: 360,clockwise: true) + backgroundCircle.path = backgroundPath.cgPath + self.layer.addSublayer(backgroundCircle) + } + + // Progress Layer + do { + progressLayer.strokeEnd = 0 //REMOVe this + progressLayer.fillColor = UIColor.clear.cgColor + progressLayer.lineCap = kCALineCapRound + progressLayer.lineWidth = strokeWidth == -1 ? (rect.width * strokeScalingFactor) : strokeWidth + + progressLayer.frame = rect + progressLayer.strokeColor = foreground.cgColor + let arcPath = UIBezierPath() + let startAngle = CGFloat(90) + arcPath.addArc(withCenter: rect.mid, radius: radius, startAngle: startAngle, endAngle: (startAngle - 360), clockwise: true) + progressLayer.path = arcPath.cgPath + self.layer.addSublayer(progressLayer) + } + + // Percentage Layer + do { + percentLabelLayer.string = "0%" + percentLabelLayer.foregroundColor = foreground.cgColor + percentLabelLayer.frame = rect + percentLabelLayer.font = "Helvetica Neue Light" as CFTypeRef + percentLabelLayer.alignmentMode = kCAAlignmentCenter + percentLabelLayer.position.y = rect.midY * 0.25 + percentLabelLayer.fontSize = rect.width * 0.2 + self.layer.addSublayer(percentLabelLayer) + } + } +} diff --git a/iOS/ProgressKit/ProgressKit/Determinate/DeterminateAnimation.swift b/iOS/ProgressKit/ProgressKit/Determinate/DeterminateAnimation.swift new file mode 100644 index 0000000..0b38601 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/Determinate/DeterminateAnimation.swift @@ -0,0 +1,32 @@ +// +// DeterminateAnimation.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 09/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +protocol DeterminableAnimation { + func updateProgress() +} + +@IBDesignable +open class DeterminateAnimation: BaseView, DeterminableAnimation { + + @IBInspectable open var animated: Bool = true + + /// Value of progress now. Range 0..1 + @IBInspectable open var progress: CGFloat = 0 { + didSet { + updateProgress() + } + } + + /// This function will only be called by didSet of progress. Every subclass will have its own implementation + func updateProgress() { + fatalError("Must be overriden in subclass") + } +} diff --git a/iOS/ProgressKit/ProgressKit/Determinate/ProgressBar.swift b/iOS/ProgressKit/ProgressKit/Determinate/ProgressBar.swift new file mode 100644 index 0000000..278ee6a --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/Determinate/ProgressBar.swift @@ -0,0 +1,59 @@ +// +// ProgressBar.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 31/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +@IBDesignable +open class ProgressBar: DeterminateAnimation { + + var borderLayer = CAShapeLayer() + var progressLayer = CAShapeLayer() + + @IBInspectable open var borderColor: UIColor = UIColor.black { + didSet { + notifyViewRedesigned() + } + } + + override func notifyViewRedesigned() { + super.notifyViewRedesigned() + self.layer.cornerRadius = self.frame.height / 2 + borderLayer.borderColor = borderColor.cgColor + progressLayer.backgroundColor = foreground.cgColor + } + + override func configureLayers() { + super.configureLayers() + + borderLayer.frame = self.bounds + borderLayer.cornerRadius = borderLayer.frame.height / 2 + borderLayer.borderWidth = 1.0 + self.layer.addSublayer(borderLayer) + + progressLayer.frame = borderLayer.bounds.insetBy(dx: 3, dy: 3) + progressLayer.frame.size.width = (borderLayer.bounds.width - 6) + progressLayer.cornerRadius = progressLayer.frame.height / 2 + progressLayer.backgroundColor = foreground.cgColor + borderLayer.addSublayer(progressLayer) + + } + + override func updateProgress() { + CATransaction.begin() + if animated { + CATransaction.setAnimationDuration(0.5) + } else { + CATransaction.setDisableActions(true) + } + let timing = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) + CATransaction.setAnimationTimingFunction(timing) + progressLayer.frame.size.width = (borderLayer.bounds.width - 6) * progress + CATransaction.commit() + } +} diff --git a/iOS/ProgressKit/ProgressKit/InDeterminate/Crawler.swift b/iOS/ProgressKit/ProgressKit/InDeterminate/Crawler.swift new file mode 100644 index 0000000..b09b98b --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/InDeterminate/Crawler.swift @@ -0,0 +1,81 @@ +// +// Crawler.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 11/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +private let defaultForegroundColor = UIColor.white +private let defaultBackgroundColor = UIColor(white: 0.0, alpha: 0.4) +private let duration = 1.2 + +@IBDesignable +open class Crawler: IndeterminateAnimation { + + var starList = [CAShapeLayer]() + + var smallCircleSize: Double { + return Double(self.bounds.width) * 0.2 + } + + var animationGroups = [CAAnimation]() + + override func notifyViewRedesigned() { + super.notifyViewRedesigned() + for star in starList { + star.backgroundColor = foreground.cgColor + } + } + + override func configureLayers() { + super.configureLayers() + let rect = self.bounds + + let insetRect = rect.insetBy(dx: rect.width * 0.15, dy: rect.width * 0.15) + for i in 0 ..< 5 { + let starShape = CAShapeLayer() + starList.append(starShape) + starShape.backgroundColor = foreground.cgColor + + let circleWidth = smallCircleSize - Double(i) * 2 + starShape.bounds = CGRect(x: 0, y: 0, width: circleWidth, height: circleWidth) + starShape.cornerRadius = CGFloat(circleWidth / 2) + starShape.position = CGPoint(x: rect.midX, y: rect.midY + insetRect.height / 2) + self.layer.addSublayer(starShape) + + let arcPath = UIBezierPath() + arcPath.addArc(withCenter: insetRect.mid, radius: insetRect.width / 2, startAngle: 90, endAngle: -360 + 90, clockwise: true) + + let rotationAnimation = CAKeyframeAnimation(keyPath: "position") + rotationAnimation.path = arcPath.cgPath + rotationAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) + rotationAnimation.beginTime = (duration * 0.075) * Double(i) + rotationAnimation.calculationMode = kCAAnimationCubicPaced + + let animationGroup = CAAnimationGroup() + animationGroup.animations = [rotationAnimation] + animationGroup.duration = duration + animationGroup.repeatCount = Float.infinity + animationGroups.append(animationGroup) + + } + } + + override func startAnimation() { + for (index, star) in starList.enumerated() { + star.add(animationGroups[index], forKey: "") + } + } + + override func stopAnimation() { + for star in starList { + star.removeAllAnimations() + } + } + +} + diff --git a/iOS/ProgressKit/ProgressKit/InDeterminate/IndeterminateAnimation.swift b/iOS/ProgressKit/ProgressKit/InDeterminate/IndeterminateAnimation.swift new file mode 100644 index 0000000..923484f --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/InDeterminate/IndeterminateAnimation.swift @@ -0,0 +1,57 @@ +// +// InDeterminateAnimation.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 09/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import UIKit + +protocol AnimationStatusDelegate { + func startAnimation() + func stopAnimation() +} + +open class IndeterminateAnimation: BaseView, AnimationStatusDelegate { + + /// View is hidden when *animate* property is false + @IBInspectable open var displayAfterAnimationEnds: Bool = false + + /** + Control point for all Indeterminate animation + True invokes `startAnimation()` on subclass of IndeterminateAnimation + False invokes `stopAnimation()` on subclass of IndeterminateAnimation + */ + open var animate: Bool = false { + didSet { + guard animate != oldValue else { return } + if animate { + self.isHidden = false + startAnimation() + } else { + if !displayAfterAnimationEnds { + self.isHidden = true + } + stopAnimation() + } + } + } + + /** + Every function that extends Indeterminate animation must define startAnimation(). + `animate` property of Indeterminate animation will indynamically invoke the subclass method + */ + func startAnimation() { + fatalError("This is an abstract function") + } + + /** + Every function that extends Indeterminate animation must define **stopAnimation()**. + + *animate* property of Indeterminate animation will dynamically invoke the subclass method + */ + func stopAnimation() { + fatalError("This is an abstract function") + } +} diff --git a/iOS/ProgressKit/ProgressKit/InDeterminate/MaterialProgress.swift b/iOS/ProgressKit/ProgressKit/InDeterminate/MaterialProgress.swift new file mode 100644 index 0000000..2788dfe --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/InDeterminate/MaterialProgress.swift @@ -0,0 +1,124 @@ +// +// MaterialProgress.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 30/06/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +private let duration = 1.5 +private let strokeRange = (start: 0.0, end: 0.8) + +@IBDesignable +open class MaterialProgress: IndeterminateAnimation { + + @IBInspectable open var lineWidth: CGFloat = -1 { + didSet { + progressLayer.lineWidth = lineWidth + } + } + + override func notifyViewRedesigned() { + super.notifyViewRedesigned() + progressLayer.strokeColor = foreground.cgColor + } + + var backgroundRotationLayer = CAShapeLayer() + + var progressLayer: CAShapeLayer = { + var tempLayer = CAShapeLayer() + tempLayer.strokeEnd = CGFloat(strokeRange.end) + tempLayer.lineCap = kCALineCapRound + tempLayer.fillColor = UIColor.clear.cgColor + return tempLayer + }() + + //MARK: Animation Declaration + var animationGroup: CAAnimationGroup = { + var tempGroup = CAAnimationGroup() + tempGroup.repeatCount = 1 + tempGroup.duration = duration + return tempGroup + }() + + + var rotationAnimation: CABasicAnimation = { + var tempRotation = CABasicAnimation(keyPath: "transform.rotation") + tempRotation.repeatCount = Float.infinity + tempRotation.fromValue = 0 + tempRotation.toValue = 1 + tempRotation.isCumulative = true + tempRotation.duration = duration / 2 + return tempRotation + }() + + /// Makes animation for Stroke Start and Stroke End + func makeStrokeAnimationGroup() { + var strokeStartAnimation: CABasicAnimation! + var strokeEndAnimation: CABasicAnimation! + + func makeAnimationforKeyPath(_ keyPath: String) -> CABasicAnimation { + let tempAnimation = CABasicAnimation(keyPath: keyPath) + tempAnimation.repeatCount = 1 + tempAnimation.speed = 2.0 + tempAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + + tempAnimation.fromValue = strokeRange.start + tempAnimation.toValue = strokeRange.end + tempAnimation.duration = duration + + return tempAnimation + } + strokeEndAnimation = makeAnimationforKeyPath("strokeEnd") + strokeStartAnimation = makeAnimationforKeyPath("strokeStart") + strokeStartAnimation.beginTime = duration / 2 + animationGroup.animations = [strokeEndAnimation, strokeStartAnimation, ] + animationGroup.delegate = self + } + + override func configureLayers() { + super.configureLayers() + makeStrokeAnimationGroup() + let rect = self.bounds + + backgroundRotationLayer.frame = rect + self.layer.addSublayer(backgroundRotationLayer) + + // Progress Layer + let radius = (rect.width / 2) * 0.75 + progressLayer.frame = rect + progressLayer.lineWidth = lineWidth == -1 ? radius / 10: lineWidth + let arcPath = UIBezierPath() + arcPath.addArc(withCenter: rect.mid, radius: radius, startAngle: 0, endAngle: 360, clockwise: false) + progressLayer.path = arcPath.cgPath + backgroundRotationLayer.addSublayer(progressLayer) + } + + var currentRotation = 0.0 + let π2 = M_PI * 2 + + override func startAnimation() { + progressLayer.add(animationGroup, forKey: "strokeEnd") + backgroundRotationLayer.add(rotationAnimation, forKey: rotationAnimation.keyPath) + } + override func stopAnimation() { + backgroundRotationLayer.removeAllAnimations() + progressLayer.removeAllAnimations() + } +} + +extension MaterialProgress: CAAnimationDelegate { + open func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { + if !animate { return } + CATransaction.begin() + CATransaction.setDisableActions(true) + currentRotation += strokeRange.end * π2 + currentRotation = currentRotation.truncatingRemainder(dividingBy: π2) + progressLayer.setAffineTransform(CGAffineTransform(rotationAngle: CGFloat( currentRotation))) + CATransaction.commit() + progressLayer.add(animationGroup, forKey: "strokeEnd") + } +} diff --git a/iOS/ProgressKit/ProgressKit/InDeterminate/Rainbow.swift b/iOS/ProgressKit/ProgressKit/InDeterminate/Rainbow.swift new file mode 100644 index 0000000..5a78879 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/InDeterminate/Rainbow.swift @@ -0,0 +1,76 @@ +// +// Rainbow.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 09/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +@IBDesignable +open class Rainbow: MaterialProgress { + + @IBInspectable open var onLightOffDark: Bool = false + + override func configureLayers() { + super.configureLayers() + self.background = UIColor.clear + } + + override open func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { + super.animationDidStop(anim, finished: flag) + if onLightOffDark { + progressLayer.strokeColor = lightColorList[Int(arc4random()) % lightColorList.count].cgColor + } else { + progressLayer.strokeColor = darkColorList[Int(arc4random()) % darkColorList.count].cgColor + } + } +} + +var randomColor: UIColor { + let red = Float(Double(arc4random()).truncatingRemainder(dividingBy: 256.0) / 256.0) + let green = Float(Double(arc4random()).truncatingRemainder(dividingBy: 256.0) / 256.0) + let blue = Float(Double(arc4random()).truncatingRemainder(dividingBy: 256.0) / 256.0) + return UIColor(colorLiteralRed: red, green: green, blue: blue, alpha: 1.0) +} + +private let lightColorList:[UIColor] = [ + UIColor(red: 0.9461, green: 0.6699, blue: 0.6243, alpha: 1.0), + UIColor(red: 0.8625, green: 0.7766, blue: 0.8767, alpha: 1.0), + UIColor(red: 0.6676, green: 0.6871, blue: 0.8313, alpha: 1.0), + UIColor(red: 0.7263, green: 0.6189, blue: 0.8379, alpha: 1.0), + UIColor(red: 0.8912, green: 0.9505, blue: 0.9971, alpha: 1.0), + UIColor(red: 0.7697, green: 0.9356, blue: 0.9692, alpha: 1.0), + UIColor(red: 0.3859, green: 0.7533, blue: 0.9477, alpha: 1.0), + UIColor(red: 0.6435, green: 0.8554, blue: 0.8145, alpha: 1.0), + UIColor(red: 0.8002, green: 0.936, blue: 0.7639, alpha: 1.0), + UIColor(red: 0.5362, green: 0.8703, blue: 0.8345, alpha: 1.0), + UIColor(red: 0.9785, green: 0.8055, blue: 0.4049, alpha: 1.0), + UIColor(red: 1.0, green: 0.8667, blue: 0.6453, alpha: 1.0), + UIColor(red: 0.9681, green: 0.677, blue: 0.2837, alpha: 1.0), + UIColor(red: 0.9898, green: 0.7132, blue: 0.1746, alpha: 1.0), + UIColor(red: 0.8238, green: 0.84, blue: 0.8276, alpha: 1.0), + UIColor(red: 0.8532, green: 0.8763, blue: 0.883, alpha: 1.0), +] + +let darkColorList: [UIColor] = [ + UIColor(red: 0.9472, green: 0.2496, blue: 0.0488, alpha: 1.0), + UIColor(red: 0.8098, green: 0.1695, blue: 0.0467, alpha: 1.0), + UIColor(red: 0.853, green: 0.2302, blue: 0.3607, alpha: 1.0), + UIColor(red: 0.8152, green: 0.3868, blue: 0.5021, alpha: 1.0), + UIColor(red: 0.96, green: 0.277, blue: 0.3515, alpha: 1.0), + UIColor(red: 0.3686, green: 0.3069, blue: 0.6077, alpha: 1.0), + UIColor(red: 0.5529, green: 0.3198, blue: 0.5409, alpha: 1.0), + UIColor(red: 0.2132, green: 0.4714, blue: 0.7104, alpha: 1.0), + UIColor(red: 0.1706, green: 0.2432, blue: 0.3106, alpha: 1.0), + UIColor(red: 0.195, green: 0.2982, blue: 0.3709, alpha: 1.0), + UIColor(red: 0.0, green: 0.3091, blue: 0.5859, alpha: 1.0), + UIColor(red: 0.2261, green: 0.6065, blue: 0.3403, alpha: 1.0), + UIColor(red: 0.1101, green: 0.5694, blue: 0.4522, alpha: 1.0), + UIColor(red: 0.1716, green: 0.4786, blue: 0.2877, alpha: 1.0), + UIColor(red: 0.8289, green: 0.33, blue: 0.0, alpha: 1.0), + UIColor(red: 0.4183, green: 0.4842, blue: 0.5372, alpha: 1.0), + UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0), +] diff --git a/iOS/ProgressKit/ProgressKit/InDeterminate/RotatingArc.swift b/iOS/ProgressKit/ProgressKit/InDeterminate/RotatingArc.swift new file mode 100644 index 0000000..be8f134 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/InDeterminate/RotatingArc.swift @@ -0,0 +1,104 @@ +// +// RotatingArc.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 26/10/15. +// Copyright © 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +private let duration = 0.25 + +@IBDesignable +open class RotatingArc: IndeterminateAnimation { + + var backgroundCircle = CAShapeLayer() + var arcLayer = CAShapeLayer() + + @IBInspectable open var strokeWidth: CGFloat = 5 { + didSet { + notifyViewRedesigned() + } + } + + @IBInspectable open var arcLength: Int = 35 { + didSet { + notifyViewRedesigned() + } + } + + @IBInspectable open var clockWise: Bool = true { + didSet { + notifyViewRedesigned() + } + } + + var radius: CGFloat { + return (self.frame.width / 2) * CGFloat(0.75) + } + + var rotationAnimation: CABasicAnimation = { + var tempRotation = CABasicAnimation(keyPath: "transform.rotation") + tempRotation.repeatCount = Float.infinity + tempRotation.fromValue = 0 + tempRotation.toValue = 1 + tempRotation.isCumulative = true + tempRotation.duration = duration + return tempRotation + }() + + override func notifyViewRedesigned() { + super.notifyViewRedesigned() + + arcLayer.strokeColor = foreground.cgColor + backgroundCircle.strokeColor = foreground.withAlphaComponent(0.4).cgColor + + backgroundCircle.lineWidth = self.strokeWidth + arcLayer.lineWidth = strokeWidth + rotationAnimation.toValue = clockWise ? -1 : 1 + + let arcPath = UIBezierPath() + let endAngle: CGFloat = CGFloat(-360) * CGFloat(arcLength) / 100 + arcPath.addArc(withCenter: self.bounds.mid, radius: radius, startAngle: 0, endAngle: endAngle, clockwise: true) + + arcLayer.path = arcPath.cgPath + } + + override func configureLayers() { + super.configureLayers() + let rect = self.bounds + + // Add background Circle + do { + backgroundCircle.frame = rect + backgroundCircle.lineWidth = strokeWidth + + backgroundCircle.strokeColor = foreground.withAlphaComponent(0.5).cgColor + backgroundCircle.fillColor = UIColor.clear.cgColor + let backgroundPath = UIBezierPath() + backgroundPath.addArc(withCenter: rect.mid, radius: radius, startAngle: 0, endAngle: 360,clockwise: true) + backgroundCircle.path = backgroundPath.cgPath + self.layer.addSublayer(backgroundCircle) + } + + // Arc Layer + do { + arcLayer.fillColor = UIColor.clear.cgColor + arcLayer.lineWidth = strokeWidth + + arcLayer.frame = rect + arcLayer.strokeColor = foreground.cgColor + self.layer.addSublayer(arcLayer) + } + } + + override func startAnimation() { + arcLayer.add(rotationAnimation, forKey: "") + } + + override func stopAnimation() { + arcLayer.removeAllAnimations() + } +} diff --git a/iOS/ProgressKit/ProgressKit/InDeterminate/ShootingStars.swift b/iOS/ProgressKit/ProgressKit/InDeterminate/ShootingStars.swift new file mode 100644 index 0000000..1e3cf2b --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/InDeterminate/ShootingStars.swift @@ -0,0 +1,86 @@ +// +// ShootingStars.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 09/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +@IBDesignable +open class ShootingStars: IndeterminateAnimation { + fileprivate let animationDuration = 1.0 + + var starLayer1 = CAShapeLayer() + var starLayer2 = CAShapeLayer() + var animation = CABasicAnimation(keyPath: "position.x") + var tempAnimation = CABasicAnimation(keyPath: "position.x") + + override func notifyViewRedesigned() { + super.notifyViewRedesigned() + starLayer1.backgroundColor = foreground.cgColor + starLayer2.backgroundColor = foreground.cgColor + } + + override func configureLayers() { + super.configureLayers() + + let rect = self.bounds + let dimension = rect.height + let starWidth = dimension * 1.5 + + self.layer.cornerRadius = 0 + + /// Add Stars + do { + starLayer1.position = CGPoint(x: dimension / 2, y: dimension / 2) + starLayer1.bounds.size = CGSize(width: starWidth, height: dimension) + starLayer1.backgroundColor = foreground.cgColor + self.layer.addSublayer(starLayer1) + + starLayer2.position = CGPoint(x: rect.midX, y: dimension / 2) + starLayer2.bounds.size = CGSize(width: starWidth, height: dimension) + starLayer2.backgroundColor = foreground.cgColor + self.layer.addSublayer(starLayer2) + } + + /// Add default animation + do { + animation.fromValue = -dimension + animation.toValue = rect.width * 0.9 + animation.duration = animationDuration + animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) + animation.isRemovedOnCompletion = false + animation.repeatCount = Float.infinity + } + + /** Temp animation will be removed after first animation + After finishing it will invoke animationDidStop and starLayer2 is also given default animation. + The purpose of temp animation is to generate an temporary offset + */ + tempAnimation.fromValue = rect.midX + tempAnimation.toValue = rect.width + tempAnimation.delegate = self + tempAnimation.duration = animationDuration / 2 + tempAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) + } + + //MARK: Indeterminable protocol + override func startAnimation() { + starLayer1.add(animation, forKey: "default") + starLayer2.add(tempAnimation, forKey: "tempAnimation") + } + + override func stopAnimation() { + starLayer1.removeAllAnimations() + starLayer2.removeAllAnimations() + } +} + +extension ShootingStars: CAAnimationDelegate { + open func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { + starLayer2.add(animation, forKey: "default") + } +} diff --git a/iOS/ProgressKit/ProgressKit/InDeterminate/Spinner.swift b/iOS/ProgressKit/ProgressKit/InDeterminate/Spinner.swift new file mode 100644 index 0000000..af1a342 --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/InDeterminate/Spinner.swift @@ -0,0 +1,115 @@ +// +// Spinner.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 28/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + +import Foundation +import UIKit + +@IBDesignable +open class Spinner: IndeterminateAnimation { + + var basicShape = CAShapeLayer() + var containerLayer = CAShapeLayer() + var starList = [CAShapeLayer]() + + var animation: CAKeyframeAnimation = { + var animation = CAKeyframeAnimation(keyPath: "transform.rotation") + animation.repeatCount = Float.infinity + animation.calculationMode = kCAAnimationDiscrete + return animation + }() + + @IBInspectable open var starSize:CGSize = CGSize(width: 6, height: 15) { + didSet { + notifyViewRedesigned() + } + } + + @IBInspectable open var roundedCorners: Bool = true { + didSet { + notifyViewRedesigned() + } + } + + + @IBInspectable open var distance: CGFloat = CGFloat(20) { + didSet { + notifyViewRedesigned() + } + } + + @IBInspectable open var starCount: Int = 10 { + didSet { + notifyViewRedesigned() + } + } + + @IBInspectable open var duration: Double = 1 { + didSet { + animation.duration = duration + } + } + + @IBInspectable open var clockwise: Bool = false { + didSet { + notifyViewRedesigned() + } + } + + override func configureLayers() { + super.configureLayers() + + containerLayer.frame = self.bounds + containerLayer.cornerRadius = frame.width / 2 + self.layer.addSublayer(containerLayer) + + animation.duration = duration + } + + override func notifyViewRedesigned() { + super.notifyViewRedesigned() + starList.removeAll(keepingCapacity: true) + containerLayer.sublayers = nil + animation.values = [Double]() + var i = 0.0 + while i < 360 { + var iRadian = CGFloat(i * M_PI / 180.0) + if clockwise { iRadian = -iRadian } + + animation.values?.append(iRadian) + let starShape = CAShapeLayer() + starShape.cornerRadius = roundedCorners ? starSize.width / 2 : 0 + + let centerLocation = CGPoint(x: frame.width / 2 - starSize.width / 2, y: frame.width / 2 - starSize.height / 2) + + starShape.frame = CGRect(origin: centerLocation, size: starSize) + + starShape.backgroundColor = foreground.cgColor + starShape.anchorPoint = CGPoint(x: 0.5, y: 0) + + var rotation: CATransform3D = CATransform3DMakeTranslation(0, 0, 0.0); + + rotation = CATransform3DRotate(rotation, -iRadian, 0.0, 0.0, 1.0); + rotation = CATransform3DTranslate(rotation, 0, distance, 0.0); + starShape.transform = rotation + + starShape.opacity = Float(360 - i) / 360 + containerLayer.addSublayer(starShape) + starList.append(starShape) + i = i + Double(360 / starCount) + } + } + + override func startAnimation() { + containerLayer.add(animation, forKey: "rotation") + } + + override func stopAnimation() { + containerLayer.removeAllAnimations() + } + +} diff --git a/iOS/ProgressKit/ProgressKit/Info.plist b/iOS/ProgressKit/ProgressKit/Info.plist new file mode 100644 index 0000000..38e98af --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/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/iOS/ProgressKit/ProgressKit/ViewController.swift b/iOS/ProgressKit/ProgressKit/ViewController.swift new file mode 100644 index 0000000..8eb99ef --- /dev/null +++ b/iOS/ProgressKit/ProgressKit/ViewController.swift @@ -0,0 +1,35 @@ +// +// ViewController.swift +// ProgressKit-iOS +// +// Created by BinaryBoy on 9/27/16. +// Copyright © 2016 Kauntey Suryawanshi. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + @IBOutlet weak var spinView: Spinner! + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. +// spinView.startAnimation() + + } + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + for view in self.view.subviews { + (view as? IndeterminateAnimation)?.configureLayers() + (view as? IndeterminateAnimation)?.animate = true + + } + } + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} + diff --git a/iOS/ProgressKit/ProgressUtils.swift b/iOS/ProgressKit/ProgressUtils.swift new file mode 100644 index 0000000..0cd9253 --- /dev/null +++ b/iOS/ProgressKit/ProgressUtils.swift @@ -0,0 +1,56 @@ +// +// ProgressUtils.swift +// ProgressKit +// +// Created by Kauntey Suryawanshi on 09/07/15. +// Copyright (c) 2015 Kauntey Suryawanshi. All rights reserved. +// + + +import Foundation +import UIKit + +extension CGRect { + var mid: CGPoint { + return CGPoint(x: self.midX, y: self.midY) + } +} + +//extension UIBezierPath { +// /// Converts NSBezierPath to CGPath +// var CGPath: CGPath { +// let path = CGMutablePath() +// let points = UnsafeMutablePointer.allocate(capacity: 3) +// let numElements = self.elementCount +// +// for index in 0.. Double { + return Double(degree) * (M_PI / 180) +} + +func radianToDegree(_ radian: Double) -> Int { + return Int(radian * (180 / M_PI)) +} + +func + (p1: CGPoint, p2: CGPoint) -> CGPoint { + return CGPoint(x: p1.x + p2.x, y: p1.y + p2.y) +} +