You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to set the filename of my rive file via a variable, let's say filename: "\(person.name)"
I have found a way of doing this, via a computed var, however setInputs does not work with my solution.
Provide a Repro
import SwiftUI
import RiveRuntime
struct Person {
let id = UUID()
var name: String
var shoes: String
}
struct ContentView: View {
let people = [
Person(name: "Mick", shoes: "black"),
Person(name: "Keith", shoes: "blue"),
Person(name: "Ronny", shoes: "brown")
]
var pages = [1, 2, 3, 4, 5]
var body: some View {
TabView {
NavigationStack {
TabView {
ForEach(people, id: \.id) { person in
NavigationLink(destination: DetailView(person: person)){
Text("\(person.name)")
}
}
}
.navigationTitle("Stones")
.tabViewStyle(.page)
}
.tabItem {
Label("Menu", systemImage: "list.dash")
}
NavigationStack {
Text("Tab Two")
.navigationTitle("Stones")
}.tabItem {
Label("Order", systemImage: "square.and.pencil")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct DetailView: View {
let mick_animation = RiveViewModel(fileName: "Mick")
var person: Person
@State var howHigh: Double = 30.0
// Computed property, taking filename from ViewModel above
var mick2_animation: RiveViewModel {
// Initialise the animation, using name
RiveViewModel(fileName: "\(person.name)")
}
var body: some View {
VStack{
HStack {
Text("Setting the filename in the body")
.padding()
// Initialise the animation, using name
RiveViewModel(fileName: "\(person.name)")
.view()
// Cant do this here
//.setInput("height", value: Double(timerPercentage))
}
HStack {
//Only this works, but doesn' allow the filename to be variable
Text("Hardcoding the filename in view init")
.padding()
mick_animation
.view()
}
HStack {
Text("Setting the filename in view initialize using compound var")
.padding()
mick2_animation
.view()
}
Text("\(howHigh)")
Button {
howHigh += 1
} label: {
Image(systemName: "plus")
}
}
.onChange(of: howHigh) { newValue in
changeValue()
}
.onAppear {
changeValue()
}
}
func changeValue() {
mick_animation.setInput("height", value: howHigh)
mick2_animation.setInput("height", value: howHigh)
}
}
Source .riv/.rev file
The rive file is simply an animation with a height input between 0-100, and high/low states.
Expected behavior
In the above example only the hardcoded example will be affected by the changeValue func and increase in height.
But this means I cannot set the filename by a variable and have to use switch cases and hardcoding, which is causing my app to hang.
Screenshots
n/a
Device & Versions (please complete the following information)
Device: ios 11 max pro, iPhone 14
iOS version 16.5
Additional context
Posted this info in the discord chat was asked by Zach to post here. I'd love to be able to use Rive in my app, as it has a lot of potential, but I can't get this to work and it's a deal breaker for me atm.
Thanks
Conor
The text was updated successfully, but these errors were encountered:
This pull request addresses the following GitHub issues and more:
- [rive-ios #345](#345)
- [rive-react-native #268](rive-app/rive-react-native#268)
Thanks to some help from @luigi-rosso, we discovered that the iOS runtime build scripts were _not_ including the Yoga renames, causing a collision when some frameworks were statically linked in React Native environments.
This has been tested locally, and works, but the real test will be the public.
Diffs=
437688c18e Add yoga renames to non-v2 lua build scripts (#8693)
Description
I want to set the filename of my rive file via a variable, let's say
filename: "\(person.name)"
I have found a way of doing this, via a computed var, however setInputs does not work with my solution.
Provide a Repro
Source
.riv
/.rev
fileThe rive file is simply an animation with a height input between 0-100, and high/low states.
Expected behavior
In the above example only the hardcoded example will be affected by the changeValue func and increase in height.
But this means I cannot set the filename by a variable and have to use switch cases and hardcoding, which is causing my app to hang.
Screenshots
n/a
Device & Versions (please complete the following information)
Additional context
Posted this info in the discord chat was asked by Zach to post here. I'd love to be able to use Rive in my app, as it has a lot of potential, but I can't get this to work and it's a deal breaker for me atm.
Thanks
Conor
The text was updated successfully, but these errors were encountered: