Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9576ce43
Commit
9576ce43
authored
Feb 17, 2016
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds dialog for completed exercise in Fitness demo
parent
ecfc3032
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
1 deletion
+88
-1
fitness_demo.dart
examples/material_gallery/lib/demo/fitness_demo.dart
+87
-0
pubspec.yaml
examples/material_gallery/pubspec.yaml
+1
-1
No files found.
examples/material_gallery/lib/demo/fitness_demo.dart
View file @
9576ce43
...
...
@@ -8,6 +8,7 @@ import 'dart:ui' as ui;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_sprites/flutter_sprites.dart'
;
import
'package:vector_math/vector_math_64.dart'
as
vec
;
ImageMap
_images
;
SpriteSheet
_sprites
;
...
...
@@ -173,6 +174,25 @@ class _FitnessDemoContentsState extends State<_FitnessDemoContents> {
void
endWorkout
()
{
setState
(()
{
workoutAnimation
.
stop
();
if
(
count
>=
3
)
{
showDialog
(
context:
context
,
child:
new
Stack
(
children:
<
Widget
>[
new
_Fireworks
(),
new
Dialog
(
title:
new
Text
(
"Awesome workout"
),
content:
new
Text
(
"You have completed
$count
jumping jacks. Good going!"
),
actions:
<
Widget
>[
new
FlatButton
(
child:
new
Text
(
"SWEET"
),
onPressed:
()
{
Navigator
.
pop
(
context
);
}
)
]
)
])
);
}
});
}
}
...
...
@@ -489,3 +509,70 @@ class _JumpingJackPart extends Sprite {
}
}
}
class
_Fireworks
extends
StatefulComponent
{
_Fireworks
({
Key
key
})
:
super
(
key:
key
);
_FireworksState
createState
()
=>
new
_FireworksState
();
}
class
_FireworksState
extends
State
<
_Fireworks
>
{
void
initState
()
{
super
.
initState
();
fireworks
=
new
_FireworksNode
();
}
_FireworksNode
fireworks
;
Widget
build
(
BuildContext
context
)
{
return
new
SpriteWidget
(
fireworks
);
}
}
class
_FireworksNode
extends
NodeWithSize
{
_FireworksNode
()
:
super
(
const
Size
(
1024.0
,
1024.0
));
double
_countDown
=
0.0
;
void
update
(
double
dt
)
{
if
(
_countDown
<=
0.0
)
{
_addExplosion
();
_countDown
=
randomDouble
();
}
_countDown
-=
dt
;
}
Color
_randomExplosionColor
()
{
double
rand
=
randomDouble
();
if
(
rand
<
0.25
)
return
Colors
.
pink
[
200
];
else
if
(
rand
<
0.5
)
return
Colors
.
lightBlue
[
200
];
else
if
(
rand
<
0.75
)
return
Colors
.
purple
[
200
];
else
return
Colors
.
cyan
[
200
];
}
void
_addExplosion
()
{
Color
startColor
=
_randomExplosionColor
();
Color
endColor
=
startColor
.
withAlpha
(
0
);
ParticleSystem
system
=
new
ParticleSystem
(
_sprites
[
'particle-0.png'
],
numParticlesToEmit:
100
,
emissionRate:
1000.0
,
rotateToMovement:
true
,
startRotation:
90.0
,
endRotation:
90.0
,
speed:
100.0
,
speedVar:
50.0
,
startSize:
1.0
,
startSizeVar:
0.5
,
gravity:
new
vec
.
Vector2
(
0.0
,
30.0
),
colorSequence:
new
ColorSequence
.
fromStartAndEndColor
(
startColor
,
endColor
)
);
system
.
position
=
new
Point
(
randomDouble
()
*
1024.0
,
randomDouble
()
*
1024.0
);
addChild
(
system
);
}
}
examples/material_gallery/pubspec.yaml
View file @
9576ce43
...
...
@@ -6,4 +6,4 @@ dependencies:
path
:
../../packages/flutter
flutter_sprites
:
path
:
../../packages/flutter_sprites
flutter_gallery_assets
:
'
0.0.
7
'
flutter_gallery_assets
:
'
0.0.
9
'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment