Skip to content

Commit

Permalink
Release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mmroz committed Feb 23, 2023
1 parent cad34a6 commit cf2faf3
Show file tree
Hide file tree
Showing 21 changed files with 109 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CashAppPayKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'CashAppPayKit'
s.version = '0.1.0'
s.version = '0.2.0'
s.summary = 'PayKit iOS SDK'
s.homepage = 'https://github.com/cashapp/cash-app-pay-ios-sdk'
s.license = 'Apache License, Version 2.0'
Expand Down
2 changes: 1 addition & 1 deletion CashAppPayKitUI.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'CashAppPayKitUI'
s.version = "0.1.0"
s.version = "0.2.0"
s.summary = 'UI components for the PayKit iOS SDK'
s.homepage = 'https://github.com/cashapp/cash-app-pay-ios-sdk'
s.license = 'Apache License, Version 2.0'
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let package = Package(
name: "PayKit",
defaultLocalization: "en",
platforms: [
.iOS(.v13),
.iOS(.v11),
.macOS(.v12),
],
products: [
Expand Down
14 changes: 14 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## PayKit 0.2.0 Release Notes

*PayKit 0.2.0* supports *iOS* and requires *Xcode 9* or later. The minimum supported *Base SDK* is *11.0*.

*PayKit 0.2.0* includes the following new features and enhancements.

- **PayKit Compiles in iOS 11**

*PayKit* now supports a minimum base SDK version of *11.0* however *PayKitUI* still requires SDK version *13.0*.

- **CashAppPayButton Disabled State**

The *CashAppPayButton* now supports a disabled state when the button is not tappable.

## PayKit 0.1.0 Release Notes

*PayKit 0.1.0* supports *iOS* and requires *Xcode 11* or later. The minimum supported *Base SDK* is *13.0*.
Expand Down
2 changes: 1 addition & 1 deletion Sources/PayKit/PayKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import UIKit

public class PayKit {

public static let version = "0.1.0"
public static let version = "0.2.0"

public static let RedirectNotification: Notification.Name = Notification.Name("CashAppPayRedirect")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x99",
"green" : "0x99",
"red" : "0x99"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x66",
"green" : "0x66",
"red" : "0x66"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
1 change: 1 addition & 0 deletions Sources/PayKitUI/Shared/Generated/Assets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ internal enum Asset {
internal enum Colors {
internal static let buttonTextPrimary = ColorAsset(name: "ButtonTextPrimary")
internal static let surfacePrimary = ColorAsset(name: "SurfacePrimary")
internal static let surfacePrimaryDisabled = ColorAsset(name: "SurfacePrimaryDisabled")
internal static let surfaceSecondary = ColorAsset(name: "SurfaceSecondary")
internal static let textPrimary = ColorAsset(name: "TextPrimary")
internal static let textSecondary = ColorAsset(name: "TextSecondary")
Expand Down
26 changes: 25 additions & 1 deletion Sources/PayKitUI/SwiftUI/CashAppPayButtonView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import SwiftUI

@available(iOS 13.0, *)
public struct CashAppPayButtonView: View {

// MARK: - Public Properties
Expand Down Expand Up @@ -62,6 +63,7 @@ public struct CashAppPayButtonView: View {
trailing: horizontalPadding
)
)
.opacity(tileImageOpacity)
}.disabled(!viewModel.isEnabled)
.frame(
minWidth: minButtonWidth,
Expand All @@ -71,7 +73,7 @@ public struct CashAppPayButtonView: View {
)
.background(
RoundedRectangle(cornerRadius: Constants.cornerRadius)
.fill(Asset.Colors.surfacePrimary.swiftUIColor)
.fill(buttonBackgroundColor)
)
}

Expand Down Expand Up @@ -117,6 +119,22 @@ public struct CashAppPayButtonView: View {
}
}

private var buttonBackgroundColor: Color {
if viewModel.isEnabled {
return Asset.Colors.surfacePrimary.swiftUIColor
} else {
return Asset.Colors.surfacePrimaryDisabled.swiftUIColor
}
}

private var tileImageOpacity: CGFloat {
if viewModel.isEnabled {
return Constants.opaque
} else {
return Constants.disabledOpacity
}
}

private enum Constants {
static let cornerRadius: CGFloat = 150

Expand All @@ -141,11 +159,15 @@ public struct CashAppPayButtonView: View {

static let iconTopPaddingLarge: CGFloat = 6
static let iconTopPaddingSmall: CGFloat = 4

static let opaque: CGFloat = 1
static let disabledOpacity: CGFloat = 0.4
}
}

// MARK: - View Model

@available(iOS 13.0, *)
extension CashAppPayButtonView {
public class ViewModel: ObservableObject {
@Published var size: SizingCategory
Expand All @@ -158,9 +180,11 @@ extension CashAppPayButtonView {
}
}

@available(iOS 13.0, *)
struct CashButtonView_Previews: PreviewProvider {
static var previews: some View {
VStack {
CashAppPayButtonView(isEnabled: false, onClickHandler: {})
HStack {
Spacer().frame(width: .infinity)
CashAppPayButtonView(size: .large, onClickHandler: {})
Expand Down
3 changes: 3 additions & 0 deletions Sources/PayKitUI/SwiftUI/CashAppPaymentMethodView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import Foundation
import SwiftUI

@available(iOS 13.0, *)
public struct CashAppPaymentMethodView: View {

// MARK: - Public Properties
Expand Down Expand Up @@ -123,6 +124,7 @@ public struct CashAppPaymentMethodView: View {

// MARK: - View Model

@available(iOS 13.0, *)
extension CashAppPaymentMethodView {
public class ViewModel: ObservableObject {
@Published var size: SizingCategory
Expand All @@ -141,6 +143,7 @@ extension CashAppPaymentMethodView {

// MARK: - Preview

@available(iOS 13.0, *)
struct CashAppPaymentMethodView_Previews: PreviewProvider {
static var previews: some View {
VStack(alignment: .leading, spacing: 10) {
Expand Down
2 changes: 2 additions & 0 deletions Sources/PayKitUI/UIKit/CashAppPayButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import SwiftUI

@available(iOS 13.0, *)
public class CashAppPayButton: UIView {

// MARK: - Public Properties
Expand Down Expand Up @@ -68,6 +69,7 @@ public class CashAppPayButton: UIView {

// MARK: - View Building

@available(iOS 13.0, *)
private extension CashAppPayButton {
private func makeView() -> UIView? {
guard let view = UIHostingController(rootView: cashAppButton).view else {
Expand Down
2 changes: 2 additions & 0 deletions Sources/PayKitUI/UIKit/CashAppPaymentMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import SwiftUI

@available(iOS 13.0, *)
public class CashAppPaymentMethod: UIView {

// MARK: - Private Properties
Expand Down Expand Up @@ -79,6 +80,7 @@ public class CashAppPaymentMethod: UIView {

// MARK: - View Building

@available(iOS 13.0, *)
private extension CashAppPaymentMethod {
private func makeView() -> UIView? {
guard let view = UIHostingController(rootView: paymentMethodView).view else {
Expand Down
1 change: 1 addition & 0 deletions Sources/PayKitUI/UIKit/Extensions/UIColor+SwiftUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import SwiftUI

@available(iOS 13.0, *)
extension UIColor {
var swiftUIColor: Color? {
guard let rgb = cgColor.components, rgb.count >= 3 else {
Expand Down
2 changes: 2 additions & 0 deletions Tests/PayKitUITests/BaseSnapshotTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BaseSnapshotTestCase: XCTestCase {
private let lowPrecision: Float = 0.95
private let viewBackground: UIColor = .darkGray

@available(iOS 13.0, *)
extension Snapshotting where Value: UIView, Format == UIImage {
public static func image(
filling config: ViewImageConfig,
Expand Down Expand Up @@ -78,6 +79,7 @@ extension Snapshotting where Value: UIView, Format == UIImage {
}
}

@available(iOS 13.0, *)
extension Snapshotting where Value: View, Format == UIImage {
public static func image(
on config: ViewImageConfig,
Expand Down
11 changes: 8 additions & 3 deletions Tests/PayKitUITests/CashAppPayButtonSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PayKitUI
import SnapshotTesting
import XCTest

@available(iOS 13.0, *)
class CashAppPayButtonSnapshotTests: BaseSnapshotTestCase {
func test_small_button() {
assertSnapshot(matching: CashAppPayButton(size: .small, onClickHandler: {}), as: .image(centeredIn: .iPhone8))
Expand All @@ -28,9 +29,13 @@ class CashAppPayButtonSnapshotTests: BaseSnapshotTestCase {
}

func test_button_disabled() {
let button = CashAppPayButton(size: .large, onClickHandler: {})
button.isEnabled = false
assertSnapshot(matching: button, as: .image(centeredIn: .iPhone8))
let lightButton = CashAppPayButton(size: .large, onClickHandler: {})
lightButton.isEnabled = false
assertSnapshot(matching: lightButton, as: .image(centeredIn: .iPhone8, userInterfaceStyle: .light))

let darkButton = CashAppPayButton(size: .large, onClickHandler: {})
darkButton.isEnabled = false
assertSnapshot(matching: darkButton, as: .image(centeredIn: .iPhone8, userInterfaceStyle: .dark))
}

func test_dark_mode() {
Expand Down
8 changes: 7 additions & 1 deletion Tests/PayKitUITests/CashAppPayButtonViewSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PayKitUI
import SnapshotTesting
import SwiftUI

@available(iOS 13.0, *)
class CashAppPayButtonViewSnapshotTests: BaseSnapshotTestCase {
func test_small_button() {
assertSnapshot(
Expand All @@ -36,7 +37,12 @@ class CashAppPayButtonViewSnapshotTests: BaseSnapshotTestCase {
func test_button_disabled() {
assertSnapshot(
matching: CashAppPayButtonView(size: .large, isEnabled: false, onClickHandler: {}),
as: .image(on: .iPhone8)
as: .image(on: .iPhone8, userInterfaceStyle: .light)
)

assertSnapshot(
matching: CashAppPayButtonView(size: .large, isEnabled: false, onClickHandler: {}),
as: .image(on: .iPhone8, userInterfaceStyle: .dark)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PayKitUI
import SnapshotTesting
import UIKit

@available(iOS 13.0, *)
class CashAppPaymentMethodSnapshotTests: BaseSnapshotTestCase {
func test_small_payment_method() {
let paymentMethod = CashAppPaymentMethod(size: .small)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import PayKitUI
import SnapshotTesting
import SwiftUI

@available(iOS 13.0, *)
class CashAppPaymentMethodViewSnapshotTests: BaseSnapshotTestCase {
func test_small_button() {
assertSnapshot(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cf2faf3

Please sign in to comment.