Skip to content

Commit dbf6d23

Browse files
committed
Update animations rebuild script
1 parent c80084a commit dbf6d23

File tree

1 file changed

+71
-77
lines changed

1 file changed

+71
-77
lines changed

animations/codelab_rebuild.yaml

Lines changed: 71 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ steps:
250250
TextButton(
251251
onPressed:
252252
viewModel.hasNextQuestion && viewModel.didAnswerQuestion
253-
? () {
254-
viewModel.getNextQuestion();
255-
}
256-
: null,
253+
? () {
254+
viewModel.getNextQuestion();
255+
}
256+
: null,
257257
child: const Text('Next'),
258258
),
259259
],
@@ -268,10 +268,9 @@ steps:
268268
viewModel.checkAnswer(index);
269269
},
270270
answers: viewModel.currentQuestion?.possibleAnswers ?? [],
271-
correctAnswer:
272-
viewModel.didAnswerQuestion
273-
? viewModel.currentQuestion?.correctAnswer
274-
: null,
271+
correctAnswer: viewModel.didAnswerQuestion
272+
? viewModel.currentQuestion?.correctAnswer
273+
: null,
275274
),
276275
StatusBar(viewModel: viewModel),
277276
],
@@ -438,8 +437,9 @@ steps:
438437
Icon(
439438
Icons.star,
440439
size: 50,
441-
color:
442-
score < i + 1 ? Colors.grey.shade400 : Colors.yellow.shade700,
440+
color: score < i + 1
441+
? Colors.grey.shade400
442+
: Colors.yellow.shade700,
443443
),
444444
],
445445
),
@@ -466,7 +466,7 @@ steps:
466466
import 'view_model.dart';
467467
468468
class QuestionScreen extends StatefulWidget {
469-
@@ -160,13 +161,9 @@ class StatusBar extends StatelessWidget {
469+
@@ -159,13 +160,9 @@ class StatusBar extends StatelessWidget {
470470
child: Row(
471471
mainAxisAlignment: MainAxisAlignment.spaceAround,
472472
children: [
@@ -497,15 +497,16 @@ steps:
497497
patch-u: |
498498
--- b/animations/step_02_c/lib/scoreboard.dart
499499
+++ a/animations/step_02_c/lib/scoreboard.dart
500-
@@ -18,14 +18,31 @@ class Scoreboard extends StatelessWidget {
500+
@@ -18,15 +18,31 @@ class Scoreboard extends StatelessWidget {
501501
mainAxisAlignment: MainAxisAlignment.center,
502502
children: [
503503
for (var i = 0; i < totalQuestions; i++)
504504
- Icon(
505505
- Icons.star,
506506
- size: 50,
507-
- color:
508-
- score < i + 1 ? Colors.grey.shade400 : Colors.yellow.shade700,
507+
- color: score < i + 1
508+
- ? Colors.grey.shade400
509+
- : Colors.yellow.shade700,
509510
- ),
510511
+ AnimatedStar(isActive: score > i),
511512
],
@@ -616,7 +617,7 @@ steps:
616617
patch-u: |
617618
--- b/animations/step_03_a/lib/question_screen.dart
618619
+++ a/animations/step_03_a/lib/question_screen.dart
619-
@@ -86,13 +86,17 @@ class QuestionCard extends StatelessWidget {
620+
@@ -85,13 +85,17 @@ class QuestionCard extends StatelessWidget {
620621
621622
@override
622623
Widget build(BuildContext context) {
@@ -655,7 +656,7 @@ steps:
655656
patch-u: |
656657
--- b/animations/step_03_b/lib/question_screen.dart
657658
+++ a/animations/step_03_b/lib/question_screen.dart
658-
@@ -87,6 +87,16 @@ class QuestionCard extends StatelessWidget {
659+
@@ -86,6 +86,16 @@ class QuestionCard extends StatelessWidget {
659660
@override
660661
Widget build(BuildContext context) {
661662
return AnimatedSwitcher(
@@ -686,7 +687,7 @@ steps:
686687
patch-u: |
687688
--- b/animations/step_03_c/lib/question_screen.dart
688689
+++ a/animations/step_03_c/lib/question_screen.dart
689-
@@ -95,7 +95,11 @@ class QuestionCard extends StatelessWidget {
690+
@@ -94,7 +94,11 @@ class QuestionCard extends StatelessWidget {
690691
begin: Offset(-0.1, 0.0),
691692
end: Offset.zero,
692693
).animate(curveAnimation);
@@ -713,7 +714,7 @@ steps:
713714
patch-u: |
714715
--- b/animations/step_03_d/lib/question_screen.dart
715716
+++ a/animations/step_03_d/lib/question_screen.dart
716-
@@ -87,6 +87,15 @@ class QuestionCard extends StatelessWidget {
717+
@@ -86,6 +86,15 @@ class QuestionCard extends StatelessWidget {
717718
@override
718719
Widget build(BuildContext context) {
719720
return AnimatedSwitcher(
@@ -801,14 +802,13 @@ steps:
801802
builder: (context, child) {
802803
return Transform(
803804
alignment: Alignment.center,
804-
transform:
805-
Matrix4.identity()..rotateX(_animationController.value * math.pi),
806-
child:
807-
_animationController.isAnimating
808-
? _animationController.value < 0.5
809-
? _previousChild
810-
: Transform.flip(flipY: true, child: child)
811-
: child,
805+
transform: Matrix4.identity()
806+
..rotateX(_animationController.value * math.pi),
807+
child: _animationController.isAnimating
808+
? _animationController.value < 0.5
809+
? _previousChild
810+
: Transform.flip(flipY: true, child: child)
811+
: child,
812812
);
813813
},
814814
child: widget.child,
@@ -826,7 +826,7 @@ steps:
826826
import 'scoreboard.dart';
827827
import 'view_model.dart';
828828
829-
@@ -149,21 +150,24 @@ class AnswerCards extends StatelessWidget {
829+
@@ -148,21 +149,24 @@ class AnswerCards extends StatelessWidget {
830830
if (correctAnswer == index) {
831831
color = Theme.of(context).colorScheme.tertiaryContainer;
832832
}
@@ -899,7 +899,7 @@ steps:
899899
patch-u: |
900900
--- b/animations/step_04_b/lib/question_screen.dart
901901
+++ a/animations/step_04_b/lib/question_screen.dart
902-
@@ -151,6 +151,7 @@ class AnswerCards extends StatelessWidget {
902+
@@ -150,6 +150,7 @@ class AnswerCards extends StatelessWidget {
903903
color = Theme.of(context).colorScheme.tertiaryContainer;
904904
}
905905
return CardFlipEffect(
@@ -968,7 +968,7 @@ steps:
968968
patch-u: |
969969
--- b/animations/step_04_d/lib/flip_effect.dart
970970
+++ a/animations/step_04_d/lib/flip_effect.dart
971-
@@ -66,15 +66,15 @@ class _CardFlipEffectState extends State<CardFlipEffect>
971+
@@ -66,14 +66,14 @@ class _CardFlipEffectState extends State<CardFlipEffect>
972972
@override
973973
Widget build(BuildContext context) {
974974
return AnimatedBuilder(
@@ -977,16 +977,15 @@ steps:
977977
builder: (context, child) {
978978
return Transform(
979979
alignment: Alignment.center,
980-
transform:
981-
- Matrix4.identity()..rotateX(_animationController.value * math.pi),
982-
+ Matrix4.identity()..rotateX(_animationWithDelay.value * math.pi),
983-
child:
984-
_animationController.isAnimating
985-
- ? _animationController.value < 0.5
986-
+ ? _animationWithDelay.value < 0.5
987-
? _previousChild
988-
: Transform.flip(flipY: true, child: child)
989-
: child,
980+
transform: Matrix4.identity()
981+
- ..rotateX(_animationController.value * math.pi),
982+
+ ..rotateX(_animationWithDelay.value * math.pi),
983+
child: _animationController.isAnimating
984+
- ? _animationController.value < 0.5
985+
+ ? _animationWithDelay.value < 0.5
986+
? _previousChild
987+
: Transform.flip(flipY: true, child: child)
988+
: child,
990989
- name: Copy step_04_d
991990
copydir:
992991
from: quiz
@@ -1001,7 +1000,7 @@ steps:
10011000
patch-u: |
10021001
--- b/animations/step_05_a/lib/home_screen.dart
10031002
+++ a/animations/step_05_a/lib/home_screen.dart
1004-
@@ -24,9 +24,17 @@ class HomeScreen extends StatelessWidget {
1003+
@@ -24,10 +24,17 @@ class HomeScreen extends StatelessWidget {
10051004
// Show the question screen to start the game
10061005
Navigator.push(
10071006
context,
@@ -1011,17 +1010,17 @@ steps:
10111010
+ PageRouteBuilder(
10121011
+ pageBuilder: (context, animation, secondaryAnimation) {
10131012
+ return const QuestionScreen();
1014-
+ },
1015-
+ transitionsBuilder: (
1016-
+ context,
1017-
+ animation,
1018-
+ secondaryAnimation,
1019-
+ child,
1020-
+ ) {
1021-
+ return FadeTransition(opacity: animation, child: child);
10221013
},
1014+
+ transitionsBuilder:
1015+
+ (context, animation, secondaryAnimation, child) {
1016+
+ return FadeTransition(
1017+
+ opacity: animation,
1018+
+ child: child,
1019+
+ );
1020+
+ },
10231021
),
10241022
);
1023+
},
10251024
- name: Copy step_05_a
10261025
copydir:
10271026
from: quiz
@@ -1041,19 +1040,18 @@ steps:
10411040
import 'package:flutter/material.dart';
10421041
import 'question_screen.dart';
10431042
1044-
@@ -34,7 +35,11 @@ class HomeScreen extends StatelessWidget {
1045-
secondaryAnimation,
1046-
child,
1047-
) {
1048-
- return FadeTransition(opacity: animation, child: child);
1049-
+ return FadeThroughTransition(
1050-
+ animation: animation,
1051-
+ secondaryAnimation: secondaryAnimation,
1052-
+ child: child,
1053-
+ );
1043+
@@ -30,8 +31,9 @@ class HomeScreen extends StatelessWidget {
10541044
},
1055-
),
1056-
);
1045+
transitionsBuilder:
1046+
(context, animation, secondaryAnimation, child) {
1047+
- return FadeTransition(
1048+
- opacity: animation,
1049+
+ return FadeThroughTransition(
1050+
+ animation: animation,
1051+
+ secondaryAnimation: secondaryAnimation,
1052+
child: child,
1053+
);
1054+
},
10571055
- name: Patch lib/main.dart
10581056
path: quiz/lib/main.dart
10591057
patch-u: |
@@ -1099,7 +1097,7 @@ steps:
10991097
import 'package:flutter/material.dart';
11001098
import 'question_screen.dart';
11011099
1102-
@@ -25,22 +24,10 @@ class HomeScreen extends StatelessWidget {
1100+
@@ -25,18 +24,10 @@ class HomeScreen extends StatelessWidget {
11031101
// Show the question screen to start the game
11041102
Navigator.push(
11051103
context,
@@ -1109,18 +1107,14 @@ steps:
11091107
+ builder: (context) {
11101108
return const QuestionScreen();
11111109
},
1112-
- transitionsBuilder: (
1113-
- context,
1114-
- animation,
1115-
- secondaryAnimation,
1116-
- child,
1117-
- ) {
1118-
- return FadeThroughTransition(
1119-
- animation: animation,
1120-
- secondaryAnimation: secondaryAnimation,
1121-
- child: child,
1122-
- );
1123-
- },
1110+
- transitionsBuilder:
1111+
- (context, animation, secondaryAnimation, child) {
1112+
- return FadeThroughTransition(
1113+
- animation: animation,
1114+
- secondaryAnimation: secondaryAnimation,
1115+
- child: child,
1116+
- );
1117+
- },
11241118
),
11251119
);
11261120
},
@@ -1134,7 +1128,7 @@ steps:
11341128
import 'package:flutter/material.dart';
11351129
import 'flip_effect.dart';
11361130
import 'scoreboard.dart';
1137-
@@ -87,28 +88,15 @@ class QuestionCard extends StatelessWidget {
1131+
@@ -86,28 +87,15 @@ class QuestionCard extends StatelessWidget {
11381132
11391133
@override
11401134
Widget build(BuildContext context) {
@@ -1206,7 +1200,7 @@ steps:
12061200
Spacer(),
12071201
AnswerCards(
12081202
onTapped: (index) {
1209-
@@ -59,24 +64,47 @@ class _QuestionScreenState extends State<QuestionScreen> {
1203+
@@ -58,24 +63,47 @@ class _QuestionScreenState extends State<QuestionScreen> {
12101204
);
12111205
}
12121206
@@ -1266,7 +1260,7 @@ steps:
12661260
);
12671261
}
12681262
}
1269-
@@ -84,14 +112,22 @@ class _QuestionScreenState extends State<QuestionScreen> {
1263+
@@ -83,14 +111,22 @@ class _QuestionScreenState extends State<QuestionScreen> {
12701264
class QuestionCard extends StatelessWidget {
12711265
final String? question;
12721266
@@ -1293,7 +1287,7 @@ steps:
12931287
transitionBuilder: (child, animation, secondaryAnimation) {
12941288
return FadeThroughTransition(
12951289
animation: animation,
1296-
@@ -99,17 +135,30 @@ class QuestionCard extends StatelessWidget {
1290+
@@ -98,17 +134,30 @@ class QuestionCard extends StatelessWidget {
12971291
child: child,
12981292
);
12991293
},

0 commit comments

Comments
 (0)