From 8d173616aadbdaba77377f9f73655a560c314806 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 15 Oct 2015 23:58:55 -0700 Subject: [PATCH] Rationalize exports a bit more The goal is to follow the guidelines in https://github.com/flutter/engine/blob/master/sky/specs/style-guide.md#packages Fixes #1638 --- sky/packages/sky/lib/painting.dart | 1 + sky/packages/sky/lib/rendering.dart | 1 + .../sky/lib/src/material/checkbox.dart | 47 ++++++++++--------- .../sky/lib/src/material/date_picker.dart | 1 - sky/packages/sky/lib/src/material/dialog.dart | 1 - .../sky/lib/src/material/drawer_item.dart | 6 +-- .../sky/lib/src/material/flat_button.dart | 1 - .../src/material/floating_action_button.dart | 1 - .../sky/lib/src/material/icon_button.dart | 1 - .../sky/lib/src/material/ink_well.dart | 3 +- sky/packages/sky/lib/src/material/input.dart | 2 - .../sky/lib/src/material/list_item.dart | 2 - .../sky/lib/src/material/material.dart | 1 - .../sky/lib/src/material/material_app.dart | 2 - .../sky/lib/src/material/material_button.dart | 1 - .../lib/src/material/progress_indicator.dart | 16 +++---- .../sky/lib/src/material/radial_reaction.dart | 5 +- sky/packages/sky/lib/src/material/radio.dart | 16 +++---- .../sky/lib/src/material/raised_button.dart | 1 - .../sky/lib/src/material/scaffold.dart | 1 - .../sky/lib/src/material/snack_bar.dart | 2 - sky/packages/sky/lib/src/material/switch.dart | 15 +++--- sky/packages/sky/lib/src/material/tabs.dart | 4 +- .../sky/lib/src/material/theme_data.dart | 6 +-- .../sky/lib/src/material/tool_bar.dart | 1 - .../sky/lib/src/material/typography.dart | 3 +- .../sky/lib/src/painting/basic_types.dart | 19 ++++++++ .../sky/lib/src/painting/box_painter.dart | 2 +- .../sky/lib/src/painting/text_painter.dart | 3 +- .../sky/lib/src/painting/text_style.dart | 3 +- .../sky/lib/src/rendering/basic_types.dart | 14 ++++++ sky/packages/sky/lib/src/rendering/box.dart | 14 +++--- sky/packages/sky/lib/src/rendering/image.dart | 4 ++ sky/packages/sky/lib/src/rendering/layer.dart | 7 ++- .../sky/lib/src/rendering/object.dart | 17 ++++--- .../sky/lib/src/rendering/paragraph.dart | 17 ++++++- .../sky/lib/src/rendering/proxy_box.dart | 16 +++---- sky/packages/sky/lib/src/widgets/basic.dart | 30 ++++++++++-- .../sky/lib/src/widgets/drag_target.dart | 1 - .../sky/lib/src/widgets/gesture_detector.dart | 19 ++++++++ .../lib/src/widgets/homogeneous_viewport.dart | 5 +- .../sky/lib/src/widgets/transitions.dart | 2 +- 42 files changed, 193 insertions(+), 121 deletions(-) create mode 100644 sky/packages/sky/lib/src/painting/basic_types.dart create mode 100644 sky/packages/sky/lib/src/rendering/basic_types.dart diff --git a/sky/packages/sky/lib/painting.dart b/sky/packages/sky/lib/painting.dart index e23302cef38..1ebc1e3e2ea 100644 --- a/sky/packages/sky/lib/painting.dart +++ b/sky/packages/sky/lib/painting.dart @@ -12,6 +12,7 @@ /// Note: animation.dart depends on the `newton` package. library painting; +export 'src/painting/basic_types.dart'; export 'src/painting/box_painter.dart'; export 'src/painting/shadows.dart'; export 'src/painting/text_painter.dart'; diff --git a/sky/packages/sky/lib/rendering.dart b/sky/packages/sky/lib/rendering.dart index 4a9564b7b4a..f7ed579fcf4 100644 --- a/sky/packages/sky/lib/rendering.dart +++ b/sky/packages/sky/lib/rendering.dart @@ -6,6 +6,7 @@ library rendering; export 'src/rendering/auto_layout.dart'; +export 'src/rendering/basic_types.dart'; export 'src/rendering/block.dart'; export 'src/rendering/box.dart'; export 'src/rendering/debug.dart'; diff --git a/sky/packages/sky/lib/src/material/checkbox.dart b/sky/packages/sky/lib/src/material/checkbox.dart index 4de7ed9f4ef..dca9c9775f7 100644 --- a/sky/packages/sky/lib/src/material/checkbox.dart +++ b/sky/packages/sky/lib/src/material/checkbox.dart @@ -12,8 +12,8 @@ import 'theme.dart'; export 'package:flutter/rendering.dart' show ValueChanged; const double _kMidpoint = 0.5; -const ui.Color _kLightUncheckedColor = const ui.Color(0x8A000000); -const ui.Color _kDarkUncheckedColor = const ui.Color(0xB2FFFFFF); +const Color _kLightUncheckedColor = const Color(0x8A000000); +const Color _kDarkUncheckedColor = const Color(0xB2FFFFFF); const double _kEdgeSize = 18.0; const double _kEdgeRadius = 1.0; const double _kStrokeWidth = 2.0; @@ -126,7 +126,7 @@ class _RenderCheckbox extends RenderToggleable { void paint(PaintingContext context, Offset offset) { final PaintingCanvas canvas = context.canvas; // Choose a color between grey and the theme color - ui.Paint paint = new ui.Paint() + Paint paint = new Paint() ..strokeWidth = _kStrokeWidth ..color = uncheckedColor; @@ -134,27 +134,27 @@ class _RenderCheckbox extends RenderToggleable { // Because we have a stroke size of 2, we should have a minimum 1.0 inset. double inset = 2.0 - (position - _kMidpoint).abs() * 2.0; double rectSize = _kEdgeSize - inset * _kStrokeWidth; - ui.Rect rect = - new ui.Rect.fromLTWH(offset.dx + inset, offset.dy + inset, rectSize, rectSize); + Rect rect = new Rect.fromLTWH(offset.dx + inset, offset.dy + inset, rectSize, rectSize); // Create an inner rectangle to cover inside of rectangle. This is needed to avoid // painting artefacts caused by overlayed paintings. - ui.Rect innerRect = rect.deflate(1.0); + Rect innerRect = rect.deflate(1.0); ui.RRect rrect = new ui.RRect() ..setRectXY(rect, _kEdgeRadius, _kEdgeRadius); // Outline of the empty rrect - paint.setStyle(ui.PaintingStyle.stroke); + paint.style = ui.PaintingStyle.stroke; canvas.drawRRect(rrect, paint); // Radial gradient that changes size if (position > 0) { - paint.setStyle(ui.PaintingStyle.fill); - paint.setShader(new ui.Gradient.radial( + paint + ..style = ui.PaintingStyle.fill + ..shader = new ui.Gradient.radial( new Point(_kEdgeSize / 2.0, _kEdgeSize / 2.0), _kEdgeSize * (_kMidpoint - position) * 8.0, [ - const ui.Color(0x00000000), + const Color(0x00000000), uncheckedColor - ])); + ]); canvas.drawRect(innerRect, paint); } @@ -162,24 +162,25 @@ class _RenderCheckbox extends RenderToggleable { double t = (position - _kMidpoint) / (1.0 - _kMidpoint); // First draw a rounded rect outline then fill inner rectangle with accent color. - paint.color = new Color.fromARGB((t * 255).floor(), _accentColor.red, - _accentColor.green, _accentColor.blue); - paint.setStyle(ui.PaintingStyle.stroke); + paint + ..color = new Color.fromARGB((t * 255).floor(), _accentColor.red, _accentColor.green, _accentColor.blue) + ..style = ui.PaintingStyle.stroke; canvas.drawRRect(rrect, paint); - paint.setStyle(ui.PaintingStyle.fill); + paint.style = ui.PaintingStyle.fill; canvas.drawRect(innerRect, paint); // White inner check - paint.color = const ui.Color(0xFFFFFFFF); - paint.setStyle(ui.PaintingStyle.stroke); - ui.Path path = new ui.Path(); - ui.Point start = new ui.Point(_kEdgeSize * 0.15, _kEdgeSize * 0.45); - ui.Point mid = new ui.Point(_kEdgeSize * 0.4, _kEdgeSize * 0.7); - ui.Point end = new ui.Point(_kEdgeSize * 0.85, _kEdgeSize * 0.25); + paint + ..color = const Color(0xFFFFFFFF) + ..style = ui.PaintingStyle.stroke; + Path path = new Path(); + Point start = new Point(_kEdgeSize * 0.15, _kEdgeSize * 0.45); + Point mid = new Point(_kEdgeSize * 0.4, _kEdgeSize * 0.7); + Point end = new Point(_kEdgeSize * 0.85, _kEdgeSize * 0.25); Point lerp(Point p1, Point p2, double t) => new Point(p1.x * (1.0 - t) + p2.x * t, p1.y * (1.0 - t) + p2.y * t); - ui.Point drawStart = lerp(start, mid, 1.0 - t); - ui.Point drawEnd = lerp(mid, end, t); + Point drawStart = lerp(start, mid, 1.0 - t); + Point drawEnd = lerp(mid, end, t); path.moveTo(offset.dx + drawStart.x, offset.dy + drawStart.y); path.lineTo(offset.dx + mid.x, offset.dy + mid.y); path.lineTo(offset.dx + drawEnd.x, offset.dy + drawEnd.y); diff --git a/sky/packages/sky/lib/src/material/date_picker.dart b/sky/packages/sky/lib/src/material/date_picker.dart index 46caf21ff3d..e9d57597f79 100644 --- a/sky/packages/sky/lib/src/material/date_picker.dart +++ b/sky/packages/sky/lib/src/material/date_picker.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'package:intl/date_symbols.dart'; import 'package:intl/intl.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; diff --git a/sky/packages/sky/lib/src/material/dialog.dart b/sky/packages/sky/lib/src/material/dialog.dart index 9a39a00578d..6bf57bab001 100644 --- a/sky/packages/sky/lib/src/material/dialog.dart +++ b/sky/packages/sky/lib/src/material/dialog.dart @@ -5,7 +5,6 @@ import 'dart:async'; import 'package:flutter/animation.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; import 'colors.dart'; diff --git a/sky/packages/sky/lib/src/material/drawer_item.dart b/sky/packages/sky/lib/src/material/drawer_item.dart index 6723b15f1e4..4d203d495e9 100644 --- a/sky/packages/sky/lib/src/material/drawer_item.dart +++ b/sky/packages/sky/lib/src/material/drawer_item.dart @@ -4,8 +4,6 @@ import 'dart:ui' as ui; -import 'package:flutter/gestures.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter/widgets.dart'; import 'colors.dart'; @@ -51,8 +49,8 @@ class _DrawerItemState extends State { ui.ColorFilter _getColorFilter(ThemeData themeData) { if (config.selected) - return new ui.ColorFilter.mode(themeData.primaryColor, ui.TransferMode.srcATop); - return new ui.ColorFilter.mode(const Color(0x73000000), ui.TransferMode.dstIn); + return new ui.ColorFilter.mode(themeData.primaryColor, TransferMode.srcATop); + return new ui.ColorFilter.mode(const Color(0x73000000), TransferMode.dstIn); } Widget build(BuildContext context) { diff --git a/sky/packages/sky/lib/src/material/flat_button.dart b/sky/packages/sky/lib/src/material/flat_button.dart index 5def34464a4..b078dcddd8a 100644 --- a/sky/packages/sky/lib/src/material/flat_button.dart +++ b/sky/packages/sky/lib/src/material/flat_button.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; import 'colors.dart'; diff --git a/sky/packages/sky/lib/src/material/floating_action_button.dart b/sky/packages/sky/lib/src/material/floating_action_button.dart index e9b6d83c882..b7883a78fb4 100644 --- a/sky/packages/sky/lib/src/material/floating_action_button.dart +++ b/sky/packages/sky/lib/src/material/floating_action_button.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; import 'icon.dart'; diff --git a/sky/packages/sky/lib/src/material/icon_button.dart b/sky/packages/sky/lib/src/material/icon_button.dart index 7e8abf63344..f629806d302 100644 --- a/sky/packages/sky/lib/src/material/icon_button.dart +++ b/sky/packages/sky/lib/src/material/icon_button.dart @@ -4,7 +4,6 @@ import 'dart:ui' as ui; -import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; import 'icon.dart'; diff --git a/sky/packages/sky/lib/src/material/ink_well.dart b/sky/packages/sky/lib/src/material/ink_well.dart index 161be19e5e3..bc4bb235b01 100644 --- a/sky/packages/sky/lib/src/material/ink_well.dart +++ b/sky/packages/sky/lib/src/material/ink_well.dart @@ -4,7 +4,6 @@ import 'dart:async'; import 'dart:math' as math; -import 'dart:ui' as ui; import 'package:flutter/animation.dart'; import 'package:flutter/gestures.dart'; @@ -91,7 +90,7 @@ class _InkSplash { void paint(PaintingCanvas canvas) { int opacity = (_kSplashInitialOpacity * (1.1 - (_radius.value / _targetRadius))).floor(); - ui.Paint paint = new ui.Paint()..color = new ui.Color(opacity << 24); + Paint paint = new Paint()..color = new Color(opacity << 24); double radius = _pinnedRadius == null ? _radius.value : _pinnedRadius; canvas.drawCircle(position, radius, paint); } diff --git a/sky/packages/sky/lib/src/material/input.dart b/sky/packages/sky/lib/src/material/input.dart index 31024114858..c2dfb5f902c 100644 --- a/sky/packages/sky/lib/src/material/input.dart +++ b/sky/packages/sky/lib/src/material/input.dart @@ -4,8 +4,6 @@ import 'package:flutter/animation.dart'; import 'package:flutter/services.dart'; -import 'package:flutter/painting.dart'; -import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'theme.dart'; diff --git a/sky/packages/sky/lib/src/material/list_item.dart b/sky/packages/sky/lib/src/material/list_item.dart index 84377c65ef1..9f59a7a3064 100644 --- a/sky/packages/sky/lib/src/material/list_item.dart +++ b/sky/packages/sky/lib/src/material/list_item.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter/widgets.dart'; import 'ink_well.dart'; diff --git a/sky/packages/sky/lib/src/material/material.dart b/sky/packages/sky/lib/src/material/material.dart index dcfbd2113a8..893d4788d4f 100644 --- a/sky/packages/sky/lib/src/material/material.dart +++ b/sky/packages/sky/lib/src/material/material.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/animation.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter/widgets.dart'; import 'constants.dart'; diff --git a/sky/packages/sky/lib/src/material/material_app.dart b/sky/packages/sky/lib/src/material/material_app.dart index 04b3087bd65..0d41ab62cd2 100644 --- a/sky/packages/sky/lib/src/material/material_app.dart +++ b/sky/packages/sky/lib/src/material/material_app.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; diff --git a/sky/packages/sky/lib/src/material/material_button.dart b/sky/packages/sky/lib/src/material/material_button.dart index 0a343e9edc7..bf5380d20a4 100644 --- a/sky/packages/sky/lib/src/material/material_button.dart +++ b/sky/packages/sky/lib/src/material/material_button.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; import 'colors.dart'; diff --git a/sky/packages/sky/lib/src/material/progress_indicator.dart b/sky/packages/sky/lib/src/material/progress_indicator.dart index 2c20a0af3e8..73052ecdc76 100644 --- a/sky/packages/sky/lib/src/material/progress_indicator.dart +++ b/sky/packages/sky/lib/src/material/progress_indicator.dart @@ -76,10 +76,10 @@ class LinearProgressIndicator extends ProgressIndicator { double bufferValue }) : super(key: key, value: value, bufferValue: bufferValue); - void _paint(BuildContext context, double performanceValue, ui.Canvas canvas, Size size) { + void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) { Paint paint = new Paint() ..color = _getBackgroundColor(context) - ..setStyle(ui.PaintingStyle.fill); + ..style = ui.PaintingStyle.fill; canvas.drawRect(Point.origin & size, paint); paint.color = _getValueColor(context); @@ -103,7 +103,7 @@ class LinearProgressIndicator extends ProgressIndicator { ), child: new CustomPaint( token: _getCustomPaintToken(performanceValue), - callback: (ui.Canvas canvas, Size size) { + callback: (Canvas canvas, Size size) { _paint(context, performanceValue, canvas, size); } ) @@ -124,15 +124,15 @@ class CircularProgressIndicator extends ProgressIndicator { double bufferValue }) : super(key: key, value: value, bufferValue: bufferValue); - void _paint(BuildContext context, double performanceValue, ui.Canvas canvas, Size size) { + void _paint(BuildContext context, double performanceValue, Canvas canvas, Size size) { Paint paint = new Paint() ..color = _getValueColor(context) ..strokeWidth = _kCircularProgressIndicatorStrokeWidth - ..setStyle(ui.PaintingStyle.stroke); + ..style = ui.PaintingStyle.stroke; if (value != null) { double angle = value.clamp(0.0, 1.0) * _kSweep; - ui.Path path = new ui.Path() + Path path = new Path() ..arcTo(Point.origin & size, _kStartAngle, angle, false); canvas.drawPath(path, paint); } else { @@ -140,7 +140,7 @@ class CircularProgressIndicator extends ProgressIndicator { double endAngle = startAngle + _kTwoPI * 0.75; double arcAngle = startAngle.clamp(0.0, _kTwoPI); double arcSweep = endAngle.clamp(0.0, _kTwoPI) - arcAngle; - ui.Path path = new ui.Path() + Path path = new Path() ..arcTo(Point.origin & size, _kStartAngle + arcAngle, arcSweep, false); canvas.drawPath(path, paint); } @@ -154,7 +154,7 @@ class CircularProgressIndicator extends ProgressIndicator { ), child: new CustomPaint( token: _getCustomPaintToken(performanceValue), - callback: (ui.Canvas canvas, Size size) { + callback: (Canvas canvas, Size size) { _paint(context, performanceValue, canvas, size); } ) diff --git a/sky/packages/sky/lib/src/material/radial_reaction.dart b/sky/packages/sky/lib/src/material/radial_reaction.dart index ee4748f909e..8e7349673ca 100644 --- a/sky/packages/sky/lib/src/material/radial_reaction.dart +++ b/sky/packages/sky/lib/src/material/radial_reaction.dart @@ -3,10 +3,9 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:ui' as ui; -import 'dart:ui' show Point, Offset, Color, Paint; import 'package:flutter/animation.dart'; +import 'package:flutter/painting.dart'; const Duration _kShowDuration = const Duration(milliseconds: 300); const Duration _kHideDuration = const Duration(milliseconds: 200); @@ -82,7 +81,7 @@ class RadialReaction { final Paint _innerPaint = new Paint(); /// Paint the reaction onto the given canvas at the given offset - void paint(ui.Canvas canvas, Offset offset) { + void paint(Canvas canvas, Offset offset) { _outerPaint.color = _kOuterColor.withAlpha(_roundOpacity(_outerOpacity.value * _fade.value)); canvas.drawCircle(center + offset, radius, _outerPaint); diff --git a/sky/packages/sky/lib/src/material/radio.dart b/sky/packages/sky/lib/src/material/radio.dart index e2e65d80d3d..0a5c42d7dfe 100644 --- a/sky/packages/sky/lib/src/material/radio.dart +++ b/sky/packages/sky/lib/src/material/radio.dart @@ -8,8 +8,8 @@ import 'package:flutter/widgets.dart'; import 'theme.dart'; -const ui.Color _kLightOffColor = const ui.Color(0x8A000000); -const ui.Color _kDarkOffColor = const ui.Color(0xB2FFFFFF); +const Color _kLightOffColor = const Color(0x8A000000); +const Color _kDarkOffColor = const Color(0xB2FFFFFF); typedef void RadioValueChanged(Object value); @@ -45,18 +45,18 @@ class Radio extends StatelessComponent { width: kDiameter, height: kDiameter, child: new CustomPaint( - callback: (ui.Canvas canvas, Size size) { - - Paint paint = new Paint()..color = _getColor(context); + callback: (Canvas canvas, Size size) { // Draw the outer circle - paint.setStyle(ui.PaintingStyle.stroke); - paint.strokeWidth = 2.0; + Paint paint = new Paint() + ..color = _getColor(context) + ..style = ui.PaintingStyle.stroke + ..strokeWidth = 2.0; canvas.drawCircle(const Point(kOuterRadius, kOuterRadius), kOuterRadius, paint); // Draw the inner circle if (value == groupValue) { - paint.setStyle(ui.PaintingStyle.fill); + paint.style = ui.PaintingStyle.fill; canvas.drawCircle(const Point(kOuterRadius, kOuterRadius), kInnerRadius, paint); } } diff --git a/sky/packages/sky/lib/src/material/raised_button.dart b/sky/packages/sky/lib/src/material/raised_button.dart index 2f1d9f7ce4c..4b023238ddf 100644 --- a/sky/packages/sky/lib/src/material/raised_button.dart +++ b/sky/packages/sky/lib/src/material/raised_button.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; import 'colors.dart'; diff --git a/sky/packages/sky/lib/src/material/scaffold.dart b/sky/packages/sky/lib/src/material/scaffold.dart index a33e754c353..4496187e761 100644 --- a/sky/packages/sky/lib/src/material/scaffold.dart +++ b/sky/packages/sky/lib/src/material/scaffold.dart @@ -4,7 +4,6 @@ import 'dart:ui' as ui; -import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'constants.dart'; diff --git a/sky/packages/sky/lib/src/material/snack_bar.dart b/sky/packages/sky/lib/src/material/snack_bar.dart index 3441fa74389..8ec933a93b4 100644 --- a/sky/packages/sky/lib/src/material/snack_bar.dart +++ b/sky/packages/sky/lib/src/material/snack_bar.dart @@ -3,8 +3,6 @@ // found in the LICENSE file. import 'package:flutter/animation.dart'; -import 'package:flutter/gestures.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter/widgets.dart'; import 'constants.dart'; diff --git a/sky/packages/sky/lib/src/material/switch.dart b/sky/packages/sky/lib/src/material/switch.dart index 9de1a2c2037..9fbed9b21d7 100644 --- a/sky/packages/sky/lib/src/material/switch.dart +++ b/sky/packages/sky/lib/src/material/switch.dart @@ -6,7 +6,6 @@ import 'dart:async'; import 'dart:ui' as ui; import 'package:flutter/painting.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; @@ -16,8 +15,8 @@ import 'theme.dart'; export 'package:flutter/rendering.dart' show ValueChanged; -const ui.Color _kThumbOffColor = const ui.Color(0xFFFAFAFA); -const ui.Color _kTrackOffColor = const ui.Color(0x42000000); +const Color _kThumbOffColor = const Color(0xFFFAFAFA); +const Color _kTrackOffColor = const Color(0x42000000); const double _kSwitchWidth = 35.0; const double _kThumbRadius = 10.0; const double _kSwitchHeight = _kThumbRadius * 2.0; @@ -113,18 +112,18 @@ class _RenderSwitch extends RenderToggleable { void paint(PaintingContext context, Offset offset) { final PaintingCanvas canvas = context.canvas; - ui.Color thumbColor = _kThumbOffColor; - ui.Color trackColor = _kTrackOffColor; + Color thumbColor = _kThumbOffColor; + Color trackColor = _kTrackOffColor; if (value) { thumbColor = _thumbColor; - trackColor = new ui.Color(_thumbColor.value & 0x80FFFFFF); + trackColor = new Color(_thumbColor.value & 0x80FFFFFF); } // Draw the track rrect - ui.Paint paint = new ui.Paint() + Paint paint = new Paint() ..color = trackColor ..style = ui.PaintingStyle.fill; - ui.Rect rect = new ui.Rect.fromLTWH(offset.dx, + Rect rect = new Rect.fromLTWH(offset.dx, offset.dy + _kSwitchHeight / 2.0 - _kTrackHeight / 2.0, _kTrackWidth, _kTrackHeight); ui.RRect rrect = new ui.RRect() diff --git a/sky/packages/sky/lib/src/material/tabs.dart b/sky/packages/sky/lib/src/material/tabs.dart index 695708b5311..0eb804960f2 100644 --- a/sky/packages/sky/lib/src/material/tabs.dart +++ b/sky/packages/sky/lib/src/material/tabs.dart @@ -7,8 +7,6 @@ import 'dart:ui' as ui; import 'package:newton/newton.dart'; import 'package:flutter/animation.dart'; -import 'package:flutter/gestures.dart'; -import 'package:flutter/painting.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; @@ -312,7 +310,7 @@ class Tab extends StatelessComponent { Widget _buildLabelIcon() { assert(label.icon != null); Color iconColor = selected ? selectedColor : color; - ui.ColorFilter filter = new ui.ColorFilter.mode(iconColor, ui.TransferMode.srcATop); + ui.ColorFilter filter = new ui.ColorFilter.mode(iconColor, TransferMode.srcATop); return new Icon(type: label.icon, size: _kTabIconSize, colorFilter: filter); } diff --git a/sky/packages/sky/lib/src/material/theme_data.dart b/sky/packages/sky/lib/src/material/theme_data.dart index f5a8e1fabd3..7566fd405cf 100644 --- a/sky/packages/sky/lib/src/material/theme_data.dart +++ b/sky/packages/sky/lib/src/material/theme_data.dart @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:ui'; +import 'dart:ui' show Color; -import 'package:flutter/src/material/typography.dart'; -import 'package:flutter/src/material/colors.dart'; +import 'typography.dart'; +import 'colors.dart'; enum ThemeBrightness { dark, light } diff --git a/sky/packages/sky/lib/src/material/tool_bar.dart b/sky/packages/sky/lib/src/material/tool_bar.dart index cdcbe9ccac5..b2f5daaf4d4 100644 --- a/sky/packages/sky/lib/src/material/tool_bar.dart +++ b/sky/packages/sky/lib/src/material/tool_bar.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/painting.dart'; import 'package:flutter/widgets.dart'; import 'constants.dart'; diff --git a/sky/packages/sky/lib/src/material/typography.dart b/sky/packages/sky/lib/src/material/typography.dart index 396b0acd1fa..b9eb2061f6f 100644 --- a/sky/packages/sky/lib/src/material/typography.dart +++ b/sky/packages/sky/lib/src/material/typography.dart @@ -7,7 +7,8 @@ import 'dart:ui' show Color; import 'package:flutter/painting.dart'; -import 'package:flutter/src/material/colors.dart'; + +import 'colors.dart'; // TODO(eseidel): Font weights are supposed to be language relative! // TODO(jackson): Baseline should be language relative! diff --git a/sky/packages/sky/lib/src/painting/basic_types.dart b/sky/packages/sky/lib/src/painting/basic_types.dart new file mode 100644 index 00000000000..2265c2b91d3 --- /dev/null +++ b/sky/packages/sky/lib/src/painting/basic_types.dart @@ -0,0 +1,19 @@ +// 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. + +export 'dart:ui' show + Canvas, + Color, + FontStyle, + FontWeight, + Offset, + Paint, + Path, + Point, + Rect, + Size, + TextAlign, + TextBaseline, + TextDecoration, + TextDecorationStyle; diff --git a/sky/packages/sky/lib/src/painting/box_painter.dart b/sky/packages/sky/lib/src/painting/box_painter.dart index 2d3b3363aac..864b9627c94 100644 --- a/sky/packages/sky/lib/src/painting/box_painter.dart +++ b/sky/packages/sky/lib/src/painting/box_painter.dart @@ -4,10 +4,10 @@ import 'dart:math' as math; import 'dart:ui' as ui; -import 'dart:ui' show Point, Offset, Size, Rect, Color, Paint, Path; import 'package:flutter/services.dart'; +import 'basic_types.dart'; import 'shadows.dart'; /// An immutable set of offsets in each of the four cardinal directions. diff --git a/sky/packages/sky/lib/src/painting/text_painter.dart b/sky/packages/sky/lib/src/painting/text_painter.dart index 710a11f11d4..b5140f3bbd0 100644 --- a/sky/packages/sky/lib/src/painting/text_painter.dart +++ b/sky/packages/sky/lib/src/painting/text_painter.dart @@ -4,10 +4,9 @@ import 'dart:ui' as ui; +import 'basic_types.dart'; import 'text_style.dart'; -export 'text_style.dart'; - /// An immutable span of text abstract class TextSpan { // This class must be immutable, because we won't notice when it changes diff --git a/sky/packages/sky/lib/src/painting/text_style.dart b/sky/packages/sky/lib/src/painting/text_style.dart index cf241df7006..86aa5febd01 100644 --- a/sky/packages/sky/lib/src/painting/text_style.dart +++ b/sky/packages/sky/lib/src/painting/text_style.dart @@ -3,9 +3,8 @@ // found in the LICENSE file. import 'dart:ui' as ui; -import 'dart:ui' show Point, Offset, Size, Rect, Color, Paint, Path, FontWeight, FontStyle, TextAlign, TextBaseline, TextDecoration, TextDecorationStyle; -export 'dart:ui' show FontWeight, FontStyle, TextAlign, TextBaseline, TextDecoration, TextDecorationStyle; +import 'basic_types.dart'; /// A normal font weight const normal = FontWeight.w400; diff --git a/sky/packages/sky/lib/src/rendering/basic_types.dart b/sky/packages/sky/lib/src/rendering/basic_types.dart new file mode 100644 index 00000000000..642e6c5a99f --- /dev/null +++ b/sky/packages/sky/lib/src/rendering/basic_types.dart @@ -0,0 +1,14 @@ +// 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. + +export 'dart:ui' show + Canvas, + Color, + Offset, + Paint, + Path, + Point, + Rect, + Size, + TransferMode; diff --git a/sky/packages/sky/lib/src/rendering/box.dart b/sky/packages/sky/lib/src/rendering/box.dart index 25bb5d88291..968a8c80ca1 100644 --- a/sky/packages/sky/lib/src/rendering/box.dart +++ b/sky/packages/sky/lib/src/rendering/box.dart @@ -602,16 +602,16 @@ abstract class RenderBox extends RenderObject { debugPaintBaselines(context, offset); } void debugPaintSize(PaintingContext context, Offset offset) { - Paint paint = new Paint(); - paint.setStyle(ui.PaintingStyle.stroke); - paint.strokeWidth = 1.0; - paint.color = debugPaintSizeColor; + Paint paint = new Paint() + ..style = ui.PaintingStyle.stroke + ..strokeWidth = 1.0 + ..color = debugPaintSizeColor; context.canvas.drawRect(offset & size, paint); } void debugPaintBaselines(PaintingContext context, Offset offset) { - Paint paint = new Paint(); - paint.setStyle(ui.PaintingStyle.stroke); - paint.strokeWidth = 0.25; + Paint paint = new Paint() + ..style = ui.PaintingStyle.stroke + ..strokeWidth = 0.25; Path path; // ideographic baseline double baselineI = getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true); diff --git a/sky/packages/sky/lib/src/rendering/image.dart b/sky/packages/sky/lib/src/rendering/image.dart index 3863cc0f222..52cda1c9da3 100644 --- a/sky/packages/sky/lib/src/rendering/image.dart +++ b/sky/packages/sky/lib/src/rendering/image.dart @@ -9,6 +9,10 @@ import 'package:flutter/painting.dart'; import 'box.dart'; import 'object.dart'; +export 'package:flutter/painting.dart' show + ImageFit, + ImageRepeat; + /// An image in the render tree. /// /// The render image attempts to find a size for itself that fits in the given diff --git a/sky/packages/sky/lib/src/rendering/layer.dart b/sky/packages/sky/lib/src/rendering/layer.dart index 0434fd83329..c5637e797d9 100644 --- a/sky/packages/sky/lib/src/rendering/layer.dart +++ b/sky/packages/sky/lib/src/rendering/layer.dart @@ -3,10 +3,13 @@ // found in the LICENSE file. import 'dart:ui' as ui; -import 'dart:ui' show Point, Offset, Size, Rect, Color, Paint, Path; import 'package:vector_math/vector_math_64.dart'; +import 'basic_types.dart'; + +export 'basic_types.dart'; + /// A composited layer /// /// During painting, the render tree generates a tree of composited layers that @@ -322,7 +325,7 @@ class ColorFilterLayer extends ContainerLayer { Color color; /// The transfer mode to use to combine [color] with the children's painting - ui.TransferMode transferMode; + TransferMode transferMode; void addToScene(ui.SceneBuilder builder, Offset layerOffset) { builder.pushColorFilter(color, transferMode, bounds.shift(offset)); diff --git a/sky/packages/sky/lib/src/rendering/object.dart b/sky/packages/sky/lib/src/rendering/object.dart index be74fec813f..679ccecad5d 100644 --- a/sky/packages/sky/lib/src/rendering/object.dart +++ b/sky/packages/sky/lib/src/rendering/object.dart @@ -4,7 +4,6 @@ import 'dart:math' as math; import 'dart:ui' as ui; -import 'dart:ui' show Point, Offset, Size, Rect, Color, Paint, Path; import 'package:flutter/animation.dart'; import 'package:flutter/gestures.dart'; @@ -15,8 +14,8 @@ import 'hit_test.dart'; import 'layer.dart'; import 'node.dart'; -export 'dart:ui' show Point, Offset, Size, Rect, Color, Paint, Path; -export 'hit_test.dart' show HitTestTarget, HitTestEntry, HitTestResult; +export 'layer.dart'; +export 'hit_test.dart'; typedef ui.Shader ShaderCallback(Rect bounds); @@ -39,7 +38,7 @@ class ParentData { } /// Obsolete class that will be removed eventually -class PaintingCanvas extends ui.Canvas { +class PaintingCanvas extends Canvas { PaintingCanvas(ui.PictureRecorder recorder, Rect bounds) : super(recorder, bounds); // TODO(ianh): Just use ui.Canvas everywhere instead } @@ -247,7 +246,7 @@ class PaintingContext { static Paint _getPaintForAlpha(int alpha) { return new Paint() ..color = new Color.fromARGB(alpha, 0, 0, 0) - ..setTransferMode(ui.TransferMode.srcOver) + ..setTransferMode(TransferMode.srcOver) ..isAntiAlias = false; } @@ -277,7 +276,7 @@ class PaintingContext { } } - static Paint _getPaintForColorFilter(Color color, ui.TransferMode transferMode) { + static Paint _getPaintForColorFilter(Color color, TransferMode transferMode) { return new Paint() ..colorFilter = new ui.ColorFilter.mode(color, transferMode) ..isAntiAlias = false; @@ -295,7 +294,7 @@ class PaintingContext { Point childPosition, Rect bounds, Color color, - ui.TransferMode transferMode) { + TransferMode transferMode) { assert(debugCanPaintChild(child)); final Offset childOffset = childPosition.toOffset(); if (!child.needsCompositing) { @@ -316,7 +315,7 @@ class PaintingContext { static Paint _getPaintForShaderMask(Rect bounds, ShaderCallback shaderCallback, - ui.TransferMode transferMode) { + TransferMode transferMode) { return new Paint() ..transferMode = transferMode ..shader = shaderCallback(bounds); @@ -326,7 +325,7 @@ class PaintingContext { Point childPosition, Rect bounds, ShaderCallback shaderCallback, - ui.TransferMode transferMode) { + TransferMode transferMode) { assert(debugCanPaintChild(child)); final Offset childOffset = childPosition.toOffset(); if (!child.needsCompositing) { diff --git a/sky/packages/sky/lib/src/rendering/paragraph.dart b/sky/packages/sky/lib/src/rendering/paragraph.dart index 67bbfc0baae..b12309eb7de 100644 --- a/sky/packages/sky/lib/src/rendering/paragraph.dart +++ b/sky/packages/sky/lib/src/rendering/paragraph.dart @@ -7,7 +7,22 @@ import 'package:flutter/painting.dart'; import 'box.dart'; import 'object.dart'; -export 'package:flutter/src/painting/text_painter.dart'; +export 'package:flutter/painting.dart' show + FontStyle, + FontWeight, + PlainTextSpan, + StyledTextSpan, + TextAlign, + TextBaseline, + TextDecoration, + TextDecorationStyle, + TextSpan, + TextStyle, + normal, + bold, + underline, + overline, + lineThrough; /// A render object that displays a paragraph of text class RenderParagraph extends RenderBox { diff --git a/sky/packages/sky/lib/src/rendering/proxy_box.dart b/sky/packages/sky/lib/src/rendering/proxy_box.dart index 93307aaa346..805d5063217 100644 --- a/sky/packages/sky/lib/src/rendering/proxy_box.dart +++ b/sky/packages/sky/lib/src/rendering/proxy_box.dart @@ -629,7 +629,7 @@ class RenderOpacity extends RenderProxyBox { /// Note: This class is relatively expensive because it requires painting the /// child into an intermediate buffer. class RenderColorFilter extends RenderProxyBox { - RenderColorFilter({ RenderBox child, Color color, ui.TransferMode transferMode }) + RenderColorFilter({ RenderBox child, Color color, TransferMode transferMode }) : _color = color, _transferMode = transferMode, super(child); /// The color to use as input to the color filter @@ -644,9 +644,9 @@ class RenderColorFilter extends RenderProxyBox { } /// The transfer mode to use when combining the child's painting and the [color] - ui.TransferMode get transferMode => _transferMode; - ui.TransferMode _transferMode; - void set transferMode (ui.TransferMode newTransferMode) { + TransferMode get transferMode => _transferMode; + TransferMode _transferMode; + void set transferMode (TransferMode newTransferMode) { assert(newTransferMode != null); if (_transferMode == newTransferMode) return; @@ -661,7 +661,7 @@ class RenderColorFilter extends RenderProxyBox { } class RenderShaderMask extends RenderProxyBox { - RenderShaderMask({ RenderBox child, ShaderCallback shaderCallback, ui.TransferMode transferMode }) + RenderShaderMask({ RenderBox child, ShaderCallback shaderCallback, TransferMode transferMode }) : _shaderCallback = shaderCallback, _transferMode = transferMode, super(child); ShaderCallback get shaderCallback => _shaderCallback; @@ -674,9 +674,9 @@ class RenderShaderMask extends RenderProxyBox { markNeedsPaint(); } - ui.TransferMode get transferMode => _transferMode; - ui.TransferMode _transferMode; - void set transferMode (ui.TransferMode newTransferMode) { + TransferMode get transferMode => _transferMode; + TransferMode _transferMode; + void set transferMode (TransferMode newTransferMode) { assert(newTransferMode != null); if (_transferMode == newTransferMode) return; diff --git a/sky/packages/sky/lib/src/widgets/basic.dart b/sky/packages/sky/lib/src/widgets/basic.dart index c32d23f1573..eec0075f469 100644 --- a/sky/packages/sky/lib/src/widgets/basic.dart +++ b/sky/packages/sky/lib/src/widgets/basic.dart @@ -18,25 +18,47 @@ export 'package:flutter/rendering.dart' show BoxDecoration, BoxDecorationPosition, BoxShadow, + Canvas, Color, EdgeDims, FlexAlignItems, FlexDirection, FlexJustifyContent, + FontStyle, + FontWeight, FractionalOffset, + Gradient, + ImageFit, + ImageRepeat, InputEvent, + LinearGradient, Matrix4, Offset, Paint, Path, + PlainTextSpan, Point, PointerInputEvent, + RadialGradient, Rect, ScrollDirection, Shape, ShrinkWrap, Size, - ValueChanged; + StyledTextSpan, + TextAlign, + TextBaseline, + TextDecoration, + TextDecorationStyle, + TextSpan, + TextStyle, + TransferMode, + ValueChanged, + normal, + bold, + underline, + overline, + lineThrough; // PAINTING NODES @@ -64,7 +86,7 @@ class ColorFilter extends OneChildRenderObjectWidget { } final Color color; - final ui.TransferMode transferMode; + final TransferMode transferMode; RenderColorFilter createRenderObject() => new RenderColorFilter(color: color, transferMode: transferMode); @@ -78,7 +100,7 @@ class ShaderMask extends OneChildRenderObjectWidget { ShaderMask({ Key key, this.shaderCallback, - this.transferMode: ui.TransferMode.modulate, + this.transferMode: TransferMode.modulate, Widget child }) : super(key: key, child: child) { assert(shaderCallback != null); @@ -86,7 +108,7 @@ class ShaderMask extends OneChildRenderObjectWidget { } final ShaderCallback shaderCallback; - final ui.TransferMode transferMode; + final TransferMode transferMode; RenderShaderMask createRenderObject() { return new RenderShaderMask( diff --git a/sky/packages/sky/lib/src/widgets/drag_target.dart b/sky/packages/sky/lib/src/widgets/drag_target.dart index 6de530d648d..5a6f237860f 100644 --- a/sky/packages/sky/lib/src/widgets/drag_target.dart +++ b/sky/packages/sky/lib/src/widgets/drag_target.dart @@ -5,7 +5,6 @@ import 'dart:collection'; import 'package:flutter/animation.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/rendering.dart'; import 'basic.dart'; diff --git a/sky/packages/sky/lib/src/widgets/gesture_detector.dart b/sky/packages/sky/lib/src/widgets/gesture_detector.dart index 5862ee3c434..0b8841c84dc 100644 --- a/sky/packages/sky/lib/src/widgets/gesture_detector.dart +++ b/sky/packages/sky/lib/src/widgets/gesture_detector.dart @@ -8,6 +8,25 @@ import 'package:flutter/rendering.dart'; import 'basic.dart'; import 'framework.dart'; +export 'package:flutter/gestures.dart' show + GestureTapCallback, + GestureTapCallback, + GestureTapCallback, + GestureShowPressCallback, + GestureLongPressCallback, + GestureDragStartCallback, + GestureDragUpdateCallback, + GestureDragEndCallback, + GestureDragStartCallback, + GestureDragUpdateCallback, + GestureDragEndCallback, + GesturePanStartCallback, + GesturePanUpdateCallback, + GesturePanEndCallback, + GestureScaleStartCallback, + GestureScaleUpdateCallback, + GestureScaleEndCallback; + class GestureDetector extends StatefulComponent { const GestureDetector({ Key key, diff --git a/sky/packages/sky/lib/src/widgets/homogeneous_viewport.dart b/sky/packages/sky/lib/src/widgets/homogeneous_viewport.dart index 3ee2735afa0..749488dac89 100644 --- a/sky/packages/sky/lib/src/widgets/homogeneous_viewport.dart +++ b/sky/packages/sky/lib/src/widgets/homogeneous_viewport.dart @@ -5,8 +5,9 @@ import 'dart:math' as math; import 'package:flutter/rendering.dart'; -import 'package:flutter/src/widgets/framework.dart'; -import 'package:flutter/src/widgets/basic.dart'; + +import 'framework.dart'; +import 'basic.dart'; typedef List ListBuilder(BuildContext context, int startIndex, int count); diff --git a/sky/packages/sky/lib/src/widgets/transitions.dart b/sky/packages/sky/lib/src/widgets/transitions.dart index 3749e8d987c..bd2f7dab4a5 100644 --- a/sky/packages/sky/lib/src/widgets/transitions.dart +++ b/sky/packages/sky/lib/src/widgets/transitions.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:flutter/animation.dart'; -import 'package:vector_math/vector_math_64.dart'; +import 'package:vector_math/vector_math_64.dart' show Matrix4; import 'basic.dart'; import 'framework.dart';