Skip to content

Commit eaae9dd

Browse files
committed
refactor: rename list property methods to match iOS SDK and react-hook-form
- addInstance -> append - insertInstance -> insert - removeInstance -> remove - removeInstanceAt -> removeAt
1 parent 518ce68 commit eaae9dd

12 files changed

Lines changed: 61 additions & 61 deletions

android/src/main/java/com/margelo/nitro/rive/HybridViewModelListProperty.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ class HybridViewModelListProperty(private val listProperty: ViewModelListPropert
2424
return HybridViewModelInstance(listProperty.elementAt(idx))
2525
}
2626

27-
override fun addInstance(instance: HybridViewModelInstanceSpec) {
27+
override fun append(instance: HybridViewModelInstanceSpec) {
2828
val hybridInstance = requireHybridInstance(instance)
2929
listProperty.add(hybridInstance.viewModelInstance)
3030
}
3131

32-
override fun insertInstance(instance: HybridViewModelInstanceSpec, index: Double) {
32+
override fun insert(instance: HybridViewModelInstanceSpec, index: Double) {
3333
val hybridInstance = requireHybridInstance(instance)
3434
listProperty.add(index.toInt(), hybridInstance.viewModelInstance)
3535
}
3636

37-
override fun removeInstance(instance: HybridViewModelInstanceSpec) {
37+
override fun remove(instance: HybridViewModelInstanceSpec) {
3838
val hybridInstance = requireHybridInstance(instance)
3939
listProperty.remove(hybridInstance.viewModelInstance)
4040
}
4141

42-
override fun removeInstanceAt(index: Double) {
42+
override fun removeAt(index: Double) {
4343
listProperty.removeAt(index.toInt())
4444
}
4545

example/src/pages/DataBindingListExample.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function ListExample({
6363
instance: ViewModelInstance;
6464
file: RiveFile;
6565
}) {
66-
const riveRef = useRef<RiveViewRef>(undefined);
66+
const riveRef = useRef<RiveViewRef>(null);
6767
const [isPlaying, setIsPlaying] = useState(true);
6868
const listProperty = useMemo(
6969
() => instance.listProperty('ListItemVM'),
@@ -91,19 +91,19 @@ function ListExample({
9191
if (stringProp) {
9292
stringProp.value = 'new btn';
9393
}
94-
listProperty.addInstance(newInstance);
94+
listProperty.append(newInstance);
9595
refreshLength();
9696
}, [listProperty, file, refreshLength]);
9797

9898
const handleRemoveFirst = useCallback(() => {
9999
if (!listProperty || listProperty.length === 0) return;
100-
listProperty.removeInstanceAt(0);
100+
listProperty.removeAt(0);
101101
refreshLength();
102102
}, [listProperty, refreshLength]);
103103

104104
const handleRemoveLast = useCallback(() => {
105105
if (!listProperty || listProperty.length === 0) return;
106-
listProperty.removeInstanceAt(listProperty.length - 1);
106+
listProperty.removeAt(listProperty.length - 1);
107107
refreshLength();
108108
}, [listProperty, refreshLength]);
109109

ios/HybridViewModelListProperty.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ class HybridViewModelListProperty: HybridViewModelListPropertySpec, ValuedProper
3131
return viewModelInstance
3232
}
3333

34-
func addInstance(instance: any HybridViewModelInstanceSpec) throws {
34+
func append(instance: any HybridViewModelInstanceSpec) throws {
3535
let viewModelInstance = try requireViewModelInstance(instance)
3636
property.append(viewModelInstance)
3737
}
3838

39-
func insertInstance(instance: any HybridViewModelInstanceSpec, index: Double) throws {
39+
func insert(instance: any HybridViewModelInstanceSpec, index: Double) throws {
4040
let viewModelInstance = try requireViewModelInstance(instance)
4141
_ = property.insert(viewModelInstance, at: Int32(index))
4242
}
4343

44-
func removeInstance(instance: any HybridViewModelInstanceSpec) throws {
44+
func remove(instance: any HybridViewModelInstanceSpec) throws {
4545
let viewModelInstance = try requireViewModelInstance(instance)
4646
property.remove(viewModelInstance)
4747
}
4848

49-
func removeInstanceAt(index: Double) throws {
49+
func removeAt(index: Double) throws {
5050
property.remove(at: Int32(index))
5151
}
5252

nitrogen/generated/android/c++/JHybridViewModelListPropertySpec.cpp

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nitrogen/generated/android/c++/JHybridViewModelListPropertySpec.hpp

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nitrogen/generated/android/kotlin/com/margelo/nitro/rive/HybridViewModelListPropertySpec.kt

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nitrogen/generated/ios/c++/HybridViewModelListPropertySpecSwift.hpp

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nitrogen/generated/ios/swift/HybridViewModelListPropertySpec.swift

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nitrogen/generated/ios/swift/HybridViewModelListPropertySpec_cxx.swift

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nitrogen/generated/shared/c++/HybridViewModelListPropertySpec.cpp

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)