Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
mickmaccallum committed Oct 7, 2024
1 parent 8617634 commit fac890e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 46 deletions.
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/Shopify/mobile-buy-sdk-ios", from: "13.0.0"),
.package(url: "https://github.com/Shopify/checkout-sheet-kit-swift", from: "3.0.4")
// .package(url: "https://github.com/Shopify/mobile-buy-sdk-ios", from: "13.0.0"),
// .package(url: "https://github.com/Shopify/checkout-sheet-kit-swift", from: "3.0.4")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand All @@ -46,8 +46,8 @@ let package = Package(
name: "ParraStorefront",
dependencies: [
.target(name: "Parra"),
.product(name: "Buy", package: "mobile-buy-sdk-ios"),
.product(name: "ShopifyCheckoutSheetKit", package: "checkout-sheet-kit-swift")
// .product(name: "Buy", package: "mobile-buy-sdk-ios"),
// .product(name: "ShopifyCheckoutSheetKit", package: "checkout-sheet-kit-swift")
],
path: "\(iosSdkDir)/Sources/ParraStorefront",
resources: [
Expand Down
85 changes: 43 additions & 42 deletions ios/Sources/ParraStorefront/ParraStorefrontWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@
// Created by Mick MacCallum on 10/6/24.
//

import Buy
import Parra
import ShopifyCheckoutSheetKit
import SwiftUI

// import Buy
// import ShopifyCheckoutSheetKit

public struct ParraStorefrontWidget: View {
// MARK: - Lifecycle

public init() {
let client = Graph.Client(
shopDomain: "",
apiKey: ""
)

client.cachePolicy = .cacheFirst(expireIn: 3_600)
self.client = client
// let client = Graph.Client(
// shopDomain: "",
// apiKey: ""
// )
//
// client.cachePolicy = .cacheFirst(expireIn: 3_600)
// self.client = client
}

// MARK: - Public
Expand All @@ -29,47 +30,47 @@ public struct ParraStorefrontWidget: View {
Text("Hello, World!")
Text(parraAuthState.user?.info.displayName ?? "idk")

Button("Store stuff") {
_Concurrency.Task {
do {
let q = Storefront.buildQuery { $0
.product { $0
}
}
try await performQuery(q)
} catch {}
}
}
// Button("Store stuff") {
// _Concurrency.Task {
// do {
// let q = Storefront.buildQuery { $0
// .product { $0
// }
// }
// try await performQuery(q)
// } catch {}
// }
// }
}

// MARK: - Internal

let client: Graph.Client
// let client: Graph.Client

@Environment(\.parra) var parra
@Environment(\.parraAuthState) var parraAuthState

func performQuery(
_ query: Storefront.QueryRootQuery
) async throws -> Storefront.QueryRoot {
return try await withCheckedThrowingContinuation { continuation in
let task = client.queryGraphWith(query) { response, error in
if let error {
continuation.resume(
throwing: error
)
} else if let response {
continuation.resume(
returning: response
)
} else {
// func performQuery(
// _ query: Storefront.QueryRootQuery
// ) async throws -> Storefront.QueryRoot {
// return try await withCheckedThrowingContinuation { continuation in
// let task = client.queryGraphWith(query) { response, error in
// if let error {
// continuation.resume(
// throwing:
// throwing: error
// )
}
}

task.resume()
}
}
// } else if let response {
// continuation.resume(
// returning: response
// )
// } else {
//// continuation.resume(
//// throwing:
//// )
// }
// }
//
// task.resume()
// }
// }
}

0 comments on commit fac890e

Please sign in to comment.