├── .DS_Store ├── .gitignore ├── .swift-version ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTIONS.md ├── HHFloatingView.podspec ├── HHFloatingView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── HHFloatingView ├── .DS_Store ├── Assets.xcassets │ ├── .DS_Store │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── icon-bird.imageset │ │ ├── Contents.json │ │ └── bird.png │ ├── icon-gift.imageset │ │ ├── Contents.json │ │ └── gift.png │ ├── icon-megaphone.imageset │ │ ├── Contents.json │ │ └── megaphone.png │ ├── icon-rocket.imageset │ │ ├── Contents.json │ │ └── rocket.png │ ├── icon-ufo.imageset │ │ ├── Contents.json │ │ └── ufo.png │ └── icon-umbrella.imageset │ │ ├── Contents.json │ │ └── umbrella.png ├── Base.lproj │ └── LaunchScreen.storyboard ├── Example │ ├── AppDelegate.swift │ ├── Base.lproj │ │ └── Main.storyboard │ ├── BaseViewController.swift │ └── ViewController.swift ├── Info.plist └── Source │ ├── HHFloatingView.swift │ ├── HHFloatingViewButton.swift │ └── HHFloatingViewConfiguration.swift ├── LICENSE ├── README.md └── Screenshots ├── .DS_Store ├── Screenshot-1.png └── Screenshot-2.png /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | HHFloatingView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist 69 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: swift 2 | osx_image: xcode10.2 3 | 4 | branches: 5 | only: 6 | - master 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | Latest release is available [here](https://github.com/hemangshah/HHFloatingView/releases/latest). 6 | 7 | ## [3.0.0](https://github.com/hemangshah/HHFloatingView/releases/tag/3.0.0) - May 03, 2019 8 | - Swift 5.0. 🚀 9 | - Code refactored. 10 | - Fixed #6 (https://github.com/hemangshah/HHFloatingView/issues/6) 11 | 12 | ## [2.0.0](https://github.com/hemangshah/HHFloatingView/releases/tag/2.0.0) - Oct 21, 2018 13 | - Minor code refactored. 14 | - Fixed #4 (https://github.com/hemangshah/HHFloatingView/issues/4) 15 | 16 | ## [1.4.0](https://github.com/hemangshah/HHFloatingView/releases/tag/1.4.0) - Oct 02, 2018 17 | - Code refactored: 18 | - Removed self specifier for the global properties & example. 19 | - Use swift best practice to implement protocols. 20 | - Fixed #1 (https://github.com/hemangshah/HHFloatingView/issues/1) 21 | 22 | ## [1.3.0](https://github.com/hemangshah/HHFloatingView/releases/tag/1.3.0) - Sep 21, 2018 23 | - Example updated to support swift 4.2 and code refactoring. 24 | 25 | ## [1.2.0](https://github.com/hemangshah/HHFloatingView/releases/tag/1.2.0) - Oct 24, 2017 26 | - Added Documentations and Scale Animations for Options buttons. 27 | 28 | ## [1.1.0](https://github.com/hemangshah/HHFloatingView/releases/tag/1.1.0) - Oct 22, 2017 29 | - Fixed for CocoaPods Usage, Added Delegates, and lots of Code Refactoring & Improvements. 30 | 31 | ## [1.0.0](https://github.com/hemangshah/HHFloatingView/releases/tag/1.0.0) - Oct 19, 2017 32 | - First Release. 33 | -------------------------------------------------------------------------------- /CONTRIBUTIONS.md: -------------------------------------------------------------------------------- 1 | 1. [Icons](https://www.flaticon.com/packs/basic-flat-icons) used in the example is by [Pixel buddha](https://www.flaticon.com/authors/pixel-buddha). 2 | 2. [These lovely people who encouraged me to keep developing on the HHFloatingView](https://github.com/hemangshah/HHFloatingView/stargazers). 3 | 3. [These great people who raised issues and provided me enough informations to fixed it.](https://github.com/hemangshah/HHFloatingView/issues?q=is%3Aissue+is%3Aclosed) 4 | 5 | **Thank you so much.** 💙 6 | -------------------------------------------------------------------------------- /HHFloatingView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'HHFloatingView' 3 | s.module_name = 'HHFloatingView' 4 | s.version = '3.0.0' 5 | s.summary = 'An easy to use and setup floating view for your app. 🎡' 6 | s.description = 'HHFloatingView is another options view which you can use to show basic options for your app.' 7 | s.homepage = 'https://github.com/hemangshah/HHFloatingView' 8 | s.license = 'MIT' 9 | s.author = { 'hemangshah' => 'hemangshah.in@gmail.com' } 10 | s.source = { :git => 'https://github.com/hemangshah/HHFloatingView.git', :tag => s.version.to_s } 11 | s.platform = :ios, '9.0' 12 | s.requires_arc = true 13 | s.source_files = 'HHFloatingView/Source/*.swift' 14 | end 15 | -------------------------------------------------------------------------------- /HHFloatingView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | F1ADC2361F97563800464FD3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1ADC2351F97563800464FD3 /* AppDelegate.swift */; }; 11 | F1ADC2381F97563800464FD3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1ADC2371F97563800464FD3 /* ViewController.swift */; }; 12 | F1ADC23B1F97563800464FD3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F1ADC2391F97563800464FD3 /* Main.storyboard */; }; 13 | F1ADC23D1F97563800464FD3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F1ADC23C1F97563800464FD3 /* Assets.xcassets */; }; 14 | F1ADC2401F97563800464FD3 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F1ADC23E1F97563800464FD3 /* LaunchScreen.storyboard */; }; 15 | F1ADC2481F97565A00464FD3 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1ADC2471F97565A00464FD3 /* BaseViewController.swift */; }; 16 | F1ADC24E1F97591000464FD3 /* HHFloatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1ADC24B1F9756C900464FD3 /* HHFloatingView.swift */; }; 17 | F1ADC24F1F97591000464FD3 /* HHFloatingViewButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1ADC24C1F9756C900464FD3 /* HHFloatingViewButton.swift */; }; 18 | F1ADC2501F97591000464FD3 /* HHFloatingViewConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F1ADC24D1F9756C900464FD3 /* HHFloatingViewConfiguration.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | F1ADC2321F97563800464FD3 /* HHFloatingView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HHFloatingView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 23 | F1ADC2351F97563800464FD3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | F1ADC2371F97563800464FD3 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 25 | F1ADC23A1F97563800464FD3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | F1ADC23C1F97563800464FD3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 27 | F1ADC23F1F97563800464FD3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 28 | F1ADC2411F97563800464FD3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 29 | F1ADC2471F97565A00464FD3 /* BaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseViewController.swift; sourceTree = ""; }; 30 | F1ADC24B1F9756C900464FD3 /* HHFloatingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HHFloatingView.swift; sourceTree = ""; }; 31 | F1ADC24C1F9756C900464FD3 /* HHFloatingViewButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HHFloatingViewButton.swift; sourceTree = ""; }; 32 | F1ADC24D1F9756C900464FD3 /* HHFloatingViewConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HHFloatingViewConfiguration.swift; sourceTree = ""; }; 33 | /* End PBXFileReference section */ 34 | 35 | /* Begin PBXFrameworksBuildPhase section */ 36 | F1ADC22F1F97563800464FD3 /* Frameworks */ = { 37 | isa = PBXFrameworksBuildPhase; 38 | buildActionMask = 2147483647; 39 | files = ( 40 | ); 41 | runOnlyForDeploymentPostprocessing = 0; 42 | }; 43 | /* End PBXFrameworksBuildPhase section */ 44 | 45 | /* Begin PBXGroup section */ 46 | 6B2BE7112154E34D00EED478 /* Example */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | F1ADC2391F97563800464FD3 /* Main.storyboard */, 50 | F1ADC2351F97563800464FD3 /* AppDelegate.swift */, 51 | F1ADC2471F97565A00464FD3 /* BaseViewController.swift */, 52 | F1ADC2371F97563800464FD3 /* ViewController.swift */, 53 | ); 54 | path = Example; 55 | sourceTree = ""; 56 | }; 57 | F1ADC2291F97563800464FD3 = { 58 | isa = PBXGroup; 59 | children = ( 60 | F1ADC2341F97563800464FD3 /* HHFloatingView */, 61 | F1ADC2331F97563800464FD3 /* Products */, 62 | ); 63 | sourceTree = ""; 64 | }; 65 | F1ADC2331F97563800464FD3 /* Products */ = { 66 | isa = PBXGroup; 67 | children = ( 68 | F1ADC2321F97563800464FD3 /* HHFloatingView.app */, 69 | ); 70 | name = Products; 71 | sourceTree = ""; 72 | }; 73 | F1ADC2341F97563800464FD3 /* HHFloatingView */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 6B2BE7112154E34D00EED478 /* Example */, 77 | F1ADC2491F9756C900464FD3 /* Source */, 78 | F1ADC23C1F97563800464FD3 /* Assets.xcassets */, 79 | F1ADC23E1F97563800464FD3 /* LaunchScreen.storyboard */, 80 | F1ADC2411F97563800464FD3 /* Info.plist */, 81 | ); 82 | path = HHFloatingView; 83 | sourceTree = ""; 84 | }; 85 | F1ADC2491F9756C900464FD3 /* Source */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | F1ADC24B1F9756C900464FD3 /* HHFloatingView.swift */, 89 | F1ADC24C1F9756C900464FD3 /* HHFloatingViewButton.swift */, 90 | F1ADC24D1F9756C900464FD3 /* HHFloatingViewConfiguration.swift */, 91 | ); 92 | path = Source; 93 | sourceTree = ""; 94 | }; 95 | /* End PBXGroup section */ 96 | 97 | /* Begin PBXNativeTarget section */ 98 | F1ADC2311F97563800464FD3 /* HHFloatingView */ = { 99 | isa = PBXNativeTarget; 100 | buildConfigurationList = F1ADC2441F97563800464FD3 /* Build configuration list for PBXNativeTarget "HHFloatingView" */; 101 | buildPhases = ( 102 | F1ADC22E1F97563800464FD3 /* Sources */, 103 | F1ADC22F1F97563800464FD3 /* Frameworks */, 104 | F1ADC2301F97563800464FD3 /* Resources */, 105 | ); 106 | buildRules = ( 107 | ); 108 | dependencies = ( 109 | ); 110 | name = HHFloatingView; 111 | productName = HHFloatingView; 112 | productReference = F1ADC2321F97563800464FD3 /* HHFloatingView.app */; 113 | productType = "com.apple.product-type.application"; 114 | }; 115 | /* End PBXNativeTarget section */ 116 | 117 | /* Begin PBXProject section */ 118 | F1ADC22A1F97563800464FD3 /* Project object */ = { 119 | isa = PBXProject; 120 | attributes = { 121 | LastSwiftUpdateCheck = 0900; 122 | LastUpgradeCheck = 1020; 123 | ORGANIZATIONNAME = "Hemang Shah"; 124 | TargetAttributes = { 125 | F1ADC2311F97563800464FD3 = { 126 | CreatedOnToolsVersion = 9.0; 127 | }; 128 | }; 129 | }; 130 | buildConfigurationList = F1ADC22D1F97563800464FD3 /* Build configuration list for PBXProject "HHFloatingView" */; 131 | compatibilityVersion = "Xcode 8.0"; 132 | developmentRegion = en; 133 | hasScannedForEncodings = 0; 134 | knownRegions = ( 135 | en, 136 | Base, 137 | ); 138 | mainGroup = F1ADC2291F97563800464FD3; 139 | productRefGroup = F1ADC2331F97563800464FD3 /* Products */; 140 | projectDirPath = ""; 141 | projectRoot = ""; 142 | targets = ( 143 | F1ADC2311F97563800464FD3 /* HHFloatingView */, 144 | ); 145 | }; 146 | /* End PBXProject section */ 147 | 148 | /* Begin PBXResourcesBuildPhase section */ 149 | F1ADC2301F97563800464FD3 /* Resources */ = { 150 | isa = PBXResourcesBuildPhase; 151 | buildActionMask = 2147483647; 152 | files = ( 153 | F1ADC2401F97563800464FD3 /* LaunchScreen.storyboard in Resources */, 154 | F1ADC23D1F97563800464FD3 /* Assets.xcassets in Resources */, 155 | F1ADC23B1F97563800464FD3 /* Main.storyboard in Resources */, 156 | ); 157 | runOnlyForDeploymentPostprocessing = 0; 158 | }; 159 | /* End PBXResourcesBuildPhase section */ 160 | 161 | /* Begin PBXSourcesBuildPhase section */ 162 | F1ADC22E1F97563800464FD3 /* Sources */ = { 163 | isa = PBXSourcesBuildPhase; 164 | buildActionMask = 2147483647; 165 | files = ( 166 | F1ADC24E1F97591000464FD3 /* HHFloatingView.swift in Sources */, 167 | F1ADC24F1F97591000464FD3 /* HHFloatingViewButton.swift in Sources */, 168 | F1ADC2501F97591000464FD3 /* HHFloatingViewConfiguration.swift in Sources */, 169 | F1ADC2381F97563800464FD3 /* ViewController.swift in Sources */, 170 | F1ADC2361F97563800464FD3 /* AppDelegate.swift in Sources */, 171 | F1ADC2481F97565A00464FD3 /* BaseViewController.swift in Sources */, 172 | ); 173 | runOnlyForDeploymentPostprocessing = 0; 174 | }; 175 | /* End PBXSourcesBuildPhase section */ 176 | 177 | /* Begin PBXVariantGroup section */ 178 | F1ADC2391F97563800464FD3 /* Main.storyboard */ = { 179 | isa = PBXVariantGroup; 180 | children = ( 181 | F1ADC23A1F97563800464FD3 /* Base */, 182 | ); 183 | name = Main.storyboard; 184 | sourceTree = ""; 185 | }; 186 | F1ADC23E1F97563800464FD3 /* LaunchScreen.storyboard */ = { 187 | isa = PBXVariantGroup; 188 | children = ( 189 | F1ADC23F1F97563800464FD3 /* Base */, 190 | ); 191 | name = LaunchScreen.storyboard; 192 | sourceTree = ""; 193 | }; 194 | /* End PBXVariantGroup section */ 195 | 196 | /* Begin XCBuildConfiguration section */ 197 | F1ADC2421F97563800464FD3 /* Debug */ = { 198 | isa = XCBuildConfiguration; 199 | buildSettings = { 200 | ALWAYS_SEARCH_USER_PATHS = NO; 201 | CLANG_ANALYZER_NONNULL = YES; 202 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 203 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 204 | CLANG_CXX_LIBRARY = "libc++"; 205 | CLANG_ENABLE_MODULES = YES; 206 | CLANG_ENABLE_OBJC_ARC = YES; 207 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 208 | CLANG_WARN_BOOL_CONVERSION = YES; 209 | CLANG_WARN_COMMA = YES; 210 | CLANG_WARN_CONSTANT_CONVERSION = YES; 211 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 212 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 213 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INFINITE_RECURSION = YES; 217 | CLANG_WARN_INT_CONVERSION = YES; 218 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 219 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 220 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 221 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 222 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 223 | CLANG_WARN_STRICT_PROTOTYPES = YES; 224 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 225 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 226 | CLANG_WARN_UNREACHABLE_CODE = YES; 227 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 228 | CODE_SIGN_IDENTITY = "iPhone Developer"; 229 | COPY_PHASE_STRIP = NO; 230 | DEBUG_INFORMATION_FORMAT = dwarf; 231 | ENABLE_STRICT_OBJC_MSGSEND = YES; 232 | ENABLE_TESTABILITY = YES; 233 | GCC_C_LANGUAGE_STANDARD = gnu11; 234 | GCC_DYNAMIC_NO_PIC = NO; 235 | GCC_NO_COMMON_BLOCKS = YES; 236 | GCC_OPTIMIZATION_LEVEL = 0; 237 | GCC_PREPROCESSOR_DEFINITIONS = ( 238 | "DEBUG=1", 239 | "$(inherited)", 240 | ); 241 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 242 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 243 | GCC_WARN_UNDECLARED_SELECTOR = YES; 244 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 245 | GCC_WARN_UNUSED_FUNCTION = YES; 246 | GCC_WARN_UNUSED_VARIABLE = YES; 247 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 248 | MTL_ENABLE_DEBUG_INFO = YES; 249 | ONLY_ACTIVE_ARCH = YES; 250 | SDKROOT = iphoneos; 251 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 252 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 253 | SWIFT_VERSION = 5.0; 254 | }; 255 | name = Debug; 256 | }; 257 | F1ADC2431F97563800464FD3 /* Release */ = { 258 | isa = XCBuildConfiguration; 259 | buildSettings = { 260 | ALWAYS_SEARCH_USER_PATHS = NO; 261 | CLANG_ANALYZER_NONNULL = YES; 262 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 263 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 264 | CLANG_CXX_LIBRARY = "libc++"; 265 | CLANG_ENABLE_MODULES = YES; 266 | CLANG_ENABLE_OBJC_ARC = YES; 267 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 268 | CLANG_WARN_BOOL_CONVERSION = YES; 269 | CLANG_WARN_COMMA = YES; 270 | CLANG_WARN_CONSTANT_CONVERSION = YES; 271 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 272 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 273 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 274 | CLANG_WARN_EMPTY_BODY = YES; 275 | CLANG_WARN_ENUM_CONVERSION = YES; 276 | CLANG_WARN_INFINITE_RECURSION = YES; 277 | CLANG_WARN_INT_CONVERSION = YES; 278 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 279 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 280 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 282 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 283 | CLANG_WARN_STRICT_PROTOTYPES = YES; 284 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 285 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 286 | CLANG_WARN_UNREACHABLE_CODE = YES; 287 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 288 | CODE_SIGN_IDENTITY = "iPhone Developer"; 289 | COPY_PHASE_STRIP = NO; 290 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 291 | ENABLE_NS_ASSERTIONS = NO; 292 | ENABLE_STRICT_OBJC_MSGSEND = YES; 293 | GCC_C_LANGUAGE_STANDARD = gnu11; 294 | GCC_NO_COMMON_BLOCKS = YES; 295 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 296 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 297 | GCC_WARN_UNDECLARED_SELECTOR = YES; 298 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 299 | GCC_WARN_UNUSED_FUNCTION = YES; 300 | GCC_WARN_UNUSED_VARIABLE = YES; 301 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 302 | MTL_ENABLE_DEBUG_INFO = NO; 303 | SDKROOT = iphoneos; 304 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 305 | SWIFT_VERSION = 5.0; 306 | VALIDATE_PRODUCT = YES; 307 | }; 308 | name = Release; 309 | }; 310 | F1ADC2451F97563800464FD3 /* Debug */ = { 311 | isa = XCBuildConfiguration; 312 | buildSettings = { 313 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 314 | INFOPLIST_FILE = HHFloatingView/Info.plist; 315 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 316 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 317 | PRODUCT_BUNDLE_IDENTIFIER = com.hemangshah.HHFloatingView; 318 | PRODUCT_NAME = "$(TARGET_NAME)"; 319 | SWIFT_VERSION = 5.0; 320 | TARGETED_DEVICE_FAMILY = "1,2"; 321 | }; 322 | name = Debug; 323 | }; 324 | F1ADC2461F97563800464FD3 /* Release */ = { 325 | isa = XCBuildConfiguration; 326 | buildSettings = { 327 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 328 | INFOPLIST_FILE = HHFloatingView/Info.plist; 329 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 330 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 331 | PRODUCT_BUNDLE_IDENTIFIER = com.hemangshah.HHFloatingView; 332 | PRODUCT_NAME = "$(TARGET_NAME)"; 333 | SWIFT_VERSION = 5.0; 334 | TARGETED_DEVICE_FAMILY = "1,2"; 335 | }; 336 | name = Release; 337 | }; 338 | /* End XCBuildConfiguration section */ 339 | 340 | /* Begin XCConfigurationList section */ 341 | F1ADC22D1F97563800464FD3 /* Build configuration list for PBXProject "HHFloatingView" */ = { 342 | isa = XCConfigurationList; 343 | buildConfigurations = ( 344 | F1ADC2421F97563800464FD3 /* Debug */, 345 | F1ADC2431F97563800464FD3 /* Release */, 346 | ); 347 | defaultConfigurationIsVisible = 0; 348 | defaultConfigurationName = Release; 349 | }; 350 | F1ADC2441F97563800464FD3 /* Build configuration list for PBXNativeTarget "HHFloatingView" */ = { 351 | isa = XCConfigurationList; 352 | buildConfigurations = ( 353 | F1ADC2451F97563800464FD3 /* Debug */, 354 | F1ADC2461F97563800464FD3 /* Release */, 355 | ); 356 | defaultConfigurationIsVisible = 0; 357 | defaultConfigurationName = Release; 358 | }; 359 | /* End XCConfigurationList section */ 360 | }; 361 | rootObject = F1ADC22A1F97563800464FD3 /* Project object */; 362 | } 363 | -------------------------------------------------------------------------------- /HHFloatingView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /HHFloatingView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/.DS_Store -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/Assets.xcassets/.DS_Store -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-bird.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "bird.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-bird.imageset/bird.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/Assets.xcassets/icon-bird.imageset/bird.png -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-gift.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "gift.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-gift.imageset/gift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/Assets.xcassets/icon-gift.imageset/gift.png -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-megaphone.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "megaphone.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-megaphone.imageset/megaphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/Assets.xcassets/icon-megaphone.imageset/megaphone.png -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-rocket.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "rocket.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-rocket.imageset/rocket.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/Assets.xcassets/icon-rocket.imageset/rocket.png -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-ufo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "ufo.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-ufo.imageset/ufo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/Assets.xcassets/icon-ufo.imageset/ufo.png -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-umbrella.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "umbrella.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /HHFloatingView/Assets.xcassets/icon-umbrella.imageset/umbrella.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/HHFloatingView/Assets.xcassets/icon-umbrella.imageset/umbrella.png -------------------------------------------------------------------------------- /HHFloatingView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /HHFloatingView/Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // HHFloatingView 4 | // 5 | // Created by Hemang Shah on 10/18/17. 6 | // Copyright © 2017 Hemang Shah. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | 20 | func applicationWillResignActive(_ application: UIApplication) { 21 | 22 | } 23 | 24 | func applicationDidEnterBackground(_ application: UIApplication) { 25 | 26 | } 27 | 28 | func applicationWillEnterForeground(_ application: UIApplication) { 29 | 30 | } 31 | 32 | func applicationDidBecomeActive(_ application: UIApplication) { 33 | 34 | } 35 | 36 | func applicationWillTerminate(_ application: UIApplication) { 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /HHFloatingView/Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /HHFloatingView/Example/BaseViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.swift 3 | // HHFloatingView 4 | // 5 | // Created by Hemang Shah on 10/18/17. 6 | // Copyright © 2017 Hemang Shah. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class BaseViewController: UIViewController { 12 | 13 | //Initialize HHFloatingView 14 | fileprivate var floatingView: HHFloatingView = { 15 | let floatingViewSize: CGFloat = 100.0 16 | let padding: CGFloat = 10.0 17 | let hhfv = HHFloatingView.init(frame: CGRect.init(origin: CGPoint.init(x: UIScreen.main.bounds.size.width - (floatingViewSize + padding), y: UIScreen.main.bounds.size.height - (floatingViewSize + padding)), size: CGSize.init(width: floatingViewSize, height: floatingViewSize))) 18 | return hhfv 19 | }() 20 | 21 | //MARK: Add Floating View. 22 | internal func addFloatingView() { 23 | floatingView.delegate = self 24 | floatingView.datasource = self 25 | view.addSubview(floatingView) 26 | floatingView.reload() 27 | } 28 | } 29 | 30 | //MARK: HHFloatingViewDatasource 31 | extension BaseViewController: HHFloatingViewDatasource { 32 | func floatingViewConfiguration(floatingView: HHFloatingView) -> HHFloatingViewConfiguration { 33 | let configure = HHFloatingViewConfiguration.init() 34 | configure.animationTimerDuration = 0.3 35 | configure.internalAnimationTimerDuration = 0.2 36 | configure.optionsDisplayDirection = .top 37 | configure.numberOfOptions = 5 38 | configure.handlerSize = CGSize.init(width: 90.0, height: 90.0) 39 | configure.optionsSize = CGSize.init(width: 60.0, height: 60.0) 40 | configure.initialMargin = 20.0 41 | configure.internalMargin = 10.0 42 | configure.handlerImage = #imageLiteral(resourceName: "icon-bird") 43 | configure.handlerColor = UIColor.blue.withAlphaComponent(0.5) 44 | configure.optionImages = [#imageLiteral(resourceName: "icon-ufo"), #imageLiteral(resourceName: "icon-gift"), #imageLiteral(resourceName: "icon-megaphone"), #imageLiteral(resourceName: "icon-rocket"), #imageLiteral(resourceName: "icon-umbrella")] 45 | configure.optionColors = [UIColor.red.withAlphaComponent(0.5), 46 | UIColor.purple.withAlphaComponent(0.5), 47 | UIColor.blue.withAlphaComponent(0.5), 48 | UIColor.cyan.withAlphaComponent(0.5), 49 | UIColor.magenta.withAlphaComponent(0.5)] 50 | configure.isDraggable = true 51 | return configure 52 | } 53 | } 54 | 55 | //MARK: HHFloatingViewDelegate 56 | extension BaseViewController: HHFloatingViewDelegate { 57 | func floatingView(floatingView: HHFloatingView, didSelectOption index: Int) { 58 | print("HHFloatingView: Button Selected: \(index)") 59 | floatingView.close() 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /HHFloatingView/Example/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // HHFloatingView 4 | // 5 | // Created by Hemang Shah on 10/18/17. 6 | // Copyright © 2017 Hemang Shah. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: BaseViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | addFloatingView() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /HHFloatingView/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 3.0.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /HHFloatingView/Source/HHFloatingView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HHFloatingView.swift 3 | // HHFloatingView 4 | // 5 | // Created by Hemang Shah on 10/18/17. 6 | // Copyright © 2017 Hemang Shah. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public protocol HHFloatingViewDatasource: class { 12 | /// This datasource will be the entry point to configure the floating-view. 13 | func floatingViewConfiguration(floatingView: HHFloatingView) -> HHFloatingViewConfiguration 14 | } 15 | 16 | public protocol HHFloatingViewDelegate: class { 17 | /// This delegate will tell which option is selected. 18 | func floatingView(floatingView: HHFloatingView, didSelectOption index: Int) 19 | 20 | /// This delegate will tell when you're opening or closing the floating-view. 21 | func floatingView(floatingView: HHFloatingView, didTapHandler isOpening: Bool) 22 | 23 | /// This delegate will tell which option is going to display. 24 | func floatingView(floatingView: HHFloatingView, willShowOption index: Int) 25 | /// This delegate will tell which option is displayed. 26 | func floatingView(floatingView: HHFloatingView, didShowOption index: Int) 27 | /// This delegate will tell which option is going to hide. 28 | func floatingView(floatingView: HHFloatingView, willHideOption index: Int) 29 | /// This delegate will tell which option is hidden. 30 | func floatingView(floatingView: HHFloatingView, didHideOption index: Int) 31 | } 32 | 33 | public extension HHFloatingViewDelegate { 34 | func floatingView(floatingView: HHFloatingView, didTapHandler isOpening: Bool) {} 35 | func floatingView(floatingView: HHFloatingView, willShowOption index: Int) {} 36 | func floatingView(floatingView: HHFloatingView, didShowOption index: Int) {} 37 | func floatingView(floatingView: HHFloatingView, willHideOption index: Int) {} 38 | func floatingView(floatingView: HHFloatingView, didHideOption index: Int) {} 39 | } 40 | 41 | public final class HHFloatingView: UIView { 42 | 43 | //MARK: Datasource/Delegate 44 | /// Datasource for HHFloatingView. 45 | public weak var datasource: HHFloatingViewDatasource? 46 | /// Delegate for HHFloatingView. 47 | public weak var delegate: HHFloatingViewDelegate? 48 | /// Check whether HHFloatingView is open or closed. 49 | public private(set) var isOpen = false 50 | 51 | fileprivate var options = [HHFloatingViewButton]() 52 | fileprivate var openingCenters = [CGPoint]() 53 | fileprivate var currentButtonIndex = 0 54 | 55 | //MARK: Handler Button 56 | fileprivate var handlerButton: HHFloatingViewButton? 57 | 58 | //MARK: Configurations 59 | fileprivate var configurations: HHFloatingViewConfiguration! 60 | 61 | //MARK: Timer 62 | fileprivate var animationTimer: Timer! 63 | 64 | //MARK: Init 65 | override public init(frame: CGRect) { 66 | super.init(frame: frame) 67 | } 68 | 69 | required public init?(coder aDecoder: NSCoder) { 70 | fatalError("init(coder:) has not been implemented") 71 | } 72 | 73 | //MARK: Scale Animations 74 | fileprivate func scaleAnimateButton(button: HHFloatingViewButton?, scaleValue: CGFloat) { 75 | button?.transform = CGAffineTransform.init(scaleX: scaleValue, y: scaleValue) 76 | } 77 | 78 | //MARK: Setup 79 | fileprivate func fetchDatasource() { 80 | configurations = datasource?.floatingViewConfiguration(floatingView: self) 81 | } 82 | 83 | fileprivate func updateUI() { 84 | handlerButton?.backgroundColor = configurations.handlerColor 85 | handlerButton?.setImage(configurations.handlerImage, for: .normal) 86 | 87 | for (index, optionButton) in options.enumerated() { 88 | optionButton.backgroundColor = configurations.optionColors[index] 89 | optionButton.setImage(configurations.optionImages[index], for: .normal) 90 | } 91 | 92 | calculateOptionButtonsOpeningCenters() 93 | 94 | if configurations.showScaleAnimation { 95 | scaleAnimateButton(button: handlerButton, scaleValue: 0.0) 96 | } 97 | 98 | DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) { [weak self] in 99 | guard let strongSelf = self else { return } 100 | UIView.animate(withDuration: strongSelf.configurations.internalAnimationTimerDuration) { 101 | if strongSelf.configurations.showScaleAnimation { 102 | strongSelf.scaleAnimateButton(button: strongSelf.handlerButton, scaleValue: strongSelf.configurations.scaleAnimationSize) 103 | } 104 | } 105 | } 106 | } 107 | 108 | fileprivate func setupUI() { 109 | let superView = self.superview! 110 | 111 | let optionButton = HHFloatingViewButton() 112 | optionButton.backgroundColor = configurations.handlerColor 113 | optionButton.setImage(configurations.handlerImage, for: .normal) 114 | optionButton.addTarget(self, action: #selector(actionOpenOrCloseOptionsView), for: .touchUpInside) 115 | optionButton.frame = CGRect.init(origin: CGPoint.zero, size: configurations.handlerSize) 116 | self.dropShadow(onView: optionButton, withRadius: optionButton.layer.cornerRadius, withColor: optionButton.backgroundColor!.cgColor, isHandlerButton: true) 117 | superView.addSubview(optionButton) 118 | optionButton.center = self.center 119 | handlerButton = optionButton 120 | 121 | if configurations.showScaleAnimation { 122 | scaleAnimateButton(button: handlerButton, scaleValue: 0.0) 123 | } 124 | 125 | for index in 0.. frameMaxX { 199 | requirePosition.x = positionMaxX - ((positionMaxX - frameMaxX) + configurations.handlerSize.width + margin) 200 | } else if positionMinX < 0.0 { 201 | requirePosition.x = margin 202 | } 203 | 204 | if positionMaxY > frameMaxY { 205 | requirePosition.y = positionMaxY - ((positionMaxY - frameMaxY) + configurations.handlerSize.height + margin) 206 | } else if positionMinY < 0.0 { 207 | requirePosition.y = margin 208 | } 209 | 210 | var frame = handlerButton.frame 211 | frame.origin = requirePosition 212 | handlerButton.frame = frame 213 | } 214 | 215 | fileprivate func updateOptionsDisplayDirection() { 216 | guard let superView = superview, let handlerButton = handlerButton else { return } 217 | let position = handlerButton.frame.origin 218 | let frameMaxX = superView.frame.maxX 219 | let frameMaxY = superView.frame.maxY 220 | 221 | if position.x < frameMaxX/2.0 && position.y > frameMaxY/2.0 { 222 | configurations.optionsDisplayDirection = .top 223 | } else if position.x > frameMaxX/2.0 && position.y > frameMaxY/2.0 { 224 | configurations.optionsDisplayDirection = .top 225 | } else if position.x < frameMaxX/2.0 && position.y > frameMaxY/3.0 { 226 | configurations.optionsDisplayDirection = .top 227 | } else if position.x > frameMaxX/2.0 && position.y < frameMaxY/3.0 { 228 | configurations.optionsDisplayDirection = .bottom 229 | } else if position.x < frameMaxX/2.0 && position.y < frameMaxY/3.0 { 230 | configurations.optionsDisplayDirection = .bottom 231 | } else if position.x > frameMaxX/2.0 && position.y > frameMaxY/3.0 { 232 | configurations.optionsDisplayDirection = .top 233 | } 234 | } 235 | 236 | //MARK: UI Helpers 237 | fileprivate func dropShadow(onView view: UIView, withRadius radius: CGFloat, withColor color: CGColor, isHandlerButton: Bool) { 238 | if isHandlerButton { 239 | if !configurations.showShadowInHandlerButton { 240 | return 241 | } 242 | } else { 243 | if !configurations.showShadowInButtons { 244 | return 245 | } 246 | } 247 | view.layer.masksToBounds = false 248 | view.layer.shadowColor = color 249 | view.layer.shadowOpacity = 0.2 250 | view.layer.shadowOffset = CGSize(width: -1, height: 1) 251 | view.layer.shadowRadius = radius 252 | view.layer.shadowPath = UIBezierPath(rect: self.bounds).cgPath 253 | view.layer.shouldRasterize = true 254 | view.layer.rasterizationScale = UIScreen.main.scale 255 | } 256 | 257 | //MARK: Animation Open/Close 258 | fileprivate func resetTimer() { 259 | animationTimer.invalidate() 260 | animationTimer = nil 261 | } 262 | 263 | @objc fileprivate func optionsOpenAnimation() { 264 | guard currentButtonIndex <= maxOptions() else { 265 | enableOptionButtons() 266 | resetTimer() 267 | return 268 | } 269 | 270 | let optionButton = options[currentButtonIndex] 271 | delegate?.floatingView(floatingView: self, willShowOption: optionButton.tag) 272 | 273 | let optionButtonCenter = openingCenters[currentButtonIndex] 274 | optionButton.alpha = 0.0 275 | scaleAnimateButton(button: optionButton, scaleValue: 0.0) 276 | 277 | UIView.animate(withDuration: configurations.internalAnimationTimerDuration, animations: { 278 | optionButton.alpha = 1.0 279 | optionButton.center = optionButtonCenter 280 | self.scaleAnimateButton(button: optionButton, scaleValue: self.configurations.scaleAnimationSize) 281 | }, completion: { (isCompleted) in 282 | if isCompleted { 283 | self.delegate?.floatingView(floatingView: self, didShowOption: optionButton.tag) 284 | } 285 | }) 286 | 287 | currentButtonIndex += 1 288 | } 289 | 290 | @objc fileprivate func optionsCloseAnimation() { 291 | guard currentButtonIndex >= 0 else { 292 | enableOptionButtons() 293 | currentButtonIndex = 0 294 | resetTimer() 295 | return 296 | } 297 | 298 | let optionButton = options[currentButtonIndex] 299 | delegate?.floatingView(floatingView: self, willHideOption: optionButton.tag) 300 | 301 | UIView.animate(withDuration: configurations.internalAnimationTimerDuration, animations: { 302 | self.scaleAnimateButton(button: optionButton, scaleValue: self.configurations.scaleAnimationSize) 303 | optionButton.center = self.center 304 | }, completion: { (isCompleted) in 305 | if isCompleted { 306 | optionButton.alpha = 0.0 307 | self.delegate?.floatingView(floatingView: self, didHideOption: optionButton.tag) 308 | } 309 | }) 310 | 311 | currentButtonIndex -= 1 312 | } 313 | 314 | //MARK: UI Helpers 315 | fileprivate func disableOptionButtons() { 316 | handlerButton?.isUserInteractionEnabled = false 317 | _ = options.map{ $0.isUserInteractionEnabled = false } 318 | } 319 | 320 | fileprivate func enableOptionButtons() { 321 | handlerButton?.isUserInteractionEnabled = true 322 | _ = options.map{ $0.isUserInteractionEnabled = true } 323 | } 324 | 325 | fileprivate func maxOptions() -> Int { 326 | return (options.count - 1) 327 | } 328 | 329 | //MARK: Calculate Option Buttons Origins 330 | fileprivate func calculateOptionButtonsOpeningCenters() { 331 | 332 | openingCenters.removeAll() 333 | 334 | var lastCenter: CGPoint = center 335 | let initialMargin: CGFloat = configurations.initialMargin 336 | let internalMargin: CGFloat = configurations.internalMargin 337 | let topButtonSize: CGSize = configurations.handlerSize 338 | let optionsButtonSize: CGSize = configurations.optionsSize 339 | var index: Int = 0 340 | let optionsDisplayDirection = configurations.optionsDisplayDirection 341 | 342 | if optionsDisplayDirection == .top { 343 | self.options.forEach({ (optionButton) in 344 | lastCenter.y -= (index == 0) ? (topButtonSize.height + initialMargin) : (optionsButtonSize.height + internalMargin) 345 | openingCenters.append(lastCenter) 346 | index += 1 347 | }) 348 | } else if optionsDisplayDirection == .left { 349 | self.options.forEach({ (optionButton) in 350 | lastCenter.x -= (index == 0) ? (topButtonSize.height + initialMargin) : (optionsButtonSize.height + internalMargin) 351 | openingCenters.append(lastCenter) 352 | index += 1 353 | }) 354 | } else if optionsDisplayDirection == .right { 355 | self.options.forEach({ (optionButton) in 356 | lastCenter.x += (index == 0) ? (topButtonSize.height + initialMargin) : (optionsButtonSize.height + internalMargin) 357 | openingCenters.append(lastCenter) 358 | index += 1 359 | }) 360 | } else if optionsDisplayDirection == .bottom { 361 | self.options.forEach({ (optionButton) in 362 | lastCenter.y += (index == 0) ? (topButtonSize.height + initialMargin) : (optionsButtonSize.height + internalMargin) 363 | openingCenters.append(lastCenter) 364 | index += 1 365 | }) 366 | } 367 | } 368 | 369 | //MARK: Actions 370 | @objc fileprivate func actionOptionsTapped(sender: HHFloatingViewButton) { 371 | delegate?.floatingView(floatingView: self, didSelectOption: sender.tag) 372 | } 373 | 374 | @objc fileprivate func actionOpenOrCloseOptionsView(sender: HHFloatingViewButton?) { 375 | disableOptionButtons() 376 | if isOpen { 377 | delegate?.floatingView(floatingView: self, didTapHandler: false) 378 | currentButtonIndex = maxOptions() 379 | isOpen = false 380 | animationTimer = Timer.scheduledTimer(timeInterval: configurations.animationTimerDuration, target: self, selector: #selector(self.optionsCloseAnimation), userInfo: nil, repeats: true) 381 | } else { 382 | delegate?.floatingView(floatingView: self, didTapHandler: true) 383 | currentButtonIndex = 0 384 | isOpen = true 385 | animationTimer = Timer.scheduledTimer(timeInterval: configurations.animationTimerDuration, target: self, selector: #selector(self.optionsOpenAnimation), userInfo: nil, repeats: true) 386 | } 387 | } 388 | 389 | /// Reload HHFloatingView. 390 | public func reload() { 391 | if isDatasourceSet() { 392 | if isDelegateSet() { 393 | fetchDatasource() 394 | if isValidConfiguration() { 395 | if (handlerButton != nil) { 396 | updateUI() 397 | } else { 398 | setupUI() 399 | } 400 | } 401 | } 402 | } 403 | } 404 | 405 | /// Open HHFloatingView. 406 | public func open() { 407 | if !isOpen { 408 | actionOpenOrCloseOptionsView(sender: handlerButton) 409 | } 410 | } 411 | 412 | /// Close HHFloatingView. 413 | public func close() { 414 | if isOpen { 415 | actionOpenOrCloseOptionsView(sender: handlerButton) 416 | } 417 | } 418 | 419 | /// Toggle Open/Close 420 | public func toggle() { 421 | actionOpenOrCloseOptionsView(sender: handlerButton) 422 | } 423 | 424 | //MARK: Validations 425 | fileprivate func isDatasourceSet() -> Bool { 426 | if datasource != nil { 427 | return true 428 | } else { 429 | fatalError("HHFloatingView: Datasource should be set.") 430 | } 431 | } 432 | 433 | fileprivate func isDelegateSet() -> Bool { 434 | if delegate != nil { 435 | return true 436 | } else { 437 | fatalError("HHFloatingView: Delegate should be set.") 438 | } 439 | } 440 | 441 | fileprivate func isValidConfiguration() -> Bool { 442 | let isOptionIsNotZero = (configurations.numberOfOptions > 0) 443 | let isOptionsNotEmpty = (!configurations.optionImages.isEmpty && !configurations.optionColors.isEmpty) 444 | let isNumberOfOptionsAreEqualsToOptionsImages = (configurations.numberOfOptions == configurations.optionImages.count) 445 | let isNumberOfOptionsAreEqualsToOptionsColors = (configurations.numberOfOptions == configurations.optionColors.count) 446 | 447 | if isOptionIsNotZero { 448 | if (isOptionsNotEmpty && (isNumberOfOptionsAreEqualsToOptionsColors && isNumberOfOptionsAreEqualsToOptionsImages)) { 449 | return true 450 | } else { 451 | fatalError("HHFloatingView: HHFloatingViewConfiguration.optionImages and HHFloatingViewConfiguration.optionColors should be equals to the numberOfOptions.") 452 | } 453 | } else { 454 | fatalError("HHFloatingView: numberOfOptions should not be Zero.") 455 | } 456 | } 457 | } 458 | -------------------------------------------------------------------------------- /HHFloatingView/Source/HHFloatingViewButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HHFloatingViewButton.swift 3 | // HHFloatingView 4 | // 5 | // Created by Hemang Shah on 10/18/17. 6 | // Copyright © 2017 Hemang Shah. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public final class HHFloatingViewButton: UIButton { 12 | 13 | override init(frame: CGRect) { 14 | super.init(frame: frame) 15 | } 16 | 17 | override public var frame: CGRect { 18 | didSet { 19 | self.layer.cornerRadius = self.frame.size.width/2.0 20 | self.layer.masksToBounds = true 21 | } 22 | } 23 | 24 | required public init?(coder aDecoder: NSCoder) { 25 | fatalError("init(coder:) has not been implemented") 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /HHFloatingView/Source/HHFloatingViewConfiguration.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HHFloatingViewConfiguration.swift 3 | // HHFloatingView 4 | // 5 | // Created by Hemang Shah on 10/18/17. 6 | // Copyright © 2017 Hemang Shah. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @objc public enum HHFloatingViewOptionsDisplayDirection: Int { 12 | case top, left, right, bottom 13 | } 14 | 15 | @objc public class HHFloatingViewConfiguration: NSObject { 16 | /// Total number of options will be display in HHFloatingView. Default: 0 17 | public var numberOfOptions: Int = 0 18 | /// Images to be display for each of the options. 19 | public var optionImages = [UIImage]() 20 | /// Colors to be display for each of the options. 21 | public var optionColors = [UIColor]() 22 | /// Handler Image to be display for HHFloatingView. 23 | public var handlerImage = UIImage.init() 24 | /// Handler Color to be display for HHFloatingView. Default: white 25 | public var handlerColor = UIColor.white 26 | /// Position for HHFloatingView. Default: top 27 | public var optionsDisplayDirection: HHFloatingViewOptionsDisplayDirection = .top 28 | /// Handler Button Size. Default: 80x80 29 | public var handlerSize: CGSize = .init(width: 80.0, height: 80.0) 30 | /// Options Button Size. Default: 60x60 31 | public var optionsSize: CGSize = .init(width: 60.0, height: 60.0) 32 | /// Internal Margins. Default: 10.0 33 | public var internalMargin: CGFloat = 10.0 34 | /// Initial Margin. Default: 20.0 35 | public var initialMargin: CGFloat = 20.0 36 | /// Animation Timer Duration. Default: 0.3 37 | public var animationTimerDuration: TimeInterval = 0.3 38 | /// Internal Animation Timer Duration. Default: 0.2 39 | public var internalAnimationTimerDuration: TimeInterval = 0.2 40 | /// Show Shadow for Options. Default: false 41 | public var showShadowInButtons = false 42 | /// Show Shadow for Handler Button. Default: false 43 | public var showShadowInHandlerButton = false 44 | /// Show Scale Animation for Buttons and Handler. Default: false 45 | public var showScaleAnimation = false 46 | /// Size for the Scale Animation. Default: 1.0 47 | public var scaleAnimationSize: CGFloat = 1.0 48 | /// To drag floating view within application screen. Default: false 49 | public var isDraggable: Bool = false 50 | } 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Hemang Shah 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HHFloatingView 2 | An easy to use and setup floating view for your app. 🎡 3 | 4 | 5 | [![License](https://img.shields.io/badge/License-MIT-lightgrey.svg)](https://github.com/hemangshah/HHFloatingView/blob/master/LICENSE) 6 | [![Platform](https://img.shields.io/badge/Platforms-iOS-red.svg)](https://www.apple.com/in/ios/) 7 | [![Swift 5.0](https://img.shields.io/badge/Swift-5.0-blue.svg)](https://swift.org/) 8 | [![iOS >= 9.0](https://img.shields.io/badge/iOS%20-%3E%3D%209.0-yellowgreen.svg)](https://www.apple.com/in/ios) 9 | [![MadeWithLove](https://img.shields.io/badge/Made%20with%20%E2%9D%A4-India-green.svg)](https://madewithlove.org.in/) 10 | [![Awesome-Swift](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/matteocrippa/awesome-swift/) 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | ## Installation 20 | 21 | 1. **Manually** - Add `HHFloatingView/Source` folder to your Project. And you're good to use `HHFloatingView`. 22 | 23 | 2. **CocoaPods**: `pod 'HHFloatingView'` 24 | 25 | > You can read the [CHANGELOG](https://github.com/hemangshah/HHFloatingView/blob/master/CHANGELOG.md) file for a particular release. 26 | 27 | ## Usage 28 | 29 | Please check the [example](https://github.com/hemangshah/HHFloatingView/tree/master/HHFloatingView/Example) project. 30 | 31 | 32 | # ToDo[s] 33 | 34 | You can [watch](https://github.com/hemangshah/HHFloatingView/subscription) to **HHFloatingView** to see continuous updates. Stay tuned. 35 | 36 | Have an idea for improvements of this class? 37 | Please open an [issue](https://github.com/hemangshah/HHFloatingView/issues/new). 38 |     39 | ## Credits 40 | 41 | [Hemang Shah](https://about.me/hemang.shah) 42 | 43 | **You can shoot me an [email](http://www.google.com/recaptcha/mailhide/d?k=01IzGihUsyfigse2G9z80rBw==&c=vU7vyAaau8BctOAIJFwHVbKfgtIqQ4QLJaL73yhnB3k=) to contact.** 44 | 45 | ## Thank You!! 46 | 47 | See the [contributions](https://github.com/hemangshah/HHFloatingView/blob/master/CONTRIBUTIONS.md) for details. 48 | 49 | ## License 50 | 51 | The MIT License (MIT) 52 | 53 | > Read the [LICENSE](https://github.com/hemangshah/HHFloatingView/blob/master/LICENSE) file for details. 54 | -------------------------------------------------------------------------------- /Screenshots/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/Screenshots/.DS_Store -------------------------------------------------------------------------------- /Screenshots/Screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/Screenshots/Screenshot-1.png -------------------------------------------------------------------------------- /Screenshots/Screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hemangshah/HHFloatingView/c884a7e63e498cfdedf12d6525ec4b3cbc5c3dda/Screenshots/Screenshot-2.png --------------------------------------------------------------------------------