add animation ticker inside render loop

This commit is contained in:
Nick Fisher
2021-09-26 10:23:58 +08:00
parent a0fc14c33b
commit 4a87ccd143
6 changed files with 158 additions and 71 deletions

View File

@@ -4,8 +4,10 @@ import 'package:mimetic_filament/view/filament_widget.dart';
class GestureDetectingFilamentView extends StatefulWidget {
final FilamentController controller;
final bool rotate;
const GestureDetectingFilamentView({Key? key, required this.controller})
const GestureDetectingFilamentView(
{Key? key, required this.controller, this.rotate = false})
: super(key: key);
@override
@@ -14,7 +16,6 @@ class GestureDetectingFilamentView extends StatefulWidget {
class _GestureDetectingFilamentViewState
extends State<GestureDetectingFilamentView> {
bool _rotate = false;
int _primitiveIndex = 0;
double _weight = 0.0;
@@ -23,21 +24,23 @@ class _GestureDetectingFilamentViewState
return GestureDetector(
behavior: HitTestBehavior.opaque,
onPanDown: (details) {
_rotate
widget.rotate
? widget.controller.rotateStart(
details.localPosition.dx, details.localPosition.dy)
: widget.controller
.panStart(details.localPosition.dx, details.localPosition.dy);
},
onPanUpdate: (details) {
_rotate
widget.rotate
? widget.controller.rotateUpdate(
details.localPosition.dx, details.localPosition.dy)
: widget.controller.panUpdate(
details.localPosition.dx, details.localPosition.dy);
},
onPanEnd: (d) {
_rotate ? widget.controller.rotateEnd() : widget.controller.panEnd();
widget.rotate
? widget.controller.rotateEnd()
: widget.controller.panEnd();
},
child: FilamentWidget(controller: widget.controller));
}