Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animation to Heart when liking a post #77

Merged
merged 7 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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