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