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

changes to accomodate the new settings area #34

Merged
merged 4 commits into from
Jun 7, 2024
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
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