ARAnnotationsView
public struct ARAnnotationsView<Scan, Card, Marker, CardItem> : View where Scan : View, Card : View, Marker : View, CardItem : CardItemModel
Content View which displays the card and marker views after a discovery flow for a single Image in the scene after the discoveryFlowHasFinished has been set to True. Only displays the views which are set to isVisible. Cards and Markers are initially set to isVisible.
Usage
// Constructor for Default ScanningView, CardView, and MarkerView
ARAnnotationsView(arModel: arModel,
image: Image("qrImage"),
cardAction: { id in
// set the card action for id corresponding to the CardItemModel
print(id)
})
.onAppear(perform: loadData)
// Constructors with viewbuilders for each combination of Views
// Use the CarouselOptions View Modifier to adjust the behavior of the Carousel
ARAnnotationsView(arModel: arModel,
scanLabel: { anchorPosition in
CustomScanView(image: Image("qrImage"), position: anchorPosition)
},
cardLabel: { cardmodel, isSelected in
CustomCardView(networkModel: cardmodel, isSelected: isSelected)
},
markerLabel: { state, icon in
CustomMarkerView(state: state)
})
.carouselOptions(CarouselOptions(itemSpacing: 5, carouselHeight: 200, alignment: .center))
.onAppear(perform: loadData)
func loadData() {
let cardItems = Tests.cardItems
guard let anchorImage = UIImage(named: "qrImage") else { return }
let strategy = RealityComposerStrategy(cardContents: cardItems, anchorImage: anchorImage, rcFile: "ExampleRC", rcScene: "ExampleScene")
arModel.load(loadingStrategy: strategy)
}
Parameters
arModel
|
The ViewModel which managers the AR Experience |
guideImage
|
The image that is provided to the ScanView which displays what should be discovered for in the physical scene for the user |
scanLabel
|
View Builder for a custom Scanning View. After the Image/Object has been discovered there is a 3 second delay until the ContentView displays Markers and Cards |
cardLabel
|
View Builder for a custom CardView |
markerLabel
|
View Builder for a custom MarkerView |
-
arModel
Declaration
Swift
@ObservedObject public var arModel: ARAnnotationViewModel<CardItem> { get set }
-
View Builder for a custom Scanning View. After the Image/Object has been discovered there is a 3 second delay until the ContentView displays Markers and Cards Note: GuideStateImage will only return as .finished(UIImage) when using a synchronous AnnotationLoadingStrategy with a custom scanLabel ViewBuilder
Declaration
Swift
public let scanLabel: (GuideImageState, CGPoint?) -> Scan
-
View Builder for a custom CardView
Declaration
Swift
public let cardLabel: (CardItem, Bool) -> Card
-
ViewBuilder for a custom MarkerView
Declaration
Swift
public let markerLabel: (MarkerControl.State, Image?) -> Marker
-
Initializer (View Builder based)
Declaration
Swift
public init(arModel: ARAnnotationViewModel<CardItem>, guideImage: UIImage? = nil, @ViewBuilder scanLabel: @escaping (GuideImageState, CGPoint?) -> Scan, @ViewBuilder cardLabel: @escaping (CardItem, Bool) -> Card, @ViewBuilder markerLabel: @escaping (MarkerControl.State, Image?) -> Marker)
Parameters
arModel
The ViewModel which managers the AR Experience
guideImage
The image that is provided to the ScanView which displays what should be discovered for in the physical scene for the user
scanLabel
View Builder for a custom Scanning View. After the Image/Object has been discovered there is a 3 second delay until the ContentView displays Markers and Cards
cardLabel
View Builder for a custom CardView
markerLabel
View Builder for a custom MarkerView
-
SwiftUI’s view body
Declaration
Swift
public var body: some View { get }
Available where Scan
== ARScanView
, Card
== CardView<Text
, _ConditionalContent<Text
, EmptyView
>, _ConditionalContent<ImagePreview
, DefaultIcon
>, _ConditionalContent<Text
, EmptyView
>, CardItem
>, Marker
== MarkerView
-
Initializer
Declaration
Swift
init(arModel: ARAnnotationViewModel<CardItem>, guideImage: UIImage? = nil, cardAction: ((CardItem.ID) -> Void)?)
Parameters
arModel
The ViewModel which managers the AR Experience
guideImage
The image that is provided to the ScanView which displays what should be discovered for in the physical scene for the user
cardAction
Closure to handle a card action when tapped by the user
Available where Scan
== ARScanView
, Card
== CardView<Text
, _ConditionalContent<Text
, EmptyView
>, _ConditionalContent<ImagePreview
, DefaultIcon
>, _ConditionalContent<Text
, EmptyView
>, CardItem
>
-
Initializer
Declaration
Swift
init(arModel: ARAnnotationViewModel<CardItem>, guideImage: UIImage? = nil, @ViewBuilder markerLabel: @escaping (MarkerControl.State, Image?) -> Marker, cardAction: ((CardItem.ID) -> Void)?)
Parameters
arModel
The ViewModel which managers the AR Experience
guideImage
The image that is provided to the ScanView which displays what should be discovered for in the physical scene for the user
markerLabel
View Builder for a custom MarkerView
cardAction
Closure to handle a card action when tapped by the user
-
Initializer
Declaration
Swift
init(arModel: ARAnnotationViewModel<CardItem>, guideImage: UIImage? = nil, @ViewBuilder cardLabel: @escaping (CardItem, Bool) -> Card)
Parameters
arModel
The ViewModel which managers the AR Experience
guideImage
The image that is provided to the ScanView which displays what should be discovered for in the physical scene for the user
cardLabel
View Builder for a custom CardView
Available where Card
== CardView<Text
, _ConditionalContent<Text
, EmptyView
>, _ConditionalContent<ImagePreview
, DefaultIcon
>, _ConditionalContent<Text
, EmptyView
>, CardItem
>, Marker
== MarkerView
-
Initializer
Declaration
Swift
init(arModel: ARAnnotationViewModel<CardItem>, guideImage: UIImage? = nil, @ViewBuilder scanLabel: @escaping (GuideImageState, CGPoint?) -> Scan, cardAction: ((CardItem.ID) -> Void)?)
Parameters
arModel
The ViewModel which managers the AR Experience
guideImage
The image that is provided to the ScanView which displays what should be discovered for in the physical scene for the user
scanLabel
View Builder for a custom Scanning View. After the Image/Object has been discovered there is a 3 second delay until the ContentView displays Markers and Cards
cardAction
Closure to handle a card action when tapped by the user
-
Initializer
Declaration
Swift
init(arModel: ARAnnotationViewModel<CardItem>, guideImage: UIImage? = nil, @ViewBuilder cardLabel: @escaping (CardItem, Bool) -> Card, @ViewBuilder markerLabel: @escaping (MarkerControl.State, Image?) -> Marker)
Parameters
arModel
The ViewModel which managers the AR Experience
guideImage
The image that is provided to the ScanView which displays what should be discovered for in the physical scene for the user
cardLabel
View Builder for a custom CardView
markerLabel
View Builder for a custom MarkerView
-
Initializer
Declaration
Swift
init(arModel: ARAnnotationViewModel<CardItem>, @ViewBuilder scanLabel: @escaping (GuideImageState, CGPoint?) -> Scan, @ViewBuilder cardLabel: @escaping (CardItem, Bool) -> Card)
Parameters
arModel
The ViewModel which managers the AR Experience
scanLabel
View Builder for a custom Scanning View. After the Image/Object has been discovered there is a 3 second delay until the ContentView displays Markers and Cards
cardLabel
View Builder for a custom CardView
Available where Card
== CardView<Text
, _ConditionalContent<Text
, EmptyView
>, _ConditionalContent<ImagePreview
, DefaultIcon
>, _ConditionalContent<Text
, EmptyView
>, CardItem
>
-
Initializer
Declaration
Swift
init(arModel: ARAnnotationViewModel<CardItem>, @ViewBuilder scanLabel: @escaping (GuideImageState, CGPoint?) -> Scan, @ViewBuilder markerLabel: @escaping (MarkerControl.State, Image?) -> Marker, cardAction: ((CardItem.ID) -> Void)?)
Parameters
arModel
The ViewModel which managers the AR Experience
scanLabel
View Builder for a custom Scanning View. After the Image/Object has been discovered there is a 3 second delay until the ContentView displays Markers and Cards
markerLabel
View Builder for a custom MarkerView
cardAction
Closure to handle a card action when tapped by the user