mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-05-19 22:36:51 +08:00
Don't collapse child constraints of Solos
Fixes the problem where FollowPathConstraints were not working with Solos in CPP runtime (works only in editor). The proposed solution is to not collapse constraints of the Solo because in the case of FollowPathConstraint, a call to it's update() is required in order to get the path info. Before the fix: https://github.com/rive-app/rive/assets/186340/48df0eb5-a422-464c-84c0-4c49412fa90e After the fix: https://github.com/rive-app/rive/assets/186340/dbfc8172-217d-4685-92c8-c34c551235ca Diffs= a91b1b764 Don't collapse child constraints of Solos - fixes Follow Paths on Solos (#5866) 033489f8b Fix follow path contention with MetricsPath (#5868) Co-authored-by: Philip Chung <philterdesign@gmail.com>
This commit is contained in:
@ -1 +1 @@
|
||||
ad4236501bdf0218046a93c54f2ee4a379747890
|
||||
a91b1b7647965149bd1b7894fa428f189e57f653
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:rive/src/generated/solo_base.dart';
|
||||
import 'package:rive/src/rive_core/component.dart';
|
||||
import 'package:rive/src/rive_core/constraints/constraint.dart';
|
||||
import 'package:rive/src/rive_core/container_component.dart';
|
||||
|
||||
export 'package:rive/src/generated/solo_base.dart';
|
||||
@ -24,6 +25,9 @@ class Solo extends SoloBase {
|
||||
@override
|
||||
void propagateCollapseToChildren(bool collapse) {
|
||||
for (final child in children) {
|
||||
if (child is Constraint) {
|
||||
continue;
|
||||
}
|
||||
child.propagateCollapse(collapse || child != _activeComponent);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
BIN
test/assets/follow_path_solos.riv
Normal file
BIN
test/assets/follow_path_solos.riv
Normal file
Binary file not shown.
59
test/goldens/follow_path/golden_follow_path_solos_test.dart
Normal file
59
test/goldens/follow_path/golden_follow_path_solos_test.dart
Normal file
@ -0,0 +1,59 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rive/rive.dart';
|
||||
|
||||
import '../../src/utils.dart';
|
||||
import '../golden_comparator.dart';
|
||||
|
||||
void main() {
|
||||
group('Golden - follow path solo tests', () {
|
||||
testWidgets('Follow path over time', (WidgetTester tester) async {
|
||||
final riveBytes = loadFile('assets/follow_path_solos.riv');
|
||||
final file = RiveFile.import(riveBytes);
|
||||
late Artboard artboard;
|
||||
|
||||
final widget = RiveAnimation.direct(
|
||||
file,
|
||||
stateMachines: const ['State Machine 1'],
|
||||
onInit: (a) {
|
||||
artboard = a;
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(widget);
|
||||
|
||||
await tester.pump();
|
||||
|
||||
await expectGoldenMatches(
|
||||
find.byType(RiveAnimation),
|
||||
'follow_path_solos_01.png',
|
||||
reason: 'Follow path should work as animation advances',
|
||||
);
|
||||
|
||||
artboard.advance(1.0, nested: true);
|
||||
await tester.pump();
|
||||
|
||||
await expectGoldenMatches(
|
||||
find.byType(RiveAnimation),
|
||||
'follow_path_solos_02.png',
|
||||
reason: 'Follow path should work as animation advances',
|
||||
);
|
||||
|
||||
artboard.advance(1.5, nested: true);
|
||||
await tester.pump();
|
||||
|
||||
await expectGoldenMatches(
|
||||
find.byType(RiveAnimation),
|
||||
'follow_path_solos_03.png',
|
||||
reason: 'Follow path should work as animation advances',
|
||||
);
|
||||
|
||||
artboard.advance(1.0, nested: true);
|
||||
await tester.pump();
|
||||
|
||||
await expectGoldenMatches(
|
||||
find.byType(RiveAnimation),
|
||||
'follow_path_solos_04.png',
|
||||
reason: 'Follow path should work as animation advances',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
BIN
test/goldens/follow_path/images/follow_path_solos_01.png
Normal file
BIN
test/goldens/follow_path/images/follow_path_solos_01.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
BIN
test/goldens/follow_path/images/follow_path_solos_02.png
Normal file
BIN
test/goldens/follow_path/images/follow_path_solos_02.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
test/goldens/follow_path/images/follow_path_solos_03.png
Normal file
BIN
test/goldens/follow_path/images/follow_path_solos_03.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
BIN
test/goldens/follow_path/images/follow_path_solos_04.png
Normal file
BIN
test/goldens/follow_path/images/follow_path_solos_04.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
Reference in New Issue
Block a user