Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 1e5394b
Author: Luigi Rosso <[email protected]>
Date:   Wed Jul 24 11:47:01 2019 -0700

    Adding artboard option.

commit 6f6000f
Author: Luigi Rosso <[email protected]>
Date:   Mon Jul 8 21:19:43 2019 -0700

    Squashed commit of the following:

    commit f24a688
    Author: Luigi Rosso <[email protected]>
    Date:   Mon Jul 8 21:18:32 2019 -0700

        Squashed commit of the following:

        commit 085a15c
        Author: Luigi Rosso <[email protected]>
        Date:   Mon Jul 8 21:17:28 2019 -0700

            Squashed commit of the following:

            commit 56cea07
            Author: Luigi Rosso <[email protected]>
            Date:   Mon Jul 8 21:15:07 2019 -0700

                Updating stable to latest flare_flutter from dev.

            commit 28846c5
            Merge: e1a55f9 52d5e6e
            Author: Luigi Rosso <[email protected]>
            Date:   Sat Jul 6 11:06:01 2019 -0700

                Merge pull request #121 from 2d-inc/master

                Merging intrinsic_size_experiment changes

            commit e1a55f9
            Merge: 5533e73 15682ac
            Author: Luigi Rosso <[email protected]>
            Date:   Sat Jul 6 10:28:42 2019 -0700

                Merge pull request #119 from 2d-inc/master

                Check for null children before iterating for initialization.

            commit 5533e73
            Merge: 01387cd a17469b
            Author: Luigi Rosso <[email protected]>
            Date:   Wed Jul 3 10:40:12 2019 -0700

                Merge pull request #116 from 2d-inc/master

                Remove console spam.

            commit 01387cd
            Merge: 0ee2efe 525613e
            Author: Luigi Rosso <[email protected]>
            Date:   Tue Jul 2 18:13:31 2019 -0700

                Merge pull request #115 from 2d-inc/master

                Instance shape node from actor.

            commit 0ee2efe
            Merge: 8f04aa6 0230aab
            Author: Luigi Rosso <[email protected]>
            Date:   Thu Jun 20 16:27:00 2019 -0700

                Merge pull request #108 from 2d-inc/master

                Fixing rectangle and clips.

            commit 8f04aa6
            Merge: 6606b73 865e090
            Author: Luigi Rosso <[email protected]>
            Date:   Thu Jun 13 16:07:43 2019 -0700

                Merge pull request #102 from 2d-inc/master

                Updating dev branch.

            commit 6606b73
            Merge: 396cd88 f147157
            Author: Luigi Rosso <[email protected]>
            Date:   Tue Jun 4 11:59:29 2019 -0700

                Merge branch 'master' into dev

            commit 396cd88
            Merge: 006d85b 9db2d97
            Author: Luigi Rosso <[email protected]>
            Date:   Mon May 20 10:56:46 2019 -0700

                Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

            commit 006d85b
            Merge: c51192d 850ea83
            Author: Luigi Rosso <[email protected]>
            Date:   Mon May 20 10:45:58 2019 -0700

                Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

            commit c51192d
            Merge: 4aebb0f 4e9961b
            Author: Luigi Rosso <[email protected]>
            Date:   Thu May 9 11:44:40 2019 -0700

                Merge pull request #89 from 2d-inc/master

                Update indices to 16 bit unsigned, compatibility with flutter master.

            commit 4aebb0f
            Merge: 113d791 63c1d05
            Author: Luigi Rosso <[email protected]>
            Date:   Fri Apr 26 13:42:11 2019 -0700

                Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

            commit 113d791
            Merge: 2ec15af 4416a67
            Author: Luigi Rosso <[email protected]>
            Date:   Fri Apr 26 12:33:04 2019 -0700

                Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

            commit 2ec15af
            Merge: d8defc4 2dbb7ab
            Author: Luigi Rosso <[email protected]>
            Date:   Wed Apr 24 12:07:45 2019 -0700

                Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

            commit d8defc4
            Author: Luigi Rosso <[email protected]>
            Date:   Wed Apr 24 10:15:51 2019 -0700

                Fixing relative path for flare_dart.

            commit 2e1fcaa
            Author: Luigi Rosso <[email protected]>
            Date:   Wed Apr 24 10:14:38 2019 -0700

                Updating flare_dart dependency to dev branch of Flare-Flutter.

    commit 28846c5
    Merge: e1a55f9 52d5e6e
    Author: Luigi Rosso <[email protected]>
    Date:   Sat Jul 6 11:06:01 2019 -0700

        Merge pull request #121 from 2d-inc/master

        Merging intrinsic_size_experiment changes

    commit e1a55f9
    Merge: 5533e73 15682ac
    Author: Luigi Rosso <[email protected]>
    Date:   Sat Jul 6 10:28:42 2019 -0700

        Merge pull request #119 from 2d-inc/master

        Check for null children before iterating for initialization.

    commit 5533e73
    Merge: 01387cd a17469b
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Jul 3 10:40:12 2019 -0700

        Merge pull request #116 from 2d-inc/master

        Remove console spam.

    commit 01387cd
    Merge: 0ee2efe 525613e
    Author: Luigi Rosso <[email protected]>
    Date:   Tue Jul 2 18:13:31 2019 -0700

        Merge pull request #115 from 2d-inc/master

        Instance shape node from actor.

    commit 0ee2efe
    Merge: 8f04aa6 0230aab
    Author: Luigi Rosso <[email protected]>
    Date:   Thu Jun 20 16:27:00 2019 -0700

        Merge pull request #108 from 2d-inc/master

        Fixing rectangle and clips.

    commit 8f04aa6
    Merge: 6606b73 865e090
    Author: Luigi Rosso <[email protected]>
    Date:   Thu Jun 13 16:07:43 2019 -0700

        Merge pull request #102 from 2d-inc/master

        Updating dev branch.

    commit 6606b73
    Merge: 396cd88 f147157
    Author: Luigi Rosso <[email protected]>
    Date:   Tue Jun 4 11:59:29 2019 -0700

        Merge branch 'master' into dev

    commit 396cd88
    Merge: 006d85b 9db2d97
    Author: Luigi Rosso <[email protected]>
    Date:   Mon May 20 10:56:46 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit 006d85b
    Merge: c51192d 850ea83
    Author: Luigi Rosso <[email protected]>
    Date:   Mon May 20 10:45:58 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit c51192d
    Merge: 4aebb0f 4e9961b
    Author: Luigi Rosso <[email protected]>
    Date:   Thu May 9 11:44:40 2019 -0700

        Merge pull request #89 from 2d-inc/master

        Update indices to 16 bit unsigned, compatibility with flutter master.

    commit 4aebb0f
    Merge: 113d791 63c1d05
    Author: Luigi Rosso <[email protected]>
    Date:   Fri Apr 26 13:42:11 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit 113d791
    Merge: 2ec15af 4416a67
    Author: Luigi Rosso <[email protected]>
    Date:   Fri Apr 26 12:33:04 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit 2ec15af
    Merge: d8defc4 2dbb7ab
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Apr 24 12:07:45 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit d8defc4
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Apr 24 10:15:51 2019 -0700

        Fixing relative path for flare_dart.

    commit 2e1fcaa
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Apr 24 10:14:38 2019 -0700

        Updating flare_dart dependency to dev branch of Flare-Flutter.

