-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67c98b4
commit c250b29
Showing
5 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
Sources/FlareUI/FlareUI.docc/Articles/creating-custom-product-style.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Creating a Custom Product Style | ||
|
||
Learn how to create a custom style for a product. | ||
|
||
## Custom Product Style | ||
|
||
The `FlareUI` provides a simple way to customize the appearance of the products. For this, you need to implement an object that conforms to ``IProductStyle`` and pass it to ``SwiftUI/View/productViewStyle(_:)`` or ``SwiftUI/View/productViewStyle(_:)``. | ||
|
||
> note: You can use one of the predefined styles that are optimized for various platforms: ``LargeProductStyle`` and ``CompactProductStyle``. | ||
Based on the ``ProductStyleConfiguration/State-swift.enum`` enum, you can define different views to display for various states. | ||
|
||
```swift | ||
struct CustomProductStyle: IProductStyle { | ||
func makeBody(configuration: Configuration) -> some View { | ||
switch configuration.state { | ||
case .loading: | ||
// Provide a custom loader view | ||
case let .product(product): | ||
// Provide a custom view that displays the product's info | ||
case let .error(error): | ||
// Provide a view for displaying an error to a user. | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Custom Subscription Style | ||
|
58 changes: 58 additions & 0 deletions
58
Sources/FlareUI/FlareUI.docc/Articles/displaying-products.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Displaying Products | ||
|
||
Learn how to display a set of products to a user. | ||
|
||
## Overview | ||
|
||
The `FlareUI` provides an easy way to display different kinds of products with a single line of code. To display a set of products to the user, just pass a collection of identifiers to the ``ProductsView``. | ||
|
||
```swift | ||
ProductsView(ids: ["com.company.product_id_1", "com.company.product_id_2"]) | ||
``` | ||
|
||
Once `ProductsView` fetches these products from the App Store, it will display them to the user. If the products can't be fetched for any reason, the `ProductsView` shows a message to the user that the App Store is not available. | ||
|
||
> important: By default, all Flare views use cached data if available; otherwise, they fetch the data. If you want to change this behavior, please read more about Flare configuration [here](link). | ||
## UIKit | ||
|
||
The `FlareUI` package provides wrappers for the UIKit views. It can be easily integrated into UIKit environments using ``ProductsViewController``. | ||
|
||
```swift | ||
let productsVC = ProductsViewController(ids: ["com.company.product_id_1", "com.company.product_id_2"]) | ||
let nav = UINavigationController(rootViewController: productsVC) | ||
present(nav, animated: true) | ||
``` | ||
|
||
The `ProductsViewController` is backed by `ProductsView`, and its behavior is the same. | ||
|
||
## Customization | ||
|
||
The appearance of the displayed products can be customized using ``SwiftUI/View/productViewStyle(_:)``. There are predefined styles for different platforms: ``LargeProductStyle``, ``CompactProductStyle``. | ||
|
||
You can also create your own style. For this, please, read [How to Create a Custom Product Style](<doc:creating-custom-product-style>). | ||
|
||
## Custom Buttons | ||
|
||
If you have restorable products, the `ProductsView` can show a restore button to the customer. For this, you can use ``SwiftUI/View/storeButton(_:types:)-4x8yd`` or ``ProductsViewController/storeButton(_:types:)``. | ||
|
||
```swift | ||
// SwiftUI | ||
|
||
ProductsView(ids: ["com.company.product_id_1", "com.company.product_id_2"]) | ||
.storeButton(.visible, types: .restore) | ||
``` | ||
|
||
```swift | ||
// UIKit | ||
|
||
let productsVC = ProductsViewController(ids: ["com.company.product_id_1", "com.company.product_id_2"]) | ||
productsVC.storeButton(.visible, types: [.restore]) | ||
``` | ||
|
||
## Topics | ||
|
||
### Articles | ||
|
||
- <doc:creating-custom-product-style> | ||
- <doc:handling-transactions> |
3 changes: 3 additions & 0 deletions
3
Sources/FlareUI/FlareUI.docc/Articles/displaying-subscriptions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Displaying Subscriptions | ||
|
||
Learn how to display a set of subscriptions to a user. |
19 changes: 19 additions & 0 deletions
19
Sources/FlareUI/FlareUI.docc/Articles/handling-transactions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Handling Transactions | ||
|
||
Learn how to handle transactions. | ||
|
||
## Overview | ||
|
||
If you have restorable products, the `ProductsView` can show a restore button to the customer. For this, you can use ``SwiftUI/View/onInAppPurchaseCompletion(completion:)`` or ``ProductsViewController/onInAppPurchaseCompletion``. | ||
|
||
```swift | ||
ProductsView(ids: ["com.company.product_id_1", "com.company.product_id_2"]) | ||
.onInAppPurchaseCompletion { result in | ||
switch result { | ||
case let .success(transaction): | ||
// Handle the transaction | ||
case let .failure(error): | ||
// Handle the error | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters