Skip to content

Commit

Permalink
Merge pull request yoomoney#73 in MI/yandex-checkout-payments-swift f…
Browse files Browse the repository at this point in the history
…rom feature/dark-mode to dev

* commit 'c8dfc7927728b4c41517e9f6328c589a433c77aa':
  [BIOS-1255] Add iOS 13 dark mode
  • Loading branch information
AutoMergeBot authored and AutoMergeBot committed Nov 19, 2019
2 parents 24a2acd + c8dfc79 commit d8d396e
Show file tree
Hide file tree
Showing 18 changed files with 212 additions and 53 deletions.
4 changes: 2 additions & 2 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PODS:
- Reveal-SDK (24)
- SwiftLint (0.34.0)
- When (4.0.0)
- YandexCheckoutPayments (2.2.2):
- YandexCheckoutPayments (2.3.0):
- FunctionalSwift (~> 1.1.0)
- When (~> 4.0.0)
- YandexCheckoutPaymentsApi (~> 1.5.0)
Expand Down Expand Up @@ -63,7 +63,7 @@ SPEC CHECKSUMS:
Reveal-SDK: 5d7e56b8f018c0a88b3a2c10bf68d598bbd3b071
SwiftLint: 79d48a17c6565dc286c37efb8322c7b450f95c67
When: 4ffc88d535a094ad4bd5eaf2fd187de747e716d1
YandexCheckoutPayments: 1aefd76d9512cdf91a4aab1fbcf058ae8588d33a
YandexCheckoutPayments: a560fd50ec1c5b8ed247f1e86183ef41e1740345
YandexCheckoutPaymentsApi: e3f45d08993fc8e67f63c28d194b04d25a31e303
YandexCheckoutShowcaseApi: 44382163176b3a53692fa1c3b85c0c8d0a82b7e6
YandexCheckoutWalletApi: 5d2774cd1216ee0ce47d6412184008b37caeaeac
Expand Down
2 changes: 1 addition & 1 deletion YandexCheckoutPayments.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'YandexCheckoutPayments'
s.version = '2.2.2'
s.version = '2.3.0'
s.homepage = 'https://github.com/yandex-money/yandex-checkout-payments-swift'
s.license = {
:type => "MIT",
Expand Down
38 changes: 21 additions & 17 deletions YandexCheckoutPayments.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
301D747F20B5D7E60000E394 /* PassKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301D747E20B5D7E60000E394 /* PassKit.framework */; };
303FD05A21B92EC900CE82B4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 303FD05D21B92EC900CE82B4 /* InfoPlist.strings */; };
303FD05B21B92EC900CE82B4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 303FD05D21B92EC900CE82B4 /* InfoPlist.strings */; };
309CECE7237D62BC002010DD /* PriceView+Style.swift in Sources */ = {isa = PBXBuildFile; fileRef = 309CECE6237D62BC002010DD /* PriceView+Style.swift */; };
30A588242177B792002AFFF1 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 30A588232177B792002AFFF1 /* Settings.bundle */; };
30A588252177B792002AFFF1 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 30A588232177B792002AFFF1 /* Settings.bundle */; };
30B24DE1206C2850002C823B /* YandexMobileMetrica.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 30B24DE0206C2850002C823B /* YandexMobileMetrica.framework */; };
Expand Down Expand Up @@ -656,6 +657,7 @@
303FD05C21B92EC900CE82B4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
303FD05E21B92ECD00CE82B4 /* ru */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ru; path = ru.lproj/InfoPlist.strings; sourceTree = "<group>"; };
307D0CEB2061918600CAAAE6 /* CardIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CardIO.framework; path = Carthage/Build/iOS/CardIO.framework; sourceTree = "<group>"; };
309CECE6237D62BC002010DD /* PriceView+Style.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PriceView+Style.swift"; sourceTree = "<group>"; };
30A588232177B792002AFFF1 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
30B24DE0206C2850002C823B /* YandexMobileMetrica.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = YandexMobileMetrica.framework; path = Carthage/Build/iOS/YandexMobileMetrica.framework; sourceTree = "<group>"; };
30FFA679234E63EA00B09847 /* TrustDefender.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = TrustDefender.framework; path = Frameworks/TrustDefender.framework; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1145,8 +1147,8 @@
children = (
559073911FF3C2B90094AE5D /* YandexCheckoutPayments.h */,
244F7D88849ACD598FFD45ED /* Info.plist */,
402EB13ECBDC29975E13A501 /* Public */,
402EB5FB503B7E55FB658855 /* Private */,
402EB13ECBDC29975E13A501 /* Public */,
);
path = YandexCheckoutPayments;
sourceTree = "<group>";
Expand Down Expand Up @@ -1485,18 +1487,18 @@
isa = PBXGroup;
children = (
402EB0D91B5AEDF9532119F1 /* MSDKActionSheetHeaderView.swift */,
402EB918DF3B063B9DFC9AD9 /* Styles */,
402EBA8DACAA2FAC35017032 /* Formatters */,
402EB384CB68D21365AFC6BC /* Organisms */,
402EB634BAF3BC404B10B86D /* Molecules */,
402EB434378916092B3D1A75 /* Templates */,
402EB71B3FA4CE37A176F38D /* Space.swift */,
402EBFE44EA0B8EB4A229E2B /* Stylist */,
402EB88C7730B769B35F7B95 /* Protocols */,
402EBFD02C24C5B853406E19 /* Pages */,
402EB07E3A4A08B7FA0C352C /* AutoLayout */,
402EBA8DACAA2FAC35017032 /* Formatters */,
402EBB48E92A6C120529260B /* Keyboard */,
402EB634BAF3BC404B10B86D /* Molecules */,
402EB384CB68D21365AFC6BC /* Organisms */,
402EBFD02C24C5B853406E19 /* Pages */,
402EBF96800334C9DF5EFC45 /* PresentationTransitions */,
402EB88C7730B769B35F7B95 /* Protocols */,
402EB918DF3B063B9DFC9AD9 /* Styles */,
402EBFE44EA0B8EB4A229E2B /* Stylist */,
402EB434378916092B3D1A75 /* Templates */,
402EB152B4911AB058FF53B1 /* Views */,
);
path = "Atomic Design";
Expand Down Expand Up @@ -1839,19 +1841,20 @@
402EB634BAF3BC404B10B86D /* Molecules */ = {
isa = PBXGroup;
children = (
402EBB761608F1C750B0D45F /* PriceView.swift */,
402EBE34DAB5E4AE1FC8E6B1 /* AdditionalCardDataInputView.swift */,
402EBC8C494983AD7DA811B5 /* PaymentMethodView */,
402EB3C27AB9FBDF54BD39ED /* PaymentMethodViewFactory.swift */,
402EB5955724BED0443AEBC5 /* ItemViews */,
402EBB761608F1C750B0D45F /* PriceView.swift */,
309CECE6237D62BC002010DD /* PriceView+Style.swift */,
402EB20C58086E203F50942D /* ActionTextDialog */,
402EB95D4399B06C5C92280B /* IconView */,
402EB55BA4ECB1C0470B054F /* UIKit+Styles */,
402EB66D490EE34B6298F44F /* ActivityIndicatorView */,
402EBB02AE37900695528473 /* ActivityIndicator */,
402EBF6C8C9339744A871AA8 /* TextControl */,
402EBCC197FE30C498F5E43B /* NotificationView */,
402EB66D490EE34B6298F44F /* ActivityIndicatorView */,
402EB12114BA5FBF04075BAB /* Button */,
402EB95D4399B06C5C92280B /* IconView */,
402EB5955724BED0443AEBC5 /* ItemViews */,
402EBCC197FE30C498F5E43B /* NotificationView */,
402EBC8C494983AD7DA811B5 /* PaymentMethodView */,
402EBF6C8C9339744A871AA8 /* TextControl */,
402EB55BA4ECB1C0470B054F /* UIKit+Styles */,
);
path = Molecules;
sourceTree = "<group>";
Expand Down Expand Up @@ -3267,6 +3270,7 @@
402EBB63E95FBBA1BA1B59BE /* Style.swift in Sources */,
402EBB0D7303FCBCDB26B74B /* Stylable.swift in Sources */,
402EBE993BF501D9158671E4 /* StyleStorage.swift in Sources */,
309CECE7237D62BC002010DD /* PriceView+Style.swift in Sources */,
402EB760A3EDD767C76A1AE9 /* UILabel+Stylable.swift in Sources */,
402EBBB3276C2F6BC3AC5827 /* UIButton+Stylable.swift in Sources */,
402EB6F495D788A1A3FE0194 /* PlaceholderProvider.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -38,8 +36,8 @@
ReferencedContainer = "container:YandexCheckoutPayments.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -61,8 +59,6 @@
ReferencedContainer = "container:YandexCheckoutPayments.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "AdHoc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ final class LargeIconButtonItemView: UIView {

private(set) lazy var titleLabel: UILabel = {
$0.setStyles(UILabel.DynamicStyle.bodySemibold,
UILabel.Styles.multiline)
UILabel.Styles.multiline,
UILabel.ColorStyle.primary)
$0.setContentCompressionResistancePriority(.required, for: .vertical)
$0.setContentHuggingPriority(.required, for: .vertical)
return $0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* The MIT License
*
* Copyright (c) 2019 NBCO Yandex.Money LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

import UIKit

// MARK: - Styles

extension PriceView {

enum Styles {

static let primary = Style(name: "PriceView.primary") { (view: PriceView) in
view.textLabel.setStyles(UILabel.ColorStyle.primary)
view.priceLabel.setStyles(UILabel.ColorStyle.primary)
}

static let secondary = Style(name: "PriceView.secondary") { (view: PriceView) in
view.textLabel.setStyles(UILabel.ColorStyle.secondary)
view.priceLabel.setStyles(UILabel.ColorStyle.secondary)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ final class PriceView: UIView {

// MARK: - UI properties

private lazy var textLabel: UILabel = {
lazy var textLabel: UILabel = {
$0.setStyles(UILabel.DynamicStyle.body, UILabel.Styles.multiline)
return $0

}(UILabel())

private lazy var priceLabel: UILabel = {
lazy var priceLabel: UILabel = {
$0.setContentHuggingPriority(.required, for: .horizontal)
return $0
}(UILabel())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ extension TextControl {
item.textView.textContainer.lineFragmentPadding = 0

item.textView.font = .dynamicBody
item.textView.textColor = .black

if #available(iOS 13.0, *) {
item.textView.textColor = .label
} else {
item.textView.textColor = .black
}

item.topHintLabel.font = .dynamicCaption2
item.topHintLabel.textColor = .nobel
Expand All @@ -48,14 +53,13 @@ extension TextControl {
item.set(bottomHintColor: .nobel, for: .normal)
item.set(bottomHintColor: .redOrange, for: .error)

item.lineView.backgroundColor = .black5

item.placeholderLabel.textColor = UIColor.AdaptiveColors.secondary
item.placeholderLabel.font = .dynamicBody
item.placeholderLabel.textColor = .nobel
item.placeholderLabel.numberOfLines = 0

item.set(lineState: .filled(color: .mustard, height: 1), for: .normal)
item.set(lineState: .filled(color: .redOrange, height: 1), for: .error)
item.lineView.backgroundColor = UIColor.AdaptiveColors.secondary

item.clearMode = .default
item.placeholderMode = .default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ extension UIButton {
let tintColor: UIColor = button.tintColor
let cornerRadius = UIButton.Styles.cornerRadius

let disabledBackgroundColor: UIColor
if #available(iOS 13.0, *) {
disabledBackgroundColor = .systemGray2
} else {
disabledBackgroundColor = .mousegrey
}

let colors: [(UIControl.State, foreground: UIColor, background: UIColor, backgroundImage: UIImage)] = [
(.normal,
.inverse,
Expand All @@ -211,9 +218,9 @@ extension UIButton {
UIButton.Styles.roundedBackground(color: .highlighted(from: tintColor),
cornerRadius: cornerRadius)),
(.disabled,
.nobel,
.mousegrey,
UIButton.Styles.roundedBackground(color: .mousegrey,
UIColor.AdaptiveColors.secondary,
.clear,
UIButton.Styles.roundedBackground(color: disabledBackgroundColor,
cornerRadius: cornerRadius)),
]
colors.forEach { (state, foreground, background, backgroundImage) in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,29 @@ extension UIColor {
brightness *= 0.9
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: alpha)
}

// MARK: - Adaptive colors

enum AdaptiveColors {
static var secondary: UIColor = {
let color: UIColor
if #available(iOS 13.0, *) {
color = .init(dynamicProvider: { (trait) -> UIColor in
let dynamicProviderColor: UIColor
switch trait.userInterfaceStyle {
case .dark, .light:
dynamicProviderColor = .secondaryLabel
case .unspecified:
dynamicProviderColor = .doveGray
@unknown default:
dynamicProviderColor = .doveGray
}
return dynamicProviderColor
})
} else {
color = .doveGray
}
return color
}()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,27 @@ extension UILabel {

enum ColorStyle {
private static let black = Style(name: "color.black") { (label: UILabel) in
label.textColor = .black
if #available(iOS 13.0, *) {
label.textColor = .label
} else {
label.textColor = .black
}
}

private static let doveGray = Style(name: "color.doveGray") { (label: UILabel) in
label.textColor = .doveGray
if #available(iOS 13.0, *) {
label.textColor = .secondaryLabel
} else {
label.textColor = .doveGray
}
}

private static let nobel = Style(name: "color.nobel") { (label: UILabel) in
label.textColor = .nobel
if #available(iOS 13.0, *) {
label.textColor = .tertiaryLabel
} else {
label.textColor = .nobel
}
}

static let primary = black
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ extension UINavigationBar {

// MARK: - Main styles

static let `default` = Style(
name: "default") { (view: UINavigationBar) in
static let `default` = Style(name: "default") { (view: UINavigationBar) in

view.isTranslucent = true
view.barTintColor = .cararra
let barTintColor: UIColor
if #available(iOS 13, *) {
barTintColor = .systemBackground
} else {
barTintColor = .cararra
}

view.isTranslucent = false
view.barTintColor = barTintColor
view.shadowImage = UIImage()
view.clipsToBounds = true
view.layoutMargins = UIEdgeInsets(top: 0, left: Space.double, bottom: 0, right: Space.double)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,23 @@ extension UIView {
///
/// mercury background color, 1pt height with natural scale factor associated with the screen.
static let separator = Style(name: "separator") { (view: UIView) in
view.backgroundColor = .alto
if #available(iOS 13.0, *) {
view.backgroundColor = .separator
} else {
view.backgroundColor = .alto
}
view.height.constraint(equalToConstant: 1 / UIScreen.main.scale).isActive = true
}

/// Style for view with default background.
///
/// cararra background color.
static let defaultBackground = Style(name: "defaultBackground") { (view: UIView) in
view.backgroundColor = .cararra
if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .cararra
}
}

/// Style for view with tint background.
Expand Down
Loading

0 comments on commit d8d396e

Please sign in to comment.