commit 085a15c
Author: Luigi Rosso <[email protected]>
Date:   Mon Jul 8 21:17:28 2019 -0700

    Squashed commit of the following:

    commit 56cea07
    Author: Luigi Rosso <[email protected]>
    Date:   Mon Jul 8 21:15:07 2019 -0700

        Updating stable to latest flare_flutter from dev.

    commit 28846c5
    Merge: e1a55f9 52d5e6e
    Author: Luigi Rosso <[email protected]>
    Date:   Sat Jul 6 11:06:01 2019 -0700

        Merge pull request #121 from 2d-inc/master

        Merging intrinsic_size_experiment changes

    commit e1a55f9
    Merge: 5533e73 15682ac
    Author: Luigi Rosso <[email protected]>
    Date:   Sat Jul 6 10:28:42 2019 -0700

        Merge pull request #119 from 2d-inc/master

        Check for null children before iterating for initialization.

    commit 5533e73
    Merge: 01387cd a17469b
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Jul 3 10:40:12 2019 -0700

        Merge pull request #116 from 2d-inc/master

        Remove console spam.

    commit 01387cd
    Merge: 0ee2efe 525613e
    Author: Luigi Rosso <[email protected]>
    Date:   Tue Jul 2 18:13:31 2019 -0700

        Merge pull request #115 from 2d-inc/master

        Instance shape node from actor.

    commit 0ee2efe
    Merge: 8f04aa6 0230aab
    Author: Luigi Rosso <[email protected]>
    Date:   Thu Jun 20 16:27:00 2019 -0700

        Merge pull request #108 from 2d-inc/master

        Fixing rectangle and clips.

    commit 8f04aa6
    Merge: 6606b73 865e090
    Author: Luigi Rosso <[email protected]>
    Date:   Thu Jun 13 16:07:43 2019 -0700

        Merge pull request #102 from 2d-inc/master

        Updating dev branch.

    commit 6606b73
    Merge: 396cd88 f147157
    Author: Luigi Rosso <[email protected]>
    Date:   Tue Jun 4 11:59:29 2019 -0700

        Merge branch 'master' into dev

    commit 396cd88
    Merge: 006d85b 9db2d97
    Author: Luigi Rosso <[email protected]>
    Date:   Mon May 20 10:56:46 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit 006d85b
    Merge: c51192d 850ea83
    Author: Luigi Rosso <[email protected]>
    Date:   Mon May 20 10:45:58 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit c51192d
    Merge: 4aebb0f 4e9961b
    Author: Luigi Rosso <[email protected]>
    Date:   Thu May 9 11:44:40 2019 -0700

        Merge pull request #89 from 2d-inc/master

        Update indices to 16 bit unsigned, compatibility with flutter master.

    commit 4aebb0f
    Merge: 113d791 63c1d05
    Author: Luigi Rosso <[email protected]>
    Date:   Fri Apr 26 13:42:11 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit 113d791
    Merge: 2ec15af 4416a67
    Author: Luigi Rosso <[email protected]>
    Date:   Fri Apr 26 12:33:04 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit 2ec15af
    Merge: d8defc4 2dbb7ab
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Apr 24 12:07:45 2019 -0700

        Merge branch 'master' of https://github.com/2d-inc/Flare-Flutter into dev

    commit d8defc4
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Apr 24 10:15:51 2019 -0700

        Fixing relative path for flare_dart.

    commit 2e1fcaa
    Author: Luigi Rosso <[email protected]>
    Date:   Wed Apr 24 10:14:38 2019 -0700

        Updating flare_dart dependency to dev branch of Flare-Flutter.
  • Loading branch information
