Skip to content

Commit

Permalink
PLA-6873: Changes to accomodate the new settings area (#34)
Browse files Browse the repository at this point in the history
* changes to accomodate the new settings area

* update the framework checksum

* reverted the checksum and changed the UI to respect color scheme (light/dark modes)

* included KeychainAccess

---------

Co-authored-by: Ronaldo Gomes <[email protected]>
  • Loading branch information
linkrjr and Ronaldo Gomes authored Jun 7, 2024
1 parent 21f5f6d commit 4bafee5
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 29 deletions.
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/krzyzanowskim/OpenSSL.git", .upToNextMinor(from: "3.1.4000")),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0")
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
.package(url: "https://github.com/kishikawakatsumi/KeychainAccess.git", from: "4.2.2")
],
targets: [
.target(name: "TyroTapToPaySDKPackage",
dependencies: [
.product(name: "OpenSSL", package: "OpenSSL"),
.product(name: "KeychainAccess", package: "KeychainAccess"),
.target(name: "TyroTapToPaySDK"),
.target(name: "MobileMPOSSDK"),
.target(name: "MobileConfiguration"),
Expand All @@ -37,7 +39,7 @@ let package = Package(
.target(name: "TrustKit"),
.target(name: "VisaSensoryBranding"),
]
),
),
.binaryTarget(name: "TyroTapToPaySDK",
url: "https://tap-to-pay.connect.tyro.com/tyro/0.12.0/TyroTapToPaySDK.xcframework.zip",
checksum: "282a22d834215a2a42b16dce36817409a40b2f17a36cb0867215c3570556a506"),
Expand Down
9 changes: 9 additions & 0 deletions SampleApp/SampleApp/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
},
"Actions" : {

},
"Admin" : {

},
"ALERT_BTN_OK" : {
"extractionState" : "manual",
Expand Down Expand Up @@ -40,6 +43,9 @@
},
"Email" : {

},
"Home" : {

},
"Outcome: %@" : {

Expand All @@ -61,6 +67,9 @@
},
"Transact" : {

},
"Tyro Settings" : {

}
},
"version" : "1.0"
Expand Down
111 changes: 84 additions & 27 deletions SampleApp/SampleApp/SampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,90 @@ import TyroTapToPaySDK

@main
struct SampleApp: App {
@Environment(\.scenePhase) private var scenePhase: ScenePhase
@ObservedObject var tapToPaySdk: TyroTapToPay
private var contentViewModel: ContentViewModel

init() {
do {
let tapToPaySdk = try TyroTapToPay(
environment: .sandbox,
connectionProvider: DemoConnectionProvider()
)
contentViewModel = ContentViewModel(tapToPaySdk: tapToPaySdk)
self.tapToPaySdk = tapToPaySdk
} catch {
fatalError(error.localizedDescription)
}
}

var body: some Scene {
WindowGroup {
Image(.tyroLogo)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 100)
.padding()
ContentView(viewModel: contentViewModel)
}
}
var body: some Scene {
WindowGroup {
Home()
.navigationBarHidden(true)
}
}
}

struct Home : View {
@Environment(\.scenePhase) private var scenePhase: ScenePhase
@ObservedObject var tapToPaySdk: TyroTapToPay
private var contentViewModel: ContentViewModel

@State private var isSettingsPresented = false

@State private var selectedIndex: Int = 0;

init() {
do {
let tapToPaySdk = try TyroTapToPay(
environment: .sandbox,
connectionProvider: DemoConnectionProvider()
)
contentViewModel = ContentViewModel(tapToPaySdk: tapToPaySdk)
self.tapToPaySdk = tapToPaySdk
} catch {
fatalError(error.localizedDescription)
}
}

var body: some View {
TabView(selection: $selectedIndex) {
NavigationStack {
VStack {
HStack {
Spacer(minLength: 0)
Image(.tyroLogo)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 100)
.padding()
Spacer(minLength: 0)
Button(action: {
isSettingsPresented.toggle()
}) {
Image(systemName: "gear")
.renderingMode(.template)
.resizable()
.frame(width: 25, height: 25)

}.fullScreenCover(isPresented: $isSettingsPresented) {
TyroSettingsViewWrapper()
}
}.padding()
ContentView(viewModel: contentViewModel)
}.navigationTitle("")
}.tabItem {
Label("Home", systemImage: "house")
}.tag(0)

NavigationStack {
TyroSettingsView().navigationTitle("Tyro Settings")
}.tabItem {
Label("Admin", systemImage: "gear")
}.tag(1)
}
}
}

struct TyroSettingsViewWrapper: View {
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
ZStack {
TyroSettingsView()
}.toolbar(content: {
Button {
dismiss()
} label: {
Image(systemName: "xmark")
}
})
}
}
}

extension TyroTapToPay: ObservableObject {
Expand Down

0 comments on commit 4bafee5

Please sign in to comment.