Skip to content

Commit

Permalink
Adjusted example to only instantiate one RiveFile
Browse files Browse the repository at this point in the history
  • Loading branch information
duncandoit committed Jun 7, 2022
1 parent 1841550 commit 619987e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Example-iOS/Source/Examples/SwiftUI/SwiftMultipleAnimations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,30 @@ import RiveRuntime
/// This shows how to utilize one animation file to show content in different artboards and
/// different animations within those artboards
struct SwiftMultipleAnimations: DismissableView {
private let fileName = "artboard_animations"
private let file = try! RiveFile(name: "artboard_animations")
var dismiss: () -> Void = {}

var body: some View {
ScrollView{
VStack {
Text("Square - go around")
RiveViewModel(fileName: fileName, artboardName: "Square", animationName: "goaround").view()
.frame(height:200)
RiveViewModel(model(), artboardName: "Square", animationName: "goaround").view()
.aspectRatio(1, contentMode: .fit)

Text("Square - roll around")
RiveViewModel(fileName: fileName, artboardName: "Square", animationName: "rollaround").view()
.frame(height:200)
RiveViewModel(model(), artboardName: "Square", animationName: "rollaround").view()
.aspectRatio(1, contentMode: .fit)

Text("Circle")
RiveViewModel(fileName: fileName, artboardName: "Circle").view()
.frame(height:200)
RiveViewModel(model(), artboardName: "Circle").view()
.aspectRatio(1, contentMode: .fit)

Text("Star")
RiveViewModel(fileName: fileName, artboardName: "Star").view()
.frame(height:200)
RiveViewModel(model(), artboardName: "Star").view()
.aspectRatio(1, contentMode: .fit)
}
}
}

func model() -> RiveModel { RiveModel(riveFile: file) }
}

0 comments on commit 619987e

Please sign in to comment.