Merge branch 'main'

#Conflicts:
#	PadelClub.xcodeproj/project.pbxproj
xcode16
Razmig Sarkissian 1 year ago
commit fdfaebe44c
  1. 2
      PadelClub.xcodeproj/xcshareddata/xcschemes/PadelClub.xcscheme
  2. 3
      PadelClub/AppDelegate.swift
  3. 2
      PadelClub/Data/DataStore.swift
  4. 6
      PadelClub/Utils/URLs.swift
  5. 40
      PadelClub/Views/Navigation/Umpire/UmpireView.swift
  6. 33
      PadelClub/Views/Tournament/Subscription/Guard.swift

@ -74,7 +74,7 @@
</BuildableReference>
</BuildableProductRunnable>
<StoreKitConfigurationFileReference
identifier = "../../PadelClub/SyncedProducts.storekit">
identifier = "../PadelClub/SyncedProducts.storekit">
</StoreKitConfigurationFileReference>
</LaunchAction>
<ProfileAction

@ -14,6 +14,9 @@ class AppDelegate : NSObject, UIApplicationDelegate, UNUserNotificationCenterDel
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
_ = Guard.main // init guard
UIApplication.shared.registerForRemoteNotifications()
UNUserNotificationCenter.current().delegate = self

@ -68,8 +68,6 @@ class DataStore: ObservableObject {
var synchronized: Bool = true
_ = Guard.main // init
#if DEBUG
if let sync = PListReader.readBool(plist: "local", key: "synchronized") {
synchronized = sync

@ -9,9 +9,15 @@ import Foundation
enum URLs: String, Identifiable {
#if DEBUG
case activationHost = "xlr.alwaysdata.net"
case main = "https://xlr.alwaysdata.net/"
case api = "https://xlr.alwaysdata.net/roads/"
#else
case activationHost = "padelclub.app"
case main = "https://padelclub.app/"
case api = "https://padelclub.app/roads/"
#endif
case subscriptions = "https://apple.co/2Th4vqI"
case beachPadel = "https://beach-padel.app.fft.fr/beachja/index/"

@ -16,6 +16,7 @@ struct UmpireView: View {
@State private var presentSearchView: Bool = false
@State private var showSubscriptions: Bool = false
@State private var showProductIds: Bool = false
// @State var isConnected: Bool = false
@ -36,7 +37,20 @@ struct UmpireView: View {
self.showSubscriptions = true
} label: {
Label("Les offres", systemImage: "bookmark.fill")
}
}.simultaneousGesture(
LongPressGesture()
.onEnded { _ in
self.showProductIds = true
}
)
.highPriorityGesture(
TapGesture()
.onEnded { _ in
self.showSubscriptions = true
}
)
}
}
@ -161,6 +175,9 @@ struct UmpireView: View {
.environment(\.colorScheme, .light)
}
})
.sheet(isPresented: self.$showProductIds, content: {
ProductIdsView()
})
.sheet(isPresented: $presentSearchView) {
let user = dataStore.user
NavigationStack {
@ -228,6 +245,27 @@ struct AccountRowView: View {
}
}
struct ProductIdsView: View {
@State var ids: [String] = []
var body: some View {
VStack {
List {
LabeledContent("count", value: String(ids.count))
ForEach(self.ids) { id in
Text(id)
}
}.onAppear {
Task {
self.ids = await Guard.main.productIds()
}
}
}
}
}
//#Preview {
// UmpireView()
//}

@ -18,7 +18,7 @@ import LeStorage
var currentBestPlan: StoreKit.Transaction? = nil
var updateListenerTask: Task<Void, Error>? = nil
var updateListenerTask: Task<Void, Never>? = nil
fileprivate(set) var purchases: StoredCollection<Purchase>
@ -39,6 +39,23 @@ import LeStorage
}
}
deinit {
self.updateListenerTask?.cancel()
}
func productIds() async -> [String] {
var productIds: [String] = []
for await result in Transaction.all {
do {
let verified = try self.checkVerified(result)
productIds.append(verified.productID)
} catch {
Logger.error(error)
}
}
return productIds
}
func refreshPurchasedAppleProducts() async throws {
// Iterate through the user's purchased products.
@ -51,10 +68,11 @@ import LeStorage
}
}
func listenForTransactions() -> Task<Void, Error> {
return Task.detached {
func listenForTransactions() -> Task<Void, Never> {
return Task(priority: .background) {
//Iterate through any transactions which didn't come from a direct call to `purchase()`.
for await result in Transaction.updates {
Logger.log(">>> update = \(result)")
do {
let transaction = try self.checkVerified(result)
@ -140,7 +158,14 @@ import LeStorage
}
var currentPlan: StoreItem? {
return .monthlyUnlimited
#if DEBUG
return .monthlyUnlimited
#else
if let currentBestPlan = self.currentBestPlan, let plan = StoreItem(rawValue: currentBestPlan.productID) {
return plan
}
return nil
#endif
}
func userFilteredPurchases() -> [StoreKit.Transaction] {

Loading…
Cancel
Save