This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add loading indicator to character sprites (#579)
- Loading branch information
Showing
12 changed files
with
125 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/photobooth_ui/lib/src/widgets/app_animated_cross_fade.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
/// {@template app_animated_cross_fade} | ||
/// Abstraction of AnimatedCrossFade to override the layout centering | ||
/// the widgets inside | ||
/// {@endtemplate} | ||
class AppAnimatedCrossFade extends StatelessWidget { | ||
/// {@macro app_animated_cross_fade} | ||
const AppAnimatedCrossFade({ | ||
Key? key, | ||
required this.firstChild, | ||
required this.secondChild, | ||
required this.crossFadeState, | ||
}) : super(key: key); | ||
|
||
/// First [Widget] to display | ||
final Widget firstChild; | ||
|
||
/// Second [Widget] to display | ||
final Widget secondChild; | ||
|
||
/// Specifies when to display [firstChild] or [secondChild] | ||
final CrossFadeState crossFadeState; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return AnimatedCrossFade( | ||
firstChild: firstChild, | ||
secondChild: secondChild, | ||
crossFadeState: crossFadeState, | ||
duration: const Duration(seconds: 1), | ||
layoutBuilder: ( | ||
Widget topChild, | ||
Key topChildKey, | ||
Widget bottomChild, | ||
Key bottomChildKey, | ||
) { | ||
return Stack( | ||
clipBehavior: Clip.none, | ||
alignment: Alignment.center, | ||
children: [ | ||
Align( | ||
alignment: Alignment.center, | ||
key: bottomChildKey, | ||
child: bottomChild, | ||
), | ||
Align( | ||
alignment: Alignment.center, | ||
key: topChildKey, | ||
child: topChild, | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
packages/photobooth_ui/test/src/widgets/app_animated_cross_fade_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// ignore_for_file: prefer_const_constructors | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:photobooth_ui/photobooth_ui.dart'; | ||
|
||
void main() { | ||
group('AppAnimatedCrossFade', () { | ||
testWidgets('renders both children', (tester) async { | ||
await tester.pumpWidget( | ||
AppAnimatedCrossFade( | ||
firstChild: SizedBox(key: Key('first')), | ||
secondChild: SizedBox(key: Key('second')), | ||
crossFadeState: CrossFadeState.showFirst), | ||
); | ||
expect(find.byKey(Key('first')), findsOneWidget); | ||
expect(find.byKey(Key('second')), findsOneWidget); | ||
}); | ||
}); | ||
} |