Skip to content

Commit 36a82d3

Browse files
authored
[104] Changing "Panel" to "Layer" (#24)
* [104] Clarifying backdrop. * [104] Changing panel to layer.
1 parent d848b07 commit 36a82d3

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

mdc_100_series/lib/backdrop.dart

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import 'login.dart';
2020

2121
const double _kFlingVelocity = 2.0;
2222

23-
class _BackdropPanel extends StatelessWidget {
24-
const _BackdropPanel({
23+
class _FrontLayer extends StatelessWidget {
24+
const _FrontLayer({
2525
Key key,
2626
this.onTap,
2727
this.child,
@@ -101,26 +101,26 @@ class _BackdropTitle extends AnimatedWidget {
101101

102102
/// Builds a Backdrop.
103103
///
104-
/// A Backdrop widget has two panels, front and back. The front panel is shown
105-
/// by default, and slides down to show the back panel, from which a user
104+
/// A Backdrop widget has two layers, front and back. The front layer is shown
105+
/// by default, and slides down to show the back layer, from which a user
106106
/// can make a selection. The user can also configure the titles for when the
107-
/// front or back panel is showing.
107+
/// front or back layer is showing.
108108
class Backdrop extends StatefulWidget {
109109
final Category currentCategory;
110-
final Widget frontPanel;
111-
final Widget backPanel;
110+
final Widget frontLayer;
111+
final Widget backLayer;
112112
final Widget frontTitle;
113113
final Widget backTitle;
114114

115115
const Backdrop({
116116
@required this.currentCategory,
117-
@required this.frontPanel,
118-
@required this.backPanel,
117+
@required this.frontLayer,
118+
@required this.backLayer,
119119
@required this.frontTitle,
120120
@required this.backTitle,
121121
}) : assert(currentCategory != null),
122-
assert(frontPanel != null),
123-
assert(backPanel != null),
122+
assert(frontLayer != null),
123+
assert(backLayer != null),
124124
assert(frontTitle != null),
125125
assert(backTitle != null);
126126

@@ -150,9 +150,9 @@ class _BackdropState extends State<Backdrop>
150150
setState(() {
151151
_controller.fling(
152152
velocity:
153-
_backdropPanelVisible ? -_kFlingVelocity : _kFlingVelocity);
153+
_frontLayerVisible ? -_kFlingVelocity : _kFlingVelocity);
154154
});
155-
} else if (!_backdropPanelVisible) {
155+
} else if (!_frontLayerVisible) {
156156
setState(() {
157157
_controller.fling(velocity: _kFlingVelocity);
158158
});
@@ -165,37 +165,38 @@ class _BackdropState extends State<Backdrop>
165165
super.dispose();
166166
}
167167

168-
bool get _backdropPanelVisible {
168+
bool get _frontLayerVisible {
169169
final AnimationStatus status = _controller.status;
170170
return status == AnimationStatus.completed ||
171171
status == AnimationStatus.forward;
172172
}
173173

174-
void _toggleBackdropPanelVisibility() {
174+
void _toggleBackdropLayerVisibility() {
175+
print(_frontLayerVisible);
175176
_controller.fling(
176-
velocity: _backdropPanelVisible ? -_kFlingVelocity : _kFlingVelocity);
177+
velocity: _frontLayerVisible ? -_kFlingVelocity : _kFlingVelocity);
177178
}
178179

179180
Widget _buildStack(BuildContext context, BoxConstraints constraints) {
180-
const double panelTitleHeight = 48.0;
181-
final Size panelSize = constraints.biggest;
182-
final double panelTop = panelSize.height - panelTitleHeight;
181+
const double layerTitleHeight = 48.0;
182+
final Size layerSize = constraints.biggest;
183+
final double layerTop = layerSize.height - layerTitleHeight;
183184

184-
Animation<RelativeRect> panelAnimation = RelativeRectTween(
185+
Animation<RelativeRect> layerAnimation = RelativeRectTween(
185186
begin: RelativeRect.fromLTRB(
186-
0.0, panelTop, 0.0, panelTop - panelSize.height),
187+
0.0, layerTop, 0.0, layerTop - layerSize.height),
187188
end: RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0),
188189
).animate(_controller.view);
189190

190191
return Stack(
191192
key: _backdropKey,
192193
children: <Widget>[
193-
widget.backPanel,
194+
widget.backLayer,
194195
PositionedTransition(
195-
rect: panelAnimation,
196-
child: _BackdropPanel(
197-
onTap: _toggleBackdropPanelVisibility,
198-
child: widget.frontPanel,
196+
rect: layerAnimation,
197+
child: _FrontLayer(
198+
onTap: _toggleBackdropLayerVisibility,
199+
child: widget.frontLayer,
199200
),
200201
),
201202
],

0 commit comments

Comments
 (0)