Skip to content

Commit

Permalink
add other controller
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Jun 3, 2019
1 parent 1359061 commit c4359dc
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 2 deletions.
67 changes: 67 additions & 0 deletions lib/widget/pull/gsy_flare_mutli_pull_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'package:flare_dart/math/mat2d.dart';
import 'package:flare_flutter/flare.dart';
import 'package:flare_flutter/flare_controller.dart';

mixin GSYFlarePullMutliController implements FlareController {

ActorAnimation _loadingAnimation;
ActorAnimation _successAnimation;
ActorAnimation _pullAnimation;
ActorAnimation _cometAnimation;

double pulledExtentFlare = 0;
bool _isSurround = false;


double _refreshTriggerPullDistance = 140;

double _successTime = 0.0;
double _loadingTime = 0.0;
double _cometTime = 0.0;

@override
void initialize(FlutterActorArtboard artboard) {
_pullAnimation = artboard.getAnimation("pull");
_successAnimation = artboard.getAnimation("success");
_loadingAnimation = artboard.getAnimation("loading");
_cometAnimation = artboard.getAnimation("idle comet");
}

@override
void setViewTransform(Mat2D viewTransform) {}

@override
bool advance(FlutterActorArtboard artboard, double elapsed) {
double animationPosition = pulledExtentFlare / _refreshTriggerPullDistance;
animationPosition *= animationPosition;
_cometTime += elapsed;
_cometAnimation.apply(_cometTime % _cometAnimation.duration, artboard, 1.0);
_pullAnimation.apply(
_pullAnimation.duration * animationPosition, artboard, 1.0);
if (_isSurround) {
_successTime += elapsed;
if (_successTime >= _successAnimation.duration) {
_loadingTime += elapsed;
}
} else {
_successTime = _loadingTime = 0.0;
}
if (_successTime >= _successAnimation.duration) {
_loadingAnimation.apply(
_loadingTime % _loadingAnimation.duration, artboard, 1.0);
} else if (_successTime > 0.0) {
_successAnimation.apply(_successTime, artboard, 1.0);
}
return true;
}

void onRefreshing() {
_isSurround = true;
}

void onRefreshEnd() {
_isSurround = false;
}

bool get getPlayAuto;
}
15 changes: 13 additions & 2 deletions lib/widget/pull/gsy_pull_new_load_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:gsy_github_app_flutter/common/utils/common_utils.dart';
import 'dart:math';

import 'custom_bouncing_scroll_physics.dart';
import 'gsy_flare_mutli_pull_controller.dart';
import 'gsy_flare_pull_controller.dart';

const double iosRefreshHeight = 140;
Expand Down Expand Up @@ -43,6 +44,7 @@ class GSYPullLoadWidget extends StatefulWidget {

class _GSYPullLoadWidgetState extends State<GSYPullLoadWidget>
with GSYFlarePullController {
//with GSYFlarePullMutliController {
ScrollController _scrollController;

bool isRefreshing = false;
Expand Down Expand Up @@ -307,6 +309,11 @@ class _GSYPullLoadWidgetState extends State<GSYPullLoadWidget>
) {
pulledExtentFlare = pulledExtent * 0.6;
playAuto = refreshState == IOS.RefreshIndicatorMode.refresh;
/*if(refreshState == IOS.RefreshIndicatorMode.refresh) {
onRefreshing();
} else {
onRefreshEnd();
}*/
return Align(
alignment: Alignment.bottomCenter,
child: new Container(
Expand All @@ -316,11 +323,15 @@ class _GSYPullLoadWidgetState extends State<GSYPullLoadWidget>
///动态大小处理
height:
pulledExtent > iosRefreshHeight ? pulledExtent : iosRefreshHeight,
child: FlareActor("static/file/loading_world_now.flr",
child: FlareActor(
//"static/file/Space-Demo.flr",
"static/file/loading_world_now.flr",
alignment: Alignment.topCenter,
fit: BoxFit.cover,
controller: this,
animation: "Earth Moving"),
animation: "Earth Moving"
//animation: "idle"
),
),
);
}
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ flutter:
- static/file/rejection2.json
- static/file/flare_flutter_logo_.flr
- static/file/loading_world_now.flr
- static/file/Space-Demo.flr

fonts:
- family: wxcIconFont
Expand Down
Binary file added static/file/Space-Demo.flr
Binary file not shown.

0 comments on commit c4359dc

Please sign in to comment.