Commit db90d5f0 authored by Hixie's avatar Hixie

Rename UINode to Widget.

Also, move a widget example from examples/raw/ to examples/widgets/

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/1190793002.
parent abc8eaa5
...@@ -20,7 +20,7 @@ import 'package:sky/widgets/popup_menu.dart'; ...@@ -20,7 +20,7 @@ import 'package:sky/widgets/popup_menu.dart';
import 'package:sky/widgets/radio.dart'; import 'package:sky/widgets/radio.dart';
import 'package:sky/widgets/scaffold.dart'; import 'package:sky/widgets/scaffold.dart';
import 'package:sky/widgets/tool_bar.dart'; import 'package:sky/widgets/tool_bar.dart';
import 'package:sky/widgets/ui_node.dart'; import 'package:sky/widgets/widget.dart';
import 'stock_data.dart'; import 'stock_data.dart';
import 'stock_list.dart'; import 'stock_list.dart';
...@@ -151,7 +151,7 @@ class StocksApp extends App { ...@@ -151,7 +151,7 @@ class StocksApp extends App {
); );
} }
UINode buildToolBar() { Widget buildToolBar() {
return new ToolBar( return new ToolBar(
left: new IconButton( left: new IconButton(
icon: 'navigation/menu_white', icon: 'navigation/menu_white',
...@@ -170,7 +170,7 @@ class StocksApp extends App { ...@@ -170,7 +170,7 @@ class StocksApp extends App {
} }
// TODO(abarth): Should we factor this into a SearchBar in the framework? // TODO(abarth): Should we factor this into a SearchBar in the framework?
UINode buildSearchBar() { Widget buildSearchBar() {
return new ToolBar( return new ToolBar(
left: new IconButton( left: new IconButton(
icon: 'navigation/arrow_back_grey600', icon: 'navigation/arrow_back_grey600',
...@@ -183,7 +183,7 @@ class StocksApp extends App { ...@@ -183,7 +183,7 @@ class StocksApp extends App {
); );
} }
void addMenuToOverlays(List<UINode> overlays) { void addMenuToOverlays(List<Widget> overlays) {
if (_menuController == null) if (_menuController == null)
return; return;
overlays.add(new ModalOverlay( overlays.add(new ModalOverlay(
...@@ -195,8 +195,8 @@ class StocksApp extends App { ...@@ -195,8 +195,8 @@ class StocksApp extends App {
onDismiss: _handleMenuHide)); onDismiss: _handleMenuHide));
} }
UINode build() { Widget build() {
List<UINode> overlays = [ List<Widget> overlays = [
new Scaffold( new Scaffold(
toolbar: _isSearching ? buildSearchBar() : buildToolBar(), toolbar: _isSearching ? buildSearchBar() : buildToolBar(),
body: new Stocklist(stocks: _stocks, query: _searchQuery), body: new Stocklist(stocks: _stocks, query: _searchQuery),
...@@ -214,8 +214,8 @@ class StocksApp extends App { ...@@ -214,8 +214,8 @@ class StocksApp extends App {
void main() { void main() {
print("starting stocks app!"); print("starting stocks app!");
App app = new StocksApp(); App app = new StocksApp();
UINodeAppView.appView.onFrame = () { WidgetAppView.appView.onFrame = () {
// uncomment this for debugging: // uncomment this for debugging:
// UINodeAppView.appView.debugDumpRenderTree(); // WidgetAppView.appView.debugDumpRenderTree();
}; };
} }
...@@ -28,7 +28,7 @@ class StockArrow extends Component { ...@@ -28,7 +28,7 @@ class StockArrow extends Component {
return colors.Red[_colorIndexForPercentChange(percentChange)]; return colors.Red[_colorIndexForPercentChange(percentChange)];
} }
UINode build() { Widget build() {
// TODO(jackson): This should change colors with the theme // TODO(jackson): This should change colors with the theme
Color color = _colorForPercentChange(percentChange); Color color = _colorForPercentChange(percentChange);
const double kSize = 40.0; const double kSize = 40.0;
......
...@@ -25,7 +25,7 @@ class Stocklist extends FixedHeightScrollable { ...@@ -25,7 +25,7 @@ class Stocklist extends FixedHeightScrollable {
super.syncFields(source); super.syncFields(source);
} }
List<UINode> buildItems(int start, int count) { List<Widget> buildItems(int start, int count) {
var filteredStocks = stocks.where((stock) { var filteredStocks = stocks.where((stock) {
return query == null || return query == null ||
stock.symbol.contains(new RegExp(query, caseSensitive: false)); stock.symbol.contains(new RegExp(query, caseSensitive: false));
......
...@@ -20,7 +20,7 @@ class StockMenu extends Component { ...@@ -20,7 +20,7 @@ class StockMenu extends Component {
final bool autorefresh; final bool autorefresh;
final ValueChanged onAutorefreshChanged; final ValueChanged onAutorefreshChanged;
UINode build() { Widget build() {
var checkbox = new Checkbox( var checkbox = new Checkbox(
value: this.autorefresh, value: this.autorefresh,
onChanged: this.onAutorefreshChanged onChanged: this.onAutorefreshChanged
......
...@@ -19,13 +19,13 @@ class StockRow extends Component { ...@@ -19,13 +19,13 @@ class StockRow extends Component {
static const double kHeight = 79.0; static const double kHeight = 79.0;
UINode build() { Widget build() {
String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}"; String lastSale = "\$${stock.lastSale.toStringAsFixed(2)}";
String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%"; String changeInPrice = "${stock.percentChange.toStringAsFixed(2)}%";
if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice; if (stock.percentChange > 0) changeInPrice = "+" + changeInPrice;
List<UINode> children = [ List<Widget> children = [
new Container( new Container(
child: new StockArrow(percentChange: stock.percentChange), child: new StockArrow(percentChange: stock.percentChange),
margin: const EdgeDims.only(right: 5.0)), margin: const EdgeDims.only(right: 5.0)),
......
...@@ -8,7 +8,7 @@ import 'package:sky/widgets/raised_button.dart'; ...@@ -8,7 +8,7 @@ import 'package:sky/widgets/raised_button.dart';
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
class ContainerApp extends App { class ContainerApp extends App {
UINode build() { Widget build() {
return new Flex([ return new Flex([
new Container( new Container(
key: 'a', key: 'a',
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
class HelloWorldApp extends App { class HelloWorldApp extends App {
UINode build() { Widget build() {
return new Text('Hello, fn2!'); return new Text('Hello, fn2!');
} }
} }
......
...@@ -14,7 +14,7 @@ import 'package:sky/widgets/material.dart'; ...@@ -14,7 +14,7 @@ import 'package:sky/widgets/material.dart';
import 'package:sky/widgets/raised_button.dart'; import 'package:sky/widgets/raised_button.dart';
import 'package:sky/widgets/scaffold.dart'; import 'package:sky/widgets/scaffold.dart';
import 'package:sky/widgets/tool_bar.dart'; import 'package:sky/widgets/tool_bar.dart';
import 'package:sky/widgets/ui_node.dart'; import 'package:sky/widgets/widget.dart';
import '../rendering/sector_layout.dart'; import '../rendering/sector_layout.dart';
...@@ -72,7 +72,7 @@ class SectorApp extends App { ...@@ -72,7 +72,7 @@ class SectorApp extends App {
}); });
} }
UINode build() { Widget build() {
return new Scaffold( return new Scaffold(
toolbar: new ToolBar( toolbar: new ToolBar(
center: new Text('Sector Layout in a Widget Tree', style: white.title), center: new Text('Sector Layout in a Widget Tree', style: white.title),
...@@ -91,7 +91,7 @@ class SectorApp extends App { ...@@ -91,7 +91,7 @@ class SectorApp extends App {
new Container( new Container(
padding: new EdgeDims.all(4.0), padding: new EdgeDims.all(4.0),
margin: new EdgeDims.only(right: 10.0), margin: new EdgeDims.only(right: 10.0),
child: new UINodeToRenderBoxAdapter(sectorAddIcon) child: new WidgetToRenderBoxAdapter(sectorAddIcon)
), ),
new Text('ADD SECTOR'), new Text('ADD SECTOR'),
]) ])
...@@ -106,7 +106,7 @@ class SectorApp extends App { ...@@ -106,7 +106,7 @@ class SectorApp extends App {
new Container( new Container(
padding: new EdgeDims.all(4.0), padding: new EdgeDims.all(4.0),
margin: new EdgeDims.only(right: 10.0), margin: new EdgeDims.only(right: 10.0),
child: new UINodeToRenderBoxAdapter(sectorRemoveIcon) child: new WidgetToRenderBoxAdapter(sectorRemoveIcon)
), ),
new Text('REMOVE SECTOR'), new Text('REMOVE SECTOR'),
]) ])
...@@ -124,7 +124,7 @@ class SectorApp extends App { ...@@ -124,7 +124,7 @@ class SectorApp extends App {
border: new Border.all(new BorderSide(color: new Color(0xFF000000))) border: new Border.all(new BorderSide(color: new Color(0xFF000000)))
), ),
padding: new EdgeDims.all(8.0), padding: new EdgeDims.all(8.0),
child: new UINodeToRenderBoxAdapter(sectors) child: new WidgetToRenderBoxAdapter(sectors)
) )
), ),
], ],
...@@ -138,8 +138,8 @@ class SectorApp extends App { ...@@ -138,8 +138,8 @@ class SectorApp extends App {
void main() { void main() {
App app = new SectorApp(); App app = new SectorApp();
UINodeAppView.appView.onFrame = () { WidgetAppView.appView.onFrame = () {
// uncomment this for debugging: // uncomment this for debugging:
// UINodeAppView.appView.debugDumpRenderTree(); // WidgetAppView.appView.debugDumpRenderTree();
}; };
} }
...@@ -9,7 +9,7 @@ import 'package:sky/rendering/box.dart'; ...@@ -9,7 +9,7 @@ import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/flex.dart'; import 'package:sky/rendering/flex.dart';
import 'package:sky/widgets/basic.dart'; import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/raised_button.dart'; import 'package:sky/widgets/raised_button.dart';
import 'package:sky/widgets/ui_node.dart'; import 'package:sky/widgets/widget.dart';
import 'package:vector_math/vector_math.dart'; import 'package:vector_math/vector_math.dart';
import '../lib/solid_color_box.dart'; import '../lib/solid_color_box.dart';
...@@ -26,7 +26,7 @@ void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, { int ...@@ -26,7 +26,7 @@ void addFlexChildSolidColor(RenderFlex parent, sky.Color backgroundColor, { int
class Rectangle extends Component { class Rectangle extends Component {
Rectangle(this.color, { String key }) : super(key: key); Rectangle(this.color, { String key }) : super(key: key);
final Color color; final Color color;
UINode build() { Widget build() {
return new Flexible( return new Flexible(
child: new Container( child: new Container(
decoration: new BoxDecoration(backgroundColor: color) decoration: new BoxDecoration(backgroundColor: color)
...@@ -35,7 +35,7 @@ class Rectangle extends Component { ...@@ -35,7 +35,7 @@ class Rectangle extends Component {
} }
} }
UINode builder() { Widget builder() {
return new Flex([ return new Flex([
new Rectangle(const Color(0xFF00FFFF), key: 'a'), new Rectangle(const Color(0xFF00FFFF), key: 'a'),
new Container( new Container(
...@@ -74,18 +74,18 @@ void rotate(double timeStamp) { ...@@ -74,18 +74,18 @@ void rotate(double timeStamp) {
} }
void main() { void main() {
// Because we're going to use UINodes, we want to initialise its // Because we're going to use Widgets, we want to initialise its
// AppView, not use the default one. We don't really need to do // AppView, not use the default one. We don't really need to do
// this, because RenderBoxToUINodeAdapter does it for us, but // this, because RenderBoxToWidgetAdapter does it for us, but
// it's good practice in case we happen to not have a // it's good practice in case we happen to not have a
// RenderBoxToUINodeAdapter in our tree at startup, or in case we // RenderBoxToWidgetAdapter in our tree at startup, or in case we
// want a renderViewOverride. // want a renderViewOverride.
UINodeAppView.initUINodeAppView(); WidgetAppView.initWidgetAppView();
RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical); RenderFlex flexRoot = new RenderFlex(direction: FlexDirection.vertical);
RenderProxyBox proxy = new RenderProxyBox(); RenderProxyBox proxy = new RenderProxyBox();
new RenderBoxToUINodeAdapter(proxy, builder); // adds itself to proxy new RenderBoxToWidgetAdapter(proxy, builder); // adds itself to proxy
addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFF00FF), flex: 1); addFlexChildSolidColor(flexRoot, const sky.Color(0xFFFF00FF), flex: 1);
flexRoot.add(proxy); flexRoot.add(proxy);
...@@ -94,6 +94,6 @@ void main() { ...@@ -94,6 +94,6 @@ void main() {
transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity()); transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity());
RenderPadding root = new RenderPadding(padding: new EdgeDims.all(20.0), child: transformBox); RenderPadding root = new RenderPadding(padding: new EdgeDims.all(20.0), child: transformBox);
UINodeAppView.appView.root = root; WidgetAppView.appView.root = root;
addPersistentFrameCallback(rotate); addPersistentFrameCallback(rotate);
} }
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