-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added RawCard for better custom animation handling - Added a ScaleButton.builder to combine scaling and card elevation animations - Added a MainContainer that contains and manages the background and home screen. - Added Background widget - Added ZoomPageRoute transition
- Loading branch information
1 parent
755f75c
commit 6db1054
Showing
22 changed files
with
487 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch", | ||
"request": "launch", | ||
"type": "dart", | ||
"console": "terminal" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
{ | ||
"dart.lineLength": 80, | ||
"python.pythonPath": "/usr/bin/python" | ||
"dart.lineLength": 80 | ||
} |
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 was deleted.
Oops, something went wrong.
File renamed without changes.
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,29 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:shiritori/ui/main/home/widgets/widgets.dart'; | ||
|
||
class HomeScreen extends StatelessWidget { | ||
const HomeScreen({Key key}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: const [ | ||
Expanded( | ||
flex: 2, | ||
child: SizedBox( | ||
width: double.infinity, | ||
child: Padding( | ||
padding: EdgeInsets.all(24.0), | ||
child: HomeHeader(), | ||
), | ||
), | ||
), | ||
Expanded( | ||
flex: 3, | ||
child: HomeMenu(), | ||
), | ||
], | ||
); | ||
} | ||
} |
File renamed without changes.
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
File renamed without changes.
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,2 @@ | ||
export 'home/home.dart'; | ||
export 'main_container.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,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shiritori/ui/main/main.dart'; | ||
import 'package:shiritori/ui/main/widgets/widgets.dart'; | ||
import 'package:shiritori/ui/routes/routes.dart'; | ||
|
||
class MainContainer extends StatelessWidget { | ||
final _navigatorKey = GlobalKey<NavigatorState>(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: Stack( | ||
fit: StackFit.expand, | ||
children: [ | ||
Background( | ||
navigatorKey: _navigatorKey, | ||
), | ||
SafeArea( | ||
child: WillPopScope( | ||
onWillPop: () async { | ||
return !await _navigatorKey.currentState?.maybePop(); | ||
}, | ||
child: Navigator( | ||
key: _navigatorKey, | ||
onGenerateRoute: (_) { | ||
return ZoomPageRoute( | ||
builder: (_) => const HomeScreen(), | ||
); | ||
}, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
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,47 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shiritori/assets/assets.dart'; | ||
|
||
class Background extends StatefulWidget { | ||
const Background({ | ||
Key key, | ||
@required this.navigatorKey, | ||
}) : assert(navigatorKey != null), | ||
super(key: key); | ||
|
||
final GlobalKey<NavigatorState> navigatorKey; | ||
|
||
@override | ||
_BackgroundState createState() => _BackgroundState(); | ||
} | ||
|
||
class _BackgroundState extends State<Background> | ||
with SingleTickerProviderStateMixin { | ||
AnimationController animationController; | ||
|
||
Navigator get navigator => widget.navigatorKey.currentWidget as Navigator; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
initAnimations(); | ||
initNavigatorObserver(); | ||
} | ||
|
||
void initAnimations() { | ||
animationController = AnimationController( | ||
vsync: this, | ||
duration: const Duration(milliseconds: 350), | ||
); | ||
} | ||
|
||
void initNavigatorObserver() { | ||
// Pass RouteObserver through provider and fetch here? | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Images.backgroundMain( | ||
fit: BoxFit.cover, | ||
); | ||
} | ||
} |
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 @@ | ||
export 'background.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 @@ | ||
export 'zoom_page_route.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,67 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:shiritori/theme/theme.dart'; | ||
|
||
class ZoomPageRoute extends PageRouteBuilder { | ||
ZoomPageRoute({ | ||
@required final WidgetBuilder builder, | ||
}) : assert(builder != null), | ||
super( | ||
transitionDuration: const Duration(milliseconds: 350), | ||
transitionsBuilder: (context, animationIn, animationOut, child) { | ||
final curve = AppTheme.curveDefault; | ||
final reverseCurve = curve.flipped; | ||
|
||
final opacityAnimationIn = CurvedAnimation( | ||
parent: animationIn, | ||
curve: curve, | ||
reverseCurve: reverseCurve, | ||
); | ||
final opacityAnimationOut = CurvedAnimation( | ||
parent: animationOut.drive(Tween(begin: 1.0, end: 0.0)), | ||
// TODO: Determine best looking approach. | ||
// | ||
// Note: in practice, this curve is flipped because of how the | ||
// value is used within the transition. | ||
// | ||
// If `curve: curve` is set, the page will lose opacity very | ||
// slowly at the start and then drop off sharp near the end | ||
// (essentially the same as `curve.flipped`, | ||
// i.e., `reverseCurve`). | ||
// If `curve: reverseCurve` is set, the animation will exhibit | ||
// the behavior expected of `curve` (unflipped), and the | ||
// opacity will start with a fast dropoff and then slowly | ||
// settles. | ||
curve: curve, | ||
reverseCurve: curve, | ||
); | ||
final scaleAnimationIn = CurvedAnimation( | ||
parent: animationIn, | ||
curve: curve, | ||
reverseCurve: reverseCurve, | ||
).drive(Tween(begin: 0.8, end: 1.0)); | ||
final scaleAnimationOut = CurvedAnimation( | ||
parent: animationOut, | ||
curve: curve, | ||
reverseCurve: reverseCurve, | ||
).drive(Tween(begin: 1.0, end: 1.2)); | ||
|
||
return FadeTransition( | ||
opacity: opacityAnimationIn, | ||
child: FadeTransition( | ||
opacity: opacityAnimationOut, | ||
child: ScaleTransition( | ||
alignment: Alignment.center, | ||
scale: scaleAnimationIn, | ||
child: ScaleTransition( | ||
scale: scaleAnimationOut, | ||
child: child, | ||
), | ||
), | ||
), | ||
); | ||
}, | ||
pageBuilder: (context, animation, secondAnimation) { | ||
return builder(context); | ||
}, | ||
); | ||
} |
Oops, something went wrong.