luigi-rosso committed Jul 24, 2019
1 parent 307d63f commit 92d9dcb
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 44 deletions.
4 changes: 4 additions & 0 deletions flare_dart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.4.4] - 2019-07-24 11:43:51

Adding getArtboard method to Actor class. Allows finding artboards by name.

## [1.4.3] - 2019-07-06 11:08:53

Some cleanup done while fixing issue #104 (using intrinsic artboard size as an option).
Expand Down
4 changes: 4 additions & 0 deletions flare_dart/lib/actor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ abstract class Actor {
Actor();

ActorArtboard get artboard => _artboards.isNotEmpty ? _artboards.first : null;
ActorArtboard getArtboard(String name) => name == null
? artboard
: _artboards.firstWhere((artboard) => artboard?.name == name,
orElse: () => null);

int get version {
return _version;
Expand Down
6 changes: 6 additions & 0 deletions flare_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [1.5.5] - 2019-07-24 11:44:36

- Adding artboard option to FlareActor. Use this to change which artboard gets displayed by the FlareActor widget.
- Fixed incorrect signature of load method. If you were deriving FlareRenderBox, you'll need to update it to match. It's a minor change from void to Future<void>.
- Added some documentation to the FlareActor parameters.

## [1.5.4] - 2019-07-08 21:10:50

- Using Uint16List for vertex indices now that Flutter Stable has been updated.
Expand Down
141 changes: 99 additions & 42 deletions flare_flutter/lib/flare_actor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,67 @@ import 'flare_controller.dart';
typedef void FlareCompletedCallback(String name);

class FlareActor extends LeafRenderObjectWidget {
/// Name of the Flare file to be loaded from the AssetBundle.
final String filename;

/// The name of the artboard to display.
final String artboard;

/// The name of the animation to play.
final String animation;

/// When true, the animation will be applied at the end of its duration.
final bool snapToEnd;

/// The BoxFit strategy used to scale the Flare content into the
/// bounds of this widget.
final BoxFit fit;

/// The alignment that will be applied in conjuction to the [fit] to align
/// the Flare content within the bounds of this widget.
final Alignment alignment;

/// When true, animations do not advance.
final bool isPaused;

/// When true, the Flare content will be clipped against the bounds of this
/// widget.
final bool shouldClip;

/// The [FlareController] used to drive animations/mixing/procedural hierarchy
/// manipulation of the Flare contents.
final FlareController controller;

/// Callback invoked when [animation] has completed. If [animation] is looping
/// this callback is never invoked.
final FlareCompletedCallback callback;

/// The color to override any fills/strokes with.
final Color color;

/// The name of the node to use to determine the bounds of the content.
/// When null it will default to the bounds of the artboard.
final String boundsNode;

/// When true the intrinsic size of the artboard will be used as the
/// dimensions of this widget.
final bool sizeFromArtboard;

const FlareActor(this.filename,
{this.boundsNode,
this.animation,
this.fit = BoxFit.contain,
this.alignment = Alignment.center,
this.isPaused = false,
this.snapToEnd = false,
this.controller,
this.callback,
this.color,
this.shouldClip = true,
this.sizeFromArtboard = false});
const FlareActor(
this.filename, {
this.boundsNode,
this.animation,
this.fit = BoxFit.contain,
this.alignment = Alignment.center,
this.isPaused = false,
this.snapToEnd = false,
this.controller,
this.callback,
this.color,
this.shouldClip = true,
this.sizeFromArtboard = false,
this.artboard,
});

@override
RenderObject createRenderObject(BuildContext context) {
Expand All @@ -53,7 +89,8 @@ class FlareActor extends LeafRenderObjectWidget {
..color = color
..shouldClip = shouldClip
..boundsNodeName = boundsNode
..useIntrinsicSize = sizeFromArtboard;
..useIntrinsicSize = sizeFromArtboard
..artboardName = artboard;
}

@override
Expand All @@ -70,7 +107,8 @@ class FlareActor extends LeafRenderObjectWidget {
..color = color
..shouldClip = shouldClip
..boundsNodeName = boundsNode
..useIntrinsicSize = sizeFromArtboard;
..useIntrinsicSize = sizeFromArtboard
..artboardName = artboard;
}

@override
Expand All @@ -94,12 +132,24 @@ class FlareAnimationLayer {
class FlareActorRenderObject extends FlareRenderBox {
Mat2D _lastControllerViewTransform;
String _filename;
String _artboardName;
String _animationName;
String _boundsNodeName;
FlareController _controller;
FlareCompletedCallback _completedCallback;
bool snapToEnd = false;
bool _isPaused = false;
FlutterActor _actor;

String get artboardName => _artboardName;
set artboardName(String name) {
if (_artboardName == name) {
return;
}
_artboardName = name;
_instanceArtboard();
}

bool get isPaused => _isPaused;
set isPaused(bool value) {
if (_isPaused == value) {
Expand Down Expand Up @@ -213,38 +263,45 @@ class FlareActorRenderObject extends FlareRenderBox {
load();
}

bool _instanceArtboard() {
if (_actor == null || _actor.artboard == null) {
return false;
}
FlutterActorArtboard artboard = _actor
.getArtboard(_artboardName)
.makeInstance() as FlutterActorArtboard;
artboard.initializeGraphics();
_artboard = artboard;
intrinsicSize = Size(artboard.width, artboard.height);
_artboard.overrideColor = _color == null
? null
: Float32List.fromList([
_color.red / 255.0,
_color.green / 255.0,
_color.blue / 255.0,
_color.opacity
]);
_artboard.advance(0.0);
updateBounds();

if (_controller != null) {
_controller.initialize(_artboard);
}
_updateAnimation(onlyWhenMissing: true);
markNeedsPaint();
return true;
}

@override
void load() {
Future<void> load() async {
if (_filename == null) {
return;
}
super.load();
loadFlare(_filename).then((FlutterActor actor) {
if (actor == null || actor.artboard == null) {
return;
}
FlutterActorArtboard artboard =
actor.artboard.makeInstance() as FlutterActorArtboard;
artboard.initializeGraphics();
_artboard = artboard;
intrinsicSize = Size(artboard.width, artboard.height);
_artboard.overrideColor = _color == null
? null
: Float32List.fromList([
_color.red / 255.0,
_color.green / 255.0,
_color.blue / 255.0,
_color.opacity
]);
_artboard.advance(0.0);
updateBounds();

if (_controller != null) {
_controller.initialize(_artboard);
}
_updateAnimation(onlyWhenMissing: true);
markNeedsPaint();
});
_actor = await loadFlare(_filename);
if (_actor == null || _actor.artboard == null) {
return;
}
_instanceArtboard();
}

FlareCompletedCallback get completed => _completedCallback;
Expand Down
4 changes: 2 additions & 2 deletions flare_flutter/lib/flare_render_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ abstract class FlareRenderBox extends RenderBox {
bool _isLoading = false;
bool get isLoading => _isLoading;

void _load() async {
Future<void> _load() async {
if (_isLoading) {
return;
}
Expand All @@ -247,7 +247,7 @@ abstract class FlareRenderBox extends RenderBox {
}

/// Perform any loading logic necessary for this scene.
void load() async {}
Future<void> load() async {}

void _unload() {
for (final FlareCacheAsset asset in _assets) {
Expand Down

0 comments on commit 92d9dcb

Please sign in to comment.