Commit 40942233 authored by Adam Barth's avatar Adam Barth

Show ColorFilter

Instead of requiring clients to use ui.ColorFilter, we show show the
ColorFilter class, similar to what we do for Color.
parent 8402b548
...@@ -226,7 +226,7 @@ class StockHomeState extends State<StockHome> { ...@@ -226,7 +226,7 @@ class StockHomeState extends State<StockHome> {
return new ToolBar( return new ToolBar(
left: new IconButton( left: new IconButton(
icon: "navigation/arrow_back", icon: "navigation/arrow_back",
colorFilter: new ui.ColorFilter.mode(Theme.of(context).accentColor, ui.TransferMode.srcATop), colorFilter: new ColorFilter.mode(Theme.of(context).accentColor, ui.TransferMode.srcATop),
onPressed: _handleSearchEnd onPressed: _handleSearchEnd
), ),
center: new Input( center: new Input(
......
...@@ -47,10 +47,10 @@ class _DrawerItemState extends State<DrawerItem> { ...@@ -47,10 +47,10 @@ class _DrawerItemState extends State<DrawerItem> {
return Colors.transparent; return Colors.transparent;
} }
ui.ColorFilter _getColorFilter(ThemeData themeData) { ColorFilter _getColorFilter(ThemeData themeData) {
if (config.selected) if (config.selected)
return new ui.ColorFilter.mode(themeData.primaryColor, TransferMode.srcATop); return new ColorFilter.mode(themeData.primaryColor, TransferMode.srcATop);
return new ui.ColorFilter.mode(const Color(0x73000000), TransferMode.dstIn); return new ColorFilter.mode(const Color(0x73000000), TransferMode.dstIn);
} }
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -35,7 +35,7 @@ class Icon extends StatelessComponent { ...@@ -35,7 +35,7 @@ class Icon extends StatelessComponent {
final int size; final int size;
final String type; final String type;
final IconThemeColor color; final IconThemeColor color;
final ui.ColorFilter colorFilter; final ColorFilter colorFilter;
String _getColorSuffix(BuildContext context) { String _getColorSuffix(BuildContext context) {
IconThemeColor iconThemeColor = color; IconThemeColor iconThemeColor = color;
......
...@@ -20,7 +20,7 @@ class IconButton extends StatelessComponent { ...@@ -20,7 +20,7 @@ class IconButton extends StatelessComponent {
final String icon; final String icon;
final IconThemeColor color; final IconThemeColor color;
final ui.ColorFilter colorFilter; final ColorFilter colorFilter;
final GestureTapCallback onPressed; final GestureTapCallback onPressed;
Widget build(BuildContext context) { Widget build(BuildContext context) {
......
...@@ -321,7 +321,7 @@ class Tab extends StatelessComponent { ...@@ -321,7 +321,7 @@ class Tab extends StatelessComponent {
Widget _buildLabelIcon() { Widget _buildLabelIcon() {
assert(label.icon != null); assert(label.icon != null);
Color iconColor = selected ? selectedColor : color; Color iconColor = selected ? selectedColor : color;
ui.ColorFilter filter = new ui.ColorFilter.mode(iconColor, TransferMode.srcATop); ColorFilter filter = new ColorFilter.mode(iconColor, TransferMode.srcATop);
return new Icon(type: label.icon, size: _kTabIconSize, colorFilter: filter); return new Icon(type: label.icon, size: _kTabIconSize, colorFilter: filter);
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
export 'dart:ui' show export 'dart:ui' show
Canvas, Canvas,
Color, Color,
ColorFilter,
FontStyle, FontStyle,
FontWeight, FontWeight,
Offset, Offset,
......
...@@ -561,10 +561,10 @@ enum ImageRepeat { ...@@ -561,10 +561,10 @@ enum ImageRepeat {
/// Paint an image into the given rectangle in the canvas /// Paint an image into the given rectangle in the canvas
void paintImage({ void paintImage({
ui.Canvas canvas, Canvas canvas,
Rect rect, Rect rect,
ui.Image image, ui.Image image,
ui.ColorFilter colorFilter, ColorFilter colorFilter,
ImageFit fit, ImageFit fit,
repeat: ImageRepeat.noRepeat, repeat: ImageRepeat.noRepeat,
Rect centerSlice, Rect centerSlice,
...@@ -668,7 +668,7 @@ class BackgroundImage { ...@@ -668,7 +668,7 @@ class BackgroundImage {
final Rect centerSlice; final Rect centerSlice;
/// A color filter to apply to the background image before painting it. /// A color filter to apply to the background image before painting it.
final ui.ColorFilter colorFilter; final ColorFilter colorFilter;
/// The image to be painted into the background. /// The image to be painted into the background.
ui.Image get image => _image; ui.Image get image => _image;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
export 'dart:ui' show export 'dart:ui' show
Canvas, Canvas,
Color, Color,
ColorFilter,
Offset, Offset,
Paint, Paint,
Path, Path,
......
...@@ -22,7 +22,7 @@ class RenderImage extends RenderBox { ...@@ -22,7 +22,7 @@ class RenderImage extends RenderBox {
ui.Image image, ui.Image image,
double width, double width,
double height, double height,
ui.ColorFilter colorFilter, ColorFilter colorFilter,
ImageFit fit, ImageFit fit,
repeat: ImageRepeat.noRepeat, repeat: ImageRepeat.noRepeat,
Rect centerSlice Rect centerSlice
...@@ -67,9 +67,9 @@ class RenderImage extends RenderBox { ...@@ -67,9 +67,9 @@ class RenderImage extends RenderBox {
} }
/// If non-null, apply this color filter to the image before painint. /// If non-null, apply this color filter to the image before painint.
ui.ColorFilter get colorFilter => _colorFilter; ColorFilter get colorFilter => _colorFilter;
ui.ColorFilter _colorFilter; ColorFilter _colorFilter;
void set colorFilter (ui.ColorFilter value) { void set colorFilter (ColorFilter value) {
if (value == _colorFilter) if (value == _colorFilter)
return; return;
_colorFilter = value; _colorFilter = value;
......
...@@ -20,6 +20,7 @@ export 'package:flutter/rendering.dart' show ...@@ -20,6 +20,7 @@ export 'package:flutter/rendering.dart' show
BoxShadow, BoxShadow,
Canvas, Canvas,
Color, Color,
ColorFilter,
EdgeDims, EdgeDims,
FlexAlignItems, FlexAlignItems,
FlexDirection, FlexDirection,
...@@ -894,7 +895,7 @@ class Image extends LeafRenderObjectWidget { ...@@ -894,7 +895,7 @@ class Image extends LeafRenderObjectWidget {
final ui.Image image; final ui.Image image;
final double width; final double width;
final double height; final double height;
final ui.ColorFilter colorFilter; final ColorFilter colorFilter;
final ImageFit fit; final ImageFit fit;
final ImageRepeat repeat; final ImageRepeat repeat;
final Rect centerSlice; final Rect centerSlice;
...@@ -936,7 +937,7 @@ class ImageListener extends StatefulComponent { ...@@ -936,7 +937,7 @@ class ImageListener extends StatefulComponent {
final ImageResource image; final ImageResource image;
final double width; final double width;
final double height; final double height;
final ui.ColorFilter colorFilter; final ColorFilter colorFilter;
final ImageFit fit; final ImageFit fit;
final ImageRepeat repeat; final ImageRepeat repeat;
final Rect centerSlice; final Rect centerSlice;
...@@ -998,7 +999,7 @@ class NetworkImage extends StatelessComponent { ...@@ -998,7 +999,7 @@ class NetworkImage extends StatelessComponent {
final String src; final String src;
final double width; final double width;
final double height; final double height;
final ui.ColorFilter colorFilter; final ColorFilter colorFilter;
final ImageFit fit; final ImageFit fit;
final ImageRepeat repeat; final ImageRepeat repeat;
final Rect centerSlice; final Rect centerSlice;
...@@ -1033,7 +1034,7 @@ class AssetImage extends StatelessComponent { ...@@ -1033,7 +1034,7 @@ class AssetImage extends StatelessComponent {
final AssetBundle bundle; final AssetBundle bundle;
final double width; final double width;
final double height; final double height;
final ui.ColorFilter colorFilter; final ColorFilter colorFilter;
final ImageFit fit; final ImageFit fit;
final ImageRepeat repeat; final ImageRepeat repeat;
final Rect centerSlice; final Rect centerSlice;
......
...@@ -113,7 +113,7 @@ abstract class SpritePaint { ...@@ -113,7 +113,7 @@ abstract class SpritePaint {
paint.color = new Color.fromARGB((255.0*_opacity).toInt(), 255, 255, 255); paint.color = new Color.fromARGB((255.0*_opacity).toInt(), 255, 255, 255);
if (colorOverlay != null) { if (colorOverlay != null) {
paint.colorFilter = new ui.ColorFilter.mode(colorOverlay, ui.TransferMode.srcATop); paint.colorFilter = new ColorFilter.mode(colorOverlay, ui.TransferMode.srcATop);
} }
if (transferMode != null) { if (transferMode != null) {
......
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