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 #33

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ let package = Package(
),
.binaryTarget(name: "TyroTapToPaySDK",
url: "https://tap-to-pay.connect.tyro.com/tyro/0.12.0/TyroTapToPaySDK.xcframework.zip",
checksum: "282a22d834215a2a42b16dce36817409a40b2f17a36cb0867215c3570556a506"),
checksum: "ce4a9c3d006f17fcee16cb13bfb4edaa3b912fe8b948aec22bc5d982ae1332c3"),
linkrjr marked this conversation as resolved.
Show resolved Hide resolved
.binaryTarget(name: "MobileConfiguration",
url: "https://tap-to-pay.connect.tyro.com/ss/1.0.8.0/SSMobileConfiguration.xcframework.zip",
checksum: "ee6a8513480b8c39125eab131e9df5e223d63e3005dbf34b52f36734f719b115"),
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
113 changes: 86 additions & 27 deletions SampleApp/SampleApp/SampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,92 @@ 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()
.preferredColorScheme(.light)
.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)
.foregroundColor(.black)
}.fullScreenCover(isPresented: $isSettingsPresented) {
TyroSettingsView()
}
}.padding()
ContentView(viewModel: contentViewModel)
}.navigationTitle("")
}.tabItem {
Label("Home", systemImage: "house")
}.tag(0)

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

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

extension TyroTapToPay: ObservableObject {
Expand Down
Loading