Commit cf17dd96 authored by Hans Muller's avatar Hans Muller

Merge pull request #1509 from HansMuller/remove_popup_menu_margin

Remove PopupMenu margin

The margins make using showMenu's menuPosition argument difficult and they're not really needed.

I also made a few small gratuitous changes in navigator.dart.
parents 66c6ce37 56d9d85f
...@@ -6,12 +6,14 @@ part of stocks; ...@@ -6,12 +6,14 @@ part of stocks;
enum _MenuItems { autorefresh, autorefreshCheckbox, add, remove } enum _MenuItems { autorefresh, autorefreshCheckbox, add, remove }
const double _kMenuMargin = 16.0; // 24.0 on tablet
Future showStockMenu(NavigatorState navigator, { bool autorefresh, ValueChanged onAutorefreshChanged }) async { Future showStockMenu(NavigatorState navigator, { bool autorefresh, ValueChanged onAutorefreshChanged }) async {
switch (await showMenu( switch (await showMenu(
navigator: navigator, navigator: navigator,
position: new MenuPosition( position: new MenuPosition(
right: sky.view.paddingRight, right: sky.view.paddingRight + _kMenuMargin,
top: sky.view.paddingTop top: sky.view.paddingTop + _kMenuMargin
), ),
builder: (NavigatorState navigator) { builder: (NavigatorState navigator) {
return <PopupMenuItem>[ return <PopupMenuItem>[
......
...@@ -63,16 +63,11 @@ class NavigatorState extends State<Navigator> { ...@@ -63,16 +63,11 @@ class NavigatorState extends State<Navigator> {
} }
void pushNamed(String name) { void pushNamed(String name) {
RouteBuilder builder; RouteBuilder generateRoute() {
if (!config.routes.containsKey(name)) {
assert(config.onGenerateRoute != null); assert(config.onGenerateRoute != null);
builder = config.onGenerateRoute(name); return config.onGenerateRoute(name);
} else {
builder = config.routes[name];
} }
if (builder == null) RouteBuilder builder = config.routes[name] ?? generateRoute() ?? config.onUnknownRoute;
builder = config.onUnknownRoute; // 404!
assert(builder != null); // 404 getting your 404!
push(new PageRoute(builder)); push(new PageRoute(builder));
} }
...@@ -87,7 +82,6 @@ class NavigatorState extends State<Navigator> { ...@@ -87,7 +82,6 @@ class NavigatorState extends State<Navigator> {
assert(!_debugCurrentlyHaveRoute(route)); assert(!_debugCurrentlyHaveRoute(route));
setState(() { setState(() {
while (currentRoute.ephemeral) { while (currentRoute.ephemeral) {
assert(currentRoute.ephemeral);
currentRoute.didPop(null); currentRoute.didPop(null);
_currentPosition -= 1; _currentPosition -= 1;
} }
......
...@@ -21,7 +21,6 @@ import 'package:sky/src/widgets/transitions.dart'; ...@@ -21,7 +21,6 @@ import 'package:sky/src/widgets/transitions.dart';
const Duration _kMenuDuration = const Duration(milliseconds: 300); const Duration _kMenuDuration = const Duration(milliseconds: 300);
const double _kMenuCloseIntervalEnd = 2.0 / 3.0; const double _kMenuCloseIntervalEnd = 2.0 / 3.0;
const double _kMenuWidthStep = 56.0; const double _kMenuWidthStep = 56.0;
const double _kMenuMargin = 16.0; // 24.0 on tablet
const double _kMenuMinWidth = 2.0 * _kMenuWidthStep; const double _kMenuMinWidth = 2.0 * _kMenuWidthStep;
const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep; const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep;
const double _kMenuHorizontalPadding = 16.0; const double _kMenuHorizontalPadding = 16.0;
...@@ -75,39 +74,36 @@ class PopupMenu extends StatelessComponent { ...@@ -75,39 +74,36 @@ class PopupMenu extends StatelessComponent {
return new FadeTransition( return new FadeTransition(
performance: performance, performance: performance,
opacity: new AnimatedValue<double>(0.0, end: 1.0, curve: new Interval(0.0, 1.0 / 3.0)), opacity: new AnimatedValue<double>(0.0, end: 1.0, curve: new Interval(0.0, 1.0 / 3.0)),
child: new Container( child: new BuilderTransition(
margin: new EdgeDims.all(_kMenuMargin), performance: performance,
child: new BuilderTransition( variables: [width, height],
performance: performance, builder: (BuildContext context) {
variables: [width, height], return new CustomPaint(
builder: (BuildContext context) { callback: (sky.Canvas canvas, Size size) {
return new CustomPaint( double widthValue = width.value * size.width;
callback: (sky.Canvas canvas, Size size) { double heightValue = height.value * size.height;
double widthValue = width.value * size.width; painter.paint(canvas, new Rect.fromLTWH(size.width - widthValue, 0.0, widthValue, heightValue));
double heightValue = height.value * size.height; },
painter.paint(canvas, new Rect.fromLTWH(size.width - widthValue, 0.0, widthValue, heightValue)); child: new ConstrainedBox(
}, constraints: new BoxConstraints(
child: new ConstrainedBox( minWidth: _kMenuMinWidth,
constraints: new BoxConstraints( maxWidth: _kMenuMaxWidth
minWidth: _kMenuMinWidth, ),
maxWidth: _kMenuMaxWidth child: new IntrinsicWidth(
), stepWidth: _kMenuWidthStep,
child: new IntrinsicWidth( child: new ScrollableViewport(
stepWidth: _kMenuWidthStep, child: new Container(
child: new ScrollableViewport( padding: const EdgeDims.symmetric(
child: new Container( horizontal: _kMenuHorizontalPadding,
padding: const EdgeDims.symmetric( vertical: _kMenuVerticalPadding
horizontal: _kMenuHorizontalPadding, ),
vertical: _kMenuVerticalPadding child: new BlockBody(children)
),
child: new BlockBody(children)
)
) )
) )
) )
); )
} );
) }
) )
); );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment