├── .gitignore ├── DateRangeSelector.podspec ├── DateRangeSelector.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── DateRangeSelector ├── CalendarKit │ ├── CalendarLogic.swift │ ├── CalendarView.swift │ ├── CalendarView.xib │ ├── CollectionViewCell │ │ ├── DayCollectionCell.swift │ │ ├── DayCollectionCell.xib │ │ ├── MonthCollectionCell.swift │ │ └── MonthCollectionCell.xib │ ├── Extensions.swift │ ├── WeekHeaderView.swift │ └── WeekHeaderView.xib ├── DateRangeSelector.h └── Info.plist ├── DateRangeSelectorExample ├── AppDelegate.swift ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── SceneDelegate.swift └── ViewController.swift ├── DateRangeSelectorTests ├── DateRangeSelectorTests.swift └── Info.plist ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | -------------------------------------------------------------------------------- /DateRangeSelector.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | 3 | spec.name = "DateRangeSelector" 4 | spec.version = "0.0.3" 5 | spec.summary = "customizable calendar view as a date range selector" 6 | 7 | spec.homepage = "https://github.com/boof-tech/DateRangeSelector" 8 | spec.screenshots = "https://user-images.githubusercontent.com/35375629/110629989-115ade00-81ba-11eb-85af-f6d5f026066c.png" 9 | 10 | 11 | spec.swift_versions = '5.0' 12 | spec.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' } 13 | spec.license = { :type => "MIT" } 14 | spec.author = { "Boof.tech" => "info@boof.tech" } 15 | spec.platform = :ios, "11.0" 16 | spec.source = { :git => 'https://github.com/boof-tech/DateRangeSelector.git', :tag => '0.0.3'} 17 | spec.source_files = "DateRangeSelector/**/*.{swift,xib}" 18 | end -------------------------------------------------------------------------------- /DateRangeSelector.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 29950FE125F1016A00B305DE /* DateRangeSelector.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29950FD725F1016900B305DE /* DateRangeSelector.framework */; }; 11 | 29950FE625F1016A00B305DE /* DateRangeSelectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29950FE525F1016A00B305DE /* DateRangeSelectorTests.swift */; }; 12 | 29950FE825F1016A00B305DE /* DateRangeSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = 29950FDA25F1016900B305DE /* DateRangeSelector.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | 29950FFC25F101DC00B305DE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29950FFB25F101DC00B305DE /* AppDelegate.swift */; }; 14 | 29950FFE25F101DC00B305DE /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29950FFD25F101DC00B305DE /* SceneDelegate.swift */; }; 15 | 2995100025F101DC00B305DE /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29950FFF25F101DC00B305DE /* ViewController.swift */; }; 16 | 2995100325F101DC00B305DE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2995100125F101DC00B305DE /* Main.storyboard */; }; 17 | 2995100525F101DF00B305DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2995100425F101DF00B305DE /* Assets.xcassets */; }; 18 | 2995100825F101DF00B305DE /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2995100625F101DF00B305DE /* LaunchScreen.storyboard */; }; 19 | 2995101B25F102D200B305DE /* MonthCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2995101125F102D200B305DE /* MonthCollectionCell.swift */; }; 20 | 2995101C25F102D200B305DE /* CalendarView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2995101225F102D200B305DE /* CalendarView.xib */; }; 21 | 2995101D25F102D200B305DE /* MonthCollectionCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2995101325F102D200B305DE /* MonthCollectionCell.xib */; }; 22 | 2995101F25F102D200B305DE /* DayCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2995101525F102D200B305DE /* DayCollectionCell.swift */; }; 23 | 2995102025F102D200B305DE /* WeekHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2995101625F102D200B305DE /* WeekHeaderView.xib */; }; 24 | 2995102125F102D200B305DE /* DayCollectionCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2995101725F102D200B305DE /* DayCollectionCell.xib */; }; 25 | 2995102225F102D200B305DE /* CalendarLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2995101825F102D200B305DE /* CalendarLogic.swift */; }; 26 | 2995102325F102D200B305DE /* WeekHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2995101925F102D200B305DE /* WeekHeaderView.swift */; }; 27 | 2995102425F102D200B305DE /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2995101A25F102D200B305DE /* CalendarView.swift */; }; 28 | 29AA51F625F1124E003FD647 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29AA51F525F1124E003FD647 /* Extensions.swift */; }; 29 | /* End PBXBuildFile section */ 30 | 31 | /* Begin PBXContainerItemProxy section */ 32 | 29950FE225F1016A00B305DE /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = 29950FCE25F1016900B305DE /* Project object */; 35 | proxyType = 1; 36 | remoteGlobalIDString = 29950FD625F1016900B305DE; 37 | remoteInfo = DateRangeSelector; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXFileReference section */ 42 | 29950FD725F1016900B305DE /* DateRangeSelector.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DateRangeSelector.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 29950FDA25F1016900B305DE /* DateRangeSelector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DateRangeSelector.h; sourceTree = ""; }; 44 | 29950FDB25F1016900B305DE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | 29950FE025F1016A00B305DE /* DateRangeSelectorTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DateRangeSelectorTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 29950FE525F1016A00B305DE /* DateRangeSelectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateRangeSelectorTests.swift; sourceTree = ""; }; 47 | 29950FE725F1016A00B305DE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 48 | 29950FF925F101DC00B305DE /* DateRangeSelectorExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DateRangeSelectorExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 29950FFB25F101DC00B305DE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 50 | 29950FFD25F101DC00B305DE /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 51 | 29950FFF25F101DC00B305DE /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 52 | 2995100225F101DC00B305DE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | 2995100425F101DF00B305DE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | 2995100725F101DF00B305DE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | 2995100925F101DF00B305DE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 2995101125F102D200B305DE /* MonthCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MonthCollectionCell.swift; sourceTree = ""; }; 57 | 2995101225F102D200B305DE /* CalendarView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CalendarView.xib; sourceTree = ""; }; 58 | 2995101325F102D200B305DE /* MonthCollectionCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MonthCollectionCell.xib; sourceTree = ""; }; 59 | 2995101525F102D200B305DE /* DayCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DayCollectionCell.swift; sourceTree = ""; }; 60 | 2995101625F102D200B305DE /* WeekHeaderView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WeekHeaderView.xib; sourceTree = ""; }; 61 | 2995101725F102D200B305DE /* DayCollectionCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DayCollectionCell.xib; sourceTree = ""; }; 62 | 2995101825F102D200B305DE /* CalendarLogic.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarLogic.swift; sourceTree = ""; }; 63 | 2995101925F102D200B305DE /* WeekHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WeekHeaderView.swift; sourceTree = ""; }; 64 | 2995101A25F102D200B305DE /* CalendarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = ""; }; 65 | 29AA51F525F1124E003FD647 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; 66 | 29AA51FE25F12C13003FD647 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 67 | /* End PBXFileReference section */ 68 | 69 | /* Begin PBXFrameworksBuildPhase section */ 70 | 29950FD425F1016900B305DE /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | ); 75 | runOnlyForDeploymentPostprocessing = 0; 76 | }; 77 | 29950FDD25F1016A00B305DE /* Frameworks */ = { 78 | isa = PBXFrameworksBuildPhase; 79 | buildActionMask = 2147483647; 80 | files = ( 81 | 29950FE125F1016A00B305DE /* DateRangeSelector.framework in Frameworks */, 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 29950FF625F101DC00B305DE /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | 29AA51FB25F12C13003FD647 /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | /* End PBXFrameworksBuildPhase section */ 100 | 101 | /* Begin PBXGroup section */ 102 | 29950FCD25F1016900B305DE = { 103 | isa = PBXGroup; 104 | children = ( 105 | 29950FD925F1016900B305DE /* DateRangeSelector */, 106 | 29950FE425F1016A00B305DE /* DateRangeSelectorTests */, 107 | 29950FFA25F101DC00B305DE /* DateRangeSelectorExample */, 108 | 29950FD825F1016900B305DE /* Products */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 29950FD825F1016900B305DE /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 29950FD725F1016900B305DE /* DateRangeSelector.framework */, 116 | 29950FE025F1016A00B305DE /* DateRangeSelectorTests.xctest */, 117 | 29950FF925F101DC00B305DE /* DateRangeSelectorExample.app */, 118 | 29AA51FE25F12C13003FD647 /* Example.app */, 119 | ); 120 | name = Products; 121 | sourceTree = ""; 122 | }; 123 | 29950FD925F1016900B305DE /* DateRangeSelector */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 2995101025F102D200B305DE /* CalendarKit */, 127 | 29950FDA25F1016900B305DE /* DateRangeSelector.h */, 128 | 29950FDB25F1016900B305DE /* Info.plist */, 129 | ); 130 | path = DateRangeSelector; 131 | sourceTree = ""; 132 | }; 133 | 29950FE425F1016A00B305DE /* DateRangeSelectorTests */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 29950FE525F1016A00B305DE /* DateRangeSelectorTests.swift */, 137 | 29950FE725F1016A00B305DE /* Info.plist */, 138 | ); 139 | path = DateRangeSelectorTests; 140 | sourceTree = ""; 141 | }; 142 | 29950FFA25F101DC00B305DE /* DateRangeSelectorExample */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 29950FFB25F101DC00B305DE /* AppDelegate.swift */, 146 | 29950FFD25F101DC00B305DE /* SceneDelegate.swift */, 147 | 29950FFF25F101DC00B305DE /* ViewController.swift */, 148 | 2995100125F101DC00B305DE /* Main.storyboard */, 149 | 2995100425F101DF00B305DE /* Assets.xcassets */, 150 | 2995100625F101DF00B305DE /* LaunchScreen.storyboard */, 151 | 2995100925F101DF00B305DE /* Info.plist */, 152 | ); 153 | path = DateRangeSelectorExample; 154 | sourceTree = ""; 155 | }; 156 | 2995101025F102D200B305DE /* CalendarKit */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | 2995102825F1030E00B305DE /* CollectionViewCell */, 160 | 2995101A25F102D200B305DE /* CalendarView.swift */, 161 | 2995101225F102D200B305DE /* CalendarView.xib */, 162 | 2995101925F102D200B305DE /* WeekHeaderView.swift */, 163 | 2995101625F102D200B305DE /* WeekHeaderView.xib */, 164 | 2995101825F102D200B305DE /* CalendarLogic.swift */, 165 | 29AA51F525F1124E003FD647 /* Extensions.swift */, 166 | ); 167 | path = CalendarKit; 168 | sourceTree = ""; 169 | }; 170 | 2995102825F1030E00B305DE /* CollectionViewCell */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | 2995101125F102D200B305DE /* MonthCollectionCell.swift */, 174 | 2995101325F102D200B305DE /* MonthCollectionCell.xib */, 175 | 2995101525F102D200B305DE /* DayCollectionCell.swift */, 176 | 2995101725F102D200B305DE /* DayCollectionCell.xib */, 177 | ); 178 | path = CollectionViewCell; 179 | sourceTree = ""; 180 | }; 181 | /* End PBXGroup section */ 182 | 183 | /* Begin PBXHeadersBuildPhase section */ 184 | 29950FD225F1016900B305DE /* Headers */ = { 185 | isa = PBXHeadersBuildPhase; 186 | buildActionMask = 2147483647; 187 | files = ( 188 | 29950FE825F1016A00B305DE /* DateRangeSelector.h in Headers */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXHeadersBuildPhase section */ 193 | 194 | /* Begin PBXNativeTarget section */ 195 | 29950FD625F1016900B305DE /* DateRangeSelector */ = { 196 | isa = PBXNativeTarget; 197 | buildConfigurationList = 29950FEB25F1016A00B305DE /* Build configuration list for PBXNativeTarget "DateRangeSelector" */; 198 | buildPhases = ( 199 | 29950FD225F1016900B305DE /* Headers */, 200 | 29950FD325F1016900B305DE /* Sources */, 201 | 29950FD425F1016900B305DE /* Frameworks */, 202 | 29950FD525F1016900B305DE /* Resources */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | ); 208 | name = DateRangeSelector; 209 | productName = DateRangeSelector; 210 | productReference = 29950FD725F1016900B305DE /* DateRangeSelector.framework */; 211 | productType = "com.apple.product-type.framework"; 212 | }; 213 | 29950FDF25F1016A00B305DE /* DateRangeSelectorTests */ = { 214 | isa = PBXNativeTarget; 215 | buildConfigurationList = 29950FEE25F1016A00B305DE /* Build configuration list for PBXNativeTarget "DateRangeSelectorTests" */; 216 | buildPhases = ( 217 | 29950FDC25F1016A00B305DE /* Sources */, 218 | 29950FDD25F1016A00B305DE /* Frameworks */, 219 | 29950FDE25F1016A00B305DE /* Resources */, 220 | ); 221 | buildRules = ( 222 | ); 223 | dependencies = ( 224 | 29950FE325F1016A00B305DE /* PBXTargetDependency */, 225 | ); 226 | name = DateRangeSelectorTests; 227 | productName = DateRangeSelectorTests; 228 | productReference = 29950FE025F1016A00B305DE /* DateRangeSelectorTests.xctest */; 229 | productType = "com.apple.product-type.bundle.unit-test"; 230 | }; 231 | 29950FF825F101DC00B305DE /* DateRangeSelectorExample */ = { 232 | isa = PBXNativeTarget; 233 | buildConfigurationList = 2995100C25F101DF00B305DE /* Build configuration list for PBXNativeTarget "DateRangeSelectorExample" */; 234 | buildPhases = ( 235 | 29950FF525F101DC00B305DE /* Sources */, 236 | 29950FF625F101DC00B305DE /* Frameworks */, 237 | 29950FF725F101DC00B305DE /* Resources */, 238 | ); 239 | buildRules = ( 240 | ); 241 | dependencies = ( 242 | ); 243 | name = DateRangeSelectorExample; 244 | productName = DateRangeSelectorExample; 245 | productReference = 29950FF925F101DC00B305DE /* DateRangeSelectorExample.app */; 246 | productType = "com.apple.product-type.application"; 247 | }; 248 | 29AA51FD25F12C13003FD647 /* Example */ = { 249 | isa = PBXNativeTarget; 250 | buildConfigurationList = 29AA520F25F12C15003FD647 /* Build configuration list for PBXNativeTarget "Example" */; 251 | buildPhases = ( 252 | 29AA51FA25F12C13003FD647 /* Sources */, 253 | 29AA51FB25F12C13003FD647 /* Frameworks */, 254 | 29AA51FC25F12C13003FD647 /* Resources */, 255 | ); 256 | buildRules = ( 257 | ); 258 | dependencies = ( 259 | ); 260 | name = Example; 261 | productName = Example; 262 | productReference = 29AA51FE25F12C13003FD647 /* Example.app */; 263 | productType = "com.apple.product-type.application"; 264 | }; 265 | /* End PBXNativeTarget section */ 266 | 267 | /* Begin PBXProject section */ 268 | 29950FCE25F1016900B305DE /* Project object */ = { 269 | isa = PBXProject; 270 | attributes = { 271 | LastSwiftUpdateCheck = 1200; 272 | LastUpgradeCheck = 1200; 273 | TargetAttributes = { 274 | 29950FD625F1016900B305DE = { 275 | CreatedOnToolsVersion = 12.0.1; 276 | }; 277 | 29950FDF25F1016A00B305DE = { 278 | CreatedOnToolsVersion = 12.0.1; 279 | }; 280 | 29950FF825F101DC00B305DE = { 281 | CreatedOnToolsVersion = 12.0.1; 282 | }; 283 | 29AA51FD25F12C13003FD647 = { 284 | CreatedOnToolsVersion = 12.0.1; 285 | }; 286 | }; 287 | }; 288 | buildConfigurationList = 29950FD125F1016900B305DE /* Build configuration list for PBXProject "DateRangeSelector" */; 289 | compatibilityVersion = "Xcode 9.3"; 290 | developmentRegion = en; 291 | hasScannedForEncodings = 0; 292 | knownRegions = ( 293 | en, 294 | Base, 295 | ); 296 | mainGroup = 29950FCD25F1016900B305DE; 297 | productRefGroup = 29950FD825F1016900B305DE /* Products */; 298 | projectDirPath = ""; 299 | projectRoot = ""; 300 | targets = ( 301 | 29950FD625F1016900B305DE /* DateRangeSelector */, 302 | 29950FDF25F1016A00B305DE /* DateRangeSelectorTests */, 303 | 29950FF825F101DC00B305DE /* DateRangeSelectorExample */, 304 | 29AA51FD25F12C13003FD647 /* Example */, 305 | ); 306 | }; 307 | /* End PBXProject section */ 308 | 309 | /* Begin PBXResourcesBuildPhase section */ 310 | 29950FD525F1016900B305DE /* Resources */ = { 311 | isa = PBXResourcesBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | 2995102125F102D200B305DE /* DayCollectionCell.xib in Resources */, 315 | 2995102025F102D200B305DE /* WeekHeaderView.xib in Resources */, 316 | 2995101D25F102D200B305DE /* MonthCollectionCell.xib in Resources */, 317 | 2995101C25F102D200B305DE /* CalendarView.xib in Resources */, 318 | ); 319 | runOnlyForDeploymentPostprocessing = 0; 320 | }; 321 | 29950FDE25F1016A00B305DE /* Resources */ = { 322 | isa = PBXResourcesBuildPhase; 323 | buildActionMask = 2147483647; 324 | files = ( 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | 29950FF725F101DC00B305DE /* Resources */ = { 329 | isa = PBXResourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | 2995100825F101DF00B305DE /* LaunchScreen.storyboard in Resources */, 333 | 2995100525F101DF00B305DE /* Assets.xcassets in Resources */, 334 | 2995100325F101DC00B305DE /* Main.storyboard in Resources */, 335 | ); 336 | runOnlyForDeploymentPostprocessing = 0; 337 | }; 338 | 29AA51FC25F12C13003FD647 /* Resources */ = { 339 | isa = PBXResourcesBuildPhase; 340 | buildActionMask = 2147483647; 341 | files = ( 342 | ); 343 | runOnlyForDeploymentPostprocessing = 0; 344 | }; 345 | /* End PBXResourcesBuildPhase section */ 346 | 347 | /* Begin PBXSourcesBuildPhase section */ 348 | 29950FD325F1016900B305DE /* Sources */ = { 349 | isa = PBXSourcesBuildPhase; 350 | buildActionMask = 2147483647; 351 | files = ( 352 | 2995101B25F102D200B305DE /* MonthCollectionCell.swift in Sources */, 353 | 2995102325F102D200B305DE /* WeekHeaderView.swift in Sources */, 354 | 2995102425F102D200B305DE /* CalendarView.swift in Sources */, 355 | 2995101F25F102D200B305DE /* DayCollectionCell.swift in Sources */, 356 | 2995102225F102D200B305DE /* CalendarLogic.swift in Sources */, 357 | 29AA51F625F1124E003FD647 /* Extensions.swift in Sources */, 358 | ); 359 | runOnlyForDeploymentPostprocessing = 0; 360 | }; 361 | 29950FDC25F1016A00B305DE /* Sources */ = { 362 | isa = PBXSourcesBuildPhase; 363 | buildActionMask = 2147483647; 364 | files = ( 365 | 29950FE625F1016A00B305DE /* DateRangeSelectorTests.swift in Sources */, 366 | ); 367 | runOnlyForDeploymentPostprocessing = 0; 368 | }; 369 | 29950FF525F101DC00B305DE /* Sources */ = { 370 | isa = PBXSourcesBuildPhase; 371 | buildActionMask = 2147483647; 372 | files = ( 373 | 2995100025F101DC00B305DE /* ViewController.swift in Sources */, 374 | 29950FFC25F101DC00B305DE /* AppDelegate.swift in Sources */, 375 | 29950FFE25F101DC00B305DE /* SceneDelegate.swift in Sources */, 376 | ); 377 | runOnlyForDeploymentPostprocessing = 0; 378 | }; 379 | 29AA51FA25F12C13003FD647 /* Sources */ = { 380 | isa = PBXSourcesBuildPhase; 381 | buildActionMask = 2147483647; 382 | files = ( 383 | ); 384 | runOnlyForDeploymentPostprocessing = 0; 385 | }; 386 | /* End PBXSourcesBuildPhase section */ 387 | 388 | /* Begin PBXTargetDependency section */ 389 | 29950FE325F1016A00B305DE /* PBXTargetDependency */ = { 390 | isa = PBXTargetDependency; 391 | target = 29950FD625F1016900B305DE /* DateRangeSelector */; 392 | targetProxy = 29950FE225F1016A00B305DE /* PBXContainerItemProxy */; 393 | }; 394 | /* End PBXTargetDependency section */ 395 | 396 | /* Begin PBXVariantGroup section */ 397 | 2995100125F101DC00B305DE /* Main.storyboard */ = { 398 | isa = PBXVariantGroup; 399 | children = ( 400 | 2995100225F101DC00B305DE /* Base */, 401 | ); 402 | name = Main.storyboard; 403 | sourceTree = ""; 404 | }; 405 | 2995100625F101DF00B305DE /* LaunchScreen.storyboard */ = { 406 | isa = PBXVariantGroup; 407 | children = ( 408 | 2995100725F101DF00B305DE /* Base */, 409 | ); 410 | name = LaunchScreen.storyboard; 411 | sourceTree = ""; 412 | }; 413 | /* End PBXVariantGroup section */ 414 | 415 | /* Begin XCBuildConfiguration section */ 416 | 29950FE925F1016A00B305DE /* Debug */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ALWAYS_SEARCH_USER_PATHS = NO; 420 | CLANG_ANALYZER_NONNULL = YES; 421 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 422 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 423 | CLANG_CXX_LIBRARY = "libc++"; 424 | CLANG_ENABLE_MODULES = YES; 425 | CLANG_ENABLE_OBJC_ARC = YES; 426 | CLANG_ENABLE_OBJC_WEAK = YES; 427 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 428 | CLANG_WARN_BOOL_CONVERSION = YES; 429 | CLANG_WARN_COMMA = YES; 430 | CLANG_WARN_CONSTANT_CONVERSION = YES; 431 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 432 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 433 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 434 | CLANG_WARN_EMPTY_BODY = YES; 435 | CLANG_WARN_ENUM_CONVERSION = YES; 436 | CLANG_WARN_INFINITE_RECURSION = YES; 437 | CLANG_WARN_INT_CONVERSION = YES; 438 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 439 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 440 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 441 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 442 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 443 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 444 | CLANG_WARN_STRICT_PROTOTYPES = YES; 445 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 446 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 447 | CLANG_WARN_UNREACHABLE_CODE = YES; 448 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 449 | COPY_PHASE_STRIP = NO; 450 | CURRENT_PROJECT_VERSION = 1; 451 | DEBUG_INFORMATION_FORMAT = dwarf; 452 | ENABLE_STRICT_OBJC_MSGSEND = YES; 453 | ENABLE_TESTABILITY = YES; 454 | GCC_C_LANGUAGE_STANDARD = gnu11; 455 | GCC_DYNAMIC_NO_PIC = NO; 456 | GCC_NO_COMMON_BLOCKS = YES; 457 | GCC_OPTIMIZATION_LEVEL = 0; 458 | GCC_PREPROCESSOR_DEFINITIONS = ( 459 | "DEBUG=1", 460 | "$(inherited)", 461 | ); 462 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 463 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 464 | GCC_WARN_UNDECLARED_SELECTOR = YES; 465 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 466 | GCC_WARN_UNUSED_FUNCTION = YES; 467 | GCC_WARN_UNUSED_VARIABLE = YES; 468 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 469 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 470 | MTL_FAST_MATH = YES; 471 | ONLY_ACTIVE_ARCH = YES; 472 | SDKROOT = iphoneos; 473 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 474 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 475 | VERSIONING_SYSTEM = "apple-generic"; 476 | VERSION_INFO_PREFIX = ""; 477 | }; 478 | name = Debug; 479 | }; 480 | 29950FEA25F1016A00B305DE /* Release */ = { 481 | isa = XCBuildConfiguration; 482 | buildSettings = { 483 | ALWAYS_SEARCH_USER_PATHS = NO; 484 | CLANG_ANALYZER_NONNULL = YES; 485 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 486 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 487 | CLANG_CXX_LIBRARY = "libc++"; 488 | CLANG_ENABLE_MODULES = YES; 489 | CLANG_ENABLE_OBJC_ARC = YES; 490 | CLANG_ENABLE_OBJC_WEAK = YES; 491 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 492 | CLANG_WARN_BOOL_CONVERSION = YES; 493 | CLANG_WARN_COMMA = YES; 494 | CLANG_WARN_CONSTANT_CONVERSION = YES; 495 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 496 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 497 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 498 | CLANG_WARN_EMPTY_BODY = YES; 499 | CLANG_WARN_ENUM_CONVERSION = YES; 500 | CLANG_WARN_INFINITE_RECURSION = YES; 501 | CLANG_WARN_INT_CONVERSION = YES; 502 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 503 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 504 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 505 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 506 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 507 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 508 | CLANG_WARN_STRICT_PROTOTYPES = YES; 509 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 510 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 511 | CLANG_WARN_UNREACHABLE_CODE = YES; 512 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 513 | COPY_PHASE_STRIP = NO; 514 | CURRENT_PROJECT_VERSION = 1; 515 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 516 | ENABLE_NS_ASSERTIONS = NO; 517 | ENABLE_STRICT_OBJC_MSGSEND = YES; 518 | GCC_C_LANGUAGE_STANDARD = gnu11; 519 | GCC_NO_COMMON_BLOCKS = YES; 520 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 521 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 522 | GCC_WARN_UNDECLARED_SELECTOR = YES; 523 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 524 | GCC_WARN_UNUSED_FUNCTION = YES; 525 | GCC_WARN_UNUSED_VARIABLE = YES; 526 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 527 | MTL_ENABLE_DEBUG_INFO = NO; 528 | MTL_FAST_MATH = YES; 529 | SDKROOT = iphoneos; 530 | SWIFT_COMPILATION_MODE = wholemodule; 531 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 532 | VALIDATE_PRODUCT = YES; 533 | VERSIONING_SYSTEM = "apple-generic"; 534 | VERSION_INFO_PREFIX = ""; 535 | }; 536 | name = Release; 537 | }; 538 | 29950FEC25F1016A00B305DE /* Debug */ = { 539 | isa = XCBuildConfiguration; 540 | buildSettings = { 541 | CODE_SIGN_STYLE = Automatic; 542 | DEFINES_MODULE = YES; 543 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 544 | DYLIB_COMPATIBILITY_VERSION = 1; 545 | DYLIB_CURRENT_VERSION = 1; 546 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 547 | INFOPLIST_FILE = DateRangeSelector/Info.plist; 548 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 549 | LD_RUNPATH_SEARCH_PATHS = ( 550 | "$(inherited)", 551 | "@executable_path/Frameworks", 552 | "@loader_path/Frameworks", 553 | ); 554 | MARKETING_VERSION = 0.0.3; 555 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.DateRangeSelector; 556 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 557 | SKIP_INSTALL = YES; 558 | SWIFT_VERSION = 5.0; 559 | TARGETED_DEVICE_FAMILY = "1,2"; 560 | }; 561 | name = Debug; 562 | }; 563 | 29950FED25F1016A00B305DE /* Release */ = { 564 | isa = XCBuildConfiguration; 565 | buildSettings = { 566 | CODE_SIGN_STYLE = Automatic; 567 | DEFINES_MODULE = YES; 568 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 569 | DYLIB_COMPATIBILITY_VERSION = 1; 570 | DYLIB_CURRENT_VERSION = 1; 571 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 572 | INFOPLIST_FILE = DateRangeSelector/Info.plist; 573 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 574 | LD_RUNPATH_SEARCH_PATHS = ( 575 | "$(inherited)", 576 | "@executable_path/Frameworks", 577 | "@loader_path/Frameworks", 578 | ); 579 | MARKETING_VERSION = 0.0.3; 580 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.DateRangeSelector; 581 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 582 | SKIP_INSTALL = YES; 583 | SWIFT_VERSION = 5.0; 584 | TARGETED_DEVICE_FAMILY = "1,2"; 585 | }; 586 | name = Release; 587 | }; 588 | 29950FEF25F1016A00B305DE /* Debug */ = { 589 | isa = XCBuildConfiguration; 590 | buildSettings = { 591 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 592 | CODE_SIGN_STYLE = Automatic; 593 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 594 | INFOPLIST_FILE = DateRangeSelectorTests/Info.plist; 595 | LD_RUNPATH_SEARCH_PATHS = ( 596 | "$(inherited)", 597 | "@executable_path/Frameworks", 598 | "@loader_path/Frameworks", 599 | ); 600 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.DateRangeSelectorTests; 601 | PRODUCT_NAME = "$(TARGET_NAME)"; 602 | SWIFT_VERSION = 5.0; 603 | TARGETED_DEVICE_FAMILY = "1,2"; 604 | }; 605 | name = Debug; 606 | }; 607 | 29950FF025F1016A00B305DE /* Release */ = { 608 | isa = XCBuildConfiguration; 609 | buildSettings = { 610 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 611 | CODE_SIGN_STYLE = Automatic; 612 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 613 | INFOPLIST_FILE = DateRangeSelectorTests/Info.plist; 614 | LD_RUNPATH_SEARCH_PATHS = ( 615 | "$(inherited)", 616 | "@executable_path/Frameworks", 617 | "@loader_path/Frameworks", 618 | ); 619 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.DateRangeSelectorTests; 620 | PRODUCT_NAME = "$(TARGET_NAME)"; 621 | SWIFT_VERSION = 5.0; 622 | TARGETED_DEVICE_FAMILY = "1,2"; 623 | }; 624 | name = Release; 625 | }; 626 | 2995100A25F101DF00B305DE /* Debug */ = { 627 | isa = XCBuildConfiguration; 628 | buildSettings = { 629 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 630 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 631 | CODE_SIGN_STYLE = Automatic; 632 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 633 | INFOPLIST_FILE = DateRangeSelectorExample/Info.plist; 634 | LD_RUNPATH_SEARCH_PATHS = ( 635 | "$(inherited)", 636 | "@executable_path/Frameworks", 637 | ); 638 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.DateRangeSelectorExample; 639 | PRODUCT_NAME = "$(TARGET_NAME)"; 640 | SWIFT_VERSION = 5.0; 641 | TARGETED_DEVICE_FAMILY = "1,2"; 642 | }; 643 | name = Debug; 644 | }; 645 | 2995100B25F101DF00B305DE /* Release */ = { 646 | isa = XCBuildConfiguration; 647 | buildSettings = { 648 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 649 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 650 | CODE_SIGN_STYLE = Automatic; 651 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 652 | INFOPLIST_FILE = DateRangeSelectorExample/Info.plist; 653 | LD_RUNPATH_SEARCH_PATHS = ( 654 | "$(inherited)", 655 | "@executable_path/Frameworks", 656 | ); 657 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.DateRangeSelectorExample; 658 | PRODUCT_NAME = "$(TARGET_NAME)"; 659 | SWIFT_VERSION = 5.0; 660 | TARGETED_DEVICE_FAMILY = "1,2"; 661 | }; 662 | name = Release; 663 | }; 664 | 29AA521025F12C15003FD647 /* Debug */ = { 665 | isa = XCBuildConfiguration; 666 | buildSettings = { 667 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 668 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 669 | CODE_SIGN_STYLE = Automatic; 670 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 671 | INFOPLIST_FILE = Example/Info.plist; 672 | LD_RUNPATH_SEARCH_PATHS = ( 673 | "$(inherited)", 674 | "@executable_path/Frameworks", 675 | ); 676 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.Example; 677 | PRODUCT_NAME = "$(TARGET_NAME)"; 678 | SWIFT_VERSION = 5.0; 679 | TARGETED_DEVICE_FAMILY = "1,2"; 680 | }; 681 | name = Debug; 682 | }; 683 | 29AA521125F12C15003FD647 /* Release */ = { 684 | isa = XCBuildConfiguration; 685 | buildSettings = { 686 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 687 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 688 | CODE_SIGN_STYLE = Automatic; 689 | DEVELOPMENT_TEAM = Y5SH4GJWBN; 690 | INFOPLIST_FILE = Example/Info.plist; 691 | LD_RUNPATH_SEARCH_PATHS = ( 692 | "$(inherited)", 693 | "@executable_path/Frameworks", 694 | ); 695 | PRODUCT_BUNDLE_IDENTIFIER = ca.edgecomenergy.Example; 696 | PRODUCT_NAME = "$(TARGET_NAME)"; 697 | SWIFT_VERSION = 5.0; 698 | TARGETED_DEVICE_FAMILY = "1,2"; 699 | }; 700 | name = Release; 701 | }; 702 | /* End XCBuildConfiguration section */ 703 | 704 | /* Begin XCConfigurationList section */ 705 | 29950FD125F1016900B305DE /* Build configuration list for PBXProject "DateRangeSelector" */ = { 706 | isa = XCConfigurationList; 707 | buildConfigurations = ( 708 | 29950FE925F1016A00B305DE /* Debug */, 709 | 29950FEA25F1016A00B305DE /* Release */, 710 | ); 711 | defaultConfigurationIsVisible = 0; 712 | defaultConfigurationName = Release; 713 | }; 714 | 29950FEB25F1016A00B305DE /* Build configuration list for PBXNativeTarget "DateRangeSelector" */ = { 715 | isa = XCConfigurationList; 716 | buildConfigurations = ( 717 | 29950FEC25F1016A00B305DE /* Debug */, 718 | 29950FED25F1016A00B305DE /* Release */, 719 | ); 720 | defaultConfigurationIsVisible = 0; 721 | defaultConfigurationName = Release; 722 | }; 723 | 29950FEE25F1016A00B305DE /* Build configuration list for PBXNativeTarget "DateRangeSelectorTests" */ = { 724 | isa = XCConfigurationList; 725 | buildConfigurations = ( 726 | 29950FEF25F1016A00B305DE /* Debug */, 727 | 29950FF025F1016A00B305DE /* Release */, 728 | ); 729 | defaultConfigurationIsVisible = 0; 730 | defaultConfigurationName = Release; 731 | }; 732 | 2995100C25F101DF00B305DE /* Build configuration list for PBXNativeTarget "DateRangeSelectorExample" */ = { 733 | isa = XCConfigurationList; 734 | buildConfigurations = ( 735 | 2995100A25F101DF00B305DE /* Debug */, 736 | 2995100B25F101DF00B305DE /* Release */, 737 | ); 738 | defaultConfigurationIsVisible = 0; 739 | defaultConfigurationName = Release; 740 | }; 741 | 29AA520F25F12C15003FD647 /* Build configuration list for PBXNativeTarget "Example" */ = { 742 | isa = XCConfigurationList; 743 | buildConfigurations = ( 744 | 29AA521025F12C15003FD647 /* Debug */, 745 | 29AA521125F12C15003FD647 /* Release */, 746 | ); 747 | defaultConfigurationIsVisible = 0; 748 | defaultConfigurationName = Release; 749 | }; 750 | /* End XCConfigurationList section */ 751 | }; 752 | rootObject = 29950FCE25F1016900B305DE /* Project object */; 753 | } 754 | -------------------------------------------------------------------------------- /DateRangeSelector.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DateRangeSelector.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/CalendarLogic.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class CalendarLogic { 4 | 5 | 6 | var baseDate: Date { 7 | didSet { 8 | calculateVisibleDays() 9 | } 10 | } 11 | 12 | private lazy var dateFormatter = DateFormatter() 13 | 14 | var dateFormatterString = "MMM yyyy" 15 | 16 | var currentMonthAndYear: String { 17 | dateFormatter.dateFormat = dateFormatterString 18 | return dateFormatter.string(from: baseDate) 19 | } 20 | 21 | var currentMonthDays: [Date]? 22 | var previousMonthVisibleDays: [Date]? 23 | var nextMonthVisibleDays: [Date]? 24 | 25 | init(date: Date) { 26 | baseDate = date.firstDayOfTheMonth 27 | calculateVisibleDays() 28 | } 29 | 30 | func retreatToPreviousMonth() { 31 | baseDate = baseDate.firstDayOfPreviousMonth 32 | } 33 | 34 | func advanceToNextMonth() { 35 | baseDate = baseDate.firstDayOfFollowingMonth 36 | } 37 | 38 | func moveToMonth(date: Date) { 39 | baseDate = date 40 | } 41 | 42 | func isVisible(date: Date) -> Bool { 43 | if currentMonthDays!.contains(date) { 44 | return true 45 | } else if previousMonthVisibleDays!.contains(date) { 46 | return true 47 | } else if nextMonthVisibleDays!.contains(date) { 48 | return true 49 | } 50 | return false 51 | } 52 | 53 | func containsDate(date: Date) -> Bool { 54 | if (date.month == baseDate.month) && 55 | (date.year == baseDate.year) { 56 | return true 57 | } 58 | 59 | return false 60 | } 61 | 62 | //Mark: Private methods. 63 | private var numberOfDaysInPreviousPartialWeek: Int { 64 | return baseDate.weekDay - 1 65 | } 66 | 67 | private var numberOfVisibleDaysforFollowingMonth: Int { 68 | // Traverse to the last day of the month. 69 | var parts = baseDate.monthDayAndYearComponents 70 | 71 | parts.day = baseDate.numberOfDaysInMonth 72 | 73 | // 7*6 = 42 :- 7 columns (7 days in a week) and 6 rows (max 6 weeks in a month) 74 | return 42 - (numberOfDaysInPreviousPartialWeek + baseDate.numberOfDaysInMonth) 75 | } 76 | 77 | private var calculateCurrentMonthVisibleDays: [Date] { 78 | let numberOfDaysInMonth = baseDate.numberOfDaysInMonth 79 | let component = baseDate.monthDayAndYearComponents 80 | 81 | return (1...numberOfDaysInMonth).map { 82 | Date.date(day: $0, month: component.month!, year: component.year!) 83 | } 84 | } 85 | 86 | private var calculatePreviousMonthVisibleDays: [Date] { 87 | let date = baseDate.firstDayOfPreviousMonth 88 | let numberOfDaysInMonth = date.numberOfDaysInMonth 89 | 90 | let numberOfVisibleDays = numberOfDaysInPreviousPartialWeek 91 | let startDay = numberOfDaysInMonth - (numberOfVisibleDays - 1) 92 | 93 | if startDay > numberOfDaysInMonth { 94 | return [] 95 | } 96 | 97 | let parts = date.monthDayAndYearComponents 98 | return (startDay...numberOfDaysInMonth).map { 99 | Date.date(day: $0, month: parts.month!, year: parts.year!) 100 | } 101 | } 102 | 103 | private var calculateFollowingMonthVisibleDays: [Date] { 104 | 105 | let date = baseDate.firstDayOfFollowingMonth 106 | let numberOfDays = numberOfVisibleDaysforFollowingMonth 107 | let parts = date.monthDayAndYearComponents 108 | 109 | return (1...numberOfDays).map { 110 | Date.date(day: $0, month: parts.month!, year: parts.year!) 111 | } 112 | } 113 | 114 | private func calculateVisibleDays() { 115 | currentMonthDays = calculateCurrentMonthVisibleDays 116 | previousMonthVisibleDays = calculatePreviousMonthVisibleDays 117 | nextMonthVisibleDays = calculateFollowingMonthVisibleDays 118 | } 119 | } 120 | 121 | extension CalendarLogic: Comparable { 122 | static func < (lhs: CalendarLogic, rhs: CalendarLogic) -> Bool { 123 | return (lhs.baseDate.compare(rhs.baseDate) == .orderedAscending) 124 | } 125 | 126 | static func >(lhs: CalendarLogic, rhs: CalendarLogic) -> Bool { 127 | return (lhs.baseDate.compare(rhs.baseDate) == .orderedDescending) 128 | } 129 | 130 | static func ==(lhs: CalendarLogic, rhs: CalendarLogic) -> Bool { 131 | return lhs.hashValue == rhs.hashValue 132 | } 133 | } 134 | 135 | extension CalendarLogic: Hashable { 136 | func hash(into hasher: inout Hasher) { 137 | hasher.combine(baseDate.hashValue) 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/CalendarView.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | public protocol CalendarViewDelegate: class { 4 | func didSelectDate(startDate: Date , endDate : Date) 5 | } 6 | 7 | public final class CalendarViewFrameworkBundle { 8 | public static let main: Bundle = Bundle(for: CalendarViewFrameworkBundle.self) 9 | } 10 | 11 | public class CalendarView: UIView { 12 | 13 | @IBOutlet var contentView: UIView! 14 | @IBOutlet var monthYearLabel: UILabel! 15 | @IBOutlet weak var headerBgView: UIView! 16 | @IBOutlet var collectionView: UICollectionView! 17 | @IBOutlet var nextButton: UIButton! 18 | @IBOutlet var previousButton: UIButton! 19 | 20 | public weak var delegate: CalendarViewDelegate? 21 | private var calendarItemList = [CalendarLogic]() 22 | 23 | public var monthRange = 13 { 24 | didSet { 25 | calcuteDays() 26 | updateHeader() 27 | collectionView.reloadData() 28 | } 29 | } 30 | public var maxDate: Date = Date() { 31 | didSet { 32 | calcuteDays() 33 | updateHeader() 34 | collectionView.reloadData() 35 | } 36 | } 37 | 38 | public var selectedYear: Int = Date().year{ 39 | didSet { 40 | let date = Date.from(year: selectedYear, month: 1, day: 1) 41 | setStartAndEnd(date: date) 42 | calcuteDays(year: selectedYear) 43 | updateHeader() 44 | collectionView.reloadData() 45 | } 46 | } 47 | 48 | public var startDate: Date? { 49 | didSet { 50 | DispatchQueue.main.async { [self] in 51 | self.moveToSelectedDate(selectedDate: startDate,animated: false) 52 | } 53 | } 54 | } 55 | 56 | public var endDate: Date? { 57 | didSet { 58 | DispatchQueue.main.async { [self] in 59 | self.moveToSelectedDate(selectedDate: endDate,animated: false) 60 | guard let start = startDate , let end = endDate else { return } 61 | self.delegate?.didSelectDate(startDate: start, endDate : end) 62 | } 63 | } 64 | } 65 | 66 | public var previousButtonIsEnable: Bool = true { 67 | didSet { 68 | self.previousButton.isEnabled = previousButtonIsEnable 69 | } 70 | } 71 | 72 | public var nextButtonIsEnable: Bool = true { 73 | didSet { 74 | self.nextButton.isEnabled = nextButtonIsEnable 75 | } 76 | } 77 | 78 | public var headerTitleColor: UIColor = .darkGray{ 79 | didSet { 80 | monthYearLabel.textColor = headerTitleColor 81 | } 82 | } 83 | 84 | public var headerTitleFont: UIFont = UIFont.systemFont(ofSize: 18){ 85 | didSet { 86 | monthYearLabel.font = headerTitleFont 87 | } 88 | } 89 | 90 | public var headerBackgroundColor: UIColor = UIColor.lightGray.withAlphaComponent(0.5){ 91 | didSet { 92 | headerBgView.backgroundColor = headerBackgroundColor 93 | } 94 | } 95 | 96 | public var previousButtonTitleColor: UIColor = .darkGray{ 97 | didSet { 98 | previousButton.setTitleColor(previousButtonTitleColor, for: .normal) 99 | } 100 | } 101 | 102 | public var previousButtonTitleFont: UIFont = UIFont.systemFont(ofSize: 20){ 103 | didSet { 104 | previousButton.titleLabel?.font = previousButtonTitleFont 105 | } 106 | } 107 | 108 | public var previousButtonAligment: NSTextAlignment = .right{ 109 | didSet { 110 | previousButton.titleLabel?.textAlignment = previousButtonAligment 111 | } 112 | } 113 | 114 | public var nextButtonTitleColor: UIColor = .darkGray{ 115 | didSet { 116 | nextButton.setTitleColor(nextButtonTitleColor, for: .normal) 117 | } 118 | } 119 | public var nextButtonTitleFont: UIFont = UIFont.systemFont(ofSize: 20){ 120 | didSet { 121 | nextButton.titleLabel?.font = nextButtonTitleFont 122 | } 123 | } 124 | 125 | public var nextButtonAligment: NSTextAlignment = .left{ 126 | didSet { 127 | previousButton.titleLabel?.textAlignment = previousButtonAligment 128 | } 129 | } 130 | 131 | public var highlightColor: UIColor = UIColor(red: 11/255.0, green: 75/255.0, blue: 105/255.0, alpha: 1) { 132 | didSet { 133 | collectionView.layoutSubviews() 134 | } 135 | } 136 | 137 | public var highlightScale: CGFloat = 0.8 { 138 | didSet { 139 | collectionView.layoutSubviews() 140 | } 141 | } 142 | 143 | public var todayHighlightColor: UIColor = .red { 144 | didSet { 145 | collectionView.layoutSubviews() 146 | } 147 | } 148 | 149 | public var todayTextColor: UIColor = .white { 150 | didSet { 151 | collectionView.layoutSubviews() 152 | } 153 | } 154 | 155 | public var dayTextColor: UIColor = .gray { 156 | didSet { 157 | collectionView.layoutSubviews() 158 | } 159 | } 160 | 161 | public var dayFont: UIFont = UIFont.systemFont(ofSize: 16) { 162 | didSet { 163 | collectionView.layoutSubviews() 164 | } 165 | } 166 | 167 | 168 | public override init(frame: CGRect) { 169 | super.init(frame: frame) 170 | commonInit() 171 | registerCell() 172 | setupUI() 173 | setupCollectionView() 174 | } 175 | 176 | public required init?(coder: NSCoder) { 177 | super.init(coder: coder) 178 | commonInit() 179 | registerCell() 180 | setupUI() 181 | setupCollectionView() 182 | } 183 | 184 | func commonInit() { 185 | CalendarViewFrameworkBundle.main.loadNibNamed(CalendarView.nameOfClass, owner: self, options: nil) 186 | contentView.fixInView(self) 187 | } 188 | 189 | public override func awakeFromNib() { 190 | registerCell() 191 | setupUI() 192 | setupCollectionView() 193 | } 194 | 195 | func registerCell(){ 196 | MonthCollectionCell.register(for: collectionView) 197 | selectedYear = Date().year 198 | } 199 | 200 | func setupCollectionView(){ 201 | collectionView.dataSource = self 202 | collectionView.delegate = self 203 | } 204 | 205 | func setupUI(){ 206 | nextButtonTitleColor = .darkGray 207 | nextButtonTitleFont = UIFont.systemFont(ofSize: 20) 208 | previousButtonTitleColor = .darkGray 209 | previousButtonTitleFont = UIFont.systemFont(ofSize: 20) 210 | headerTitleColor = .darkGray 211 | headerTitleFont = UIFont.systemFont(ofSize: 18) 212 | headerBackgroundColor = UIColor.lightGray.withAlphaComponent(0.5) 213 | } 214 | 215 | public override func layoutSubviews() { 216 | super.layoutSubviews() 217 | collectionView.setContentOffset(CGPoint(x: 0, y: 0), animated: false) 218 | } 219 | 220 | func calcuteDays(year: Int? = nil){ 221 | calendarItemList = [CalendarLogic]() 222 | var date : Date = maxDate 223 | if let year = year { 224 | date = Date.from(year: year, month: 1, day: 1) 225 | } 226 | self.startDate = date 227 | self.endDate = date 228 | var dateIter1 = date 229 | var dateIter2 = date 230 | 231 | var set = Set() 232 | set.insert(CalendarLogic(date: date)) 233 | 234 | (0.. pageNumber && pageNumber>=0{ 260 | let logic = calendarItemList[pageNumber] 261 | monthYearLabel.text = logic.currentMonthAndYear as String 262 | } 263 | } 264 | 265 | @IBAction func retreatToPreviousMonth(button: UIButton) { 266 | advance(byIndex: -1, animate: false) 267 | } 268 | 269 | @IBAction func advanceToFollowingMonth(button: UIButton) { 270 | advance(byIndex: 1, animate: false) 271 | } 272 | 273 | func advance(byIndex: Int, animate: Bool) { 274 | var visibleIndexPath = self.collectionView.indexPathsForVisibleItems.first! 275 | let pageNumber = visibleIndexPath.item + byIndex 276 | 277 | if calendarItemList.count <= pageNumber || pageNumber < 0{ 278 | return 279 | } 280 | visibleIndexPath = IndexPath(item: pageNumber, 281 | section: visibleIndexPath.section) 282 | updateHeader(pageNumber: pageNumber) 283 | collectionView.scrollToItem(at: visibleIndexPath, 284 | at: .centeredHorizontally, 285 | animated: false) 286 | } 287 | 288 | func moveToSelectedDate(selectedDate: Date?, animated: Bool) { 289 | guard let selectedDate = selectedDate else { return } 290 | let index = (0.. Bool in 291 | let logic = calendarItemList[index] 292 | if logic.containsDate(date: selectedDate) { 293 | return true 294 | } 295 | return false 296 | } 297 | 298 | if let index = index { 299 | let indexPath = IndexPath(item: index, section: 0) 300 | updateHeader(pageNumber: indexPath.item) 301 | collectionView.scrollToItem(at: indexPath, 302 | at: .centeredHorizontally, 303 | animated: animated) 304 | } 305 | } 306 | 307 | } 308 | 309 | extension CalendarView: UICollectionViewDataSource { 310 | public func collectionView(_ collectionView: UICollectionView, 311 | numberOfItemsInSection section: Int) -> Int { 312 | return calendarItemList.count 313 | } 314 | 315 | public func collectionView(_ collectionView: UICollectionView, 316 | cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 317 | let cell = collectionView.dequeueReusableCell( 318 | withReuseIdentifier: MonthCollectionCell.nameOfClass, 319 | for: indexPath) as! MonthCollectionCell 320 | cell.monthCellDelegate = self 321 | let calendarLogic = calendarItemList[indexPath.item] 322 | cell.logic = calendarLogic 323 | cell.maxDate = maxDate 324 | cell.setStartAndEndDate(start: startDate, end: endDate) 325 | cell.setUserInterfaceProperties(highlightColor: highlightColor, 326 | highlightScale: highlightScale, 327 | todayHighlightColor: todayHighlightColor, 328 | todayTextColor: todayTextColor, 329 | dayTextColor: dayTextColor, 330 | dayFont: dayFont) 331 | return cell 332 | } 333 | } 334 | 335 | extension CalendarView: UICollectionViewDelegateFlowLayout { 336 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 337 | return collectionView.frame.size 338 | } 339 | } 340 | 341 | extension CalendarView: UIScrollViewDelegate { 342 | public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { 343 | if (!decelerate) { 344 | updateHeader() 345 | } 346 | } 347 | 348 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 349 | updateHeader() 350 | } 351 | } 352 | 353 | extension CalendarView : MonthCollectionCellDelegate { 354 | func startSelectedDate() -> Date? { 355 | return startDate 356 | } 357 | 358 | func endSelectedDate() -> Date? { 359 | return endDate 360 | } 361 | 362 | func didSelect(startDate: Date?, endDate: Date?) { 363 | self.startDate = startDate ?? nil 364 | self.endDate = endDate ?? nil 365 | print(startDate , " " , endDate) 366 | collectionView.reloadData() 367 | } 368 | 369 | func isStartOrEnd(date: Date) -> Bool { 370 | let result = date.areSameDay(date: startDate) || date.areSameDay(date: endDate) 371 | return result 372 | } 373 | 374 | func isBetweenStartAndEnd(date: Date) -> Bool{ 375 | guard let start = startDate, let end = endDate else { return false } 376 | return date >= start && date <= end && start != end 377 | } 378 | } 379 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/CalendarView.xib: -------------------------------------------------------------------------------- 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 | 27 | 33 | 45 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/CollectionViewCell/DayCollectionCell.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class DayCollectionCell: UICollectionViewCell { 4 | 5 | @IBOutlet var label: UILabel! 6 | 7 | @IBOutlet var markedView: UIView! 8 | @IBOutlet var markedViewWidth: NSLayoutConstraint! 9 | @IBOutlet var markedViewHeight: NSLayoutConstraint! 10 | 11 | var highlightColor = UIColor(red: 11/255.0, green: 75/255.0, blue: 105/255.0, alpha: 1) 12 | var todayHighlightColor: UIColor = .red 13 | var todayTextColor: UIColor = .white 14 | var highlightScale: CGFloat = 0.8 15 | lazy var yHighlightPosition : CGFloat = height * ((1.0 - highlightScale)/2) 16 | 17 | var selectedView: UIView? 18 | var halfBackgroundView: UIView? 19 | var roundHighlightView: UIView? 20 | lazy var width = self.frame.size.width 21 | lazy var height = self.frame.size.height 22 | 23 | 24 | var date: Date? { 25 | didSet { 26 | if date != nil { 27 | label.text = "\(date!.day)" 28 | } else { 29 | label.text = "" 30 | } 31 | } 32 | } 33 | 34 | var disabled: Bool = false { 35 | didSet { 36 | if disabled { 37 | label.textColor = UIColor.lightGray.withAlphaComponent(0.30) 38 | } else { 39 | label.textColor = UIColor.darkGray 40 | } 41 | } 42 | } 43 | 44 | var mark: Bool = false { 45 | didSet { 46 | if mark { 47 | markedView!.isHidden = false 48 | markedView.backgroundColor = highlightColor.withAlphaComponent(1) 49 | label.textColor = .white 50 | } else { 51 | markedView!.isHidden = true 52 | } 53 | } 54 | } 55 | 56 | var idToday : Bool = false{ 57 | didSet { 58 | if mark { 59 | markedView!.isHidden = false 60 | markedView.backgroundColor = todayTextColor 61 | label.textColor = todayTextColor 62 | } else { 63 | markedView!.isHidden = true 64 | } 65 | } 66 | } 67 | 68 | 69 | override func layoutSubviews() { 70 | super.layoutSubviews() 71 | markedViewWidth!.constant = min(self.frame.width, self.frame.height) 72 | markedViewHeight!.constant = min(self.frame.width, self.frame.height) 73 | markedView!.layer.cornerRadius = min(self.frame.width, self.frame.height) / 2.0 74 | } 75 | 76 | func config(date: Date, 77 | fetchDate: Date?, 78 | startDate: Date?, 79 | endDate: Date?, 80 | isDisable: Bool) { 81 | self.date = fetchDate 82 | self.disabled = isDisable 83 | self.reset() 84 | 85 | validateToday(date: date) 86 | validateMark(date: date, startDate: startDate, endDate: endDate) 87 | validateHighlight(date: date, startDate: startDate, endDate: endDate) 88 | } 89 | 90 | func setCellProperties(highlightColor: UIColor, 91 | highlightScale: CGFloat, 92 | todayHighlightColor: UIColor, 93 | todayTextColor: UIColor, 94 | dayTextColor:UIColor, 95 | dayFont: UIFont){ 96 | self.highlightColor = highlightColor 97 | self.highlightScale = highlightScale 98 | self.todayHighlightColor = todayHighlightColor 99 | self.todayTextColor = todayTextColor 100 | self.label.textColor = dayTextColor 101 | self.label.font = dayFont 102 | } 103 | 104 | func validateToday(date: Date){ 105 | if Date().areSameDay(date: date), !disabled { 106 | self.today() 107 | } 108 | } 109 | 110 | func validateMark(date: Date?, startDate: Date?, endDate: Date?){ 111 | guard let date = date, let startDate = startDate else { 112 | self.mark = false 113 | return 114 | } 115 | if date.areSameDay(date: startDate) || date.areSameDay(date: endDate) { 116 | self.mark = !disabled 117 | }else{ 118 | self.mark = false 119 | } 120 | } 121 | 122 | func validateHighlight(date: Date, startDate: Date?, endDate: Date?) { 123 | guard let startDate = startDate, let endDate = endDate, !disabled else { 124 | return 125 | } 126 | highlightRange(startDate: startDate, endDate: endDate, date: date) 127 | } 128 | 129 | func highlightRange(startDate: Date, endDate: Date, date: Date){ 130 | if date >= startDate && date <= endDate && startDate != endDate { 131 | if date.areSameDay(date: startDate) { 132 | self.highlightRight() 133 | }else if date.areSameDay(date: endDate){ 134 | self.highlightLeft() 135 | }else{ 136 | self.highlight() 137 | } 138 | } 139 | } 140 | 141 | func reset() { 142 | resetView(view: &selectedView) 143 | resetView(view: &halfBackgroundView) 144 | resetView(view: &roundHighlightView) 145 | } 146 | 147 | func resetView(view: inout UIView?){ 148 | if view != nil { 149 | view?.removeFromSuperview() 150 | view = nil 151 | } 152 | } 153 | 154 | func today() { 155 | selectedView = UIView(frame: CGRect(x: (width - height) / 2, y: 0, width: height, height: height)) 156 | selectedView?.backgroundColor = todayHighlightColor 157 | selectedView?.layer.cornerRadius = height / 2 158 | self.addSubview(selectedView!) 159 | self.sendSubviewToBack(selectedView!) 160 | label.textColor = UIColor.white 161 | } 162 | 163 | func select() { 164 | let width = self.width * 0.9 165 | let height = self.height * 0.9 166 | selectedView = UIView(frame: CGRect(x: (width - height) / 2, y: 0, width: height, height: height)) 167 | selectedView?.backgroundColor = highlightColor.withAlphaComponent(1) 168 | selectedView?.layer.cornerRadius = height / 2 169 | label.textColor = todayTextColor 170 | self.addSubview(selectedView!) 171 | self.sendSubviewToBack(selectedView!) 172 | } 173 | 174 | func highlightRight() { 175 | halfBackgroundView = UIView(frame: CGRect(x: width / 2, y: yHighlightPosition, width: width / 2, height: height*highlightScale)) 176 | halfBackgroundView?.backgroundColor = highlightColor.withAlphaComponent(0.3) 177 | self.addSubview(halfBackgroundView!) 178 | self.sendSubviewToBack(halfBackgroundView!) 179 | addRoundHighlightView() 180 | } 181 | 182 | func highlightLeft() { 183 | halfBackgroundView = UIView(frame: CGRect(x: 0, y: yHighlightPosition, width: width / 2, height: height*highlightScale)) 184 | halfBackgroundView?.backgroundColor = highlightColor.withAlphaComponent(0.3) 185 | self.addSubview(halfBackgroundView!) 186 | self.sendSubviewToBack(halfBackgroundView!) 187 | addRoundHighlightView() 188 | } 189 | 190 | func addRoundHighlightView() { 191 | roundHighlightView = UIView(frame: CGRect(x: (width - height) / 2, y: 0, width: height, height: height)) 192 | roundHighlightView?.backgroundColor = highlightColor.withAlphaComponent(1) 193 | roundHighlightView?.layer.cornerRadius = height / 2 194 | self.addSubview(roundHighlightView!) 195 | self.sendSubviewToBack(roundHighlightView!) 196 | } 197 | 198 | func highlight() { 199 | roundHighlightView = UIView(frame: CGRect(x: 0, y: yHighlightPosition, width: width, height: height*highlightScale)) 200 | roundHighlightView?.backgroundColor = highlightColor.withAlphaComponent(0.3) 201 | self.addSubview(roundHighlightView!) 202 | self.sendSubviewToBack(roundHighlightView!) 203 | } 204 | 205 | } 206 | 207 | 208 | extension DayCollectionCell { 209 | class func register(for collectionView: UICollectionView) { 210 | collectionView.register(UINib(nibName: DayCollectionCell.nameOfClass, bundle: CalendarViewFrameworkBundle.main), 211 | forCellWithReuseIdentifier: DayCollectionCell.nameOfClass) 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/CollectionViewCell/DayCollectionCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 27 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/CollectionViewCell/MonthCollectionCell.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | protocol MonthCollectionCellDelegate: class { 4 | func didSelect(startDate: Date? , endDate : Date?) 5 | func isStartOrEnd(date : Date) -> Bool 6 | func isBetweenStartAndEnd(date : Date) -> Bool 7 | } 8 | 9 | class MonthCollectionCell: UICollectionViewCell { 10 | 11 | @IBOutlet var collectionView: UICollectionView! 12 | 13 | weak var monthCellDelegate: MonthCollectionCellDelegate? 14 | var startDate : Date? 15 | var endDate : Date? 16 | let columns = 7 17 | var rows = 6 18 | lazy var total = columns * rows 19 | var dates = [Date]() 20 | var previousMonthVisibleDatesCount = 0 21 | var currentMonthVisibleDatesCount = 0 22 | var nextMonthVisibleDatesCount = 0 23 | var headerHeight : CGFloat = 40.0 24 | var maxDate: Date = Date() 25 | var logic: CalendarLogic? { 26 | didSet { 27 | populateDates() 28 | collectionView.reloadData() 29 | } 30 | } 31 | 32 | var highlightColor: UIColor = UIColor(red: 11/255.0, green: 75/255.0, blue: 105/255.0, alpha: 1) 33 | var highlightScale: CGFloat = 0.8 34 | var todayHighlightColor: UIColor = .red 35 | var todayTextColor: UIColor = .white 36 | var dayTextColor: UIColor = .gray 37 | var dayFont: UIFont = UIFont.systemFont(ofSize: 16) 38 | 39 | override func awakeFromNib() { 40 | super.awakeFromNib() 41 | DayCollectionCell.register(for: collectionView) 42 | WeekHeaderView.register(for: collectionView) 43 | } 44 | 45 | func setUserInterfaceProperties(highlightColor: UIColor, 46 | highlightScale: CGFloat, 47 | todayHighlightColor: UIColor, 48 | todayTextColor: UIColor, 49 | dayTextColor: UIColor, 50 | dayFont: UIFont){ 51 | self.highlightColor = highlightColor 52 | self.highlightScale = highlightScale 53 | self.todayHighlightColor = todayHighlightColor 54 | self.todayTextColor = todayTextColor 55 | self.dayFont = dayFont 56 | } 57 | 58 | func populateDates() { 59 | if let logic = logic { 60 | dates = [] 61 | dates += logic.previousMonthVisibleDays! 62 | dates += logic.currentMonthDays! 63 | dates += logic.nextMonthVisibleDays! 64 | 65 | previousMonthVisibleDatesCount = logic.previousMonthVisibleDays!.count 66 | currentMonthVisibleDatesCount = logic.currentMonthDays!.count 67 | nextMonthVisibleDatesCount = logic.nextMonthVisibleDays!.count 68 | 69 | } else { 70 | dates.removeAll(keepingCapacity: false) 71 | } 72 | } 73 | 74 | func setStartAndEndDate(start: Date?, end: Date?){ 75 | startDate = start 76 | endDate = end 77 | self.collectionView.layoutIfNeeded() 78 | } 79 | } 80 | 81 | extension MonthCollectionCell: UICollectionViewDataSource { 82 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 83 | return total 84 | } 85 | 86 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 87 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: DayCollectionCell.nameOfClass,for: indexPath) as! DayCollectionCell 88 | let date = dates[indexPath.item] 89 | let validateDate = fetchDate(indexPath: indexPath, date: date) 90 | let isDisable = isValidDate(indexPath: indexPath, date: date) 91 | cell.setCellProperties(highlightColor: highlightColor, 92 | highlightScale: highlightScale, 93 | todayHighlightColor: todayHighlightColor, 94 | todayTextColor: todayTextColor, 95 | dayTextColor: dayTextColor, 96 | dayFont: dayFont) 97 | cell.config(date: date, 98 | fetchDate: validateDate, 99 | startDate: startDate, 100 | endDate: endDate, 101 | isDisable: isDisable) 102 | return cell 103 | } 104 | 105 | func fetchDate(indexPath: IndexPath, date: Date)-> Date?{ 106 | return (indexPath.item < dates.count) ? date : nil 107 | } 108 | 109 | func isValidDate(indexPath: IndexPath, date: Date)-> Bool { 110 | let totalDay = previousMonthVisibleDatesCount 111 | + currentMonthVisibleDatesCount 112 | return (indexPath.item < previousMonthVisibleDatesCount) || 113 | (indexPath.item >= totalDay) || 114 | date > maxDate 115 | } 116 | 117 | func collectionView(_ collectionView: UICollectionView, 118 | didSelectItemAt indexPath: IndexPath) { 119 | let date = dates[indexPath.item] 120 | let isVisible = self.logic!.isVisible(date: date) 121 | validateRange(date: date, isVisible: isVisible) 122 | collectionView.layoutIfNeeded() 123 | } 124 | 125 | func validateRange(date: Date, isVisible: Bool){ 126 | if date <= maxDate && isVisible { 127 | if startDate != nil && endDate == nil && date >= startDate! { 128 | monthCellDelegate?.didSelect(startDate: startDate!, endDate: date) 129 | } 130 | else{ 131 | monthCellDelegate?.didSelect(startDate: date, endDate: nil) 132 | } 133 | } 134 | } 135 | } 136 | 137 | extension MonthCollectionCell: UICollectionViewDelegateFlowLayout { 138 | func collectionView(_ collectionView: UICollectionView, 139 | viewForSupplementaryElementOfKind kind: String, 140 | at indexPath: IndexPath) -> UICollectionReusableView { 141 | return collectionView.dequeueReusableSupplementaryView( 142 | ofKind: UICollectionView.elementKindSectionHeader, 143 | withReuseIdentifier: WeekHeaderView.nameOfClass, 144 | for: indexPath 145 | ) 146 | } 147 | 148 | func collectionView(_ collectionView: UICollectionView, 149 | layout collectionViewLayout: UICollectionViewLayout, 150 | sizeForItemAt indexPath: IndexPath) -> CGSize { 151 | return CGSize(width: self.frame.width/7.001, height: (collectionView.frame.height-headerHeight)/6.5) 152 | 153 | } 154 | 155 | func collectionView(_ collectionView: UICollectionView, 156 | layout collectionViewLayout: UICollectionViewLayout, 157 | referenceSizeForHeaderInSection section: Int) -> CGSize { 158 | return CGSize(width: collectionView.frame.width, height: headerHeight) 159 | } 160 | } 161 | 162 | extension MonthCollectionCell { 163 | class func register(for collectionView: UICollectionView) { 164 | collectionView.register(UINib(nibName: MonthCollectionCell.nameOfClass, bundle: CalendarViewFrameworkBundle.main), 165 | forCellWithReuseIdentifier: MonthCollectionCell.nameOfClass) 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/CollectionViewCell/MonthCollectionCell.xib: -------------------------------------------------------------------------------- 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 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extensions.swift 3 | // DateRangeSelector 4 | // 5 | // Created by Amir on 3/4/21. 6 | // 7 | 8 | import Foundation 9 | import UIKit 10 | 11 | extension NSObject { 12 | @objc 13 | static var nameOfClass: String { 14 | return NSStringFromClass(self).components(separatedBy: ".").last! 15 | } 16 | } 17 | 18 | extension UITableViewCell { 19 | @objc 20 | static func reuseIdentifier() -> String { 21 | return self.nameOfClass 22 | } 23 | } 24 | 25 | extension UICollectionViewCell { 26 | @objc 27 | static func reuseIdentifier() -> String { 28 | return self.nameOfClass 29 | } 30 | } 31 | 32 | extension Date { 33 | static func from(year: Int, month: Int, day: Int) -> Date { 34 | let calendar = Calendar(identifier: .gregorian) 35 | var dateComponents = DateComponents() 36 | dateComponents.year = year 37 | dateComponents.month = month 38 | dateComponents.day = day 39 | return calendar.date(from: dateComponents) ?? Date() 40 | } 41 | } 42 | 43 | extension UIView{ 44 | func fixInView(_ container: UIView!) -> Void{ 45 | self.translatesAutoresizingMaskIntoConstraints = false; 46 | self.frame = container.frame; 47 | container.addSubview(self); 48 | NSLayoutConstraint(item: self, attribute: .leading, relatedBy: .equal, toItem: container, attribute: .leading, multiplier: 1.0, constant: 0).isActive = true 49 | NSLayoutConstraint(item: self, attribute: .trailing, relatedBy: .equal, toItem: container, attribute: .trailing, multiplier: 1.0, constant: 0).isActive = true 50 | NSLayoutConstraint(item: self, attribute: .top, relatedBy: .equal, toItem: container, attribute: .top, multiplier: 1.0, constant: 0).isActive = true 51 | NSLayoutConstraint(item: self, attribute: .bottom, relatedBy: .equal, toItem: container, attribute: .bottom, multiplier: 1.0, constant: 0).isActive = true 52 | } 53 | } 54 | 55 | extension Date { 56 | 57 | func areSameDay(date: Date?) -> Bool { 58 | guard let date = date else { return false } 59 | return Calendar.current.compare(self, to: date, toGranularity: .day) == ComparisonResult.orderedSame 60 | } 61 | 62 | static func date(day: Int, month: Int, year: Int) -> Date { 63 | var dateComponents = DateComponents() 64 | 65 | dateComponents.year = year 66 | dateComponents.month = month 67 | dateComponents.day = day 68 | 69 | return Calendar.current.date(from: dateComponents)! 70 | } 71 | 72 | var startOfDay: Date { 73 | var components = dateComponents 74 | 75 | components.hour = 0 76 | components.minute = 0 77 | components.second = 0 78 | 79 | return Calendar.current.date(from: components)! 80 | } 81 | 82 | var endOfTheDay: Date { 83 | var components = dateComponents 84 | 85 | components.hour = 23 86 | components.minute = 59 87 | components.second = 59 88 | 89 | return Calendar.current.date(from: components)! 90 | } 91 | 92 | var firstDayOfTheMonth: Date { 93 | let startOfDay = Calendar.current.startOfDay(for: self) 94 | let dateComponents = Calendar.current.dateComponents([.year, .month], from: startOfDay) 95 | return Calendar.current.date(from: dateComponents)! 96 | } 97 | 98 | var firstDayOfPreviousMonth: Date { 99 | return firstDay(followingMonth: false) 100 | } 101 | 102 | var firstDayOfFollowingMonth: Date { 103 | return firstDay(followingMonth: true) 104 | } 105 | 106 | var monthDayAndYearComponents: DateComponents { 107 | return dateComponents(components: [.month, .year]) 108 | } 109 | 110 | var weekDay: Int { 111 | return dateComponents.weekday! 112 | } 113 | 114 | var numberOfDaysInMonth: Int { 115 | return Calendar.current.range(of: .day, in: .month, for: self)!.count 116 | } 117 | 118 | var day: Int { 119 | return dateComponents.day! 120 | } 121 | 122 | var month: Int { 123 | return dateComponents.month! 124 | } 125 | 126 | var year: Int { 127 | return dateComponents.year! 128 | } 129 | 130 | var minute: Int { 131 | return dateComponents.minute! 132 | } 133 | 134 | var second: Int { 135 | return dateComponents.second! 136 | } 137 | 138 | var hour: Int { 139 | return dateComponents.hour! 140 | } 141 | 142 | //MARK: Private variable and methods. 143 | 144 | private var dateComponents: DateComponents { 145 | return dateComponents(components: [.second, .hour, .day, .weekday, .month, .year]) 146 | } 147 | 148 | private func dateComponents(components: Set) -> DateComponents { 149 | let components = Calendar.current.dateComponents(components, from: self) 150 | return components 151 | } 152 | 153 | private func firstDay(followingMonth: Bool) -> Date { 154 | var dateComponent = DateComponents() 155 | dateComponent.month = followingMonth ? 1: -1 156 | 157 | let date = Calendar.current.date(byAdding: dateComponent, to: self) 158 | return date!.firstDayOfTheMonth 159 | } 160 | } 161 | 162 | 163 | -------------------------------------------------------------------------------- /DateRangeSelector/CalendarKit/WeekHeaderView.swift: -------------------------------------------------------------------------------- 1 | 2 | import UIKit 3 | 4 | class WeekHeaderView: UICollectionReusableView { 5 | 6 | @IBOutlet var labels: [UILabel]! 7 | let formatter = DateFormatter() 8 | var bgColor: UIColor = UIColor.lightGray.withAlphaComponent(0.5) 9 | var textColor: UIColor = UIColor.darkGray 10 | 11 | override func awakeFromNib() { 12 | self.backgroundColor = bgColor 13 | labels.forEach { $0.textColor = textColor } 14 | if labels.count == formatter.weekdaySymbols.count { 15 | let weekdaySymbols = formatter.weekdaySymbols! 16 | (0.. 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 28 | 34 | 40 | 46 | 52 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /DateRangeSelector/DateRangeSelector.h: -------------------------------------------------------------------------------- 1 | // 2 | // DateRangeSelector.h 3 | // DateRangeSelector 4 | // 5 | // Created by Amir on 3/4/21. 6 | // 7 | 8 | #import 9 | 10 | //! Project version number for DateRangeSelector. 11 | FOUNDATION_EXPORT double DateRangeSelectorVersionNumber; 12 | 13 | //! Project version string for DateRangeSelector. 14 | FOUNDATION_EXPORT const unsigned char DateRangeSelectorVersionString[]; 15 | 16 | // In this header, you should import all the public headers of your framework using statements like #import 17 | 18 | 19 | -------------------------------------------------------------------------------- /DateRangeSelector/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 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DateRangeSelectorExample 4 | // 5 | // Created by Amir on 3/4/21. 6 | // 7 | 8 | import UIKit 9 | 10 | 11 | @main 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | 21 | // MARK: UISceneSession Lifecycle 22 | @available(iOS 13.0, *) 23 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 24 | // Called when a new scene session is being created. 25 | // Use this method to select a configuration to create the new scene with. 26 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 27 | } 28 | @available(iOS 13.0, *) 29 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 30 | // Called when the user discards a scene session. 31 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 32 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 33 | } 34 | 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/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 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 43 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 82 | 88 | 89 | 90 | 91 | 92 | 93 | 102 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/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 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UIApplicationSceneManifest 24 | 25 | UIApplicationSupportsMultipleScenes 26 | 27 | UISceneConfigurations 28 | 29 | UIWindowSceneSessionRoleApplication 30 | 31 | 32 | UISceneConfigurationName 33 | Default Configuration 34 | UISceneDelegateClassName 35 | $(PRODUCT_MODULE_NAME).SceneDelegate 36 | UISceneStoryboardFile 37 | Main 38 | 39 | 40 | 41 | 42 | UIApplicationSupportsIndirectInputEvents 43 | 44 | UILaunchStoryboardName 45 | LaunchScreen 46 | UIMainStoryboardFile 47 | Main 48 | UIRequiredDeviceCapabilities 49 | 50 | armv7 51 | 52 | UISupportedInterfaceOrientations 53 | 54 | UIInterfaceOrientationPortrait 55 | UIInterfaceOrientationLandscapeLeft 56 | UIInterfaceOrientationLandscapeRight 57 | 58 | UISupportedInterfaceOrientations~ipad 59 | 60 | UIInterfaceOrientationPortrait 61 | UIInterfaceOrientationPortraitUpsideDown 62 | UIInterfaceOrientationLandscapeLeft 63 | UIInterfaceOrientationLandscapeRight 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // DateRangeSelectorExample 4 | // 5 | // Created by Amir on 3/4/21. 6 | // 7 | 8 | import UIKit 9 | 10 | @available(iOS 13.0, *) 11 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 12 | 13 | var window: UIWindow? 14 | 15 | 16 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 17 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 18 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 19 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 20 | guard let _ = (scene as? UIWindowScene) else { return } 21 | } 22 | 23 | func sceneDidDisconnect(_ scene: UIScene) { 24 | // Called as the scene is being released by the system. 25 | // This occurs shortly after the scene enters the background, or when its session is discarded. 26 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 27 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 28 | } 29 | 30 | func sceneDidBecomeActive(_ scene: UIScene) { 31 | // Called when the scene has moved from an inactive state to an active state. 32 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 33 | } 34 | 35 | func sceneWillResignActive(_ scene: UIScene) { 36 | // Called when the scene will move from an active state to an inactive state. 37 | // This may occur due to temporary interruptions (ex. an incoming phone call). 38 | } 39 | 40 | func sceneWillEnterForeground(_ scene: UIScene) { 41 | // Called as the scene transitions from the background to the foreground. 42 | // Use this method to undo the changes made on entering the background. 43 | } 44 | 45 | func sceneDidEnterBackground(_ scene: UIScene) { 46 | // Called as the scene transitions from the foreground to the background. 47 | // Use this method to save data, release shared resources, and store enough scene-specific state information 48 | // to restore the scene back to its current state. 49 | } 50 | 51 | 52 | } 53 | 54 | -------------------------------------------------------------------------------- /DateRangeSelectorExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DateRangeSelectorExample 4 | // 5 | // Created by Amir on 3/4/21. 6 | // 7 | 8 | import UIKit 9 | import DateRangeSelector 10 | 11 | class ViewController: UIViewController { 12 | 13 | @IBOutlet weak var monthTextField: UITextField! 14 | @IBOutlet weak var saveMonthButton: UIButton! 15 | @IBOutlet weak var resetMonthButton: UIButton! 16 | @IBOutlet weak var fromValueLabel: UILabel! 17 | @IBOutlet weak var toValueLabel: UILabel! 18 | @IBOutlet weak var calendarView: CalendarView! 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | setupUI() 23 | setupCalendarUI() 24 | calendarView.delegate = self 25 | } 26 | 27 | func setupUI(){ 28 | saveMonthButton.layer.borderWidth = 1 29 | saveMonthButton.layer.borderColor = UIColor.gray.cgColor 30 | saveMonthButton.layer.cornerRadius = 8 31 | resetMonthButton.layer.borderWidth = 1 32 | resetMonthButton.layer.borderColor = UIColor.gray.cgColor 33 | resetMonthButton.layer.cornerRadius = 8 34 | } 35 | 36 | func setupCalendarUI(){ 37 | calendarView.selectedYear = 2019 38 | calendarView.maxDate = Date() 39 | calendarView.previousButtonIsEnable = true 40 | calendarView.nextButtonIsEnable = true 41 | calendarView.headerTitleColor = .darkGray 42 | calendarView.headerTitleFont = UIFont.systemFont(ofSize: 18) 43 | calendarView.headerBackgroundColor = UIColor.lightGray.withAlphaComponent(0.5) 44 | calendarView.previousButtonTitleColor = .darkGray 45 | calendarView.previousButtonTitleFont = UIFont.systemFont(ofSize: 20) 46 | calendarView.previousButtonAligment = .right 47 | calendarView.nextButtonTitleColor = .darkGray 48 | calendarView.nextButtonTitleFont = UIFont.systemFont(ofSize: 20) 49 | calendarView.nextButtonAligment = .left 50 | calendarView.highlightColor = UIColor(red: 11/255.0, green: 75/255.0, blue: 105/255.0, alpha: 1) 51 | calendarView.highlightScale = 0.8 52 | calendarView.todayHighlightColor = .red 53 | calendarView.todayTextColor = .white 54 | calendarView.dayTextColor = .gray 55 | calendarView.dayFont = UIFont.systemFont(ofSize: 16) 56 | } 57 | 58 | 59 | @IBAction func saveMonthButtonPressed(_ sender: Any) { 60 | guard let monthCount = monthTextField.text else { 61 | return 62 | } 63 | calendarView.monthRange = Int(monthCount) ?? 12 64 | monthTextField.endEditing(true) 65 | } 66 | 67 | @IBAction func resetMonthButtonPressed(_ sender: Any) { 68 | calendarView.monthRange = 12 69 | monthTextField.text = "" 70 | monthTextField.endEditing(true) 71 | } 72 | 73 | } 74 | 75 | extension ViewController: CalendarViewDelegate { 76 | func didSelectDate(startDate: Date, endDate: Date) { 77 | let dateFormatter = DateFormatter() 78 | dateFormatter.dateFormat = "MMM d, yyyy" 79 | fromValueLabel.text = dateFormatter.string(from: startDate) 80 | toValueLabel.text = dateFormatter.string(from: endDate) 81 | } 82 | } 83 | 84 | 85 | -------------------------------------------------------------------------------- /DateRangeSelectorTests/DateRangeSelectorTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DateRangeSelectorTests.swift 3 | // DateRangeSelectorTests 4 | // 5 | // Created by Amir on 3/4/21. 6 | // 7 | 8 | import XCTest 9 | @testable import DateRangeSelector 10 | 11 | class DateRangeSelectorTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /DateRangeSelectorTests/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 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Tiss-energy 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 | # DateRangeSelector 2 | 3 | Screen Shot 2021-03-10 at 4 02 20 PM 4 | 5 | # Requirements 6 | - Xcode 11+ 7 | - Swift 5 8 | - iOS 10.0+ 9 | 10 | 11 | # Installation 12 | 13 | 14 | ## Cocoapods 15 | ```ruby 16 | pod 'DateRangeSelector', :git => 'https://github.com/boof-tech/DateRangeSelector', :tag => '0.0.3' 17 | ``` 18 | 19 | # Usage 20 | 21 | ### Import DateRangeSelector 22 | ```swift 23 | import DateRangeSelector 24 | ``` 25 | 26 | ### Create an instance of Calendar 27 | ```swift 28 | let frame = CGRect(x: 0, y: 50, width: self.view.frame.width, height: 300) 29 | var calendarView: CalendarView = CalendarView(frame: frame) 30 | 31 | ``` 32 | ### Setup Calendar 33 | ```swift 34 | calendarView.monthRange = 12 // Show the 12 month ago of Max Date 35 | calendarView.selectedYear = 2019 // The defult value is now year but when you set selected year, the range month of year is changed 36 | 37 | ``` 38 | 39 | ### Delegate 40 | ```swift 41 | class ViewController: UIViewController { 42 | override func viewDidLoad() { 43 | super.viewDidLoad() 44 | ... 45 | calendarView.delegate = self 46 | } 47 | ... 48 | } 49 | 50 | extension ViewController: CalendarViewDelegate { 51 | func didSelectDate(startDate: Date, endDate: Date) { 52 | let dateFormatter = DateFormatter() 53 | dateFormatter.dateFormat = "MMM d, yyyy" 54 | fromValueLabel.text = dateFormatter.string(from: startDate) 55 | toValueLabel.text = dateFormatter.string(from: endDate) 56 | } 57 | } 58 | ``` 59 | 60 | ### Customize gauge 61 | 62 | - Max Date 63 | ```swift 64 | calendarView.maxDate = Date() // Limited to show future days 65 | ``` 66 | 67 | - Header Calendar 68 | ```swift 69 | calendarView.headerTitleColor = .darkGray 70 | calendarView.headerTitleFont = UIFont.systemFont(ofSize: 18) 71 | calendarView.headerBackgroundColor = UIColor.lightGray.withAlphaComponent(0.5) 72 | ``` 73 | - Previous and Next Month 74 | ```swift 75 | calendarView.previousButtonIsEnable = true 76 | calendarView.nextButtonIsEnable = true 77 | calendarView.previousButtonTitleColor = .darkGray 78 | calendarView.previousButtonTitleFont = UIFont.systemFont(ofSize: 20) 79 | calendarView.previousButtonAligment = .right 80 | calendarView.nextButtonTitleColor = .darkGray 81 | calendarView.nextButtonTitleFont = UIFont.systemFont(ofSize: 20) 82 | calendarView.nextButtonAligment = .left 83 | ``` 84 | - Highlight 85 | ```swift 86 | calendarView.highlightColor = UIColor(red: 11/255.0, green: 75/255.0, blue: 105/255.0, alpha: 1) 87 | calendarView.highlightScale = 0.8 88 | ``` 89 | - Today 90 | ```swift 91 | calendarView.todayHighlightColor = .red 92 | calendarView.todayTextColor = .white 93 | ``` 94 | - Day 95 | ```swift 96 | calendarView.dayTextColor = .gray 97 | calendarView.dayFont = UIFont.systemFont(ofSize: 16) 98 | ``` 99 | 100 | ## Licence 101 | Date Range Selector is available under the MIT license. See the [LICENSE.txt](https://github.com/boof-tech/DateRangeSelector/blob/main/LICENSE) file for more info. 102 | 103 | 104 | --------------------------------------------------------------------------------