From 619987ec49cb7875cda1ed90ff9329b212f47725 Mon Sep 17 00:00:00 2001 From: Zachary Duncan Date: Thu, 2 Jun 2022 21:33:59 -0400 Subject: [PATCH] Adjusted example to only instantiate one RiveFile --- .../SwiftUI/SwiftMultipleAnimations.swift | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Example-iOS/Source/Examples/SwiftUI/SwiftMultipleAnimations.swift b/Example-iOS/Source/Examples/SwiftUI/SwiftMultipleAnimations.swift index 9756e3db..34ccb8d9 100644 --- a/Example-iOS/Source/Examples/SwiftUI/SwiftMultipleAnimations.swift +++ b/Example-iOS/Source/Examples/SwiftUI/SwiftMultipleAnimations.swift @@ -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) } } -