-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[material_3_demo] Refactor application code into multiple small libra…
…ries (#2581)
- Loading branch information
Showing
23 changed files
with
1,000 additions
and
910 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2021 The Flutter team. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class SizeAnimation extends CurvedAnimation { | ||
SizeAnimation(Animation<double> parent) | ||
: super( | ||
parent: parent, | ||
curve: const Interval(0.2, 0.8, curve: Curves.easeInOutCubicEmphasized), | ||
reverseCurve: Interval( | ||
0, | ||
0.2, | ||
curve: Curves.easeInOutCubicEmphasized.flipped, | ||
), | ||
); | ||
} | ||
|
||
class OffsetAnimation extends CurvedAnimation { | ||
OffsetAnimation(Animation<double> parent) | ||
: super( | ||
parent: parent, | ||
curve: const Interval(0.4, 1.0, curve: Curves.easeInOutCubicEmphasized), | ||
reverseCurve: Interval( | ||
0, | ||
0.2, | ||
curve: Curves.easeInOutCubicEmphasized.flipped, | ||
), | ||
); | ||
} |
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,59 @@ | ||
// Copyright 2021 The Flutter team. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
import 'package:flutter/widgets.dart'; | ||
|
||
import 'animations.dart'; | ||
|
||
class BarTransition extends StatefulWidget { | ||
const BarTransition({ | ||
super.key, | ||
required this.animation, | ||
required this.backgroundColor, | ||
required this.child, | ||
}); | ||
|
||
final Animation<double> animation; | ||
final Color backgroundColor; | ||
final Widget child; | ||
|
||
@override | ||
State<BarTransition> createState() => _BarTransition(); | ||
} | ||
|
||
class _BarTransition extends State<BarTransition> { | ||
late final Animation<Offset> offsetAnimation; | ||
late final Animation<double> heightAnimation; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
|
||
offsetAnimation = Tween<Offset>( | ||
begin: const Offset(0, 1), | ||
end: Offset.zero, | ||
).animate(OffsetAnimation(widget.animation)); | ||
|
||
heightAnimation = Tween<double>( | ||
begin: 0, | ||
end: 1, | ||
).animate(SizeAnimation(widget.animation)); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ClipRect( | ||
child: DecoratedBox( | ||
decoration: BoxDecoration(color: widget.backgroundColor), | ||
child: Align( | ||
alignment: Alignment.topLeft, | ||
heightFactor: heightAnimation.value, | ||
child: FractionalTranslation( | ||
translation: offsetAnimation.value, | ||
child: widget.child, | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.