Adam Barth 70b8347fe1 Hoist knowledge of image_cache into widgets/basic.dart
Previously, RenderImage knew about image_cache and expected to work in terms of
URLs. Now RenderImage works directly with sky.Image and it's the job of the
widgets system to interact with the network cache.

At the widgets layer, I've factored this work into three parts:
1) A wrapper for RenderImage that works in terms of sky.Image.
2) A component that can deal with any sort of Future<sky.Image>.
3) A NetworkImage component that translates relative URLs into
   Future<sky.Image> using the image_cache.

A future CL will add a peer to NetworkImage that gets Future<sky.Image>s from
an asset bundle.

R=ianh@google.com, jackson@google.com

Review URL: https://codereview.chromium.org/1218023013.
2015-07-01 14:41:45 -07:00

52 lines
1.6 KiB
Dart

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:sky/rendering/box.dart';
import 'package:sky/rendering/flex.dart';
import 'package:sky/widgets/raised_button.dart';
import 'package:sky/widgets/basic.dart';
class ContainerApp extends App {
Widget build() {
return new Flex([
new Container(
padding: new EdgeDims.all(10.0),
margin: new EdgeDims.all(10.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)),
child: new NetworkImage(
src: "https://www.dartlang.org/logos/dart-logo.png",
size: new Size(300.0, 300.0)
)
),
new Container(
decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFF00)),
padding: new EdgeDims.symmetric(horizontal: 50.0, vertical: 75.0),
child: new Flex([
new RaisedButton(
child: new Text('PRESS ME'),
onPressed: () => print("Hello World")
),
new RaisedButton(
child: new Text('DISABLED'),
onPressed: () => print("Hello World"),
enabled: false
)
])
),
new Flexible(
child: new Container(
decoration: new BoxDecoration(backgroundColor: const Color(0xFF00FFFF))
)
),
],
direction: FlexDirection.vertical,
justifyContent: FlexJustifyContent.spaceBetween
);
}
}
void main() {
runApp(new ContainerApp());
}