From 8c6d3e2a9e7d260098a48d2edd8657bfedccbaa8 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 19 Oct 2015 13:15:22 -0700 Subject: [PATCH] Show ColorFilter Instead of requiring clients to use ui.ColorFilter, we show show the ColorFilter class, similar to what we do for Color. --- examples/stocks/lib/stock_home.dart | 2 +- sky/packages/sky/lib/src/material/drawer_item.dart | 6 +++--- sky/packages/sky/lib/src/material/icon.dart | 2 +- sky/packages/sky/lib/src/material/icon_button.dart | 2 +- sky/packages/sky/lib/src/material/tabs.dart | 2 +- sky/packages/sky/lib/src/painting/basic_types.dart | 1 + sky/packages/sky/lib/src/painting/box_painter.dart | 6 +++--- sky/packages/sky/lib/src/rendering/basic_types.dart | 1 + sky/packages/sky/lib/src/rendering/image.dart | 8 ++++---- sky/packages/sky/lib/src/widgets/basic.dart | 9 +++++---- skysprites/lib/src/sprite.dart | 2 +- 11 files changed, 22 insertions(+), 19 deletions(-) diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 33d9cdd5dee..f613dc74cba 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -226,7 +226,7 @@ class StockHomeState extends State { return new ToolBar( left: new IconButton( 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 ), center: new Input( diff --git a/sky/packages/sky/lib/src/material/drawer_item.dart b/sky/packages/sky/lib/src/material/drawer_item.dart index 4d203d495e9..123053efd64 100644 --- a/sky/packages/sky/lib/src/material/drawer_item.dart +++ b/sky/packages/sky/lib/src/material/drawer_item.dart @@ -47,10 +47,10 @@ class _DrawerItemState extends State { return Colors.transparent; } - ui.ColorFilter _getColorFilter(ThemeData themeData) { + ColorFilter _getColorFilter(ThemeData themeData) { if (config.selected) - return new ui.ColorFilter.mode(themeData.primaryColor, TransferMode.srcATop); - return new ui.ColorFilter.mode(const Color(0x73000000), TransferMode.dstIn); + return new ColorFilter.mode(themeData.primaryColor, TransferMode.srcATop); + return new ColorFilter.mode(const Color(0x73000000), TransferMode.dstIn); } Widget build(BuildContext context) { diff --git a/sky/packages/sky/lib/src/material/icon.dart b/sky/packages/sky/lib/src/material/icon.dart index 0257564fec7..1112594dc0d 100644 --- a/sky/packages/sky/lib/src/material/icon.dart +++ b/sky/packages/sky/lib/src/material/icon.dart @@ -35,7 +35,7 @@ class Icon extends StatelessComponent { final int size; final String type; final IconThemeColor color; - final ui.ColorFilter colorFilter; + final ColorFilter colorFilter; String _getColorSuffix(BuildContext context) { IconThemeColor iconThemeColor = color; diff --git a/sky/packages/sky/lib/src/material/icon_button.dart b/sky/packages/sky/lib/src/material/icon_button.dart index f7dd28925e7..b2f9f0a022d 100644 --- a/sky/packages/sky/lib/src/material/icon_button.dart +++ b/sky/packages/sky/lib/src/material/icon_button.dart @@ -20,7 +20,7 @@ class IconButton extends StatelessComponent { final String icon; final IconThemeColor color; - final ui.ColorFilter colorFilter; + final ColorFilter colorFilter; final GestureTapCallback onPressed; Widget build(BuildContext context) { diff --git a/sky/packages/sky/lib/src/material/tabs.dart b/sky/packages/sky/lib/src/material/tabs.dart index 798f3362e57..4ca1b450f8e 100644 --- a/sky/packages/sky/lib/src/material/tabs.dart +++ b/sky/packages/sky/lib/src/material/tabs.dart @@ -321,7 +321,7 @@ class Tab extends StatelessComponent { Widget _buildLabelIcon() { assert(label.icon != null); 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); } diff --git a/sky/packages/sky/lib/src/painting/basic_types.dart b/sky/packages/sky/lib/src/painting/basic_types.dart index 2265c2b91d3..e2edd579b2c 100644 --- a/sky/packages/sky/lib/src/painting/basic_types.dart +++ b/sky/packages/sky/lib/src/painting/basic_types.dart @@ -5,6 +5,7 @@ export 'dart:ui' show Canvas, Color, + ColorFilter, FontStyle, FontWeight, Offset, diff --git a/sky/packages/sky/lib/src/painting/box_painter.dart b/sky/packages/sky/lib/src/painting/box_painter.dart index 5aa148c9622..0980795733a 100644 --- a/sky/packages/sky/lib/src/painting/box_painter.dart +++ b/sky/packages/sky/lib/src/painting/box_painter.dart @@ -561,10 +561,10 @@ enum ImageRepeat { /// Paint an image into the given rectangle in the canvas void paintImage({ - ui.Canvas canvas, + Canvas canvas, Rect rect, ui.Image image, - ui.ColorFilter colorFilter, + ColorFilter colorFilter, ImageFit fit, repeat: ImageRepeat.noRepeat, Rect centerSlice, @@ -668,7 +668,7 @@ class BackgroundImage { final Rect centerSlice; /// 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. ui.Image get image => _image; diff --git a/sky/packages/sky/lib/src/rendering/basic_types.dart b/sky/packages/sky/lib/src/rendering/basic_types.dart index 642e6c5a99f..acc920dd37a 100644 --- a/sky/packages/sky/lib/src/rendering/basic_types.dart +++ b/sky/packages/sky/lib/src/rendering/basic_types.dart @@ -5,6 +5,7 @@ export 'dart:ui' show Canvas, Color, + ColorFilter, Offset, Paint, Path, diff --git a/sky/packages/sky/lib/src/rendering/image.dart b/sky/packages/sky/lib/src/rendering/image.dart index 52cda1c9da3..079e4dfdf4a 100644 --- a/sky/packages/sky/lib/src/rendering/image.dart +++ b/sky/packages/sky/lib/src/rendering/image.dart @@ -22,7 +22,7 @@ class RenderImage extends RenderBox { ui.Image image, double width, double height, - ui.ColorFilter colorFilter, + ColorFilter colorFilter, ImageFit fit, repeat: ImageRepeat.noRepeat, Rect centerSlice @@ -67,9 +67,9 @@ class RenderImage extends RenderBox { } /// If non-null, apply this color filter to the image before painint. - ui.ColorFilter get colorFilter => _colorFilter; - ui.ColorFilter _colorFilter; - void set colorFilter (ui.ColorFilter value) { + ColorFilter get colorFilter => _colorFilter; + ColorFilter _colorFilter; + void set colorFilter (ColorFilter value) { if (value == _colorFilter) return; _colorFilter = value; diff --git a/sky/packages/sky/lib/src/widgets/basic.dart b/sky/packages/sky/lib/src/widgets/basic.dart index 374f82b8432..b843032e35b 100644 --- a/sky/packages/sky/lib/src/widgets/basic.dart +++ b/sky/packages/sky/lib/src/widgets/basic.dart @@ -20,6 +20,7 @@ export 'package:flutter/rendering.dart' show BoxShadow, Canvas, Color, + ColorFilter, EdgeDims, FlexAlignItems, FlexDirection, @@ -894,7 +895,7 @@ class Image extends LeafRenderObjectWidget { final ui.Image image; final double width; final double height; - final ui.ColorFilter colorFilter; + final ColorFilter colorFilter; final ImageFit fit; final ImageRepeat repeat; final Rect centerSlice; @@ -936,7 +937,7 @@ class ImageListener extends StatefulComponent { final ImageResource image; final double width; final double height; - final ui.ColorFilter colorFilter; + final ColorFilter colorFilter; final ImageFit fit; final ImageRepeat repeat; final Rect centerSlice; @@ -998,7 +999,7 @@ class NetworkImage extends StatelessComponent { final String src; final double width; final double height; - final ui.ColorFilter colorFilter; + final ColorFilter colorFilter; final ImageFit fit; final ImageRepeat repeat; final Rect centerSlice; @@ -1033,7 +1034,7 @@ class AssetImage extends StatelessComponent { final AssetBundle bundle; final double width; final double height; - final ui.ColorFilter colorFilter; + final ColorFilter colorFilter; final ImageFit fit; final ImageRepeat repeat; final Rect centerSlice; diff --git a/skysprites/lib/src/sprite.dart b/skysprites/lib/src/sprite.dart index 3a532f42dc6..1bc818ab8c5 100644 --- a/skysprites/lib/src/sprite.dart +++ b/skysprites/lib/src/sprite.dart @@ -113,7 +113,7 @@ abstract class SpritePaint { paint.color = new Color.fromARGB((255.0*_opacity).toInt(), 255, 255, 255); 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) {