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

Add fastlane + github workflow for building example app #2

Merged
merged 7 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build Example Apps

on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
build:
name: "Build Example App"
runs-on: macos-13
strategy:
max-parallel: 2
matrix:
project: [
{ name: 'Co-Badged Cards', path: 'Co-Badged Cards/SwiftUI/Co-Badged Cards Example.xcodeproj' }
]
steps:
- name: Cancel previous jobs
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}
- name: Git - Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
- name: Select Xcode Version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.0'
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: true
- name: Build with fastlane
run: |
bundle exec fastlane ios build_example_app "scheme:${{ matrix.project.scheme }}" "project_path:${{ matrix.project.path }}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
xcuserdata
fastlane/README.md
fastlane/report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 60;
objectVersion = 56;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -27,6 +27,7 @@
04420E792B14A84500EA8790 /* ExampleAppLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04420E782B14A84500EA8790 /* ExampleAppLogger.swift */; };
0471BB072AFD1FFB000B286D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0471BB062AFD1FFB000B286D /* ContentView.swift */; };
0479FB1B2AF270B900D0AFC9 /* PrimerDataService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0479FB1A2AF270B900D0AFC9 /* PrimerDataService.swift */; };
049A69572B485EE20027E644 /* PrimerSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 049A69562B485EE20027E644 /* PrimerSDK */; };
04AFFEE72B02797A002B2019 /* StartPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04AFFEE62B02797A002B2019 /* StartPage.swift */; };
04D06A332B45945500C6141C /* PrimerSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 04D06A322B45945500C6141C /* PrimerSDK */; };
04D781562AF517BD00A3B29B /* ImageColorInverterModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04D781552AF517BD00A3B29B /* ImageColorInverterModifier.swift */; };
Expand Down Expand Up @@ -108,7 +109,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
04D06A332B45945500C6141C /* PrimerSDK in Frameworks */,
049A69572B485EE20027E644 /* PrimerSDK in Frameworks */,
04FAFA252AE816EF002E4BAE /* PrimerSDK in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -312,7 +313,7 @@
name = "Co-Badged Cards Example";
packageProductDependencies = (
04FAFA242AE816EF002E4BAE /* PrimerSDK */,
04D06A322B45945500C6141C /* PrimerSDK */,
049A69562B485EE20027E644 /* PrimerSDK */,
);
productName = "Co-Badged Cards Example";
productReference = 04FAF9F62AE81563002E4BAE /* Co-Badged Cards Example.app */;
Expand Down Expand Up @@ -387,7 +388,7 @@
);
mainGroup = 04FAF9ED2AE81563002E4BAE;
packageReferences = (
04D06A342B45946600C6141C /* XCLocalSwiftPackageReference "../../../sdk-co-badged-cards" */,
049A69552B485EE20027E644 /* XCRemoteSwiftPackageReference "primer-sdk-ios" */,
);
productRefGroup = 04FAF9F72AE81563002E4BAE /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -804,16 +805,21 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
04D06A342B45946600C6141C /* XCLocalSwiftPackageReference "../../../sdk-co-badged-cards" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = "../../../sdk-co-badged-cards";
/* Begin XCRemoteSwiftPackageReference section */
049A69552B485EE20027E644 /* XCRemoteSwiftPackageReference "primer-sdk-ios" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/primer-io/primer-sdk-ios.git";
requirement = {
branch = "feature/co-badged-cards";
kind = branch;
};
};
/* End XCLocalSwiftPackageReference section */
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
04D06A322B45945500C6141C /* PrimerSDK */ = {
049A69562B485EE20027E644 /* PrimerSDK */ = {
isa = XCSwiftPackageProductDependency;
package = 049A69552B485EE20027E644 /* XCRemoteSwiftPackageReference "primer-sdk-ios" */;
productName = PrimerSDK;
};
04FAFA242AE816EF002E4BAE /* PrimerSDK */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"revision" : "f13260c24a900f28e21bafd213c22191e6280e86",
"version" : "1.0.4"
}
},
{
"identity" : "primer-sdk-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/primer-io/primer-sdk-ios.git",
"state" : {
"branch" : "feature/co-badged-cards",
"revision" : "a377605b21637814372ed98c025031907d7964bf"
}
}
],
"version" : 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PrimerBaseCardDataModel: ObservableObject {

@Published var cardholderName: String = ""

@Published var selectedCardNetwork: String = ""
@Published var selectedCardNetwork: CardNetwork = .unknown

var isCardNumberFormatted: Bool {
return (try? /(?:\d{4}+\s)*(?:\d{0,4})?/.wholeMatch(in: cardNumber)) != nil
Expand All @@ -43,6 +43,10 @@ class PrimerCardDataModel: PrimerBaseCardDataModel {

weak var service: PrimerDataService?

func selectCardNetwork(at index: Int) {
selectedCardNetwork = cardNetworkModels[index].value
}

override init() {
super.init()
logger.info("[PrimerCardDataModel.init]")
Expand Down Expand Up @@ -73,7 +77,7 @@ class PrimerCardDataErrorsModel: PrimerBaseCardDataModel {
self.expiryDate = ""
self.cvvNumber = ""
self.cardholderName = ""
self.selectedCardNetwork = ""
self.selectedCardNetwork = .unknown
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class PrimerDataService: NSObject {
expiryDate: model.expiryDate,
cvv: model.cvvNumber,
cardholderName: model.cardholderName,
cardNetworkIdentifier: model.selectedCardNetwork.isEmpty ? nil : model.selectedCardNetwork // JN TODO: move logic to SDK? Pretty sure
cardNetwork: model.selectedCardNetwork == .unknown ? nil : model.selectedCardNetwork
)
}

Expand Down Expand Up @@ -206,7 +206,10 @@ extension PrimerDataService: PrimerHeadlessUniversalCheckoutRawDataManagerDelega
.enumerated()
.map { index, model in
// JN TODO: should be getting image from the asset manager
CardDisplayModel(index: index, name: model.displayName, image: mapImageName(model))
CardDisplayModel(index: index,
name: model.displayName,
image: mapImageName(model),
value: model.network)
}
modelsDelegate?.didReceiveCardModels(models: models)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct CardDetailsFormView: View {

@State var isMakingPayment: Bool = false

@State var selectedCardNetworkIndex: Int? = nil

var body: some View {
VStack(spacing: 4) {
HStack(alignment: .bottom, spacing: 4) {
Expand All @@ -28,11 +30,12 @@ struct CardDetailsFormView: View {
errorMessage: $errors.cardNumber
)
if model.shouldDisplayCardSelectionView {
CardSelectionView(cards: $model.cardNetworkModels)
.frame(height: 45)
// Align with text field - account for border (1)
.padding(.bottom, errors.cardNumber.isEmpty ? 1 : 19)
.padding(.trailing, 8)
CardSelectionView(cards: $model.cardNetworkModels) { index in
}
.frame(height: 45)
// Align with text field - account for border (1)
.padding(.bottom, errors.cardNumber.isEmpty ? 1 : 19)
.padding(.trailing, 8)
}
}
HStack(spacing: 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
//

import SwiftUI
import PrimerSDK

struct CardDisplayModel {
let index: Int
let name: String
let image: String

let value: CardNetwork

var uiImage: UIImage {
if let image = UIImage(named: image) {
return image
Expand Down Expand Up @@ -50,6 +53,8 @@ struct CardSelectionView: View {

@State var selectedIndex: Int = 0

let onChange: (Int?) -> Void

var body: some View {
HStack(spacing: 4) {
ForEach(cards, id: \.name) { card in
Expand All @@ -70,7 +75,7 @@ struct CardSelectionView: View {

#Preview {
CardSelectionView(cards: .constant([
CardDisplayModel(index: 0, name: "MasterCard", image: "MasterCard"),
CardDisplayModel(index: 1, name: "VISA", image: "Visa")
]))
CardDisplayModel(index: 0, name: "MasterCard", image: "MasterCard", value: .masterCard),
CardDisplayModel(index: 1, name: "VISA", image: "Visa", value: .visa)
])) { _ in }
}
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gem "fastlane"
Loading