Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix font and image resources #40

Merged
merged 3 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ env:

jobs:
Run_Tests:
runs-on: macOS-12
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_13.4.app && /usr/bin/xcodebuild -version
run: sudo xcode-select -switch /Applications/Xcode_14.2.app && /usr/bin/xcodebuild -version

- name: List Simulators
run: xcrun simctl list runtimes
Expand All @@ -26,6 +26,6 @@ jobs:
xcodebuild \
-project RecurlySDK-iOS.xcodeproj \
-scheme RecurlySDK-iOS \
-destination 'platform=iOS Simulator,name=iPhone 13' \
-destination 'platform=iOS Simulator,name=iPhone 14' \
PUBLIC_KEY=$API_TOKEN \
test \
2 changes: 1 addition & 1 deletion .github/workflows/deploy_to_cocoapods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_13.2.app && /usr/bin/xcodebuild -version
run: sudo xcode-select -switch /Applications/Xcode_14.2.app && /usr/bin/xcodebuild -version
- name: List Simulators
run: xcrun simctl list runtimes
- name: Install Cocoapods
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lldb.library": "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/LLDB",
"lldb.launch.expressions": "native"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For more information on CocoaPods and the `Podfile`, visit: <https://guides.coco
Once the framework is added to your project (via either of the methods above) you only need to import the SDK.

```SwiftUI
import RecurlySDK_iOS
import RecurlySDK
```

