diff --git a/.travis.yml b/.travis.yml index e29a5af..583c90c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode8.3 +osx_image: xcode9.2 before_install: - ./scripts/install_dependencies.sh script: diff --git a/Cartfile b/Cartfile index 5f266d8..3216141 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "facebook/ios-snapshot-test-case" ~>2.1.1 +github "uber/ios-snapshot-test-case" ~>3.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index ad423d2..79daa1c 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "facebook/ios-snapshot-test-case" "2.1.4" +github "uber/ios-snapshot-test-case" "3.0.0" diff --git a/DashboardUI.xcodeproj/project.pbxproj b/DashboardUI.xcodeproj/project.pbxproj index 0bc0086..95777dc 100644 --- a/DashboardUI.xcodeproj/project.pbxproj +++ b/DashboardUI.xcodeproj/project.pbxproj @@ -222,20 +222,20 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = stripe; TargetAttributes = { 96FA3F3E1D4A592C0045B6B9 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0830; + LastSwiftMigration = 0920; }; 96FA3F761D4A5BDC0045B6B9 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0830; + LastSwiftMigration = 0920; }; 96FA3FB41D4A5FE50045B6B9 = { CreatedOnToolsVersion = 7.3.1; - LastSwiftMigration = 0830; + LastSwiftMigration = 0920; TestTargetID = 96FA3F761D4A5BDC0045B6B9; }; }; @@ -357,14 +357,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -408,14 +414,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -460,7 +472,8 @@ PRODUCT_NAME = StripeDashboardUI; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -479,7 +492,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUI; PRODUCT_NAME = StripeDashboardUI; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -491,7 +505,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUIExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -503,7 +518,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUIExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -519,7 +535,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DashboardUIExample.app/DashboardUIExample"; }; name = Debug; @@ -536,7 +553,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stripe.DashboardUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/DashboardUIExample.app/DashboardUIExample"; }; name = Release; diff --git a/DashboardUI.xcodeproj/xcshareddata/xcschemes/DashboardUI.xcscheme b/DashboardUI.xcodeproj/xcshareddata/xcschemes/DashboardUI.xcscheme index fd0bf94..fbced20 100644 --- a/DashboardUI.xcodeproj/xcshareddata/xcschemes/DashboardUI.xcscheme +++ b/DashboardUI.xcodeproj/xcshareddata/xcschemes/DashboardUI.xcscheme @@ -1,6 +1,6 @@ + + + + + + + + 0 { + if integerPart.count > 0 { let number = NSDecimalNumber(string: integerPart.stp_sanitize(), locale: self.locale) let formatted = self.formatNumber(number, @@ -233,7 +235,7 @@ open class MoneyTextField: UIControl, UITextViewDelegate, InternalTextViewDelega } if let fractional = fractionalPart { // using a space rather than kerning in order to make the caret resize - let spaceAttributes = [NSFontAttributeName: UIFont.systemFont(ofSize: 10)] + let spaceAttributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 10)] let space = NSAttributedString(string: " ", attributes: spaceAttributes) string.append(space) let fraction = NSAttributedString(string: fractional, @@ -242,7 +244,7 @@ open class MoneyTextField: UIControl, UITextViewDelegate, InternalTextViewDelega } let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = .center - string.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, string.length)) + string.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, string.length)) return string } @@ -318,17 +320,17 @@ open class MoneyTextField: UIControl, UITextViewDelegate, InternalTextViewDelega // MARK: UITextViewDelegate open func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { var newRawString = self.rawString - let deleting = range.location == textView.text.characters.count - 1 && range.length == 1 && text == "" + let deleting = range.location == textView.text.count - 1 && range.length == 1 && text == "" if deleting { - if newRawString.characters.count > 0 { - var lastIndex = newRawString.characters.index(before: newRawString.endIndex) + if newRawString.count > 0 { + var lastIndex = newRawString.index(before: newRawString.endIndex) // delete over the decimal separator if String(newRawString[lastIndex]) == self.decimalSeparator && - newRawString.characters.count > 1 { - lastIndex = newRawString.characters.index(before: lastIndex) + newRawString.count > 1 { + lastIndex = newRawString.index(before: lastIndex) } - newRawString = newRawString.substring(to: lastIndex) - if newRawString.characters.isEmpty { + newRawString = String(newRawString[.. - + + + + + - + + @@ -15,18 +19,18 @@ - + - - + + - + diff --git a/DashboardUIExample/ViewController.swift b/DashboardUIExample/ViewController.swift index 31a4967..97d2631 100644 --- a/DashboardUIExample/ViewController.swift +++ b/DashboardUIExample/ViewController.swift @@ -21,11 +21,11 @@ class ViewController: UIViewController { // Do any additional setup after loading the view, typically from a nib. } - func tap() { + @objc func tap() { let _ = self.moneyTextField.resignFirstResponder() } - func amountChanged() { + @objc func amountChanged() { print(self.moneyTextField.amountString) } diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_1-original@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_1-original@3x.png new file mode 100644 index 0000000..0420bea Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_1-original@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_2-usesGroupingSeparator=false@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_2-usesGroupingSeparator=false@3x.png new file mode 100644 index 0000000..1f1accb Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_2-usesGroupingSeparator=false@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_3-currency=gbp@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_3-currency=gbp@3x.png new file mode 100644 index 0000000..ecb4a19 Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_3-currency=gbp@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_4-amount=50@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_4-amount=50@3x.png new file mode 100644 index 0000000..9e67a1c Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testConfigure_4-amount=50@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_jpy@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_jpy@3x.png new file mode 100644 index 0000000..3222bde Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_jpy@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_usd@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_usd@3x.png new file mode 100644 index 0000000..a975c42 Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_0_usd@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_1000000_jpy@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_1000000_jpy@3x.png new file mode 100644 index 0000000..58009fa Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_1000000_jpy@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_100000_usd@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_100000_usd@3x.png new file mode 100644 index 0000000..0420bea Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_100000_usd@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_123_jod@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_123_jod@3x.png new file mode 100644 index 0000000..633bbb5 Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_123_jod@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_jpy@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_jpy@3x.png new file mode 100644 index 0000000..b6f6641 Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_jpy@3x.png differ diff --git a/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_usd@3x.png b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_usd@3x.png new file mode 100644 index 0000000..33f8b6c Binary files /dev/null and b/DashboardUITests/ReferenceImages_64/DashboardUITests.MoneyTextFieldTests/testInit_50_usd@3x.png differ diff --git a/README.md b/README.md index a1ae2ea..f8924bf 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This is a collection of UI components used in the [Stripe Dashboard](https://itu * Manual * drag source files from the `DashboardUI` directory into your project. -Swift 3 +Swift 4 ## Components ### MoneyTextField diff --git a/StripeDashboardUI.podspec b/StripeDashboardUI.podspec index eb843a8..b9fd351 100644 --- a/StripeDashboardUI.podspec +++ b/StripeDashboardUI.podspec @@ -1,17 +1,17 @@ Pod::Spec.new do |s| s.name = "StripeDashboardUI" - s.version = "0.2" + s.version = "0.3" s.authors = { "Ben Guo" => "bg@stripe.com", "Jack Flintermann" => "jack@stripe.com", "Brian Dorfman" => "bdorfman@stripe.com" } s.homepage = "https://github.com/stripe/ios-dashboard-ui" s.summary = "UI components from the Stripe Dashboard iOS app" s.source = { :git => "https://github.com/stripe/ios-dashboard-ui.git", - :tag => '0.2' } + :tag => '0.3' } s.license = { :type => "MIT", :file => "LICENSE" } - s.platform = :ios, '8.0' + s.platform = :ios, '9.0' s.source_files = "DashboardUI/*.swift" s.requires_arc = true - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '9.0' s.ios.frameworks = ['UIKit', 'Foundation'] end diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index ebb194e..6a0468b 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -1,5 +1,5 @@ set -o pipefail && xcodebuild test -scheme DashboardUI\ -configuration Debug\ -sdk iphonesimulator\ - -destination "OS=10.3.1,name=iPhone 6"\ + -destination "OS=11.2,name=iPhone X"\ -verbose | xcpretty -c