@@ -15,47 +15,49 @@ struct SubscriptionView: View {
15
15
let privacyPolicy = URL ( string: " https://wangchujiang.com/copybook-generator/privacy-policy.html " ) !
16
16
let termsOfService = URL ( string: " https://wangchujiang.com/copybook-generator/terms-of-service.html " ) !
17
17
var body : some View {
18
- if !subscriptions. products. isEmpty {
19
- VStack {
20
- SubscriptionStoreView ( productIDs: subscriptions. productIDs)
21
- . storeButton ( . visible, for: . policies)
22
- . subscriptionStorePolicyDestination ( url: privacyPolicy, for: . privacyPolicy)
23
- . subscriptionStorePolicyDestination ( url: termsOfService, for: . termsOfService)
24
- . onInAppPurchaseCompletion ( perform: { product, result in
25
- if case . success( . success( let transaction) ) = result {
26
- print ( " Purchased successfully: \( transaction. signedDate) " )
27
- await subscriptions. updatePurchasedProducts ( )
18
+ NavigationStack {
19
+ if !subscriptions. products. isEmpty {
20
+ VStack {
21
+ SubscriptionStoreView ( productIDs: subscriptions. productIDs)
22
+ . storeButton ( . visible, for: . policies)
23
+ . subscriptionStorePolicyDestination ( url: privacyPolicy, for: . privacyPolicy)
24
+ . subscriptionStorePolicyDestination ( url: termsOfService, for: . termsOfService)
25
+ . onInAppPurchaseCompletion ( perform: { product, result in
26
+ if case . success( . success( let transaction) ) = result {
27
+ print ( " Purchased successfully: \( transaction. signedDate) " )
28
+ await subscriptions. updatePurchasedProducts ( )
29
+ dismiss ( )
30
+ } else {
31
+ print ( " Something else happened " )
32
+ }
33
+ } )
34
+ Button ( action: {
35
+ Task {
36
+ await subscriptions. restorePurchases ( )
28
37
dismiss ( )
29
- } else {
30
- print ( " Something else happened " )
31
38
}
39
+ } , label: {
40
+ Text ( " Restore Subscription " )
32
41
} )
33
- Button ( action: {
34
- Task {
35
- await subscriptions. restorePurchases ( )
36
- dismiss ( )
42
+ #if os(macOS)
43
+ . buttonStyle( . link)
44
+ #endif
45
+ . offset( y: - 22 )
46
+ }
47
+ . background ( . background)
48
+ . frame ( minWidth: 320 , minHeight: 580 )
49
+ . frame ( maxWidth: 450 )
50
+ } else {
51
+ VStack {
52
+ if message. isEmpty {
53
+ ProgressView ( ) . progressViewStyle ( . circular) . scaleEffect ( 1 ) . ignoresSafeArea ( . all)
54
+ } else {
55
+ Text ( message) . foregroundStyle ( . red)
37
56
}
38
- } , label: {
39
- Text ( " Restore Subscription " )
40
- } )
41
- #if os(macOS)
42
- . buttonStyle( . link)
43
- #endif
44
- . offset( y: - 22 )
45
- }
46
- . background ( . background)
47
- . frame ( minWidth: 320 , minHeight: 580 )
48
- . frame ( maxWidth: 450 )
49
- } else {
50
- VStack {
51
- if message. isEmpty {
52
- ProgressView ( ) . progressViewStyle ( . circular) . scaleEffect ( 1 ) . ignoresSafeArea ( . all)
53
- } else {
54
- Text ( message) . foregroundStyle ( . red)
55
57
}
58
+ . padding ( . horizontal)
59
+ . frame ( minWidth: 230 , minHeight: 120 )
56
60
}
57
- . padding ( . horizontal)
58
- . frame ( minWidth: 230 , minHeight: 120 )
59
61
}
60
62
}
61
63
}
0 commit comments