diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..893afb8 Binary files /dev/null and b/.DS_Store differ diff --git a/AZEmptyState.podspec b/AZEmptyState.podspec new file mode 100644 index 0000000..8ce8912 --- /dev/null +++ b/AZEmptyState.podspec @@ -0,0 +1,12 @@ + +Pod::Spec.new do |s| + s.name = "AZEmptyState" + s.version = "1.0.0" + s.summary = "An easy way to create empty states." + s.homepage = "https://github.com/Minitour/AZEmptyState" + s.license = "MIT" + s.author = { "Antonio Zaitoun" => "tony.z.1711@gmail.com" } + s.platform = :ios, "9.0" + s.source = { :git => "https://github.com/Minitour/AZEmptyState.git", :tag => "#{s.version}" } + s.source_files = "Sources/*.swift" +end diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj new file mode 100644 index 0000000..a5bb6f2 --- /dev/null +++ b/Example/Example.xcodeproj/project.pbxproj @@ -0,0 +1,326 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9D1D327A1ED6253D00911AFF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1D32791ED6253D00911AFF /* AppDelegate.swift */; }; + 9D1D327C1ED6253D00911AFF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1D327B1ED6253D00911AFF /* ViewController.swift */; }; + 9D1D327F1ED6253D00911AFF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D1D327D1ED6253D00911AFF /* Main.storyboard */; }; + 9D1D32811ED6253D00911AFF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9D1D32801ED6253D00911AFF /* Assets.xcassets */; }; + 9D1D32841ED6253D00911AFF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D1D32821ED6253D00911AFF /* LaunchScreen.storyboard */; }; + 9D1D328D1ED6260C00911AFF /* AZEmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1D328C1ED6260C00911AFF /* AZEmptyStateView.swift */; }; + 9D1D32971ED6325500911AFF /* MyEmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D1D32961ED6325500911AFF /* MyEmptyStateView.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 9D1D32761ED6253D00911AFF /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 9D1D32791ED6253D00911AFF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 9D1D327B1ED6253D00911AFF /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 9D1D327E1ED6253D00911AFF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 9D1D32801ED6253D00911AFF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 9D1D32831ED6253D00911AFF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 9D1D32851ED6253D00911AFF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9D1D328C1ED6260C00911AFF /* AZEmptyStateView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AZEmptyStateView.swift; sourceTree = ""; }; + 9D1D32961ED6325500911AFF /* MyEmptyStateView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyEmptyStateView.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 9D1D32731ED6253D00911AFF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9D1D326D1ED6253D00911AFF = { + isa = PBXGroup; + children = ( + 9D1D328B1ED6260C00911AFF /* Sources */, + 9D1D32781ED6253D00911AFF /* Example */, + 9D1D32771ED6253D00911AFF /* Products */, + ); + sourceTree = ""; + }; + 9D1D32771ED6253D00911AFF /* Products */ = { + isa = PBXGroup; + children = ( + 9D1D32761ED6253D00911AFF /* Example.app */, + ); + name = Products; + sourceTree = ""; + }; + 9D1D32781ED6253D00911AFF /* Example */ = { + isa = PBXGroup; + children = ( + 9D1D32791ED6253D00911AFF /* AppDelegate.swift */, + 9D1D327B1ED6253D00911AFF /* ViewController.swift */, + 9D1D32961ED6325500911AFF /* MyEmptyStateView.swift */, + 9D1D327D1ED6253D00911AFF /* Main.storyboard */, + 9D1D32801ED6253D00911AFF /* Assets.xcassets */, + 9D1D32821ED6253D00911AFF /* LaunchScreen.storyboard */, + 9D1D32851ED6253D00911AFF /* Info.plist */, + ); + path = Example; + sourceTree = ""; + }; + 9D1D328B1ED6260C00911AFF /* Sources */ = { + isa = PBXGroup; + children = ( + 9D1D328C1ED6260C00911AFF /* AZEmptyStateView.swift */, + ); + name = Sources; + path = ../Sources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 9D1D32751ED6253D00911AFF /* Example */ = { + isa = PBXNativeTarget; + buildConfigurationList = 9D1D32881ED6253D00911AFF /* Build configuration list for PBXNativeTarget "Example" */; + buildPhases = ( + 9D1D32721ED6253D00911AFF /* Sources */, + 9D1D32731ED6253D00911AFF /* Frameworks */, + 9D1D32741ED6253D00911AFF /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Example; + productName = Example; + productReference = 9D1D32761ED6253D00911AFF /* Example.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 9D1D326E1ED6253D00911AFF /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0830; + LastUpgradeCheck = 0830; + ORGANIZATIONNAME = "Antonio Zaitoun"; + TargetAttributes = { + 9D1D32751ED6253D00911AFF = { + CreatedOnToolsVersion = 8.3.2; + DevelopmentTeam = Y759RK5K7D; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 9D1D32711ED6253D00911AFF /* Build configuration list for PBXProject "Example" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 9D1D326D1ED6253D00911AFF; + productRefGroup = 9D1D32771ED6253D00911AFF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 9D1D32751ED6253D00911AFF /* Example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 9D1D32741ED6253D00911AFF /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9D1D32841ED6253D00911AFF /* LaunchScreen.storyboard in Resources */, + 9D1D32811ED6253D00911AFF /* Assets.xcassets in Resources */, + 9D1D327F1ED6253D00911AFF /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 9D1D32721ED6253D00911AFF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9D1D327C1ED6253D00911AFF /* ViewController.swift in Sources */, + 9D1D328D1ED6260C00911AFF /* AZEmptyStateView.swift in Sources */, + 9D1D32971ED6325500911AFF /* MyEmptyStateView.swift in Sources */, + 9D1D327A1ED6253D00911AFF /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 9D1D327D1ED6253D00911AFF /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9D1D327E1ED6253D00911AFF /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 9D1D32821ED6253D00911AFF /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 9D1D32831ED6253D00911AFF /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 9D1D32861ED6253D00911AFF /* 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++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.3; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 9D1D32871ED6253D00911AFF /* 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++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.3; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 9D1D32891ED6253D00911AFF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = Y759RK5K7D; + INFOPLIST_FILE = Example/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.crofis.Example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 9D1D328A1ED6253D00911AFF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = Y759RK5K7D; + INFOPLIST_FILE = Example/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = net.crofis.Example; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 9D1D32711ED6253D00911AFF /* Build configuration list for PBXProject "Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9D1D32861ED6253D00911AFF /* Debug */, + 9D1D32871ED6253D00911AFF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 9D1D32881ED6253D00911AFF /* Build configuration list for PBXNativeTarget "Example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 9D1D32891ED6253D00911AFF /* Debug */, + 9D1D328A1ED6253D00911AFF /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 9D1D326E1ED6253D00911AFF /* Project object */; +} diff --git a/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..6d2a51b --- /dev/null +++ b/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Example/Example/AppDelegate.swift b/Example/Example/AppDelegate.swift new file mode 100644 index 0000000..c5286a1 --- /dev/null +++ b/Example/Example/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// Example +// +// Created by Antonio Zaitoun on 24/05/2017. +// Copyright © 2017 Antonio Zaitoun. 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/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..b8236c6 --- /dev/null +++ b/Example/Example/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/Example/Example/Assets.xcassets/Contents.json b/Example/Example/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/Example/Example/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Assets.xcassets/ic_bookmark.imageset/Contents.json b/Example/Example/Assets.xcassets/ic_bookmark.imageset/Contents.json new file mode 100644 index 0000000..90e5744 --- /dev/null +++ b/Example/Example/Assets.xcassets/ic_bookmark.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "bookmark-3.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Assets.xcassets/ic_bookmark.imageset/bookmark-3.png b/Example/Example/Assets.xcassets/ic_bookmark.imageset/bookmark-3.png new file mode 100644 index 0000000..af48d88 Binary files /dev/null and b/Example/Example/Assets.xcassets/ic_bookmark.imageset/bookmark-3.png differ diff --git a/Example/Example/Assets.xcassets/ic_calender.imageset/Contents.json b/Example/Example/Assets.xcassets/ic_calender.imageset/Contents.json new file mode 100644 index 0000000..1cb9d3f --- /dev/null +++ b/Example/Example/Assets.xcassets/ic_calender.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "calendar-23.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Assets.xcassets/ic_calender.imageset/calendar-23.png b/Example/Example/Assets.xcassets/ic_calender.imageset/calendar-23.png new file mode 100644 index 0000000..6ecbc07 Binary files /dev/null and b/Example/Example/Assets.xcassets/ic_calender.imageset/calendar-23.png differ diff --git a/Example/Example/Assets.xcassets/ic_emoji_thinking.imageset/Contents.json b/Example/Example/Assets.xcassets/ic_emoji_thinking.imageset/Contents.json new file mode 100644 index 0000000..0296ae6 --- /dev/null +++ b/Example/Example/Assets.xcassets/ic_emoji_thinking.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "thinking.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Assets.xcassets/ic_emoji_thinking.imageset/thinking.png b/Example/Example/Assets.xcassets/ic_emoji_thinking.imageset/thinking.png new file mode 100644 index 0000000..6785a8e Binary files /dev/null and b/Example/Example/Assets.xcassets/ic_emoji_thinking.imageset/thinking.png differ diff --git a/Example/Example/Assets.xcassets/ic_tasks.imageset/Contents.json b/Example/Example/Assets.xcassets/ic_tasks.imageset/Contents.json new file mode 100644 index 0000000..889d2c7 --- /dev/null +++ b/Example/Example/Assets.xcassets/ic_tasks.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "tasks.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Assets.xcassets/ic_tasks.imageset/tasks.png b/Example/Example/Assets.xcassets/ic_tasks.imageset/tasks.png new file mode 100644 index 0000000..ef8ec2d Binary files /dev/null and b/Example/Example/Assets.xcassets/ic_tasks.imageset/tasks.png differ diff --git a/Example/Example/Assets.xcassets/ic_users.imageset/Contents.json b/Example/Example/Assets.xcassets/ic_users.imageset/Contents.json new file mode 100644 index 0000000..3e5561d --- /dev/null +++ b/Example/Example/Assets.xcassets/ic_users.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "user-46.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Example/Example/Assets.xcassets/ic_users.imageset/user-46.png b/Example/Example/Assets.xcassets/ic_users.imageset/user-46.png new file mode 100644 index 0000000..19f93fd Binary files /dev/null and b/Example/Example/Assets.xcassets/ic_users.imageset/user-46.png differ diff --git a/Example/Example/Base.lproj/LaunchScreen.storyboard b/Example/Example/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..fdf3f97 --- /dev/null +++ b/Example/Example/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/Base.lproj/Main.storyboard b/Example/Example/Base.lproj/Main.storyboard new file mode 100644 index 0000000..7f4c4df --- /dev/null +++ b/Example/Example/Base.lproj/Main.storyboard @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/Info.plist b/Example/Example/Info.plist new file mode 100644 index 0000000..38e98af --- /dev/null +++ b/Example/Example/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/Example/Example/MyEmptyStateView.swift b/Example/Example/MyEmptyStateView.swift new file mode 100644 index 0000000..d6ae74f --- /dev/null +++ b/Example/Example/MyEmptyStateView.swift @@ -0,0 +1,75 @@ +// +// MyEmptyStateView.swift +// Example +// +// Created by Antonio Zaitoun on 25/05/2017. +// Copyright © 2017 Antonio Zaitoun. All rights reserved. +// + +import UIKit + +@IBDesignable +class MyEmptyStateView: AZEmptyStateView{ + + //Use image with content mode of `scale aspect fit` + override func setupImage() -> UIImageView { + let imageView = UIImageView() + imageView.contentMode = .scaleAspectFit + return imageView + } + + //Use the default label with extra modifications, such as different font and different color. + override func setupLabel() -> UILabel { + let label = super.setupLabel() + label.font = UIFont(name: "Helvetica-Light", size: 16) + label.numberOfLines = 0 + label.textColor = .white + return label + } + + //use a custom subclass of UIButton + override func setupButton() -> UIButton { + return HighlightableButton() + } + + //setup the stack view to your liking + override func setupStack(_ imageView: UIImageView, _ textLabel: UILabel, _ button: UIButton) -> UIStackView { + let stack = super.setupStack(imageView, textLabel, button) + stack.spacing = 14 + stack.alignment = .center + button.widthAnchor.constraint(equalTo: stack.widthAnchor, multiplier: 0.8).isActive = true + imageView.widthAnchor.constraint(equalTo: stack.widthAnchor, multiplier: 0.5).isActive = true + return stack + } +} + +class HighlightableButton: UIButton{ + + override init(frame: CGRect) { + super.init(frame: frame) + setup() + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup() + } + + func setup() { + backgroundColor = #colorLiteral(red: 0.1019607843, green: 0.737254902, blue: 0.6117647059, alpha: 1) + layer.cornerRadius = 5 + layer.masksToBounds = true + } + + override var isHighlighted: Bool{ + set{ + UIView.animate(withDuration: 0.1) { [weak self] in + self?.alpha = newValue ? 0.5 : 1 + self?.transform = newValue ? CGAffineTransform(scaleX: 0.95, y: 0.95) : .identity + } + super.isHighlighted = newValue + }get{ + return super.isHighlighted + } + } +} diff --git a/Example/Example/ViewController.swift b/Example/Example/ViewController.swift new file mode 100644 index 0000000..8f821b7 --- /dev/null +++ b/Example/Example/ViewController.swift @@ -0,0 +1,32 @@ +// +// ViewController.swift +// Example +// +// Created by Antonio Zaitoun on 24/05/2017. +// Copyright © 2017 Antonio Zaitoun. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + @IBOutlet weak var emptyState: MyEmptyStateView! + + @IBAction func addTask(_ sender: Any) { + //todo: add task + print("Add Task") + } + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + +} + + diff --git a/README.md b/README.md index ff3237a..2667f3c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,88 @@ # AZEmptyState Making empty state simple. + +## Screenshots + + +## Installation + + +### Cocoa Pods: + +```bash +pod 'AZEmptyState' +``` + +### Manual: + +Simply drag and drop the ```Sources``` folder to your project. + +## Usage: + +### Using Interface Builder: + + +### Programmatically: + +```swift +//init var +emptyStateView = AZEmptyStateView() + +//customize +emptyStateView.image = #imageLiteral(resourceName: "thinking") +emptyStateView.message = "Something went wrong..." +emptyStateView.buttonText = "Try Again" +emptyStateView.addTarget(self, action: #selector(tryAgain), for: .touchUpInside) + +//add subview +view.addSubview(emptyStateView) + +//add autolayout +emptyStateView.translatesAutoresizingMaskIntoConstraints = false +emptyStateView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true +emptyStateView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true +emptyStateView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true +emptyStateView.heightAnchor.constraint(equalTo: view.heightAnchor, multiplier: 0.55).isActive = true +``` + +## Sub Classing + +Here is an example of sub-classing: + +```swift +@IBDesignable +class MyEmptyStateView: AZEmptyStateView{ + + //Use image with content mode of `scale aspect fit` + override func setupImage() -> UIImageView { + let imageView = UIImageView() + imageView.contentMode = .scaleAspectFit + return imageView + } + + //Use the default label with extra modifications, such as different font and different color. + override func setupLabel() -> UILabel { + let label = super.setupLabel() + label.font = UIFont(name: "Helvetica-Light", size: 16) + label.numberOfLines = 0 + label.textColor = .white + return label + } + + //use a custom subclass of UIButton + override func setupButton() -> UIButton { + return HighlightableButton() + } + + //setup the stack view to your liking + override func setupStack(_ imageView: UIImageView, _ textLabel: UILabel, _ button: UIButton) -> UIStackView { + let stack = super.setupStack(imageView, textLabel, button) + stack.spacing = 14 + stack.alignment = .center + button.widthAnchor.constraint(equalTo: stack.widthAnchor, multiplier: 0.8).isActive = true + imageView.widthAnchor.constraint(equalTo: stack.widthAnchor, multiplier: 0.5).isActive = true + return stack + } +} +``` + diff --git a/Screenshots/howto.gif b/Screenshots/howto.gif new file mode 100644 index 0000000..aede81f Binary files /dev/null and b/Screenshots/howto.gif differ diff --git a/Screenshots/interfacebuilder.png b/Screenshots/interfacebuilder.png new file mode 100644 index 0000000..fb56447 Binary files /dev/null and b/Screenshots/interfacebuilder.png differ diff --git a/Screenshots/screenshot1.png b/Screenshots/screenshot1.png new file mode 100644 index 0000000..1bdc902 Binary files /dev/null and b/Screenshots/screenshot1.png differ diff --git a/Screenshots/screenshot2.png b/Screenshots/screenshot2.png new file mode 100644 index 0000000..aae37f5 Binary files /dev/null and b/Screenshots/screenshot2.png differ diff --git a/Sources/AZEmptyStateView.swift b/Sources/AZEmptyStateView.swift new file mode 100644 index 0000000..e1237bd --- /dev/null +++ b/Sources/AZEmptyStateView.swift @@ -0,0 +1,171 @@ +// +// AZEmptyStateView.swift +// +// +// Created by Antonio Zaitoun on 24/05/2017. +// Copyright © 2017 Antonio Zaitoun. All rights reserved. +// + +import UIKit + +@IBDesignable +public class AZEmptyStateView: UIControl{ + + /// The empty state image + @IBInspectable + public var image: UIImage{ + get{ + return imageView.image! + }set{ + imageView.image = newValue + } + } + + + /// The empty state message + @IBInspectable + public var message: String{ + get{ + return textLabel.text ?? "" + }set{ + textLabel.text = newValue + } + } + + + /// The button's text + @IBInspectable + public var buttonText: String{ + get{ + return button.title(for: [])! + }set{ + button.setTitle(newValue, for: []) + } + } + + @IBInspectable + public var buttonTint: UIColor{ + get{ + return button.tintColor + }set{ + button.layer.borderColor = newValue.cgColor + button.tintColor = newValue + } + } + + + /// Is the button visable + @IBInspectable + public var buttonHidden: Bool = false{ + didSet{ + button.isHidden = buttonHidden + } + } + + fileprivate(set) open var imageView: UIImageView! + + fileprivate(set) open var textLabel: UILabel! + + fileprivate(set) open var button: UIButton! + + override init(frame: CGRect) { + super.init(frame: frame) + setup() + } + + + /// Convenience initailizer + /// + /// - Parameters: + /// - image: The image of the empty state + /// - message: The message of the empty sate + /// - buttonText: The text on the button, if nil then button will be hidden. + public convenience init(image: UIImage ,message: String, buttonText: String? = nil){ + self.init(frame: CGRect.zero) + self.image = image + self.message = message + if let buttonText = buttonText { + self.buttonText = buttonText + }else{ + buttonHidden = true + } + } + + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + setup() + } + + final override public func addTarget(_ target: Any?, action: Selector, for controlEvents: UIControlEvents) { + button.addTarget(target, action: action, for: controlEvents) + } + + /// A function that is called when it's time to setup the label. + /// + /// - Returns: The label view. + internal func setupLabel()->UILabel{ + let textLabel = UILabel() + textLabel.adjustsFontSizeToFitWidth = true + textLabel.textAlignment = .center + textLabel.numberOfLines = 2 + return textLabel + } + + + /// A function that is called when it's time to setup the image view. + /// + /// - Returns: The image view. + internal func setupImage()->UIImageView{ + return UIImageView() + } + + + /// A function that is called when it's time to setup the button. + /// + /// - Returns: The button. + internal func setupButton()->UIButton{ + let button = UIButton(type: .system) + button.layer.cornerRadius = 5 + button.layer.borderColor = button.tintColor.cgColor + button.layer.borderWidth = 1 + return button + } + + + /// A function that is called when it's time to setup the stack of the empty state which contains all the views. + /// + /// - Parameters: + /// - imageView: The image view of the empty state. + /// - textLabel: The label of the empty state. + /// - button: The button of the empty state. + /// - Returns: The stack view. + internal func setupStack(_ imageView: UIImageView,_ textLabel: UILabel,_ button: UIButton)->UIStackView{ + let stackView = UIStackView(arrangedSubviews: [imageView,textLabel,button]) + stackView.axis = .vertical + stackView.alignment = .fill + stackView.distribution = .fill + stackView.spacing = 10 + return stackView + } + + + fileprivate func setup(){ + backgroundColor = .clear + imageView = setupImage() + textLabel = setupLabel() + button = setupButton() + let stackView = setupStack(imageView,textLabel,button) + + imageView.translatesAutoresizingMaskIntoConstraints = false + imageView.heightAnchor.constraint(equalTo: imageView.widthAnchor, multiplier: 1.0).isActive = true + + addSubview(stackView) + stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.topAnchor.constraint(equalTo: topAnchor).isActive = true + stackView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true + stackView.rightAnchor.constraint(equalTo: rightAnchor).isActive = true + stackView.leftAnchor.constraint(equalTo: leftAnchor).isActive = true + + } + +}