├── .gitignore ├── .travis.yml ├── Example ├── Podfile ├── Podfile.lock ├── SwiftUIWheelPicker.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── SwiftUIWheelPicker-Example.xcscheme ├── SwiftUIWheelPicker.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── SwiftUIWheelPicker │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift └── Tests │ ├── Info.plist │ └── Tests.swift ├── LICENSE ├── README.md ├── SwiftUIWheelPicker.podspec ├── SwiftUIWheelPicker ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ └── SwiftUIWheelPicker.swift ├── _Pods.xcodeproj └── img ├── basic.gif ├── center_indicator.gif ├── scroll_to.gif ├── selected_value.gif ├── with_alpha.gif ├── with_gradient.gif ├── with_scale.gif └── with_visible_count.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 26 | # Carthage/Checkouts 27 | 28 | Carthage/Build 29 | 30 | # We recommend against adding the Pods directory to your .gitignore. However 31 | # you should judge for yourself, the pros and cons are mentioned at: 32 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 33 | # 34 | # Note: if you ignore the Pods directory, make sure to uncomment 35 | # `pod install` in .travis.yml 36 | # 37 | # Pods/ 38 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * https://www.objc.io/issues/6-build-tools/travis-ci/ 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -enableCodeCoverage YES -workspace Example/SwiftUIWheelPicker.xcworkspace -scheme SwiftUIWheelPicker-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | platform :ios, '13.0' 4 | 5 | target 'SwiftUIWheelPicker_Example' do 6 | pod 'SwiftUIWheelPicker', :path => '../' 7 | 8 | target 'SwiftUIWheelPicker_Tests' do 9 | inherit! :search_paths 10 | 11 | 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - SwiftUIWheelPicker (0.1.0) 3 | 4 | DEPENDENCIES: 5 | - SwiftUIWheelPicker (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | SwiftUIWheelPicker: 9 | :path: "../" 10 | 11 | SPEC CHECKSUMS: 12 | SwiftUIWheelPicker: d2952668112d6742dd3f2cdb3dcfdead38595960 13 | 14 | PODFILE CHECKSUM: 58f3b9ed107b94c714c46a019acf317551cb101a 15 | 16 | COCOAPODS: 1.11.0.beta.2 17 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3EF9361E63085D6365183B7E /* Pods_SwiftUIWheelPicker_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 547D2836724DB5DDC4C3A0C8 /* Pods_SwiftUIWheelPicker_Example.framework */; }; 11 | 4DEF39B04B1A409AEED1FF99 /* Pods_SwiftUIWheelPicker_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FD90AA15B119A916E85C71 /* Pods_SwiftUIWheelPicker_Tests.framework */; }; 12 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 13 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 14 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 15 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 16 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 17 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 26 | remoteInfo = SwiftUIWheelPicker; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 146902E6C78118FF6631893B /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 32 | 31BAF1744A8AC01113073A3D /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 33 | 547D2836724DB5DDC4C3A0C8 /* Pods_SwiftUIWheelPicker_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftUIWheelPicker_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 607FACD01AFB9204008FA782 /* SwiftUIWheelPicker_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftUIWheelPicker_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 38 | 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 39 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 40 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 41 | 607FACE51AFB9204008FA782 /* SwiftUIWheelPicker_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftUIWheelPicker_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 44 | 672825A04ECDCDEBD0EEE3C2 /* Pods-SwiftUIWheelPicker_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUIWheelPicker_Example.release.xcconfig"; path = "Target Support Files/Pods-SwiftUIWheelPicker_Example/Pods-SwiftUIWheelPicker_Example.release.xcconfig"; sourceTree = ""; }; 45 | 789894CDDD31F4E810327385 /* Pods-SwiftUIWheelPicker_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUIWheelPicker_Example.debug.xcconfig"; path = "Target Support Files/Pods-SwiftUIWheelPicker_Example/Pods-SwiftUIWheelPicker_Example.debug.xcconfig"; sourceTree = ""; }; 46 | A07880EE50C45C429436D336 /* SwiftUIWheelPicker.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = SwiftUIWheelPicker.podspec; path = ../SwiftUIWheelPicker.podspec; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 47 | AA1FFA81345ACD0FFCCABD3A /* Pods-SwiftUIWheelPicker_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUIWheelPicker_Tests.release.xcconfig"; path = "Target Support Files/Pods-SwiftUIWheelPicker_Tests/Pods-SwiftUIWheelPicker_Tests.release.xcconfig"; sourceTree = ""; }; 48 | B5B671F5B538372127DAB67B /* Pods-SwiftUIWheelPicker_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftUIWheelPicker_Tests.debug.xcconfig"; path = "Target Support Files/Pods-SwiftUIWheelPicker_Tests/Pods-SwiftUIWheelPicker_Tests.debug.xcconfig"; sourceTree = ""; }; 49 | F9FD90AA15B119A916E85C71 /* Pods_SwiftUIWheelPicker_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftUIWheelPicker_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | 3EF9361E63085D6365183B7E /* Pods_SwiftUIWheelPicker_Example.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | 4DEF39B04B1A409AEED1FF99 /* Pods_SwiftUIWheelPicker_Tests.framework in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 607FACC71AFB9204008FA782 = { 73 | isa = PBXGroup; 74 | children = ( 75 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 76 | 607FACD21AFB9204008FA782 /* Example for SwiftUIWheelPicker */, 77 | 607FACE81AFB9204008FA782 /* Tests */, 78 | 607FACD11AFB9204008FA782 /* Products */, 79 | E3E1802F06FB3955CC0E92A0 /* Pods */, 80 | B8DF10597F3BB472B1AD72F0 /* Frameworks */, 81 | ); 82 | sourceTree = ""; 83 | }; 84 | 607FACD11AFB9204008FA782 /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 607FACD01AFB9204008FA782 /* SwiftUIWheelPicker_Example.app */, 88 | 607FACE51AFB9204008FA782 /* SwiftUIWheelPicker_Tests.xctest */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | 607FACD21AFB9204008FA782 /* Example for SwiftUIWheelPicker */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 97 | 607FACD71AFB9204008FA782 /* ViewController.swift */, 98 | 607FACD91AFB9204008FA782 /* Main.storyboard */, 99 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 100 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 101 | 607FACD31AFB9204008FA782 /* Supporting Files */, 102 | ); 103 | name = "Example for SwiftUIWheelPicker"; 104 | path = SwiftUIWheelPicker; 105 | sourceTree = ""; 106 | }; 107 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 607FACD41AFB9204008FA782 /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | 607FACE81AFB9204008FA782 /* Tests */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 119 | 607FACE91AFB9204008FA782 /* Supporting Files */, 120 | ); 121 | path = Tests; 122 | sourceTree = ""; 123 | }; 124 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 607FACEA1AFB9204008FA782 /* Info.plist */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | A07880EE50C45C429436D336 /* SwiftUIWheelPicker.podspec */, 136 | 31BAF1744A8AC01113073A3D /* README.md */, 137 | 146902E6C78118FF6631893B /* LICENSE */, 138 | ); 139 | name = "Podspec Metadata"; 140 | sourceTree = ""; 141 | }; 142 | B8DF10597F3BB472B1AD72F0 /* Frameworks */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 547D2836724DB5DDC4C3A0C8 /* Pods_SwiftUIWheelPicker_Example.framework */, 146 | F9FD90AA15B119A916E85C71 /* Pods_SwiftUIWheelPicker_Tests.framework */, 147 | ); 148 | name = Frameworks; 149 | sourceTree = ""; 150 | }; 151 | E3E1802F06FB3955CC0E92A0 /* Pods */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | 789894CDDD31F4E810327385 /* Pods-SwiftUIWheelPicker_Example.debug.xcconfig */, 155 | 672825A04ECDCDEBD0EEE3C2 /* Pods-SwiftUIWheelPicker_Example.release.xcconfig */, 156 | B5B671F5B538372127DAB67B /* Pods-SwiftUIWheelPicker_Tests.debug.xcconfig */, 157 | AA1FFA81345ACD0FFCCABD3A /* Pods-SwiftUIWheelPicker_Tests.release.xcconfig */, 158 | ); 159 | path = Pods; 160 | sourceTree = ""; 161 | }; 162 | /* End PBXGroup section */ 163 | 164 | /* Begin PBXNativeTarget section */ 165 | 607FACCF1AFB9204008FA782 /* SwiftUIWheelPicker_Example */ = { 166 | isa = PBXNativeTarget; 167 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUIWheelPicker_Example" */; 168 | buildPhases = ( 169 | ED05502AB8AAD1F53762D522 /* [CP] Check Pods Manifest.lock */, 170 | 607FACCC1AFB9204008FA782 /* Sources */, 171 | 607FACCD1AFB9204008FA782 /* Frameworks */, 172 | 607FACCE1AFB9204008FA782 /* Resources */, 173 | C0F7BCF989BB10E1DD9FA66F /* [CP] Embed Pods Frameworks */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | ); 179 | name = SwiftUIWheelPicker_Example; 180 | productName = SwiftUIWheelPicker; 181 | productReference = 607FACD01AFB9204008FA782 /* SwiftUIWheelPicker_Example.app */; 182 | productType = "com.apple.product-type.application"; 183 | }; 184 | 607FACE41AFB9204008FA782 /* SwiftUIWheelPicker_Tests */ = { 185 | isa = PBXNativeTarget; 186 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUIWheelPicker_Tests" */; 187 | buildPhases = ( 188 | DDAEDCA76D4DA7C115194F4F /* [CP] Check Pods Manifest.lock */, 189 | 607FACE11AFB9204008FA782 /* Sources */, 190 | 607FACE21AFB9204008FA782 /* Frameworks */, 191 | 607FACE31AFB9204008FA782 /* Resources */, 192 | ); 193 | buildRules = ( 194 | ); 195 | dependencies = ( 196 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 197 | ); 198 | name = SwiftUIWheelPicker_Tests; 199 | productName = Tests; 200 | productReference = 607FACE51AFB9204008FA782 /* SwiftUIWheelPicker_Tests.xctest */; 201 | productType = "com.apple.product-type.bundle.unit-test"; 202 | }; 203 | /* End PBXNativeTarget section */ 204 | 205 | /* Begin PBXProject section */ 206 | 607FACC81AFB9204008FA782 /* Project object */ = { 207 | isa = PBXProject; 208 | attributes = { 209 | LastSwiftUpdateCheck = 0830; 210 | LastUpgradeCheck = 0830; 211 | ORGANIZATIONNAME = CocoaPods; 212 | TargetAttributes = { 213 | 607FACCF1AFB9204008FA782 = { 214 | CreatedOnToolsVersion = 6.3.1; 215 | LastSwiftMigration = 0900; 216 | }; 217 | 607FACE41AFB9204008FA782 = { 218 | CreatedOnToolsVersion = 6.3.1; 219 | LastSwiftMigration = 0900; 220 | TestTargetID = 607FACCF1AFB9204008FA782; 221 | }; 222 | }; 223 | }; 224 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftUIWheelPicker" */; 225 | compatibilityVersion = "Xcode 3.2"; 226 | developmentRegion = English; 227 | hasScannedForEncodings = 0; 228 | knownRegions = ( 229 | English, 230 | en, 231 | Base, 232 | ); 233 | mainGroup = 607FACC71AFB9204008FA782; 234 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 235 | projectDirPath = ""; 236 | projectRoot = ""; 237 | targets = ( 238 | 607FACCF1AFB9204008FA782 /* SwiftUIWheelPicker_Example */, 239 | 607FACE41AFB9204008FA782 /* SwiftUIWheelPicker_Tests */, 240 | ); 241 | }; 242 | /* End PBXProject section */ 243 | 244 | /* Begin PBXResourcesBuildPhase section */ 245 | 607FACCE1AFB9204008FA782 /* Resources */ = { 246 | isa = PBXResourcesBuildPhase; 247 | buildActionMask = 2147483647; 248 | files = ( 249 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 250 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 251 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | 607FACE31AFB9204008FA782 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | /* End PBXResourcesBuildPhase section */ 263 | 264 | /* Begin PBXShellScriptBuildPhase section */ 265 | C0F7BCF989BB10E1DD9FA66F /* [CP] Embed Pods Frameworks */ = { 266 | isa = PBXShellScriptBuildPhase; 267 | buildActionMask = 2147483647; 268 | files = ( 269 | ); 270 | inputPaths = ( 271 | "${PODS_ROOT}/Target Support Files/Pods-SwiftUIWheelPicker_Example/Pods-SwiftUIWheelPicker_Example-frameworks.sh", 272 | "${BUILT_PRODUCTS_DIR}/SwiftUIWheelPicker/SwiftUIWheelPicker.framework", 273 | ); 274 | name = "[CP] Embed Pods Frameworks"; 275 | outputPaths = ( 276 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftUIWheelPicker.framework", 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | shellPath = /bin/sh; 280 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwiftUIWheelPicker_Example/Pods-SwiftUIWheelPicker_Example-frameworks.sh\"\n"; 281 | showEnvVarsInLog = 0; 282 | }; 283 | DDAEDCA76D4DA7C115194F4F /* [CP] Check Pods Manifest.lock */ = { 284 | isa = PBXShellScriptBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | ); 288 | inputFileListPaths = ( 289 | ); 290 | inputPaths = ( 291 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 292 | "${PODS_ROOT}/Manifest.lock", 293 | ); 294 | name = "[CP] Check Pods Manifest.lock"; 295 | outputFileListPaths = ( 296 | ); 297 | outputPaths = ( 298 | "$(DERIVED_FILE_DIR)/Pods-SwiftUIWheelPicker_Tests-checkManifestLockResult.txt", 299 | ); 300 | runOnlyForDeploymentPostprocessing = 0; 301 | shellPath = /bin/sh; 302 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 303 | showEnvVarsInLog = 0; 304 | }; 305 | ED05502AB8AAD1F53762D522 /* [CP] Check Pods Manifest.lock */ = { 306 | isa = PBXShellScriptBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | ); 310 | inputFileListPaths = ( 311 | ); 312 | inputPaths = ( 313 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 314 | "${PODS_ROOT}/Manifest.lock", 315 | ); 316 | name = "[CP] Check Pods Manifest.lock"; 317 | outputFileListPaths = ( 318 | ); 319 | outputPaths = ( 320 | "$(DERIVED_FILE_DIR)/Pods-SwiftUIWheelPicker_Example-checkManifestLockResult.txt", 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | shellPath = /bin/sh; 324 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 325 | showEnvVarsInLog = 0; 326 | }; 327 | /* End PBXShellScriptBuildPhase section */ 328 | 329 | /* Begin PBXSourcesBuildPhase section */ 330 | 607FACCC1AFB9204008FA782 /* Sources */ = { 331 | isa = PBXSourcesBuildPhase; 332 | buildActionMask = 2147483647; 333 | files = ( 334 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, 335 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | }; 339 | 607FACE11AFB9204008FA782 /* Sources */ = { 340 | isa = PBXSourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 344 | ); 345 | runOnlyForDeploymentPostprocessing = 0; 346 | }; 347 | /* End PBXSourcesBuildPhase section */ 348 | 349 | /* Begin PBXTargetDependency section */ 350 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 351 | isa = PBXTargetDependency; 352 | target = 607FACCF1AFB9204008FA782 /* SwiftUIWheelPicker_Example */; 353 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 354 | }; 355 | /* End PBXTargetDependency section */ 356 | 357 | /* Begin PBXVariantGroup section */ 358 | 607FACD91AFB9204008FA782 /* Main.storyboard */ = { 359 | isa = PBXVariantGroup; 360 | children = ( 361 | 607FACDA1AFB9204008FA782 /* Base */, 362 | ); 363 | name = Main.storyboard; 364 | sourceTree = ""; 365 | }; 366 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 367 | isa = PBXVariantGroup; 368 | children = ( 369 | 607FACDF1AFB9204008FA782 /* Base */, 370 | ); 371 | name = LaunchScreen.xib; 372 | sourceTree = ""; 373 | }; 374 | /* End PBXVariantGroup section */ 375 | 376 | /* Begin XCBuildConfiguration section */ 377 | 607FACED1AFB9204008FA782 /* Debug */ = { 378 | isa = XCBuildConfiguration; 379 | buildSettings = { 380 | ALWAYS_SEARCH_USER_PATHS = NO; 381 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 382 | CLANG_CXX_LIBRARY = "libc++"; 383 | CLANG_ENABLE_MODULES = YES; 384 | CLANG_ENABLE_OBJC_ARC = YES; 385 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 386 | CLANG_WARN_BOOL_CONVERSION = YES; 387 | CLANG_WARN_COMMA = YES; 388 | CLANG_WARN_CONSTANT_CONVERSION = YES; 389 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 390 | CLANG_WARN_EMPTY_BODY = YES; 391 | CLANG_WARN_ENUM_CONVERSION = YES; 392 | CLANG_WARN_INFINITE_RECURSION = YES; 393 | CLANG_WARN_INT_CONVERSION = YES; 394 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 395 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 396 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 397 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 398 | CLANG_WARN_STRICT_PROTOTYPES = YES; 399 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 400 | CLANG_WARN_UNREACHABLE_CODE = YES; 401 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 402 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 403 | COPY_PHASE_STRIP = NO; 404 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 405 | ENABLE_STRICT_OBJC_MSGSEND = YES; 406 | ENABLE_TESTABILITY = YES; 407 | GCC_C_LANGUAGE_STANDARD = gnu99; 408 | GCC_DYNAMIC_NO_PIC = NO; 409 | GCC_NO_COMMON_BLOCKS = YES; 410 | GCC_OPTIMIZATION_LEVEL = 0; 411 | GCC_PREPROCESSOR_DEFINITIONS = ( 412 | "DEBUG=1", 413 | "$(inherited)", 414 | ); 415 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 416 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 417 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 418 | GCC_WARN_UNDECLARED_SELECTOR = YES; 419 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 420 | GCC_WARN_UNUSED_FUNCTION = YES; 421 | GCC_WARN_UNUSED_VARIABLE = YES; 422 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 423 | MTL_ENABLE_DEBUG_INFO = YES; 424 | ONLY_ACTIVE_ARCH = YES; 425 | SDKROOT = iphoneos; 426 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 427 | }; 428 | name = Debug; 429 | }; 430 | 607FACEE1AFB9204008FA782 /* Release */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | ALWAYS_SEARCH_USER_PATHS = NO; 434 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 435 | CLANG_CXX_LIBRARY = "libc++"; 436 | CLANG_ENABLE_MODULES = YES; 437 | CLANG_ENABLE_OBJC_ARC = YES; 438 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 439 | CLANG_WARN_BOOL_CONVERSION = YES; 440 | CLANG_WARN_COMMA = YES; 441 | CLANG_WARN_CONSTANT_CONVERSION = YES; 442 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 443 | CLANG_WARN_EMPTY_BODY = YES; 444 | CLANG_WARN_ENUM_CONVERSION = YES; 445 | CLANG_WARN_INFINITE_RECURSION = YES; 446 | CLANG_WARN_INT_CONVERSION = YES; 447 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 448 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 449 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 450 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 451 | CLANG_WARN_STRICT_PROTOTYPES = YES; 452 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 453 | CLANG_WARN_UNREACHABLE_CODE = YES; 454 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 455 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 456 | COPY_PHASE_STRIP = NO; 457 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 458 | ENABLE_NS_ASSERTIONS = NO; 459 | ENABLE_STRICT_OBJC_MSGSEND = YES; 460 | GCC_C_LANGUAGE_STANDARD = gnu99; 461 | GCC_NO_COMMON_BLOCKS = YES; 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 = 13.0; 469 | MTL_ENABLE_DEBUG_INFO = NO; 470 | SDKROOT = iphoneos; 471 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 472 | VALIDATE_PRODUCT = YES; 473 | }; 474 | name = Release; 475 | }; 476 | 607FACF01AFB9204008FA782 /* Debug */ = { 477 | isa = XCBuildConfiguration; 478 | baseConfigurationReference = 789894CDDD31F4E810327385 /* Pods-SwiftUIWheelPicker_Example.debug.xcconfig */; 479 | buildSettings = { 480 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 481 | INFOPLIST_FILE = SwiftUIWheelPicker/Info.plist; 482 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 483 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 484 | MARKETING_VERSION = 1.0.0; 485 | MODULE_NAME = ExampleApp; 486 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 487 | PRODUCT_NAME = "$(TARGET_NAME)"; 488 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 489 | SWIFT_VERSION = 4.0; 490 | }; 491 | name = Debug; 492 | }; 493 | 607FACF11AFB9204008FA782 /* Release */ = { 494 | isa = XCBuildConfiguration; 495 | baseConfigurationReference = 672825A04ECDCDEBD0EEE3C2 /* Pods-SwiftUIWheelPicker_Example.release.xcconfig */; 496 | buildSettings = { 497 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 498 | INFOPLIST_FILE = SwiftUIWheelPicker/Info.plist; 499 | IPHONEOS_DEPLOYMENT_TARGET = 13.0; 500 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 501 | MARKETING_VERSION = 1.0.0; 502 | MODULE_NAME = ExampleApp; 503 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 506 | SWIFT_VERSION = 4.0; 507 | }; 508 | name = Release; 509 | }; 510 | 607FACF31AFB9204008FA782 /* Debug */ = { 511 | isa = XCBuildConfiguration; 512 | baseConfigurationReference = B5B671F5B538372127DAB67B /* Pods-SwiftUIWheelPicker_Tests.debug.xcconfig */; 513 | buildSettings = { 514 | FRAMEWORK_SEARCH_PATHS = ( 515 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 516 | "$(inherited)", 517 | ); 518 | GCC_PREPROCESSOR_DEFINITIONS = ( 519 | "DEBUG=1", 520 | "$(inherited)", 521 | ); 522 | INFOPLIST_FILE = Tests/Info.plist; 523 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 524 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 525 | PRODUCT_NAME = "$(TARGET_NAME)"; 526 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 527 | SWIFT_VERSION = 4.0; 528 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUIWheelPicker_Example.app/SwiftUIWheelPicker_Example"; 529 | }; 530 | name = Debug; 531 | }; 532 | 607FACF41AFB9204008FA782 /* Release */ = { 533 | isa = XCBuildConfiguration; 534 | baseConfigurationReference = AA1FFA81345ACD0FFCCABD3A /* Pods-SwiftUIWheelPicker_Tests.release.xcconfig */; 535 | buildSettings = { 536 | FRAMEWORK_SEARCH_PATHS = ( 537 | "$(PLATFORM_DIR)/Developer/Library/Frameworks", 538 | "$(inherited)", 539 | ); 540 | INFOPLIST_FILE = Tests/Info.plist; 541 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 542 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 543 | PRODUCT_NAME = "$(TARGET_NAME)"; 544 | SWIFT_SWIFT3_OBJC_INFERENCE = Default; 545 | SWIFT_VERSION = 4.0; 546 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftUIWheelPicker_Example.app/SwiftUIWheelPicker_Example"; 547 | }; 548 | name = Release; 549 | }; 550 | /* End XCBuildConfiguration section */ 551 | 552 | /* Begin XCConfigurationList section */ 553 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "SwiftUIWheelPicker" */ = { 554 | isa = XCConfigurationList; 555 | buildConfigurations = ( 556 | 607FACED1AFB9204008FA782 /* Debug */, 557 | 607FACEE1AFB9204008FA782 /* Release */, 558 | ); 559 | defaultConfigurationIsVisible = 0; 560 | defaultConfigurationName = Release; 561 | }; 562 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUIWheelPicker_Example" */ = { 563 | isa = XCConfigurationList; 564 | buildConfigurations = ( 565 | 607FACF01AFB9204008FA782 /* Debug */, 566 | 607FACF11AFB9204008FA782 /* Release */, 567 | ); 568 | defaultConfigurationIsVisible = 0; 569 | defaultConfigurationName = Release; 570 | }; 571 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "SwiftUIWheelPicker_Tests" */ = { 572 | isa = XCConfigurationList; 573 | buildConfigurations = ( 574 | 607FACF31AFB9204008FA782 /* Debug */, 575 | 607FACF41AFB9204008FA782 /* Release */, 576 | ); 577 | defaultConfigurationIsVisible = 0; 578 | defaultConfigurationName = Release; 579 | }; 580 | /* End XCConfigurationList section */ 581 | }; 582 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 583 | } 584 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker.xcodeproj/xcshareddata/xcschemes/SwiftUIWheelPicker-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 45 | 46 | 48 | 54 | 55 | 56 | 57 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 80 | 82 | 88 | 89 | 90 | 91 | 92 | 93 | 99 | 101 | 107 | 108 | 109 | 110 | 112 | 113 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftUIWheelPicker 4 | // 5 | // Created by ggaljjak on 09/16/2021. 6 | // Copyright (c) 2021 ggaljjak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | window = UIWindow() 20 | window?.rootViewController = ViewController() 21 | window?.makeKeyAndVisible() 22 | return true 23 | } 24 | 25 | func applicationWillResignActive(_ application: UIApplication) { 26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 27 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 28 | } 29 | 30 | func applicationDidEnterBackground(_ application: UIApplication) { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | func applicationWillEnterForeground(_ application: UIApplication) { 36 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | func applicationDidBecomeActive(_ application: UIApplication) { 40 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 41 | } 42 | 43 | func applicationWillTerminate(_ application: UIApplication) { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(MARKETING_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/SwiftUIWheelPicker/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftUIWheelPicker 4 | // 5 | // Created by ggaljjak on 09/16/2021. 6 | // Copyright (c) 2021 ggaljjak. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SwiftUI 11 | import SwiftUIWheelPicker 12 | 13 | struct MainView: View { 14 | @State var indexBasic: Int = 5 15 | @State var indexRatio: Int = 5 16 | @State var indexAlpha: Int = 5 17 | @State var indexScale: Int = 5 18 | @State var indexGradient: Int = 5 19 | @State var indexIndicator: Int = 5 20 | @State var indexValue: Int = 5 21 | @State var indexScrollTo: Int = 5 22 | @State var items: [Int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 23 | 24 | var body: some View { 25 | GeometryReader { geometry in 26 | ScrollView(.vertical, showsIndicators: true) { 27 | VStack(alignment: .leading, spacing: 0) { 28 | VStack(alignment: .leading, spacing: 0) { 29 | Text("Basic").font(Font.title).padding(.top, 20) 30 | SwiftUIWheelPicker($indexBasic, items: $items) { value in 31 | GeometryReader { reader in 32 | Text("\(value)") 33 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 34 | } 35 | } 36 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 37 | .padding(.top, 10) 38 | } 39 | 40 | VStack(alignment: .leading, spacing: 0) { 41 | HStack(alignment: .bottom, spacing: 0) { 42 | Text("With Visible Count ").font(Font.title) 43 | Text("(Ratio)").font(Font.body) 44 | } 45 | SwiftUIWheelPicker($indexRatio, items: $items) { value in 46 | GeometryReader { reader in 47 | Text("\(value)") 48 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 49 | } 50 | } 51 | .width(.Ratio(0.1)) 52 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 53 | .clipShape(RoundedRectangle(cornerRadius: 20)) 54 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 55 | .padding(.top, 10) 56 | } 57 | .padding(.top, 30) 58 | 59 | VStack(alignment: .leading, spacing: 0) { 60 | Text("With Alpha").font(Font.title) 61 | SwiftUIWheelPicker($indexAlpha, items: $items) { value in 62 | GeometryReader { reader in 63 | Text("\(value)") 64 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 65 | } 66 | } 67 | .width(.VisibleCount(7)) 68 | .scrollAlpha(0.1) 69 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 70 | .clipShape(RoundedRectangle(cornerRadius: 20)) 71 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 72 | .padding(.top, 10) 73 | } 74 | .padding(.top, 30) 75 | 76 | VStack(alignment: .leading, spacing: 0) { 77 | Text("With Scale").font(Font.title) 78 | SwiftUIWheelPicker($indexScale, items: $items) { value in 79 | GeometryReader { reader in 80 | Text("\(value)") 81 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 82 | } 83 | } 84 | .width(.VisibleCount(7)) 85 | .scrollScale(0.4) 86 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 87 | .clipShape(RoundedRectangle(cornerRadius: 20)) 88 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 89 | .padding(.top, 10) 90 | } 91 | .padding(.top, 30) 92 | 93 | VStack(alignment: .leading, spacing: 0) { 94 | Text("With Gradient").font(Font.title) 95 | SwiftUIWheelPicker($indexGradient, items: $items) { value in 96 | GeometryReader { reader in 97 | Text("\(value)") 98 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 99 | } 100 | } 101 | .width(.Fixed(40)) 102 | .edgeLeft(AnyView( 103 | LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.4), Color.white.opacity(0)]), startPoint: .leading, endPoint: .trailing) 104 | ), width: .Ratio(0.2)) 105 | .edgeRight(AnyView( 106 | LinearGradient(gradient: Gradient(colors: [Color.white.opacity(0), Color.gray.opacity(0.4)]), startPoint: .leading, endPoint: .trailing) 107 | ), width: .Ratio(0.2)) 108 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 109 | .clipShape(RoundedRectangle(cornerRadius: 20)) 110 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 111 | .padding(.top, 10) 112 | } 113 | .padding(.top, 30) 114 | 115 | 116 | VStack(alignment: .leading, spacing: 0) { 117 | Text("Center indicator").font(Font.title) 118 | SwiftUIWheelPicker($indexIndicator, items: $items) { value in 119 | GeometryReader { reader in 120 | Text("\(value)") 121 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 122 | } 123 | } 124 | .width(.Fixed(40)) 125 | .centerView(AnyView( 126 | HStack(alignment: .center, spacing: 0) { 127 | Divider() 128 | .frame(width: 1) 129 | .background(Color.gray) 130 | .padding(EdgeInsets(top: 6, leading: 0, bottom: 6, trailing: 0)) 131 | .opacity(0.4) 132 | Spacer() 133 | Divider() 134 | .frame(width: 1) 135 | .background(Color.gray) 136 | .padding(EdgeInsets(top: 6, leading: 0, bottom: 6, trailing: 0)) 137 | .opacity(0.4) 138 | } 139 | ), width: .Fixed(40)) 140 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 141 | .clipShape(RoundedRectangle(cornerRadius: 20)) 142 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 143 | .padding(.top, 10) 144 | } 145 | .padding(.top, 30) 146 | 147 | VStack(alignment: .leading, spacing: 0) { 148 | Text("Selected Value : \(indexValue)").font(Font.title) 149 | SwiftUIWheelPicker($indexValue, items: $items) { value in 150 | GeometryReader { reader in 151 | Text("\(value)") 152 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 153 | .background(value % 2 == 0 ? Color.blue.opacity(0.4) : Color.green.opacity(0.4)) 154 | } 155 | } 156 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 157 | .border(Color.black, width: 1) 158 | .padding(.top, 10) 159 | } 160 | .padding(.top, 30) 161 | 162 | VStack(alignment: .leading, spacing: 0) { 163 | HStack(alignment: .bottom, spacing: 20) { 164 | Text("Scroll To ").font(Font.title) 165 | Spacer() 166 | Button("First") { 167 | indexScrollTo = 0 168 | } 169 | Button("Center") { 170 | indexScrollTo = items.count / 2 171 | } 172 | Button("Last") { 173 | indexScrollTo = items.count - 1 174 | } 175 | } 176 | SwiftUIWheelPicker($indexScrollTo, items: $items) { value in 177 | GeometryReader { reader in 178 | Text("\(value)") 179 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 180 | .background(value % 2 == 0 ? Color.blue.opacity(0.4) : Color.green.opacity(0.4)) 181 | } 182 | } 183 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 184 | .clipShape(RoundedRectangle(cornerRadius: 20)) 185 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 186 | .padding(.top, 10) 187 | } 188 | .padding(.top, 30) 189 | } 190 | .padding(EdgeInsets(top: 0, leading: 20, bottom: 40, trailing: 20)) 191 | } 192 | } 193 | } 194 | } 195 | 196 | struct MainView_Previews: PreviewProvider { 197 | static var previews: some View { 198 | MainView() 199 | .previewDevice(PreviewDevice(rawValue: "iPod touch (7th generation)")) 200 | MainView() 201 | .previewDevice(PreviewDevice(rawValue: "iPhone 12 Pro")) 202 | } 203 | } 204 | 205 | class ViewController: UIViewController { 206 | 207 | override func viewDidLoad() { 208 | super.viewDidLoad() 209 | self.navigationController?.isNavigationBarHidden = true 210 | let contentViewController = UIHostingController(rootView: MainView()) 211 | contentViewController.navigationController?.isNavigationBarHidden = true 212 | self.addChildViewController(contentViewController) 213 | self.view.addSubview(contentViewController.view) 214 | contentViewController.view.translatesAutoresizingMaskIntoConstraints = false 215 | contentViewController.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true 216 | contentViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true 217 | contentViewController.view.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true 218 | contentViewController.view.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true 219 | } 220 | 221 | override func didReceiveMemoryWarning() { 222 | super.didReceiveMemoryWarning() 223 | } 224 | } 225 | 226 | 227 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import SwiftUIWheelPicker 3 | 4 | class Tests: XCTestCase { 5 | 6 | override func setUp() { 7 | super.setUp() 8 | // Put setup code here. This method is called before the invocation of each test method in the class. 9 | } 10 | 11 | override func tearDown() { 12 | // Put teardown code here. This method is called after the invocation of each test method in the class. 13 | super.tearDown() 14 | } 15 | 16 | func testExample() { 17 | // This is an example of a functional test case. 18 | XCTAssert(true, "Pass") 19 | } 20 | 21 | func testPerformanceExample() { 22 | // This is an example of a performance test case. 23 | self.measure() { 24 | // Put the code you want to measure the time of here. 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 ggaljjak 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftUIWheelPicker 2 | 3 | [![Version](https://img.shields.io/cocoapods/v/SwiftUIWheelPicker.svg?style=flat)](https://cocoapods.org/pods/SwiftUIWheelPicker) 4 | [![License](https://img.shields.io/cocoapods/l/SwiftUIWheelPicker.svg?style=flat)](https://cocoapods.org/pods/SwiftUIWheelPicker) 5 | [![Platform](https://img.shields.io/cocoapods/p/SwiftUIWheelPicker.svg?style=flat)](https://cocoapods.org/pods/SwiftUIWheelPicker) 6 | 7 | Horizontal wheel picker for SwiftUI 8 | 9 | ## Requirements 10 | 11 | iOS 13.0+ 12 | 13 | ## Installation 14 | 15 | 16 | ### [CocoaPods](https://cocoapods.org) 17 | 18 | ```ruby 19 | pod 'SwiftUIWheelPicker' 20 | ``` 21 | 22 | ### Import 23 | 24 | ```swift 25 | import SwiftUIWheelPicker 26 | ``` 27 | 28 | ## Getting Started 29 | 30 | ### Basic use 31 | 32 | ![Basic Use](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/basic.gif?raw=true) 33 | 34 | ```swift 35 | @State var indexBasic: Int = 5 36 | @State var items: [Int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 37 | 38 | ... 39 | 40 | SwiftUIWheelPicker($indexBasic, items: $items) { value in 41 | GeometryReader { reader in 42 | Text("\(value)") 43 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 44 | } 45 | } 46 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 47 | .padding(.top, 10) 48 | ``` 49 | 50 | ### With Visible Count 51 | 52 | ![With Visible Count](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/with_visible_count.gif?raw=true) 53 | 54 | ```swift 55 | SwiftUIWheelPicker($indexRatio, items: $items) { value in 56 | GeometryReader { reader in 57 | Text("\(value)") 58 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 59 | } 60 | } 61 | .width(.Ratio(0.1)) 62 | ``` 63 | 64 | ```swift 65 | public enum WidthOption { 66 | case VisibleCount(Int) // How many items to show on the display 67 | case Fixed(CGFloat) // to a fixed width 68 | case Ratio(CGFloat) // From the width of the view to the ratio 69 | } 70 | ``` 71 | 72 | ### With Alpha 73 | 74 | ![With Alpha](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/with_alpha.gif?raw=true) 75 | 76 | ```swift 77 | SwiftUIWheelPicker($indexAlpha, items: $items) { value in 78 | GeometryReader { reader in 79 | Text("\(value)") 80 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 81 | } 82 | } 83 | .scrollAlpha(0.1) 84 | ``` 85 | 86 | ### With Scale 87 | 88 | ![With Scale](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/with_scale.gif?raw=true) 89 | 90 | ```swift 91 | SwiftUIWheelPicker($indexScale, items: $items) { value in 92 | GeometryReader { reader in 93 | Text("\(value)") 94 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 95 | } 96 | } 97 | .scrollScale(0.4) 98 | ``` 99 | 100 | ### With Gradient 101 | 102 | ![With Scale](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/with_gradient.gif?raw=true) 103 | 104 | ```swift 105 | SwiftUIWheelPicker($indexGradient, items: $items) { value in 106 | GeometryReader { reader in 107 | Text("\(value)") 108 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 109 | } 110 | } 111 | .edgeLeft(AnyView( 112 | LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.4), Color.white.opacity(0)]), startPoint: .leading, endPoint: .trailing) 113 | ), width: .Ratio(0.2)) 114 | .edgeRight(AnyView( 115 | LinearGradient(gradient: Gradient(colors: [Color.white.opacity(0), Color.gray.opacity(0.4)]), startPoint: .leading, endPoint: .trailing) 116 | ), width: .Ratio(0.2)) 117 | ``` 118 | 119 | ### Center indicator 120 | 121 | ![Center indicator](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/center_indicator.gif?raw=true) 122 | 123 | ```swift 124 | SwiftUIWheelPicker($indexIndicator, items: $items) { value in 125 | GeometryReader { reader in 126 | Text("\(value)") 127 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 128 | } 129 | } 130 | .centerView(AnyView( 131 | HStack(alignment: .center, spacing: 0) { 132 | Divider() 133 | .frame(width: 1) 134 | .background(Color.gray) 135 | .padding(EdgeInsets(top: 6, leading: 0, bottom: 6, trailing: 0)) 136 | .opacity(0.4) 137 | Spacer() 138 | Divider() 139 | .frame(width: 1) 140 | .background(Color.gray) 141 | .padding(EdgeInsets(top: 6, leading: 0, bottom: 6, trailing: 0)) 142 | .opacity(0.4) 143 | } 144 | ), width: .Fixed(40)) 145 | ``` 146 | 147 | ### Selected Value 148 | 149 | ![Selected Value](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/selected_value.gif?raw=true) 150 | 151 | ```swift 152 | @State var indexValue: Int = 5 153 | @State var items: [Int] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 154 | 155 | Text("Selected Value : \(indexValue)").font(Font.title) 156 | SwiftUIWheelPicker($indexValue, items: $items) { value in 157 | GeometryReader { reader in 158 | Text("\(value)") 159 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 160 | .background(value % 2 == 0 ? Color.blue.opacity(0.4) : Color.green.opacity(0.4)) 161 | } 162 | } 163 | ``` 164 | 165 | ### Scroll To 166 | 167 | ![Scroll To](https://github.com/GGJJack/SwiftUIWheelPicker/blob/master/img/scroll_to.gif?raw=true) 168 | 169 | ```swift 170 | HStack(alignment: .bottom, spacing: 20) { 171 | Text("Scroll To ").font(Font.title) 172 | Spacer() 173 | Button("First") { 174 | indexScrollTo = 0 175 | } 176 | Button("Center") { 177 | indexScrollTo = items.count / 2 178 | } 179 | Button("Last") { 180 | indexScrollTo = items.count - 1 181 | } 182 | } 183 | SwiftUIWheelPicker($indexScrollTo, items: $items) { value in 184 | GeometryReader { reader in 185 | Text("\(value)") 186 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 187 | .background(value % 2 == 0 ? Color.blue.opacity(0.4) : Color.green.opacity(0.4)) 188 | } 189 | } 190 | ``` 191 | 192 | ## Author 193 | 194 | ggaljjak, ggaljjak.choi@gmail.com 195 | 196 | ## License 197 | 198 | SwiftUIWheelPicker is available under the MIT license. See the LICENSE file for more info. 199 | -------------------------------------------------------------------------------- /SwiftUIWheelPicker.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint SwiftUIWheelPicker.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'SwiftUIWheelPicker' 11 | s.version = '1.0.0' 12 | s.summary = 'Horizontal wheel picker for SwiftUI' 13 | s.homepage = 'https://github.com/ggjjack/SwiftUIWheelPicker' 14 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 15 | s.license = { :type => 'MIT', :file => 'LICENSE' } 16 | s.author = { 'ggaljjak' => 'ggaljjak.choi@gmail.com' } 17 | s.source = { :git => 'https://github.com/ggjjack/SwiftUIWheelPicker.git', :tag => s.version.to_s } 18 | s.swift_versions = '4.0' 19 | # s.swift_versions = ['5.3', '5.4', '5.5'] 20 | # s.social_media_url = 'https://twitter.com/' 21 | 22 | s.ios.deployment_target = '13.0' 23 | 24 | s.source_files = 'SwiftUIWheelPicker/Classes/**/*' 25 | 26 | # s.resource_bundles = { 27 | # 'SwiftUIWheelPicker' => ['SwiftUIWheelPicker/Assets/*.png'] 28 | # } 29 | 30 | # s.public_header_files = 'Pod/Classes/**/*.h' 31 | # s.frameworks = 'UIKit', 'MapKit' 32 | # s.dependency 'AFNetworking', '~> 2.3' 33 | end 34 | -------------------------------------------------------------------------------- /SwiftUIWheelPicker/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/SwiftUIWheelPicker/Assets/.gitkeep -------------------------------------------------------------------------------- /SwiftUIWheelPicker/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/SwiftUIWheelPicker/Classes/.gitkeep -------------------------------------------------------------------------------- /SwiftUIWheelPicker/Classes/SwiftUIWheelPicker.swift: -------------------------------------------------------------------------------- 1 | 2 | import SwiftUI 3 | 4 | public enum WidthOption { 5 | case VisibleCount(Int) 6 | case Fixed(CGFloat) 7 | case Ratio(CGFloat) 8 | } 9 | //SwiftUICustomSlider 10 | public struct SwiftUIWheelPicker: View { 11 | 12 | private var items: Binding<[Item]> 13 | let contentBuilder: (Item) -> Content 14 | @Binding var position: Int 15 | @GestureState private var translation: CGFloat = 0 16 | private var contentWidthOption: WidthOption = .VisibleCount(5) 17 | private var sizeFactor: CGFloat = 1 18 | private var alphaFactor: Double = 1 19 | private var edgeLeftView: AnyView? = nil 20 | private var edgeLeftWidth: WidthOption? = nil 21 | private var edgeRightView: AnyView? = nil 22 | private var edgeRightWidth: WidthOption? = nil 23 | private var centerView: AnyView? = nil 24 | private var centerViewWidth: WidthOption? = nil 25 | //private var isInfinite: Bool = false 26 | private var onValueChanged: ((Item) -> Void)? = nil 27 | 28 | public init(_ position: Binding, items: Binding<[Item]>, @ViewBuilder content: @escaping (Item) -> Content) { 29 | self.items = items 30 | self._position = position 31 | self.contentBuilder = content 32 | } 33 | 34 | public init(_ position: Binding, items: [Item], @ViewBuilder content: @escaping (Item) -> Content) { 35 | self.items = Binding.constant(items) 36 | self._position = position 37 | self.contentBuilder = content 38 | } 39 | 40 | public var body: some View { 41 | GeometryReader { geometry in 42 | ZStack(alignment: Alignment(horizontal: .leading, vertical: .top)) { 43 | HStack(spacing: 0) { 44 | ForEach(0.. Self { 90 | var newSelf = self 91 | newSelf.contentWidthOption = option 92 | return newSelf 93 | } 94 | 95 | public func scrollAlpha(_ value: Double) -> Self { 96 | var newSelf = self 97 | newSelf.alphaFactor = value 98 | return newSelf 99 | } 100 | 101 | public func scrollScale(_ value: CGFloat) -> Self { 102 | var newSelf = self 103 | newSelf.sizeFactor = value 104 | return newSelf 105 | } 106 | 107 | public func edgeLeft(_ view: AnyView, width: WidthOption) -> Self { 108 | var newSelf = self 109 | newSelf.edgeLeftView = view 110 | newSelf.edgeLeftWidth = width 111 | return newSelf 112 | } 113 | 114 | public func edgeRight(_ view: AnyView, width: WidthOption) -> Self { 115 | var newSelf = self 116 | newSelf.edgeRightView = view 117 | newSelf.edgeRightWidth = width 118 | return newSelf 119 | } 120 | 121 | public func centerView(_ view: AnyView, width: WidthOption) -> Self { 122 | var newSelf = self 123 | newSelf.centerView = view 124 | newSelf.centerViewWidth = width 125 | return newSelf 126 | } 127 | 128 | //public func infiniteScroll(_ value: Bool) -> Self { 129 | // var newSelf = self 130 | // newSelf.isInfinite = value 131 | // return newSelf 132 | //} 133 | 134 | public func onValueChanged(_ callback: @escaping (Item) -> Void) -> Self { 135 | var newSelf = self 136 | newSelf.onValueChanged = callback 137 | return newSelf 138 | } 139 | 140 | private func drawContentView(_ position: Int, geometry: GeometryProxy) -> some View { 141 | var sizeResult: CGFloat = 1 142 | var alphaResult: Double = 1 143 | 144 | if sizeFactor != 1.0 || alphaFactor != 1.0 { 145 | let maxRange = floor(maxVisible(geometry) / 2.0) 146 | let offset = translation / self.calcContentWidth(geometry, option: contentWidthOption) 147 | let newIndex = CGFloat(self.position) - offset 148 | let posGap = CGFloat(position) - newIndex 149 | //let posGap = CGFloat(position) - (newIndex.truncatingRemainder(dividingBy: CGFloat(self.items.wrappedValue.count))) 150 | var per = abs(posGap / maxRange) 151 | if 1.0 < per { 152 | per = 1.0 153 | } 154 | 155 | if sizeFactor != 1.0 { 156 | let sizeGap = 1.0 - sizeFactor 157 | let preSizeRst = per * sizeGap 158 | sizeResult = 1 - preSizeRst 159 | } 160 | 161 | if alphaFactor != 1.0 { 162 | let alphaGap = 1.0 - alphaFactor 163 | let preAlphaRst = Double(per) * alphaGap 164 | alphaResult = 1.0 - preAlphaRst 165 | } 166 | } 167 | 168 | let item = items.wrappedValue[position] 169 | return contentBuilder(item) 170 | .scaleEffect(sizeResult) 171 | .opacity(alphaResult) 172 | .frame(width: self.calcContentWidth(geometry, option: contentWidthOption), alignment: .center) 173 | } 174 | 175 | private func maxVisible(_ geometry: GeometryProxy) -> CGFloat { 176 | let visibleCount = geometry.size.width / self.calcContentWidth(geometry, option: contentWidthOption) 177 | return min(visibleCount, CGFloat(self.items.wrappedValue.count)) 178 | } 179 | 180 | private func calcContentWidth(_ geometry: GeometryProxy, option: WidthOption) -> CGFloat { 181 | switch option { 182 | case .VisibleCount(let count): 183 | return geometry.size.width / CGFloat(count) 184 | case .Fixed(let width): 185 | return width 186 | case .Ratio(let ratio): 187 | return geometry.size.width * ratio 188 | } 189 | } 190 | } 191 | 192 | public struct ChildSizeReader: View { 193 | var size: Binding 194 | let content: () -> Content 195 | 196 | public init(size: Binding, content: @escaping () -> Content) { 197 | self.size = size 198 | self.content = content 199 | } 200 | 201 | public var body: some View { 202 | ZStack { 203 | content() 204 | .background( 205 | GeometryReader { proxy in 206 | Color.clear 207 | .preference(key: SizePreferenceKey.self, value: proxy.size) 208 | } 209 | ) 210 | } 211 | .onPreferenceChange(SizePreferenceKey.self) { preferences in 212 | self.size.wrappedValue = preferences 213 | } 214 | } 215 | } 216 | 217 | struct SizePreferenceKey: PreferenceKey { 218 | typealias Value = CGSize 219 | static var defaultValue: Value = .zero 220 | 221 | static func reduce(value _: inout Value, nextValue: () -> Value) { 222 | _ = nextValue() 223 | } 224 | } 225 | 226 | struct SwiftUIWheelPickerView_Previews: PreviewProvider { 227 | 228 | @ViewBuilder static func preview() -> some View { 229 | GeometryReader { geometry in 230 | VStack(alignment: .center, spacing: 0) { 231 | SwiftUIWheelPicker(Binding.constant(5), items: Binding.constant([0, 1, 2, 3, 4, 5, 6, 7, 8 ,9, 10])) { value in 232 | GeometryReader { reader in 233 | Text("\(value)") 234 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 235 | .background(value % 2 == 0 ? Color.orange : Color.yellow) 236 | } 237 | } 238 | .frame(width: geometry.size.width, height: 40, alignment: .center) 239 | 240 | SwiftUIWheelPicker(Binding.constant(5), items: Binding.constant([0, 1, 2, 3, 4, 5, 6, 7, 8 ,9, 10])) { value in 241 | GeometryReader { reader in 242 | Text("\(value)") 243 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 244 | .background(value % 2 == 0 ? Color.orange : Color.yellow) 245 | } 246 | } 247 | .width(.VisibleCount(3)) 248 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 249 | .clipShape(RoundedRectangle(cornerRadius: 20)) 250 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 251 | .padding(EdgeInsets(top: 20, leading: 20, bottom: 0, trailing: 20)) 252 | 253 | SwiftUIWheelPicker(Binding.constant(5), items: Binding.constant([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) { value in 254 | GeometryReader { reader in 255 | Text("\(value)") 256 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 257 | .background(value % 2 == 0 ? Color.orange : Color.yellow) 258 | } 259 | } 260 | .width(.Fixed(30)) 261 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 262 | .border(Color.black, width: 1) 263 | .padding(EdgeInsets(top: 20, leading: 20, bottom: 0, trailing: 20)) 264 | 265 | SwiftUIWheelPicker(Binding.constant(5), items: Binding.constant([0, 1, 2, 3, 4, 5, 6, 7, 8 ,9, 10])) { value in 266 | GeometryReader { reader in 267 | Text("\(value)") 268 | .frame(width: reader.size.width, height: reader.size.height, alignment: .center) 269 | } 270 | } 271 | .width(.Fixed(40)) 272 | .edgeLeft(AnyView( 273 | LinearGradient(gradient: Gradient(colors: [Color.white.opacity(0.8), Color.white.opacity(0)]), startPoint: .leading, endPoint: .trailing) 274 | ), width: .Ratio(0.2)) 275 | .edgeRight(AnyView( 276 | LinearGradient(gradient: Gradient(colors: [Color.white.opacity(0), Color.white.opacity(0.8)]), startPoint: .leading, endPoint: .trailing) 277 | ), width: .Ratio(0.2)) 278 | .scrollAlpha(0.2) 279 | .scrollScale(0.6) 280 | .frame(width: geometry.size.width - 40, height: 40, alignment: .center) 281 | .clipShape(RoundedRectangle(cornerRadius: 20)) 282 | .overlay(RoundedRectangle(cornerRadius: 20).stroke(Color.black, lineWidth: 2.0)) 283 | .padding(EdgeInsets(top: 20, leading: 20, bottom: 0, trailing: 20)) 284 | } 285 | 286 | } 287 | } 288 | 289 | static var previews: some View { 290 | VStack(alignment: .center, spacing: 0) { 291 | preview() 292 | } 293 | .previewDevice(PreviewDevice(rawValue: "iPod touch (7th generation)")) 294 | VStack(alignment: .center, spacing: 0) { 295 | preview() 296 | } 297 | .previewDevice(PreviewDevice(rawValue: "iPhone 12 Pro")) 298 | } 299 | } 300 | 301 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /img/basic.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/basic.gif -------------------------------------------------------------------------------- /img/center_indicator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/center_indicator.gif -------------------------------------------------------------------------------- /img/scroll_to.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/scroll_to.gif -------------------------------------------------------------------------------- /img/selected_value.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/selected_value.gif -------------------------------------------------------------------------------- /img/with_alpha.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/with_alpha.gif -------------------------------------------------------------------------------- /img/with_gradient.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/with_gradient.gif -------------------------------------------------------------------------------- /img/with_scale.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/with_scale.gif -------------------------------------------------------------------------------- /img/with_visible_count.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GGJJack/SwiftUIWheelPicker/7c60cfa8de5d184f0b1c3b692bb379519368fcf2/img/with_visible_count.gif --------------------------------------------------------------------------------