Skip to content

Commit

Permalink
Add animation to Heart when liking a post (#77)
Browse files Browse the repository at this point in the history
* initial flare implementation

* fix warnings

* fix merge

* use flare from pub & minor adjustments to animation
  • Loading branch information
mdanics authored Jan 4, 2020
1 parent d7a2275 commit 124b9f9
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 10 deletions.
180 changes: 180 additions & 0 deletions assets/flare/Like.flr

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions lib/image_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:async';
import 'profile_page.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'comment_screen.dart';
import 'package:flare_flutter/flare_actor.dart';

class ImagePost extends StatefulWidget {
const ImagePost(
Expand Down Expand Up @@ -135,7 +136,6 @@ class _ImagePost extends State<ImagePost> {
child: Stack(
alignment: Alignment.center,
children: <Widget>[
// FadeInImage.memoryNetwork(placeholder: kTransparentImage, image: mediaUrl),
CachedNetworkImage(
imageUrl: mediaUrl,
fit: BoxFit.fitWidth,
Expand All @@ -144,13 +144,15 @@ class _ImagePost extends State<ImagePost> {
),
showHeart
? Positioned(
child: Opacity(
opacity: 0.85,
child: Icon(
FontAwesomeIcons.solidHeart,
size: 80.0,
color: Colors.white,
)),
child: Container(
width: 100,
height: 100,
child: Opacity(
opacity: 0.85,
child: FlareActor("assets/flare/Like.flr",
animation: "Like",
)),
),
)
: Container()
],
Expand Down Expand Up @@ -287,7 +289,7 @@ class _ImagePost extends State<ImagePost> {
likes[userId] = true;
showHeart = true;
});
Timer(const Duration(milliseconds: 500), () {
Timer(const Duration(milliseconds: 2000), () {
setState(() {
showHeart = false;
});
Expand Down
14 changes: 14 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.4"
flare_dart:
dependency: transitive
description:
name: flare_dart
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.2"
flare_flutter:
dependency: "direct main"
description:
name: flare_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.3"
flutter:
dependency: "direct main"
description: flutter
Expand Down
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies:
firebase_messaging: ^5.1.2
location: ^2.3.5
geocoder: ^0.2.1
flare_flutter: ^1.8.3

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand All @@ -45,6 +46,7 @@ flutter:
- asset: assets/fonts/Billabong.ttf
assets:
- assets/images/google_signin_button.png
- assets/flare/Like.flr
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
Expand Down Expand Up @@ -73,5 +75,5 @@ flutter:
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages

0 comments on commit 124b9f9

Please sign in to comment.