## 3. Configure
Expand Down
8 changes: 8 additions & 0 deletions RecurlySDK-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
86EEFFAD2862CA4000F8059E /* REApplePayTokenRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86EEFFAC2862CA4000F8059E /* REApplePayTokenRequest.swift */; };
86EEFFAF2862E25A00F8059E /* REApplePaymentData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86EEFFAE2862E25A00F8059E /* REApplePaymentData.swift */; };
86EEFFB12862EC2D00F8059E /* REApplePaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86EEFFB02862EC2D00F8059E /* REApplePaymentMethod.swift */; };
E925776A2AB4E76F00820B2C /* Image+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E92577692AB4E76F00820B2C /* Image+Extension.swift */; };
E925776C2AB4F32200820B2C /* Resource.swift in Sources */ = {isa = PBXBuildFile; fileRef = E925776B2AB4F32200820B2C /* Resource.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -136,6 +138,8 @@
86EEFFAC2862CA4000F8059E /* REApplePayTokenRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = REApplePayTokenRequest.swift; sourceTree = "<group>"; };
86EEFFAE2862E25A00F8059E /* REApplePaymentData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = REApplePaymentData.swift; sourceTree = "<group>"; };
86EEFFB02862EC2D00F8059E /* REApplePaymentMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = REApplePaymentMethod.swift; sourceTree = "<group>"; };
E92577692AB4E76F00820B2C /* Image+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Image+Extension.swift"; sourceTree = "<group>"; };
E925776B2AB4F32200820B2C /* Resource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Resource.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -190,6 +194,7 @@
277F56AF274E7ECE0067E4E1 /* FontLoader.swift */,
27830A402754FE4700B2620C /* CreditCardValidator.swift */,
27F548DD27724D4B001014C8 /* REApplePaymentHandler.swift */,
E925776B2AB4F32200820B2C /* Resource.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand All @@ -201,6 +206,7 @@
27F498EB275A504B009227F5 /* UIDevice+Extension.swift */,
27AFBB532766DD84005274B3 /* UIApplication+Extension.swift */,
27BC1485276B90D4004FD5E0 /* String+Extension.swift */,
E92577692AB4E76F00820B2C /* Image+Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -500,6 +506,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E925776A2AB4E76F00820B2C /* Image+Extension.swift in Sources */,
27830A4927553F7F00B2620C /* RECVVTextField.swift in Sources */,
27830A51275569AD00B2620C /* TextFieldClearButton.swift in Sources */,
866B9B94278F4E6A009035C2 /* REApplePayInfo.swift in Sources */,
Expand All @@ -508,6 +515,7 @@
86EEFFB12862EC2D00F8059E /* REApplePaymentMethod.swift in Sources */,
27F498F2275D1A78009227F5 /* RETokenizationManager.swift in Sources */,
27F498E82759BBA1009227F5 /* REBaseErrorResponse.swift in Sources */,
E925776C2AB4F32200820B2C /* Resource.swift in Sources */,
27830A4527553F5F00B2620C /* RECardNumberTextField.swift in Sources */,
27F498E62759B99F009227F5 /* RETokenResponse.swift in Sources */,
27830A4F27554FDC00B2620C /* UnifiedViewModel.swift in Sources */,
Expand Down
14 changes: 14 additions & 0 deletions RecurlySDK-iOS/Extensions/Image+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Image+Extension.swift
// RecurlySDK-iOS
//
// Created by Andy Kelso on 09/15/2023.
//

import SwiftUI

extension Image {
init(_ name: String) {
self.init(name, bundle: Resource.getProjectBundle())
}
}
2 changes: 1 addition & 1 deletion RecurlySDK-iOS/Helpers/FontLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

class FontLoader {
static public func loadFont(name: String, fileExtension: String) {
if let fontUrl = Bundle(for: FontLoader.self).url(forResource: name, withExtension: fileExtension),
if let fontUrl = Resource.getProjectBundle().url(forResource: name, withExtension: fileExtension),
let dataProvider = CGDataProvider(url: fontUrl as CFURL),
let newFont = CGFont(dataProvider) {
var error: Unmanaged<CFError>?
Expand Down
4 changes: 1 addition & 3 deletions RecurlySDK-iOS/Helpers/REConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ public struct REConfiguration {
public var apiPublicKey = ""
public var sessionId = UUID()
public static var shared = REConfiguration()

public mutating func initialize(publicKey: String) {
self.apiPublicKey = publicKey
}


}
14 changes: 14 additions & 0 deletions RecurlySDK-iOS/Helpers/Resource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Resource.swift
// RecurlySDK-iOS
//
// Created by Andy Kelso on 9/15/23.
//

import SwiftUI

class Resource {
static public func getProjectBundle() -> Bundle {
return Bundle(for: Resource.self)
}
}
8 changes: 4 additions & 4 deletions RecurlySDK-iOS/Models/REBillingInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public struct REBillingInfo: Codable {
/// Customer VAT number. Used for VAT exclusion
var vatNumber: String
/// A valid CPF or CUIT. Required if it is a consumer card in Brazil early access or in Argentina.
var taxIdentifier: String
var taxIdentifier: String? = nil
/// cpf and cuit are the only accepted values for this field. Required if it is a consumer card in Brazil early access or in Argentina.
var taxIdentifierType: String
var taxIdentifierType: String? = nil

enum CodingKeys: String, CodingKey {
case firstName = "first_name"
Expand Down Expand Up @@ -64,8 +64,8 @@ public struct REBillingInfo: Codable {
postalCode: String = "",
phone: String = "",
vatNumber: String = "",
taxIdentifier: String = "",
taxIdentifierType: String = "") {
taxIdentifier: String? = nil,
taxIdentifierType: String? = nil) {

self.firstName = firstName
self.lastName = lastName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@ import Combine

/// Recurly Custom Secure TextField for Card Number Input.
public struct RECardNumberTextField: View {

@StateObject private var viewModel = IndividualViewModel()
private var placeholder: String
private var onEditingChanged: (Bool) -> Void
private var textFieldFont: Font

/// Creates a RECardNumberTextField object
/// - Parameters:
/// - placeholder: The placeholder for the Card Number TextField
/// - textFieldFont: Optional Textfield Custom Font, Default its ("Inter-Regular", size: 17)
public init(placeholder: String,
onEditingChanged: @escaping (Bool) -> Void = { _ in },
textFieldFont: Font = Font.custom("Inter-Regular", size: 17)){

self.placeholder = placeholder
self.onEditingChanged = onEditingChanged
self.textFieldFont = textFieldFont
}

private func didOnEditingChanged(editingChanged: Bool) -> Void {
if editingChanged {
viewModel.lastCardStatus = .entering
Expand All @@ -37,12 +36,12 @@ public struct RECardNumberTextField: View {
viewModel.lastCardStatus = viewModel.cardStatus
}
}

public var body: some View {
ZStack {
VStack {
HStack {
Image(viewModel.mainImageName, bundle: Bundle(identifier: "recurly.RecurlySDK-iOS"))
Image(viewModel.mainImageName)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 40, height: 26, alignment: .center)
Expand All @@ -69,13 +68,12 @@ public struct RECardNumberTextField: View {
}
}
}

Divider()
.frame(height: 0.7)
.padding(.horizontal, 0)
.background(viewModel.lastTfBorderColor)
}
}

}
}
23 changes: 11 additions & 12 deletions RecurlySDK-iOS/UIComponents/Unified/RECreditCardInputUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import Combine

/// Recurly Custom Secure TextField for Card Input.
public struct RECreditCardInputUI: View {

@StateObject private var viewModel = UnifiedViewModel()
private var cardNumberPlaceholder: String
private var expDatePlaceholder: String
private var cvvPlaceholder: String
private var textFieldFont: Font
private var titleLabelFont: Font

/// Creates a RECreditCardInputUI object
/// - Parameters:
/// - cardNumberPlaceholder: The placeholder for the Card Number TextField
Expand All @@ -30,14 +29,14 @@ public struct RECreditCardInputUI: View {
cvvPlaceholder: String,
textFieldFont: Font = Font.custom("Inter-Regular", size: 15),
titleLabelFont: Font = Font.custom("Inter-Regular", size: 13)) {

self.cardNumberPlaceholder = cardNumberPlaceholder
self.expDatePlaceholder = expDatePlaceholder
self.cvvPlaceholder = cvvPlaceholder
self.textFieldFont = textFieldFont
self.titleLabelFont = titleLabelFont
}

private func didOnEditingChanged(editingChanged: Bool) -> Void {
if editingChanged {
viewModel.lastCardStatus = .entering
Expand All @@ -46,20 +45,20 @@ public struct RECreditCardInputUI: View {
viewModel.lastCardStatus = viewModel.cardStatus
}
}

public var body: some View {

HStack(alignment: .center, spacing: 0){
Image(viewModel.mainImageName, bundle: Bundle(identifier: "recurly.RecurlySDK-iOS"))

Image(viewModel.mainImageName)
.resizable()
.frame(width: 40, height: 26, alignment: .center)
.aspectRatio(contentMode: .fit)
.padding(.vertical, 12)
.padding(.leading, 12)
.rotation3DEffect(.degrees(viewModel.rotation), axis: (x: 1, y: 0, z: 0))
.animation(.easeIn, value: viewModel.rotation)



REPlaceholderTextField(placeholder: cardNumberPlaceholder,
mainText: $viewModel.cardNumber,
onEditingChanged: didOnEditingChanged(editingChanged:),
Expand All @@ -79,7 +78,7 @@ public struct RECreditCardInputUI: View {
viewModel.cardNumber = String(viewModel.cardNumber.prefix(cardLenght))
}
}

REPlaceholderTextField(placeholder: expDatePlaceholder, mainText: $viewModel.expDate, textFieldFont: textFieldFont, titleLabelFont: titleLabelFont)
.keyboardType(.numberPad)
.frame(width: 70, alignment: .leading)
Expand All @@ -93,7 +92,7 @@ public struct RECreditCardInputUI: View {
viewModel.expDate = String(viewModel.expDate.prefix(5))
}
})

REPlaceholderTextField(placeholder: cvvPlaceholder, mainText: $viewModel.cvv, onEditingChanged: { (editingChanged) in
viewModel.cvvFocus = editingChanged
}, textFieldFont: textFieldFont, titleLabelFont: titleLabelFont)
Expand All @@ -112,7 +111,7 @@ public struct RECreditCardInputUI: View {
viewModel.cvv = String(viewModel.cvv.prefix(cvvLenght))
}
})

}.frame(height: 50)
.background(
RoundedRectangle(cornerRadius: 10)
Expand Down
6 changes: 2 additions & 4 deletions RecurlySDK-iOSTests/RecurlySDK-iOSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ class RecurlySDK_iOSTests: XCTestCase {
state: "Florida",
postalCode: "33101",
phone: "555-555-5555",
vatNumber: "",
taxIdentifier: "",
taxIdentifierType: ""
vatNumber: ""
)
)
RETokenizationManager.shared.cardData.number = "4111111111111111"
RETokenizationManager.shared.cardData.month = "12"
RETokenizationManager.shared.cardData.year = "2022"
RETokenizationManager.shared.cardData.year = "2030"
RETokenizationManager.shared.cardData.cvv = "123"
}

Expand Down
4 changes: 3 additions & 1 deletion RecurlySDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "RecurlySDK"
s.version = ENV['LIB_VERSION'] || "2.0.0"
s.version = ENV['LIB_VERSION'] || "2.0.1"
s.summary = "Integrate recurrent payments in your iOS app in a matter of minutes."

s.homepage = "https://dev.recurly.com/docs/client-libraries"
Expand All @@ -12,6 +12,8 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/recurly/recurly-client-ios.git", :tag => "v#{s.version}" }
s.source_files = 'RecurlySDK-iOS/**/*.{h,m,swift}'

s.resources = 'RecurlySDK-iOS/Resources/**/*.{ttf,xcassets}'

s.frameworks = 'UIKit', 'Foundation', 'Security', 'CoreGraphics', 'QuartzCore', 'PassKit', 'AddressBook', 'CoreTelephony'
s.requires_arc = true

Expand Down