-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from player-ui/177-enhance-demo-app
177/ add plugin examples and managed player to demo app
- Loading branch information
Showing
19 changed files
with
1,044 additions
and
18 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -52,4 +52,3 @@ public class FlowController: CreatedFromJSValue { | |
value.invokeMethod("transition", withArguments: [action]) | ||
} | ||
} | ||
|
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
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,71 @@ | ||
// | ||
// FlowManagerView.swift | ||
// Pods | ||
// | ||
// Created by Zhao Xia Wu on 2023-11-01. | ||
// | ||
|
||
import SwiftUI | ||
import PlayerUI | ||
|
||
/** | ||
SwiftUI View to wrap the `ManagedPlayer` and handle the result | ||
for use in UI testing | ||
*/ | ||
public struct FlowManagerView: View { | ||
let flowSequence: [String] | ||
let navTitle: String | ||
@State private var complete = false | ||
|
||
public var body: some View { | ||
VStack { | ||
if complete { | ||
VStack { | ||
Text("Flow Completed").font(.title) | ||
Button(action: {complete = false}, label: { Text("Start Over " )}) | ||
} | ||
} else { | ||
VStack { | ||
ManagedPlayer( | ||
plugins: [ | ||
ReferenceAssetsPlugin(), | ||
MetricsPlugin { (render, _, flow) in | ||
print("Render: \(render?.duration ?? 0 )ms | Request \(flow?.flow.requestTime ?? 0)ms") | ||
} | ||
], | ||
flowManager: ConstantFlowManager(flowSequence), | ||
onComplete: { _ in | ||
complete = true | ||
}, | ||
fallback: { (context) in | ||
VStack { | ||
Text(context.error.localizedDescription) | ||
|
||
switch context.error as? PlayerError { | ||
case .promiseRejected(error: let errorState) : | ||
Text(errorState.error) | ||
default: | ||
EmptyView() | ||
} | ||
|
||
Button(action: context.retry, label: { | ||
Text("Retry") | ||
}) | ||
Button(action: context.reset, label: { | ||
Text("Reset") | ||
}) | ||
}.accessibility(identifier: "FallbackView") | ||
}, | ||
loading: { | ||
Text("Loading Flow") | ||
} | ||
) | ||
|
||
Button(action: { complete = true }) { | ||
Text("Terminate Flow") | ||
} | ||
} | ||
} | ||
}.navigationBarTitle(Text(navTitle)) | ||
} | ||
} |
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
Oops, something went wrong.