├── .gitignore ├── CONTRIBUTING.md ├── Cartfile ├── Cartfile.resolved ├── DashboardUI.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── DashboardUI.xcscheme ├── DashboardUI ├── DashboardUI.h ├── Info.plist └── MoneyTextField.swift ├── DashboardUIExample ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── DashboardUITests ├── Info.plist ├── MoneyTextFieldTests.swift └── ReferenceImages_64 │ └── DashboardUITests.MoneyTextFieldTests │ ├── testConfigure_1-original@3x.png │ ├── testConfigure_2-usesGroupingSeparator=false@3x.png │ ├── testConfigure_3-currency=gbp@3x.png │ ├── testConfigure_4-amount=50@3x.png │ ├── testInit_0_jpy@3x.png │ ├── testInit_0_usd@3x.png │ ├── testInit_1000000_jpy@3x.png │ ├── testInit_100000_usd@3x.png │ ├── testInit_123_jod@3x.png │ ├── testInit_50_jpy@3x.png │ └── testInit_50_usd@3x.png ├── LICENSE ├── Makefile ├── README.md ├── StripeDashboardUI.podspec └── scripts ├── install_dependencies.sh └── run_tests.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | xcshareddata/ 20 | 21 | ## Other 22 | *.moved-aside 23 | *.xcuserstate 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | .build/ 40 | 41 | # CocoaPods 42 | # 43 | # We recommend against adding the Pods directory to your .gitignore. However 44 | # you should judge for yourself, the pros and cons are mentioned at: 45 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 46 | # 47 | # Pods/ 48 | 49 | # Carthage 50 | # 51 | 52 | Carthage/Checkouts 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | 67 | .DS_Store 68 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | To run tests, first install Carthage and download our dependencies. 2 | - `brew install carthage` 3 | - `./scripts/install_dependencies.sh` 4 | 5 | We use [FBSnapshotTestCase](https://github.com/facebook/ios-snapshot-test-case) for snapshot tests. You'll need to run tests on an iPhone 6s simulator for snapshot tests to pass. Please make sure existing tests pass, and if possible, write some tests of your own. 6 | 7 | Thanks for contributing! 8 | -------------------------------------------------------------------------------- /Cartfile: -------------------------------------------------------------------------------- 1 | github "uber/ios-snapshot-test-case" ~>3.0.0 2 | -------------------------------------------------------------------------------- /Cartfile.resolved: -------------------------------------------------------------------------------- 1 | github "uber/ios-snapshot-test-case" "3.0.0" 2 | -------------------------------------------------------------------------------- /DashboardUI.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 96FA3F431D4A592C0045B6B9 /* DashboardUI.h in Headers */ = {isa = PBXBuildFile; fileRef = 96FA3F421D4A592C0045B6B9 /* DashboardUI.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 96FA3F721D4A5B0F0045B6B9 /* MoneyTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96FA3F711D4A5B0F0045B6B9 /* MoneyTextField.swift */; }; 12 | 96FA3F7A1D4A5BDC0045B6B9 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96FA3F791D4A5BDC0045B6B9 /* AppDelegate.swift */; }; 13 | 96FA3F7C1D4A5BDC0045B6B9 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96FA3F7B1D4A5BDC0045B6B9 /* ViewController.swift */; }; 14 | 96FA3F7F1D4A5BDC0045B6B9 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96FA3F7D1D4A5BDC0045B6B9 /* Main.storyboard */; }; 15 | 96FA3F811D4A5BDC0045B6B9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96FA3F801D4A5BDC0045B6B9 /* Assets.xcassets */; }; 16 | 96FA3F841D4A5BDC0045B6B9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96FA3F821D4A5BDC0045B6B9 /* LaunchScreen.storyboard */; }; 17 | 96FA3FC01D4A5FF80045B6B9 /* FBSnapshotTestCase.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96FA3FBF1D4A5FF80045B6B9 /* FBSnapshotTestCase.framework */; }; 18 | 96FA3FC21D4A605C0045B6B9 /* FBSnapshotTestCase.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 96FA3FBF1D4A5FF80045B6B9 /* FBSnapshotTestCase.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 19 | 96FA3FC41D4A607C0045B6B9 /* MoneyTextFieldTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96FA3FC31D4A607C0045B6B9 /* MoneyTextFieldTests.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 96FA3F891D4A5BE60045B6B9 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 96FA3F361D4A592C0045B6B9 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 96FA3F3E1D4A592C0045B6B9; 28 | remoteInfo = DashboardUI; 29 | }; 30 | 96FA3FBA1D4A5FE50045B6B9 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 96FA3F361D4A592C0045B6B9 /* Project object */; 33 | proxyType = 1; 34 | remoteGlobalIDString = 96FA3F761D4A5BDC0045B6B9; 35 | remoteInfo = DashboardUIExample; 36 | }; 37 | /* End PBXContainerItemProxy section */ 38 | 39 | /* Begin PBXCopyFilesBuildPhase section */ 40 | 96FA3FC11D4A60270045B6B9 /* CopyFiles */ = { 41 | isa = PBXCopyFilesBuildPhase; 42 | buildActionMask = 2147483647; 43 | dstPath = ""; 44 | dstSubfolderSpec = 10; 45 | files = ( 46 | 96FA3FC21D4A605C0045B6B9 /* FBSnapshotTestCase.framework in CopyFiles */, 47 | ); 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXCopyFilesBuildPhase section */ 51 | 52 | /* Begin PBXFileReference section */ 53 | 96FA3F3F1D4A592C0045B6B9 /* StripeDashboardUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = StripeDashboardUI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 96FA3F421D4A592C0045B6B9 /* DashboardUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DashboardUI.h; sourceTree = ""; }; 55 | 96FA3F441D4A592C0045B6B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 96FA3F711D4A5B0F0045B6B9 /* MoneyTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoneyTextField.swift; sourceTree = ""; }; 57 | 96FA3F771D4A5BDC0045B6B9 /* DashboardUIExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DashboardUIExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 96FA3F791D4A5BDC0045B6B9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 59 | 96FA3F7B1D4A5BDC0045B6B9 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 60 | 96FA3F7E1D4A5BDC0045B6B9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 61 | 96FA3F801D4A5BDC0045B6B9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 62 | 96FA3F831D4A5BDC0045B6B9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 63 | 96FA3F851D4A5BDC0045B6B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 64 | 96FA3FB51D4A5FE50045B6B9 /* DashboardUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DashboardUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 65 | 96FA3FB91D4A5FE50045B6B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 66 | 96FA3FBF1D4A5FF80045B6B9 /* FBSnapshotTestCase.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FBSnapshotTestCase.framework; path = Carthage/Build/iOS/FBSnapshotTestCase.framework; sourceTree = SOURCE_ROOT; }; 67 | 96FA3FC31D4A607C0045B6B9 /* MoneyTextFieldTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoneyTextFieldTests.swift; sourceTree = ""; }; 68 | /* End PBXFileReference section */ 69 | 70 | /* Begin PBXFrameworksBuildPhase section */ 71 | 96FA3F3B1D4A592C0045B6B9 /* Frameworks */ = { 72 | isa = PBXFrameworksBuildPhase; 73 | buildActionMask = 2147483647; 74 | files = ( 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | 96FA3F741D4A5BDC0045B6B9 /* Frameworks */ = { 79 | isa = PBXFrameworksBuildPhase; 80 | buildActionMask = 2147483647; 81 | files = ( 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | 96FA3FB21D4A5FE50045B6B9 /* Frameworks */ = { 86 | isa = PBXFrameworksBuildPhase; 87 | buildActionMask = 2147483647; 88 | files = ( 89 | 96FA3FC01D4A5FF80045B6B9 /* FBSnapshotTestCase.framework in Frameworks */, 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | /* End PBXFrameworksBuildPhase section */ 94 | 95 | /* Begin PBXGroup section */ 96 | 96FA3F351D4A592C0045B6B9 = { 97 | isa = PBXGroup; 98 | children = ( 99 | 96FA3F411D4A592C0045B6B9 /* DashboardUI */, 100 | 96FA3F781D4A5BDC0045B6B9 /* DashboardUIExample */, 101 | 96FA3FB61D4A5FE50045B6B9 /* DashboardUITests */, 102 | 96FA3F401D4A592C0045B6B9 /* Products */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | 96FA3F401D4A592C0045B6B9 /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 96FA3F3F1D4A592C0045B6B9 /* StripeDashboardUI.framework */, 110 | 96FA3F771D4A5BDC0045B6B9 /* DashboardUIExample.app */, 111 | 96FA3FB51D4A5FE50045B6B9 /* DashboardUITests.xctest */, 112 | ); 113 | name = Products; 114 | sourceTree = ""; 115 | }; 116 | 96FA3F411D4A592C0045B6B9 /* DashboardUI */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 96FA3F711D4A5B0F0045B6B9 /* MoneyTextField.swift */, 120 | 96FA3F421D4A592C0045B6B9 /* DashboardUI.h */, 121 | 96FA3F441D4A592C0045B6B9 /* Info.plist */, 122 | ); 123 | path = DashboardUI; 124 | sourceTree = ""; 125 | }; 126 | 96FA3F781D4A5BDC0045B6B9 /* DashboardUIExample */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 96FA3F791D4A5BDC0045B6B9 /* AppDelegate.swift */, 130 | 96FA3F7B1D4A5BDC0045B6B9 /* ViewController.swift */, 131 | 96FA3F7D1D4A5BDC0045B6B9 /* Main.storyboard */, 132 | 96FA3F801D4A5BDC0045B6B9 /* Assets.xcassets */, 133 | 96FA3F821D4A5BDC0045B6B9 /* LaunchScreen.storyboard */, 134 | 96FA3F851D4A5BDC0045B6B9 /* Info.plist */, 135 | ); 136 | path = DashboardUIExample; 137 | sourceTree = ""; 138 | }; 139 | 96FA3FB61D4A5FE50045B6B9 /* DashboardUITests */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 96FA3FBF1D4A5FF80045B6B9 /* FBSnapshotTestCase.framework */, 143 | 96FA3FC31D4A607C0045B6B9 /* MoneyTextFieldTests.swift */, 144 | 96FA3FB91D4A5FE50045B6B9 /* Info.plist */, 145 | ); 146 | path = DashboardUITests; 147 | sourceTree = ""; 148 | }; 149 | /* End PBXGroup section */ 150 | 151 | /* Begin PBXHeadersBuildPhase section */ 152 | 96FA3F3C1D4A592C0045B6B9 /* Headers */ = { 153 | isa = PBXHeadersBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | 96FA3F431D4A592C0045B6B9 /* DashboardUI.h in Headers */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXHeadersBuildPhase section */ 161 | 162 | /* Begin PBXNativeTarget section */ 163 | 96FA3F3E1D4A592C0045B6B9 /* DashboardUI */ = { 164 | isa = PBXNativeTarget; 165 | buildConfigurationList = 96FA3F531D4A592C0045B6B9 /* Build configuration list for PBXNativeTarget "DashboardUI" */; 166 | buildPhases = ( 167 | 96FA3F3A1D4A592C0045B6B9 /* Sources */, 168 | 96FA3F3B1D4A592C0045B6B9 /* Frameworks */, 169 | 96FA3F3C1D4A592C0045B6B9 /* Headers */, 170 | 96FA3F3D1D4A592C0045B6B9 /* Resources */, 171 | ); 172 | buildRules = ( 173 | ); 174 | dependencies = ( 175 | ); 176 | name = DashboardUI; 177 | productName = DashboardUI; 178 | productReference = 96FA3F3F1D4A592C0045B6B9 /* StripeDashboardUI.framework */; 179 | productType = "com.apple.product-type.framework"; 180 | }; 181 | 96FA3F761D4A5BDC0045B6B9 /* DashboardUIExample */ = { 182 | isa = PBXNativeTarget; 183 | buildConfigurationList = 96FA3F861D4A5BDC0045B6B9 /* Build configuration list for PBXNativeTarget "DashboardUIExample" */; 184 | buildPhases = ( 185 | 96FA3F731D4A5BDC0045B6B9 /* Sources */, 186 | 96FA3F741D4A5BDC0045B6B9 /* Frameworks */, 187 | 96FA3F751D4A5BDC0045B6B9 /* Resources */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | 96FA3F8A1D4A5BE60045B6B9 /* PBXTargetDependency */, 193 | ); 194 | name = DashboardUIExample; 195 | productName = DashboardUIExample; 196 | productReference = 96FA3F771D4A5BDC0045B6B9 /* DashboardUIExample.app */; 197 | productType = "com.apple.product-type.application"; 198 | }; 199 | 96FA3FB41D4A5FE50045B6B9 /* DashboardUITests */ = { 200 | isa = PBXNativeTarget; 201 | buildConfigurationList = 96FA3FBC1D4A5FE50045B6B9 /* Build configuration list for PBXNativeTarget "DashboardUITests" */; 202 | buildPhases = ( 203 | 96FA3FB11D4A5FE50045B6B9 /* Sources */, 204 | 96FA3FB21D4A5FE50045B6B9 /* Frameworks */, 205 | 96FA3FB31D4A5FE50045B6B9 /* Resources */, 206 | 96FA3FC11D4A60270045B6B9 /* CopyFiles */, 207 | ); 208 | buildRules = ( 209 | ); 210 | dependencies = ( 211 | 96FA3FBB1D4A5FE50045B6B9 /* PBXTargetDependency */, 212 | ); 213 | name = DashboardUITests; 214 | productName = DashboardUITests; 215 | productReference = 96FA3FB51D4A5FE50045B6B9 /* DashboardUITests.xctest */; 216 | productType = "com.apple.product-type.bundle.unit-test"; 217 | }; 218 | /* End PBXNativeTarget section */ 219 | 220 | /* Begin PBXProject section */ 221 | 96FA3F361D4A592C0045B6B9 /* Project object */ = { 222 | isa = PBXProject; 223 | attributes = { 224 | LastSwiftUpdateCheck = 0730; 225 | LastUpgradeCheck = 0940; 226 | ORGANIZATIONNAME = stripe; 227 | TargetAttributes = { 228 | 96FA3F3E1D4A592C0045B6B9 = { 229 | CreatedOnToolsVersion = 7.3.1; 230 | LastSwiftMigration = 1010; 231 | }; 232 | 96FA3F761D4A5BDC0045B6B9 = { 233 | CreatedOnToolsVersion = 7.3.1; 234 | LastSwiftMigration = 1010; 235 | }; 236 | 96FA3FB41D4A5FE50045B6B9 = { 237 | CreatedOnToolsVersion = 7.3.1; 238 | LastSwiftMigration = 1010; 239 | TestTargetID = 96FA3F761D4A5BDC0045B6B9; 240 | }; 241 | }; 242 | }; 243 | buildConfigurationList = 96FA3F391D4A592C0045B6B9 /* Build configuration list for PBXProject "DashboardUI" */; 244 | compatibilityVersion = "Xcode 3.2"; 245 | developmentRegion = English; 246 | hasScannedForEncodings = 0; 247 | knownRegions = ( 248 | en, 249 | Base, 250 | ); 251 | mainGroup = 96FA3F351D4A592C0045B6B9; 252 | productRefGroup = 96FA3F401D4A592C0045B6B9 /* Products */; 253 | projectDirPath = ""; 254 | projectRoot = ""; 255 | targets = ( 256 | 96FA3F3E1D4A592C0045B6B9 /* DashboardUI */, 257 | 96FA3F761D4A5BDC0045B6B9 /* DashboardUIExample */, 258 | 96FA3FB41D4A5FE50045B6B9 /* DashboardUITests */, 259 | ); 260 | }; 261 | /* End PBXProject section */ 262 | 263 | /* Begin PBXResourcesBuildPhase section */ 264 | 96FA3F3D1D4A592C0045B6B9 /* Resources */ = { 265 | isa = PBXResourcesBuildPhase; 266 | buildActionMask = 2147483647; 267 | files = ( 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | 96FA3F751D4A5BDC0045B6B9 /* Resources */ = { 272 | isa = PBXResourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | 96FA3F841D4A5BDC0045B6B9 /* LaunchScreen.storyboard in Resources */, 276 | 96FA3F811D4A5BDC0045B6B9 /* Assets.xcassets in Resources */, 277 | 96FA3F7F1D4A5BDC0045B6B9 /* Main.storyboard in Resources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | 96FA3FB31D4A5FE50045B6B9 /* Resources */ = { 282 | isa = PBXResourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | ); 286 | runOnlyForDeploymentPostprocessing = 0; 287 | }; 288 | /* End PBXResourcesBuildPhase section */ 289 | 290 | /* Begin PBXSourcesBuildPhase section */ 291 | 96FA3F3A1D4A592C0045B6B9 /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 96FA3F721D4A5B0F0045B6B9 /* MoneyTextField.swift in Sources */, 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | }; 299 | 96FA3F731D4A5BDC0045B6B9 /* Sources */ = { 300 | isa = PBXSourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | 96FA3F7C1D4A5BDC0045B6B9 /* ViewController.swift in Sources */, 304 | 96FA3F7A1D4A5BDC0045B6B9 /* AppDelegate.swift in Sources */, 305 | ); 306 | runOnlyForDeploymentPostprocessing = 0; 307 | }; 308 | 96FA3FB11D4A5FE50045B6B9 /* Sources */ = { 309 | isa = PBXSourcesBuildPhase; 310 | buildActionMask = 2147483647; 311 | files = ( 312 | 96FA3FC41D4A607C0045B6B9 /* MoneyTextFieldTests.swift in Sources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | /* End PBXSourcesBuildPhase section */ 317 | 318 | /* Begin PBXTargetDependency section */ 319 | 96FA3F8A1D4A5BE60045B6B9 /* PBXTargetDependency */ = { 320 | isa = PBXTargetDependency; 321 | target = 96FA3F3E1D4A592C0045B6B9 /* DashboardUI */; 322 | targetProxy = 96FA3F891D4A5BE60045B6B9 /* PBXContainerItemProxy */; 323 | }; 324 | 96FA3FBB1D4A5FE50045B6B9 /* PBXTargetDependency */ = { 325 | isa = PBXTargetDependency; 326 | target = 96FA3F761D4A5BDC0045B6B9 /* DashboardUIExample */; 327 | targetProxy = 96FA3FBA1D4A5FE50045B6B9 /* PBXContainerItemProxy */; 328 | }; 329 | /* End PBXTargetDependency section */ 330 | 331 | /* Begin PBXVariantGroup section */ 332 | 96FA3F7D1D4A5BDC0045B6B9 /* Main.storyboard */ = { 333 | isa = PBXVariantGroup; 334 | children = ( 335 | 96FA3F7E1D4A5BDC0045B6B9 /* Base */, 336 | ); 337 | name = Main.storyboard; 338 | sourceTree = ""; 339 | }; 340 | 96FA3F821D4A5BDC0045B6B9 /* LaunchScreen.storyboard */ = { 341 | isa = PBXVariantGroup; 342 | children = ( 343 | 96FA3F831D4A5BDC0045B6B9 /* Base */, 344 | ); 345 | name = LaunchScreen.storyboard; 346 | sourceTree = ""; 347 | }; 348 | /* End PBXVariantGroup section */ 349 | 350 | /* Begin XCBuildConfiguration section */ 351 | 96FA3F511D4A592C0045B6B9 /* Debug */ = { 352 | isa = XCBuildConfiguration; 353 | buildSettings = { 354 | ALWAYS_SEARCH_USER_PATHS = NO; 355 | CLANG_ANALYZER_NONNULL = YES; 356 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 357 | CLANG_CXX_LIBRARY = "libc++"; 358 | CLANG_ENABLE_MODULES = YES; 359 | CLANG_ENABLE_OBJC_ARC = YES; 360 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 361 | CLANG_WARN_BOOL_CONVERSION = YES; 362 | CLANG_WARN_COMMA = YES; 363 | CLANG_WARN_CONSTANT_CONVERSION = YES; 364 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 365 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 366 | CLANG_WARN_EMPTY_BODY = YES; 367 | CLANG_WARN_ENUM_CONVERSION = YES; 368 | CLANG_WARN_INFINITE_RECURSION = YES; 369 | CLANG_WARN_INT_CONVERSION = YES; 370 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 371 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 372 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 373 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 374 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 375 | CLANG_WARN_STRICT_PROTOTYPES = YES; 376 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 377 | CLANG_WARN_UNREACHABLE_CODE = YES; 378 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 379 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 380 | COPY_PHASE_STRIP = NO; 381 | CURRENT_PROJECT_VERSION = 1; 382 | DEBUG_INFORMATION_FORMAT = dwarf; 383 | ENABLE_STRICT_OBJC_MSGSEND = YES; 384 | ENABLE_TESTABILITY = YES; 385 | GCC_C_LANGUAGE_STANDARD = gnu99; 386 | GCC_DYNAMIC_NO_PIC = NO; 387 | GCC_NO_COMMON_BLOCKS = YES; 388 | GCC_OPTIMIZATION_LEVEL = 0; 389 | GCC_PREPROCESSOR_DEFINITIONS = ( 390 | "DEBUG=1", 391 | "$(inherited)", 392 | ); 393 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 394 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 395 | GCC_WARN_UNDECLARED_SELECTOR = YES; 396 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 397 | GCC_WARN_UNUSED_FUNCTION = YES; 398 | GCC_WARN_UNUSED_VARIABLE = YES; 399 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 400 | MTL_ENABLE_DEBUG_INFO = YES; 401 | ONLY_ACTIVE_ARCH = YES; 402 | SDKROOT = iphoneos; 403 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 404 | TARGETED_DEVICE_FAMILY = "1,2"; 405 | VERSIONING_SYSTEM = "apple-generic"; 406 | VERSION_INFO_PREFIX = ""; 407 | }; 408 | name = Debug; 409 | }; 410 | 96FA3F521D4A592C0045B6B9 /* Release */ = { 411 | isa = XCBuildConfiguration; 412 | buildSettings = { 413 | ALWAYS_SEARCH_USER_PATHS = NO; 414 | CLANG_ANALYZER_NONNULL = YES; 415 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 416 | CLANG_CXX_LIBRARY = "libc++"; 417 | CLANG_ENABLE_MODULES = YES; 418 | CLANG_ENABLE_OBJC_ARC = YES; 419 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 420 | CLANG_WARN_BOOL_CONVERSION = YES; 421 | CLANG_WARN_COMMA = YES; 422 | CLANG_WARN_CONSTANT_CONVERSION = YES; 423 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 424 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 425 | CLANG_WARN_EMPTY_BODY = YES; 426 | CLANG_WARN_ENUM_CONVERSION = YES; 427 | CLANG_WARN_INFINITE_RECURSION = YES; 428 | CLANG_WARN_INT_CONVERSION = YES; 429 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 430 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 431 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 432 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 433 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 434 | CLANG_WARN_STRICT_PROTOTYPES = YES; 435 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 436 | CLANG_WARN_UNREACHABLE_CODE = YES; 437 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 438 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 439 | COPY_PHASE_STRIP = NO; 440 | CURRENT_PROJECT_VERSION = 1; 441 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 442 | ENABLE_NS_ASSERTIONS = NO; 443 | ENABLE_STRICT_OBJC_MSGSEND = YES; 444 | GCC_C_LANGUAGE_STANDARD = gnu99; 445 | GCC_NO_COMMON_BLOCKS = YES; 446 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 447 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 448 | GCC_WARN_UNDECLARED_SELECTOR = YES; 449 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 450 | GCC_WARN_UNUSED_FUNCTION = YES; 451 | GCC_WARN_UNUSED_VARIABLE = YES; 452 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 453 | MTL_ENABLE_DEBUG_INFO = NO; 454 | SDKROOT = iphoneos; 455 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 456 | TARGETED_DEVICE_FAMILY = "1,2"; 457 | VALIDATE_PRODUCT = YES; 458 | VERSIONING_SYSTEM = "apple-generic"; 459 | VERSION_INFO_PREFIX = ""; 460 | }; 461 | name = Release; 462 | }; 463 | 96FA3F541D4A592C0045B6B9 /* Debug */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | CLANG_ENABLE_MODULES = YES; 467 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 468 | DEFINES_MODULE = YES; 469 | DYLIB_COMPATIBILITY_VERSION = 1; 470 | DYLIB_CURRENT_VERSION = 1; 471 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 472 | INFOPLIST_FILE = DashboardUI/Info.plist; 473 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 475 | PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUI; 476 | PRODUCT_NAME = StripeDashboardUI; 477 | SKIP_INSTALL = YES; 478 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 479 | SWIFT_VERSION = 4.2; 480 | }; 481 | name = Debug; 482 | }; 483 | 96FA3F551D4A592C0045B6B9 /* Release */ = { 484 | isa = XCBuildConfiguration; 485 | buildSettings = { 486 | CLANG_ENABLE_MODULES = YES; 487 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 488 | DEFINES_MODULE = YES; 489 | DYLIB_COMPATIBILITY_VERSION = 1; 490 | DYLIB_CURRENT_VERSION = 1; 491 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 492 | INFOPLIST_FILE = DashboardUI/Info.plist; 493 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 494 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 495 | PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUI; 496 | PRODUCT_NAME = StripeDashboardUI; 497 | SKIP_INSTALL = YES; 498 | SWIFT_VERSION = 4.2; 499 | }; 500 | name = Release; 501 | }; 502 | 96FA3F871D4A5BDC0045B6B9 /* Debug */ = { 503 | isa = XCBuildConfiguration; 504 | buildSettings = { 505 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 506 | INFOPLIST_FILE = DashboardUIExample/Info.plist; 507 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 508 | PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUIExample; 509 | PRODUCT_NAME = "$(TARGET_NAME)"; 510 | SWIFT_VERSION = 4.2; 511 | }; 512 | name = Debug; 513 | }; 514 | 96FA3F881D4A5BDC0045B6B9 /* Release */ = { 515 | isa = XCBuildConfiguration; 516 | buildSettings = { 517 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 518 | INFOPLIST_FILE = DashboardUIExample/Info.plist; 519 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 520 | PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUIExample; 521 | PRODUCT_NAME = "$(TARGET_NAME)"; 522 | SWIFT_VERSION = 4.2; 523 | }; 524 | name = Release; 525 | }; 526 | 96FA3FBD1D4A5FE50045B6B9 /* Debug */ = { 527 | isa = XCBuildConfiguration; 528 | buildSettings = { 529 | BUNDLE_LOADER = "$(TEST_HOST)"; 530 | FRAMEWORK_SEARCH_PATHS = ( 531 | "$(inherited)", 532 | "$(PROJECT_DIR)/Carthage/Build/iOS", 533 | ); 534 | INFOPLIST_FILE = DashboardUITests/Info.plist; 535 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 536 | PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUITests; 537 | PRODUCT_NAME = "$(TARGET_NAME)"; 538 | SWIFT_VERSION = 4.2; 539 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DashboardUIExample.app/DashboardUIExample"; 540 | }; 541 | name = Debug; 542 | }; 543 | 96FA3FBE1D4A5FE50045B6B9 /* Release */ = { 544 | isa = XCBuildConfiguration; 545 | buildSettings = { 546 | BUNDLE_LOADER = "$(TEST_HOST)"; 547 | FRAMEWORK_SEARCH_PATHS = ( 548 | "$(inherited)", 549 | "$(PROJECT_DIR)/Carthage/Build/iOS", 550 | ); 551 | INFOPLIST_FILE = DashboardUITests/Info.plist; 552 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 553 | PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUITests; 554 | PRODUCT_NAME = "$(TARGET_NAME)"; 555 | SWIFT_VERSION = 4.2; 556 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DashboardUIExample.app/DashboardUIExample"; 557 | }; 558 | name = Release; 559 | }; 560 | /* End XCBuildConfiguration section */ 561 | 562 | /* Begin XCConfigurationList section */ 563 | 96FA3F391D4A592C0045B6B9 /* Build configuration list for PBXProject "DashboardUI" */ = { 564 | isa = XCConfigurationList; 565 | buildConfigurations = ( 566 | 96FA3F511D4A592C0045B6B9 /* Debug */, 567 | 96FA3F521D4A592C0045B6B9 /* Release */, 568 | ); 569 | defaultConfigurationIsVisible = 0; 570 | defaultConfigurationName = Release; 571 | }; 572 | 96FA3F531D4A592C0045B6B9 /* Build configuration list for PBXNativeTarget "DashboardUI" */ = { 573 | isa = XCConfigurationList; 574 | buildConfigurations = ( 575 | 96FA3F541D4A592C0045B6B9 /* Debug */, 576 | 96FA3F551D4A592C0045B6B9 /* Release */, 577 | ); 578 | defaultConfigurationIsVisible = 0; 579 | defaultConfigurationName = Release; 580 | }; 581 | 96FA3F861D4A5BDC0045B6B9 /* Build configuration list for PBXNativeTarget "DashboardUIExample" */ = { 582 | isa = XCConfigurationList; 583 | buildConfigurations = ( 584 | 96FA3F871D4A5BDC0045B6B9 /* Debug */, 585 | 96FA3F881D4A5BDC0045B6B9 /* Release */, 586 | ); 587 | defaultConfigurationIsVisible = 0; 588 | defaultConfigurationName = Release; 589 | }; 590 | 96FA3FBC1D4A5FE50045B6B9 /* Build configuration list for PBXNativeTarget "DashboardUITests" */ = { 591 | isa = XCConfigurationList; 592 | buildConfigurations = ( 593 | 96FA3FBD1D4A5FE50045B6B9 /* Debug */, 594 | 96FA3FBE1D4A5FE50045B6B9 /* Release */, 595 | ); 596 | defaultConfigurationIsVisible = 0; 597 | defaultConfigurationName = Release; 598 | }; 599 | /* End XCConfigurationList section */ 600 | }; 601 | rootObject = 96FA3F361D4A592C0045B6B9 /* Project object */; 602 | } 603 | -------------------------------------------------------------------------------- /DashboardUI.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DashboardUI.xcodeproj/xcshareddata/xcschemes/DashboardUI.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 93 | 99 | 100 | 101 | 102 | 106 | 107 | 108 | 109 | 110 | 111 | 117 | 118 | 124 | 125 | 126 | 127 | 129 | 130 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /DashboardUI/DashboardUI.h: -------------------------------------------------------------------------------- 1 | // 2 | // DashboardUI.h 3 | // DashboardUI 4 | // 5 | // Created by Ben Guo on 7/28/16. 6 | // Copyright © 2016 stripe. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for DashboardUI. 12 | FOUNDATION_EXPORT double DashboardUIVersionNumber; 13 | 14 | //! Project version string for DashboardUI. 15 | FOUNDATION_EXPORT const unsigned char DashboardUIVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /DashboardUI/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /DashboardUI/MoneyTextField.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MoneyTextField.swift 3 | // Dashboard 4 | // 5 | // Created by Ben Guo on 6/22/16. 6 | // Copyright © 2016 Stripe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @IBDesignable 12 | open class MoneyTextField: UIControl, UITextViewDelegate, InternalTextViewDelegate { 13 | @IBInspectable 14 | open var amount: UInt { 15 | get { 16 | var number = NSDecimalNumber(string: self.rawString, locale: self.locale) 17 | if !self.currency.stp_isNoDecimalCurrency { 18 | let handler = NSDecimalNumberHandler(roundingMode: .plain, 19 | scale: 0, 20 | raiseOnExactness: false, 21 | raiseOnOverflow: false, 22 | raiseOnUnderflow: false, 23 | raiseOnDivideByZero: false) 24 | number = number.multiplying(byPowerOf10: 2, withBehavior: handler) 25 | } 26 | if number.stp_isNAN() { 27 | return 0 28 | } else { 29 | return UInt(number.intValue) 30 | } 31 | } 32 | set(newAmount) { 33 | let number = NSDecimalNumber(value: Int(newAmount) as Int) 34 | self.rawString = self.formatNumber(number, 35 | convertToSuperUnit: !self.isNoDecimalCurrency, 36 | hideCentsIfZero: false) 37 | self.refreshAttributedString() 38 | } 39 | } 40 | @IBInspectable 41 | open var currency: String = "usd" { 42 | didSet(oldValue) { 43 | var localeInfo = [NSLocale.Key.currencyCode.rawValue: self.currency] 44 | if let language = Locale.preferredLanguages.first { 45 | localeInfo[NSLocale.Key.languageCode.rawValue] = language 46 | } 47 | let localeID = Locale.identifier(fromComponents: localeInfo) 48 | let locale = Locale(identifier: localeID) 49 | self.locale = locale 50 | self.numberFormatter = self.numberFormatter(locale) 51 | var number = NSDecimalNumber(string: self.rawString, locale: locale) 52 | if !oldValue.stp_isNoDecimalCurrency { 53 | number = number.multiplying(byPowerOf10: self.superUnitPowerOf10) 54 | } 55 | let amount = UInt(number.intValue) 56 | self.amount = amount 57 | } 58 | } 59 | open var amountString: String { 60 | let number = NSDecimalNumber(value: Int(self.amount) as Int) 61 | return self.formatNumber(number, 62 | usesGroupingSeparator: true, 63 | convertToSuperUnit: !self.isNoDecimalCurrency, 64 | hideCentsIfZero: self.isNoDecimalCurrency, 65 | hideCurrencySymbol: false) 66 | } 67 | @IBInspectable 68 | open var usesGroupingSeparator: Bool = true { 69 | didSet { 70 | self.refreshAttributedString() 71 | } 72 | } 73 | @IBInspectable 74 | open var borderColor: UIColor = UIColor(white: 0.85, alpha: 1) { 75 | didSet { self.layer.borderColor = self.borderColor.cgColor } 76 | } 77 | @IBInspectable 78 | open var borderWidth: CGFloat = 1 { 79 | didSet { self.layer.borderWidth = self.borderWidth } 80 | } 81 | @IBInspectable 82 | open var cornerRadius: CGFloat = 5 { 83 | didSet { self.layer.cornerRadius = self.cornerRadius } 84 | } 85 | open var largeFont: UIFont = UIFont.systemFont(ofSize: 58) { 86 | didSet { self.refreshAttributedString() } 87 | } 88 | open var smallFont: UIFont = UIFont.systemFont(ofSize: 37) { 89 | didSet { self.refreshAttributedString() } 90 | } 91 | @IBInspectable 92 | open var numberColor: UIColor = UIColor.black { 93 | didSet { self.refreshAttributedString() } 94 | } 95 | @IBInspectable 96 | open var currencySymbolColor: UIColor = UIColor(white: 0.54, alpha: 1) { 97 | didSet { self.refreshAttributedString() } 98 | } 99 | override open var tintColor: UIColor! { 100 | didSet { 101 | self.internalTextView.tintColor = self.tintColor 102 | } 103 | } 104 | 105 | /// MoneyTextField constrains text to its width, with margins defined by `inset`. 106 | /// This property also affects the size returned by `sizeThatFits`. 107 | @IBInspectable 108 | open var inset: CGFloat = 16 109 | 110 | fileprivate var currentEdgeInsets: UIEdgeInsets { 111 | let textSize = self.internalTextView.bounds.size 112 | let verticalInset = (self.bounds.size.height - textSize.height)/2.0 113 | let horizontalInset = (self.bounds.size.width - textSize.height)/2.0 114 | return UIEdgeInsets(top: verticalInset, left: horizontalInset, bottom: verticalInset, right: horizontalInset) 115 | } 116 | fileprivate var numberFormatter = NumberFormatter() 117 | fileprivate var locale = Locale.current 118 | fileprivate func numberFormatter(_ locale: Locale) -> NumberFormatter { 119 | let formatter = NumberFormatter() 120 | formatter.numberStyle = NumberFormatter.Style.currency 121 | formatter.locale = locale 122 | formatter.usesGroupingSeparator = true 123 | if formatter.minimumFractionDigits == 0 { 124 | formatter.minimumFractionDigits = 2 125 | } 126 | if self.isNoDecimalCurrency { 127 | formatter.minimumFractionDigits = 0 128 | } 129 | return formatter 130 | } 131 | fileprivate var decimalSeparator: String { 132 | return self.numberFormatter.decimalSeparator 133 | } 134 | fileprivate var currencySymbol: String { 135 | return self.numberFormatter.currencySymbol 136 | } 137 | fileprivate var isNoDecimalCurrency: Bool { 138 | return self.currency.stp_isNoDecimalCurrency 139 | } 140 | fileprivate var superUnitPowerOf10: Int16 { 141 | return Int16(self.numberFormatter.minimumFractionDigits) 142 | } 143 | fileprivate var zero: String { 144 | let number = NSDecimalNumber(value: 0 as Int) 145 | return self.formatNumber(number, convertToSuperUnit: false, hideCentsIfZero: true) 146 | } 147 | fileprivate var rawString = "0" 148 | fileprivate let internalTextView = InternalTextView() 149 | fileprivate let tapGestureRecognizer = UITapGestureRecognizer() 150 | 151 | public init(amount: UInt, currency: String) { 152 | super.init(frame: CGRect.zero) 153 | self.setup(amount, currency: currency) 154 | } 155 | 156 | required public init?(coder aDecoder: NSCoder) { 157 | super.init(coder: aDecoder) 158 | self.setup(0, currency: "usd") 159 | } 160 | 161 | override init(frame: CGRect) { 162 | super.init(frame: frame) 163 | self.setup(0, currency: "usd") 164 | } 165 | 166 | fileprivate func setup(_ amount: UInt, currency: String) { 167 | self.currency = currency 168 | self.amount = amount 169 | self.internalTextView.delegate = self 170 | self.internalTextView.internalTextViewDelegate = self 171 | self.layer.borderColor = self.borderColor.cgColor 172 | self.layer.borderWidth = self.borderWidth 173 | self.layer.cornerRadius = self.cornerRadius 174 | self.backgroundColor = UIColor(white: 0.97, alpha: 1) 175 | self.addSubview(self.internalTextView) 176 | self.tapGestureRecognizer.addTarget(self, action: #selector(tapped)) 177 | self.addGestureRecognizer(self.tapGestureRecognizer) 178 | } 179 | 180 | @objc fileprivate func tapped() { 181 | self.internalTextView.becomeFirstResponder() 182 | } 183 | 184 | fileprivate func refreshAttributedString() { 185 | self.internalTextView.attributedText = self.attributedString(self.rawString) 186 | } 187 | 188 | fileprivate func split(_ amountString: String) -> (String, String?) { 189 | var integerPart = amountString 190 | var fractionalPart: String? = nil 191 | if let decimalRange = amountString.range(of: self.decimalSeparator) { 192 | integerPart = String(amountString.prefix(upTo: decimalRange.lowerBound)) 193 | fractionalPart = String(amountString.suffix(from: decimalRange.upperBound)) 194 | } 195 | if integerPart.isEmpty { 196 | integerPart = self.zero 197 | } 198 | return (integerPart, fractionalPart) 199 | } 200 | 201 | fileprivate func attributedString(_ amountString: String) -> NSAttributedString { 202 | let baselinePoints = self.largeFont.pointSize - self.smallFont.pointSize 203 | // not sure why this multiplier is necessary (baseline offset is in points), 204 | // but it scales well for different font sizes. 205 | let baselineOffset = baselinePoints*0.7 206 | let smallAttributes: [NSAttributedString.Key : Any]? 207 | smallAttributes = [ 208 | .baselineOffset: baselineOffset, 209 | .font: self.smallFont 210 | ] 211 | var currencyAttributes = smallAttributes 212 | currencyAttributes![.foregroundColor] = self.currencySymbolColor 213 | var fractionalAttributes = smallAttributes 214 | fractionalAttributes![.foregroundColor] = self.numberColor 215 | let integerAttributes: [NSAttributedString.Key : Any]? 216 | integerAttributes = [ 217 | .font: self.largeFont, 218 | .foregroundColor: self.numberColor 219 | ] 220 | let string = NSMutableAttributedString(string: self.numberFormatter.currencySymbol, 221 | attributes: currencyAttributes) 222 | string.addAttribute(.kern, value: 4, 223 | range: NSRange(location: string.length - 1, length: 1)) 224 | let (integerPart, fractionalPart) = self.split(amountString) 225 | if integerPart.count > 0 { 226 | let number = NSDecimalNumber(string: integerPart.stp_sanitize(), 227 | locale: self.locale) 228 | let formatted = self.formatNumber(number, 229 | usesGroupingSeparator: self.usesGroupingSeparator, 230 | convertToSuperUnit: false, 231 | hideCentsIfZero: true) 232 | let integer = NSAttributedString(string: formatted, 233 | attributes: integerAttributes) 234 | string.append(integer) 235 | } 236 | if let fractional = fractionalPart { 237 | // using a space rather than kerning in order to make the caret resize 238 | let spaceAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 10)] 239 | let space = NSAttributedString(string: " ", attributes: spaceAttributes) 240 | string.append(space) 241 | let fraction = NSAttributedString(string: fractional, 242 | attributes: fractionalAttributes) 243 | string.append(fraction) 244 | } 245 | let paragraphStyle = NSMutableParagraphStyle() 246 | paragraphStyle.alignment = .center 247 | string.addAttribute(.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: string.length)) 248 | return string 249 | } 250 | 251 | fileprivate func formatNumber(_ number: NSDecimalNumber, 252 | usesGroupingSeparator: Bool = false, 253 | convertToSuperUnit: Bool, 254 | hideCentsIfZero: Bool, 255 | hideCurrencySymbol: Bool = true) -> String { 256 | let minimumFractionDigits = self.numberFormatter.minimumFractionDigits 257 | defer { 258 | self.numberFormatter.minimumFractionDigits = minimumFractionDigits 259 | } 260 | self.numberFormatter.minimumFractionDigits = hideCentsIfZero ? 0 : minimumFractionDigits 261 | self.numberFormatter.usesGroupingSeparator = usesGroupingSeparator 262 | var superUnits = number 263 | if convertToSuperUnit { 264 | superUnits = number.multiplying(byPowerOf10: -self.superUnitPowerOf10) 265 | } 266 | guard let string = self.numberFormatter.string(from: superUnits) else { 267 | return number.stringValue 268 | } 269 | if hideCurrencySymbol { 270 | let comps = string.components(separatedBy: self.numberFormatter.currencySymbol) 271 | return comps.joined(separator: "") 272 | } 273 | else { 274 | return string 275 | } 276 | } 277 | 278 | fileprivate var hasDecimalSeparator: Bool { 279 | return self.rawString.range(of: self.decimalSeparator) != nil 280 | } 281 | 282 | override open func becomeFirstResponder() -> Bool { 283 | return self.internalTextView.becomeFirstResponder() 284 | } 285 | 286 | override open func resignFirstResponder() -> Bool { 287 | return self.internalTextView.resignFirstResponder() 288 | } 289 | 290 | override open func layoutSubviews() { 291 | super.layoutSubviews() 292 | let size = self.internalTextView.sizeThatFits(CGSize(width: self.bounds.width, height: 0)) 293 | self.internalTextView.frame = CGRect(x: 0, y: 0, width: self.bounds.width, height: size.height) 294 | self.internalTextView.center = CGPoint(x: self.bounds.midX, y: self.bounds.midY) 295 | } 296 | 297 | override open func sizeThatFits(_ size: CGSize) -> CGSize { 298 | let width = self.internalTextView.attributedText.size().width + self.inset*2 299 | let height = self.largeFont.stp_height + self.inset*2 300 | return CGSize(width: width, height: height) 301 | } 302 | 303 | // MARK: InternalTextViewDelegate 304 | fileprivate func internalTextView(_ textView: InternalTextView, modifiedCaretRect rect: CGRect) -> CGRect { 305 | var newRect = rect 306 | var topInset = self.currentEdgeInsets.top 307 | if topInset < 0 { 308 | topInset = self.inset - topInset 309 | } 310 | newRect.origin = CGPoint(x: rect.origin.x, y: topInset) 311 | if self.hasDecimalSeparator { 312 | newRect.size = CGSize(width: rect.width, height: self.smallFont.stp_height) 313 | } 314 | else { 315 | newRect.size = CGSize(width: rect.width, height: self.largeFont.stp_height) 316 | } 317 | return newRect 318 | } 319 | 320 | // MARK: UITextViewDelegate 321 | open func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { 322 | var newRawString = self.rawString 323 | let deleting = range.location == textView.text.count - 1 && range.length == 1 && text == "" 324 | if deleting { 325 | if newRawString.count > 0 { 326 | var lastIndex = newRawString.index(before: newRawString.endIndex) 327 | // delete over the decimal separator 328 | if String(newRawString[lastIndex]) == self.decimalSeparator && 329 | newRawString.count > 1 { 330 | lastIndex = newRawString.index(before: lastIndex) 331 | } 332 | newRawString = String(newRawString[.. CGRect 369 | } 370 | 371 | private class InternalTextView: UITextView, UITextViewDelegate { 372 | var internalTextViewDelegate: InternalTextViewDelegate? 373 | 374 | init() { 375 | super.init(frame: CGRect.zero, textContainer: nil) 376 | self.isScrollEnabled = false 377 | self.keyboardType = .decimalPad 378 | self.textAlignment = .natural 379 | self.isUserInteractionEnabled = false 380 | self.backgroundColor = UIColor.clear 381 | self.delegate = self 382 | } 383 | 384 | required init?(coder aDecoder: NSCoder) { 385 | fatalError("init(coder:) has not been implemented") 386 | } 387 | 388 | override func caretRect(for position: UITextPosition) -> CGRect { 389 | let rect = super.caretRect(for: position) 390 | if let delegate = self.internalTextViewDelegate { 391 | return delegate.internalTextView(self, modifiedCaretRect:rect) 392 | } 393 | else { 394 | return rect 395 | } 396 | } 397 | } 398 | 399 | private extension String { 400 | var stp_isNoDecimalCurrency: Bool { 401 | let currencies = ["bif", "clp","djf","gnf", 402 | "jpy","kmf","krw","mga","pyg","rwf","vnd", 403 | "vuv","xaf","xof","xpf"] 404 | return currencies.contains(self.lowercased()) 405 | } 406 | 407 | func stp_sanitize() -> String { 408 | let set = CharacterSet.decimalDigits 409 | let components = self.components(separatedBy: set.inverted) 410 | return components.joined(separator: "") 411 | } 412 | } 413 | 414 | private extension UIFont { 415 | var stp_height: CGFloat { 416 | let string: NSString = "0" 417 | let rect = string.boundingRect(with: CGSize.zero, 418 | options: .usesDeviceMetrics, 419 | attributes: [.font: self], 420 | context: nil) 421 | return rect.size.height 422 | } 423 | } 424 | 425 | private extension NSDecimalNumber { 426 | func stp_isZero() -> Bool { 427 | return NSDecimalNumber.zero.isEqual(to: self) 428 | } 429 | 430 | func stp_isNAN() -> Bool { 431 | return NSDecimalNumber.notANumber.isEqual(to: self) 432 | } 433 | } 434 | -------------------------------------------------------------------------------- /DashboardUIExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // DashboardUIExample 4 | // 5 | // Created by Ben Guo on 7/28/16. 6 | // Copyright © 2016 stripe. 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: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /DashboardUIExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /DashboardUIExample/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 | 27 | 28 | -------------------------------------------------------------------------------- /DashboardUIExample/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 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /DashboardUIExample/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 | 1.0 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 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /DashboardUIExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // DashboardUIExample 4 | // 5 | // Created by Ben Guo on 7/28/16. 6 | // Copyright © 2016 stripe. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import StripeDashboardUI 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet weak var moneyTextField: MoneyTextField! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(tap)) 19 | self.view.addGestureRecognizer(tapGestureRecognizer) 20 | self.moneyTextField.addTarget(self, action: #selector(amountChanged), for: .valueChanged) 21 | // Do any additional setup after loading the view, typically from a nib. 22 | } 23 | 24 | @objc func tap() { 25 | let _ = self.moneyTextField.resignFirstResponder() 26 | } 27 | 28 | @objc func amountChanged() { 29 | print(self.moneyTextField.amountString) 30 | } 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /DashboardUITests/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 | -------------------------------------------------------------------------------- /DashboardUITests/MoneyTextFieldTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MoneyTextFieldTests.swift 3 | // MoneyTextFieldTests 4 | // 5 | // Created by Ben Guo on 6/28/16. 6 | // Copyright © 2016 stripe. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import FBSnapshotTestCase 11 | import StripeDashboardUI 12 | 13 | class MoneyTextFieldTests: FBSnapshotTestCase { 14 | 15 | override func setUp() { 16 | super.setUp() 17 | // self.recordMode = true 18 | } 19 | 20 | func testInit() { 21 | var sut = MoneyTextField(amount: 100000, currency: "usd") 22 | sut.sizeToFit() 23 | FBSnapshotVerifyView(sut, identifier: "100000_usd") 24 | 25 | sut = MoneyTextField(amount: 50, currency: "usd") 26 | sut.sizeToFit() 27 | FBSnapshotVerifyView(sut, identifier: "50_usd") 28 | 29 | sut = MoneyTextField(amount: 0, currency: "usd") 30 | sut.sizeToFit() 31 | FBSnapshotVerifyView(sut, identifier: "0_usd") 32 | 33 | sut = MoneyTextField(amount: 100000, currency: "jpy") 34 | sut.sizeToFit() 35 | FBSnapshotVerifyView(sut, identifier: "1000000_jpy") 36 | 37 | sut = MoneyTextField(amount: 50, currency: "jpy") 38 | sut.sizeToFit() 39 | FBSnapshotVerifyView(sut, identifier: "50_jpy") 40 | 41 | sut = MoneyTextField(amount: 0, currency: "jpy") 42 | sut.sizeToFit() 43 | FBSnapshotVerifyView(sut, identifier: "0_jpy") 44 | 45 | sut = MoneyTextField(amount: 123, currency: "jod") 46 | sut.sizeToFit() 47 | FBSnapshotVerifyView(sut, identifier: "123_jod") 48 | } 49 | 50 | func testConfigure() { 51 | let sut = MoneyTextField(amount: 100000, currency: "usd") 52 | sut.sizeToFit() 53 | FBSnapshotVerifyView(sut, identifier: "1-original") 54 | sut.usesGroupingSeparator = false 55 | sut.sizeToFit() 56 | FBSnapshotVerifyView(sut, identifier: "2-usesGroupingSeparator=false") 57 | sut.currency = "gbp" 58 | sut.sizeToFit() 59 | FBSnapshotVerifyView(sut, identifier: "3-currency=gbp") 60 | sut.amount = 50 61 | sut.sizeToFit() 62 | FBSnapshotVerifyView(sut, identifier: "4-amount=50") 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_1-original@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_1-original@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_2-usesGroupingSeparator=false@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_2-usesGroupingSeparator=false@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_3-currency=gbp@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_3-currency=gbp@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_4-amount=50@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_4-amount=50@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_jpy@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_jpy@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_usd@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_usd@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_1000000_jpy@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_1000000_jpy@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_100000_usd@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_100000_usd@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_123_jod@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_123_jod@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_jpy@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_jpy@3x.png -------------------------------------------------------------------------------- /DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_usd@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stripe/ios-dashboard-ui/6ae68751a4d5bf4110ec4176c395594f21da3b75/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_usd@3x.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Stripe 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 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | bootstrap: 2 | brew update || brew update 3 | brew install carthage 4 | scripts/install_dependencies.sh 5 | 6 | test: bootstrap 7 | scripts/run_tests.sh 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS Dashboard UI 2 | ## Archived 3 | This repository is no longer under active development or maintenance 4 | 5 | [![CocoaPods](https://img.shields.io/cocoapods/v/StripeDashboardUI.svg?style=flat)](http://cocoapods.org/?q=name%3Astripedashboardui) 6 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 7 | [![CocoaPods](https://img.shields.io/cocoapods/l/StripeDashboardUI.svg?style=flat)](https://github.com/stripe/ios-dashboard-ui/blob/master/LICENSE) 8 | [![CocoaPods](https://img.shields.io/cocoapods/p/StripeDashboardUI.svg?style=flat)](https://github.com/stripe/ios-dashboard-ui#) 9 | 10 | This is a collection of UI components used in the [Stripe Dashboard](https://itunes.apple.com/us/app/stripe-dashboard/id978516833?mt=8). Currently, it contains one component, `MoneyTextField`. 11 | 12 | ## Installation 13 | * [Cocoapods](https://cocoapods.org/pods/StripeDashboardUI) 14 | * `pod "StripeDashboardUI"` 15 | * [Carthage](https://github.com/Carthage/Carthage#installing-carthage) 16 | * `github "stripe/ios-dashboard-ui"` 17 | * Manual 18 | * drag source files from the `DashboardUI` directory into your project. 19 | * Development 20 | * Run `make bootstrap` to install dependencies. 21 | 22 | Swift 4 23 | 24 | ## Components 25 | ### MoneyTextField 26 | MoneyTextField is a text field for handling money. It includes many customization options, and supports most currencies and locales. 💸 27 | 28 | 29 | -------------------------------------------------------------------------------- /StripeDashboardUI.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "StripeDashboardUI" 3 | s.version = "0.3" 4 | s.authors = { "Ben Guo" => "bg@stripe.com", 5 | "Jack Flintermann" => "jack@stripe.com", 6 | "Brian Dorfman" => "bdorfman@stripe.com" } 7 | s.homepage = "https://github.com/stripe/ios-dashboard-ui" 8 | s.summary = "UI components from the Stripe Dashboard iOS app" 9 | s.source = { :git => "https://github.com/stripe/ios-dashboard-ui.git", 10 | :tag => '0.3' } 11 | s.license = { :type => "MIT", :file => "LICENSE" } 12 | s.platform = :ios, '9.0' 13 | s.source_files = "DashboardUI/*.swift" 14 | s.requires_arc = true 15 | s.ios.deployment_target = '9.0' 16 | s.ios.frameworks = ['UIKit', 'Foundation'] 17 | s.swift_version = '4.2' 18 | end 19 | -------------------------------------------------------------------------------- /scripts/install_dependencies.sh: -------------------------------------------------------------------------------- 1 | carthage bootstrap --platform ios --configuration Release --no-use-binaries 2 | -------------------------------------------------------------------------------- /scripts/run_tests.sh: -------------------------------------------------------------------------------- 1 | set -o pipefail && xcodebuild test -scheme DashboardUI\ 2 | -configuration Debug\ 3 | -sdk iphonesimulator\ 4 | -destination "OS=11.2,name=iPhone X"\ 5 | -verbose | xcpretty -c 6 | --------------------------------------------------------------------------------