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

iOS: Update plugin documentation #284

Merged
merged 4 commits into from
Jan 31, 2024
Merged
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
17 changes: 15 additions & 2 deletions docs/site/pages/plugins/beacon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ interface DefaultBeacon {
}
```

## Usage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this should be the standard nomenclature for all plugin docs, I think Expression is missing this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be there for expression


<PlatformTabs>
<core>

Expand Down Expand Up @@ -94,6 +96,15 @@ This will add additional React Context to the running player for the producers f
</react>
<ios>

### CocoaPods
Add the subspec to your `Podfile`

```ruby
pod 'PlayerUI/BeaconPlugin'
```

### Swift Usage

To receive Beacon events from Player in iOS, add the `BeaconPlugin` to your plugin array:

```swift
Expand All @@ -102,7 +113,7 @@ var body: some View {
flow: flow,
plugins: [
BeaconPlugin<DefaultBeacon> { (beacon: DefaultBeacon) in
// Process beacon into the format you need for Segment/Trinity and send it on
// Process beacon into the format you need for your analytics platform
}
]
)
Expand Down Expand Up @@ -264,6 +275,8 @@ export const Component = (props) => {
</react>
<ios>

The SwiftUIBeaconPlugin attaches a BeaconContext to the root of the SwiftUI view tree as an environment value, so when included any asset can use that context to send a beacon, if the context is in the environment:

```swift
struct ActionAssetView: View {
@ObservedObject var viewModel: AssetViewModel<ActionData>
Expand All @@ -275,4 +288,4 @@ struct ActionAssetView: View {
```

</ios>
</PlatformTabs>
</PlatformTabs>
52 changes: 52 additions & 0 deletions docs/site/pages/plugins/check-path.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ const rp = new ReactPlayer({
This will automatically create the underlying _core_ version of the `CheckPathPlugin` to be made available via `React` Context for the hooks.

</react>

<ios>

### CocoaPods

Add the subspec to your `Podfile`

```ruby
pod 'PlayerUI/SwiftUICheckPathPlugin'
```

### Swift Usage

This plugin takes no parameters, and the configuration comes from content, it can just be added to the plugin array:

```swift
var body: some View {
SwiftUIPlayer(
flow: flow,
plugins: [
SwiftUICheckPathPlugin()
],
result: $resultBinding
)
}
```
</ios>

</PlatformTabs>


Expand Down Expand Up @@ -149,6 +177,30 @@ export const MyAsset = ({ id }) => {
```

</react>
<ios>

### Swift Usage

The SwiftUICheckPathPlugin attaches the `BaseCheckPathPlugin` named `checkPath` to the root of the SwiftUI view tree as an environment value, so when included any asset can use that environment value to access the base functionality

```swift

struct MyAsset: View {
@ObservedObject var viewModel: AssetViewModel<AssetData>
@Environment(\.checkPath) var checkPath

var body: some View {
let isInForm = checkPath?.hasParentContext(id: viewModal.data.id, query: "form")
if isInForm {
SelectChoice()
} else {
RadioGroup()
}
}

```
</ios>

</PlatformTabs>


58 changes: 58 additions & 0 deletions docs/site/pages/plugins/common-expressions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,64 @@ This plugin exposes some basic expressions into Player content.

It also serves as a good reference to adding your own custom expressions into Player.

## Usage

<PlatformTabs>
<core>

Install the plugin:

```bash
yarn add @player-ui/common-types-plugin
```

Add it to Player:
```js
import CommonExpressionsPlugin from '@player-ui/common-expressions-plugin';

const commonExpressionsPlugin = new CommonExpressionsPlugin();
const player = new Player({ plugins: [commonExpressionsPlugin] });

// Start your flow
player.start(myFlow);
```

This will allow any included expressions or custom expressions to be used in the content

</core>

<ios>

### CocoaPods

Add the subspec to your `Podfile`

```ruby

pod 'PlayerUI/CommonExpressionsPlugin'

```

### Swift Usage

This plugin takes no parameters, and the configuration comes from content, it can just be added to the plugin array:

```swift

var body: some View {
SwiftUIPlayer(
flow: flow,
plugins: [
CommonExpressionsPlugin()
],
result: $resultBinding
)
}
```
</ios>

</PlatformTabs>

---

## General
Expand Down
62 changes: 60 additions & 2 deletions docs/site/pages/plugins/common-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,65 @@ This plugin exposes some basic `DataTypes`, `validations`, and `formats` into Pl

It also serves as a good reference to adding your own custom types into Player.

---
## Usage

<PlatformTabs>
<core>

Install the plugin:

```bash
yarn add @player-ui/common-types-plugin
```

Add it to Player:
```js
import CommonTypesPlugin from '@player-ui/common-types-plugin';

const commonTypesPlugin = new CommonTypesPlugin();
const player = new Player({ plugins: [commonTypesPlugin] });

// Start your flow
player.start(myFlow);
```

This will allow any `DataTypes`, `formats`, `validations` and custom data types to be used in the content

</core>

<ios>

### CocoaPods

Add the subspec to your `Podfile`

```ruby

pod 'PlayerUI/CommonTypesPlugin'

```

### Swift Usage

This plugin takes no parameters, and the configuration comes from content, it can just be added to the plugin array:

```swift

var body: some View {
SwiftUIPlayer(
flow: flow,
plugins: [
CommonTypesPlugin()
],
result: $resultBinding
)
}
```

</ios>

</PlatformTabs>


## Formats

Expand Down Expand Up @@ -313,4 +371,4 @@ Options:
> A value representing a phone number

* **validations**: `phone`
* **format**: `phone` (`(###) ###-####`)
* **format**: `phone` (`(###) ###-####`)
29 changes: 28 additions & 1 deletion docs/site/pages/plugins/computed-properties.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ const player = new Player({
```

</core>

<ios>

### CocoaPods

Add the subspec to your `Podfile`

```ruby
pod 'PlayerUI/ComputedPropertiesPlugin'
```

### Swift Usage

This plugin takes no parameters, and the configuration comes from content, it can just be added to the plugin array:

```swift
var body: some View {
SwiftUIPlayer(
flow: flow,
plugins: [
ComputedPropertiesPlugin()
],
result: $resultBinding
)
}
```
</ios>
</PlatformTabs>

## Expression Data Type
Expand Down Expand Up @@ -62,4 +89,4 @@ Any data-lookup for that binding path will evaluate the given expression and ret

Using the above schema, any reference to `{{foo.computedValue}}` will compute the `1 + 2 + 3` expression and use that as the underlying value for that path.

Any write or set operation to `{{foo.computedValue}}` will result in a thrown exception for writing to a read-only path.
Any write or set operation to `{{foo.computedValue}}` will result in a thrown exception for writing to a read-only path.
21 changes: 13 additions & 8 deletions docs/site/pages/plugins/console-logger.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,28 @@ consoleLogger.setSeverity('warn');
</core>
<ios>

Add the subspec:
### CocoaPods
Add the subspec to your `Podfile`

```ruby
pod 'PlayerUI/PrintLoggerPlugin'
```

Construct the plugin:
### Swift Usage

```swift
SwiftUIPlayer(
flow: flow,
plugins: [PrintLoggerPlugin()],
result: $result
)
var body: some View {
SwiftUIPlayer(
flow: flow,
plugins: [
PrintLoggerPlugin()
],
result: $resultBinding
)
}
```

To change the severity:
To change the severity, supply it as an argument to the constructor:
```swift
PrintLoggerPlugin(level: .warn)
```
Expand Down
11 changes: 9 additions & 2 deletions docs/site/pages/plugins/expression.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ Any calls to `myCustomFunction()` within the flow will utilize the newly registe
</core>
<ios>

### Use
### CocoaPods
Add the subspec to your `Podfile`

```ruby
pod 'PlayerUI/ExpressionPlugin'
```

### Swift Usage

The ExpressionPlugin lets you register custom expressions to run native code:

Expand All @@ -71,7 +78,7 @@ let expressionPlugin = ExpressionPlugin(expressions: [
}
])
```
### Arguments
#### Arguments

Arguments can be passed to custom expressions, and your handler receives the arguments as an array of Any:

Expand Down
Loading