Merge pull request #1503 from abarth/simplify_scaffold
Simplify Scaffold
diff --git a/examples/game/lib/main.dart b/examples/game/lib/main.dart
index 2cb407a..51366d9 100644
--- a/examples/game/lib/main.dart
+++ b/examples/game/lib/main.dart
@@ -119,8 +119,10 @@
width: 128.0,
height: 128.0
),
- new Text(
- "Last Score: $_lastScore",
+ new DefaultTextStyle(
+ child: new Text(
+ "Last Score: $_lastScore"
+ ),
style: new TextStyle(fontSize:20.0)
)
],
diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart
index cda963b..106f457 100644
--- a/examples/stocks/lib/stock_home.dart
+++ b/examples/stocks/lib/stock_home.dart
@@ -126,22 +126,23 @@
Widget buildToolBar() {
return new ToolBar(
- left: new IconButton(
- icon: "navigation/menu",
- onPressed: _showDrawer
+ level: 0,
+ left: new IconButton(
+ icon: "navigation/menu",
+ onPressed: _showDrawer
+ ),
+ center: new Text('Stocks'),
+ right: [
+ new IconButton(
+ icon: "action/search",
+ onPressed: _handleSearchBegin
),
- center: new Text('Stocks'),
- right: [
- new IconButton(
- icon: "action/search",
- onPressed: _handleSearchBegin
- ),
- new IconButton(
- icon: "navigation/more_vert",
- onPressed: _handleMenuShow
- )
- ]
- );
+ new IconButton(
+ icon: "navigation/more_vert",
+ onPressed: _handleMenuShow
+ )
+ ]
+ );
}
int selectedTabIndex = 0;
diff --git a/packages/flutter/lib/src/material/constants.dart b/packages/flutter/lib/src/material/constants.dart
index 0ec7112..6ae28e7 100644
--- a/packages/flutter/lib/src/material/constants.dart
+++ b/packages/flutter/lib/src/material/constants.dart
@@ -18,7 +18,8 @@
const double kMaterialDrawerHeight = 140.0;
const double kScrollbarSize = 10.0;
-const double kScrollbarFadeDuration = 250.0;
-const double kScrollbarFadeDelay = 300.0;
+const Duration kScrollbarFadeDuration = const Duration(milliseconds: 250);
+const Duration kScrollbarFadeDelay = const Duration(milliseconds: 300);
const double kFadingEdgeLength = 12.0;
-const double kPressedStateDuration = 64.0;
+const double kPressedStateDuration = 64.0; // units?
+const Duration kThemeChangeDuration = const Duration(milliseconds: 200);
diff --git a/packages/flutter/lib/src/widgets/material.dart b/packages/flutter/lib/src/widgets/material.dart
index c14b29f..138994c 100644
--- a/packages/flutter/lib/src/widgets/material.dart
+++ b/packages/flutter/lib/src/widgets/material.dart
@@ -67,7 +67,7 @@
style: Theme.of(context).text.body1,
child: new AnimatedContainer(
curve: ease,
- duration: const Duration(milliseconds: 200),
+ duration: kThemeChangeDuration,
decoration: new BoxDecoration(
backgroundColor: _getBackgroundColor(context),
borderRadius: _kEdges[type],
diff --git a/packages/flutter/lib/src/widgets/mimic.dart b/packages/flutter/lib/src/widgets/mimic.dart
index 45bb12f..961db37 100644
--- a/packages/flutter/lib/src/widgets/mimic.dart
+++ b/packages/flutter/lib/src/widgets/mimic.dart
@@ -9,7 +9,7 @@
class MimicableKey {
MimicableKey._(this._state);
- final _MimicableState _state;
+ final MimicableState _state;
Rect get globalBounds => _state._globalBounds;
@@ -35,10 +35,10 @@
final Widget child;
- _MimicableState createState() => new _MimicableState();
+ MimicableState createState() => new MimicableState();
}
-class _MimicableState extends State<Mimicable> {
+class MimicableState extends State<Mimicable> {
Size _size;
bool _beingMimicked = false;
diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart
index da4d940..bf4a086 100644
--- a/packages/flutter/lib/src/widgets/scrollable.dart
+++ b/packages/flutter/lib/src/widgets/scrollable.dart
@@ -575,7 +575,7 @@
class PageableList<T> extends ScrollableList<T> {
PageableList({
Key key,
- double initialScrollOffset,
+ int initialPage,
ScrollDirection scrollDirection: ScrollDirection.horizontal,
ScrollListener onScroll,
List<T> items,
@@ -588,7 +588,7 @@
this.curve: ease
}) : super(
key: key,
- initialScrollOffset: initialScrollOffset,
+ initialScrollOffset: initialPage == null ? null : initialPage * itemExtent,
scrollDirection: scrollDirection,
onScroll: onScroll,
items: items,
diff --git a/packages/flutter/lib/src/widgets/tabs.dart b/packages/flutter/lib/src/widgets/tabs.dart
index e5dc0f7..89367d9 100644
--- a/packages/flutter/lib/src/widgets/tabs.dart
+++ b/packages/flutter/lib/src/widgets/tabs.dart
@@ -11,6 +11,7 @@
import 'package:sky/material.dart';
import 'package:sky/painting.dart';
import 'package:sky/rendering.dart';
+import 'package:sky/src/widgets/animated_container.dart';
import 'package:sky/src/widgets/basic.dart';
import 'package:sky/src/widgets/framework.dart';
import 'package:sky/src/widgets/icon.dart';
@@ -51,15 +52,6 @@
}
}
- Color _backgroundColor;
- Color get backgroundColor => _backgroundColor;
- void set backgroundColor(Color value) {
- if (_backgroundColor != value) {
- _backgroundColor = value;
- markNeedsPaint();
- }
- }
-
Color _indicatorColor;
Color get indicatorColor => _indicatorColor;
void set indicatorColor(Color value) {
@@ -240,13 +232,6 @@
}
void paint(PaintingContext context, Offset offset) {
- if (backgroundColor != null) {
- double width = layoutWidths != null
- ? layoutWidths.reduce((sum, width) => sum + width)
- : size.width;
- Rect rect = offset & new Size(width, size.height);
- context.canvas.drawRect(rect, new Paint()..color = backgroundColor);
- }
int index = 0;
RenderBox child = firstChild;
while (child != null) {
@@ -264,7 +249,6 @@
Key key,
List<Widget> children,
this.selectedIndex,
- this.backgroundColor,
this.indicatorColor,
this.indicatorRect,
this.textAndIcons,
@@ -273,7 +257,6 @@
}) : super(key: key, children: children);
final int selectedIndex;
- final Color backgroundColor;
final Color indicatorColor;
final Rect indicatorRect;
final bool textAndIcons;
@@ -288,7 +271,6 @@
void updateRenderObject(_RenderTabBar renderObject, _TabBarWrapper oldWidget) {
renderObject.selectedIndex = selectedIndex;
- renderObject.backgroundColor = backgroundColor;
renderObject.indicatorColor = indicatorColor;
renderObject.indicatorRect = indicatorRect;
renderObject.textAndIcons = textAndIcons;
@@ -537,7 +519,7 @@
textAndIcons = true;
}
- Widget tabBar = new IconTheme(
+ Widget content = new IconTheme(
data: new IconThemeData(color: iconThemeColor),
child: new DefaultTextStyle(
style: textStyle,
@@ -548,7 +530,6 @@
return new _TabBarWrapper(
children: tabs,
selectedIndex: config.selectedIndex,
- backgroundColor: backgroundColor,
indicatorColor: indicatorColor,
indicatorRect: _indicatorRect.value,
textAndIcons: textAndIcons,
@@ -560,16 +541,23 @@
)
);
- if (!config.isScrollable)
- return tabBar;
+ if (config.isScrollable) {
+ content = new SizeObserver(
+ callback: _handleViewportSizeChanged,
+ child: new Viewport(
+ scrollDirection: ScrollDirection.horizontal,
+ scrollOffset: new Offset(scrollOffset, 0.0),
+ child: content
+ )
+ );
+ }
- return new SizeObserver(
- callback: _handleViewportSizeChanged,
- child: new Viewport(
- scrollDirection: ScrollDirection.horizontal,
- scrollOffset: new Offset(scrollOffset, 0.0),
- child: tabBar
- )
+ return new AnimatedContainer(
+ decoration: new BoxDecoration(
+ backgroundColor: backgroundColor
+ ),
+ duration: kThemeChangeDuration,
+ child: content
);
}
}
@@ -601,18 +589,13 @@
final TabSelectedIndexChanged onChanged;
final bool isScrollable;
- void _handleSelectedIndexChanged(int tabIndex) {
- if (onChanged != null)
- onChanged(tabIndex);
- }
-
Widget build(BuildContext context) {
assert(views != null && views.isNotEmpty);
assert(selectedIndex >= 0 && selectedIndex < views.length);
return new Column([
new TabBar(
labels: views.map((view) => view.label),
- onChanged: _handleSelectedIndexChanged,
+ onChanged: onChanged,
selectedIndex: selectedIndex,
isScrollable: isScrollable
),
diff --git a/packages/flutter/lib/src/widgets/tool_bar.dart b/packages/flutter/lib/src/widgets/tool_bar.dart
index 543531a..b92c938 100644
--- a/packages/flutter/lib/src/widgets/tool_bar.dart
+++ b/packages/flutter/lib/src/widgets/tool_bar.dart
@@ -4,35 +4,36 @@
import 'package:sky/material.dart';
import 'package:sky/painting.dart';
+import 'package:sky/src/widgets/animated_container.dart';
import 'package:sky/src/widgets/basic.dart';
import 'package:sky/src/widgets/framework.dart';
import 'package:sky/src/widgets/icon.dart';
import 'package:sky/src/widgets/theme.dart';
-import 'package:sky/src/rendering/flex.dart';
class ToolBar extends StatelessComponent {
-
ToolBar({
Key key,
this.left,
this.center,
this.right,
+ this.level: 2,
this.backgroundColor
}) : super(key: key);
final Widget left;
final Widget center;
final List<Widget> right;
+ final int level;
final Color backgroundColor;
Widget build(BuildContext context) {
- Color toolbarColor = backgroundColor;
+ Color color = backgroundColor;
IconThemeData iconThemeData;
TextStyle centerStyle = Typography.white.title;
TextStyle sideStyle = Typography.white.body1;
- if (toolbarColor == null) {
+ if (color == null) {
ThemeData themeData = Theme.of(context);
- toolbarColor = themeData.primaryColor;
+ color = themeData.primaryColor;
if (themeData.primaryColorBrightness == ThemeBrightness.light) {
centerStyle = Typography.black.title;
sideStyle = Typography.black.body2;
@@ -44,11 +45,9 @@
List<Widget> children = new List<Widget>();
- // left children
if (left != null)
children.add(left);
- // center children (left-aligned, but takes all remaining space)
children.add(
new Flexible(
child: new Padding(
@@ -58,11 +57,16 @@
)
);
- // right children
if (right != null)
children.addAll(right);
- Widget content = new Container(
+ Widget content = new AnimatedContainer(
+ duration: kThemeChangeDuration,
+ padding: new EdgeDims.symmetric(horizontal: 8.0),
+ decoration: new BoxDecoration(
+ backgroundColor: color,
+ boxShadow: level == 0 ? null : shadows[2]
+ ),
child: new DefaultTextStyle(
style: sideStyle,
child: new Column([
@@ -73,11 +77,6 @@
],
justifyContent: FlexJustifyContent.end
)
- ),
- padding: new EdgeDims.symmetric(horizontal: 8.0),
- decoration: new BoxDecoration(
- backgroundColor: toolbarColor,
- boxShadow: shadows[2]
)
);
diff --git a/packages/flutter/pubspec.yaml b/packages/flutter/pubspec.yaml
index 0abdceb..20565df 100644
--- a/packages/flutter/pubspec.yaml
+++ b/packages/flutter/pubspec.yaml
@@ -1,5 +1,5 @@
name: sky
-version: 0.0.52
+version: 0.0.53
author: Flutter Authors <flutter-dev@googlegroups.com>
description: A framework for writing Flutter applications
homepage: http://flutter.io
@@ -9,8 +9,8 @@
mojo_services: '>=0.1.0 <0.2.0'
mojo: '>=0.1.0 <0.2.0'
newton: ^0.1.4
- sky_engine: ^0.0.30
- sky_services: ^0.0.30
+ sky_engine: ^0.0.31
+ sky_services: ^0.0.31
sky_tools: ^0.0.15
vector_math: ^1.4.3
intl: ^0.12.4+2
diff --git a/packages/flutter_sprites/lib/physics_body.dart b/packages/flutter_sprites/lib/physics_body.dart
index e9446b6..d42fa8d 100644
--- a/packages/flutter_sprites/lib/physics_body.dart
+++ b/packages/flutter_sprites/lib/physics_body.dart
@@ -9,10 +9,10 @@
PhysicsBody(this.shape, {
this.tag: null,
this.type: PhysicsBodyType.dynamic,
- this.density: 1.0,
- this.friction: 0.0,
- this.restitution: 0.0,
- this.isSensor: false,
+ double density: 1.0,
+ double friction: 0.0,
+ double restitution: 0.0,
+ bool isSensor: false,
this.linearVelocity: Offset.zero,
this.angularVelocity: 0.0,
this.linearDampening: 0.0,
@@ -23,7 +23,12 @@
this.bullet: false,
this.active: true,
this.gravityScale: 1.0
- });
+ }) {
+ this.density = density;
+ this.friction = friction;
+ this.restitution = restitution;
+ this.isSensor = isSensor;
+ }
Object tag;
@@ -31,10 +36,61 @@
PhysicsBodyType type;
- double density;
- double friction;
- double restitution;
- bool isSensor;
+ double _density;
+
+ double get density => _density;
+
+ set density(double density) {
+ _density = density;
+
+ if (_body == null)
+ return;
+ for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
+ f.setDensity(density);
+ }
+ }
+
+ double _friction;
+
+ double get friction => _friction;
+
+ set friction(double friction) {
+ _friction = friction;
+
+ if (_body == null)
+ return;
+ for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
+ f.setFriction(friction);
+ }
+ }
+
+ double _restitution;
+
+ double get restitution => _restitution;
+
+ set restitution(double restitution) {
+ _restitution = restitution;
+
+ if (_body == null)
+ return;
+ for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
+ f.setRestitution(restitution);
+ }
+ }
+
+ bool _isSensor;
+
+ bool get isSensor => _isSensor;
+
+ set isSensor(bool isSensor) {
+ _isSensor = isSensor;
+
+ if (_body == null)
+ return;
+ for(box2d.Fixture f = _body.getFixtureList(); f != null; f = f.getNext()) {
+ f.setSensor(isSensor);
+ }
+ }
Offset linearVelocity;
double angularVelocity;