Commit f5481181 authored by Adam Barth's avatar Adam Barth

Port playfair to fn3

parent 76ed7ae2
...@@ -9,6 +9,6 @@ import 'dart:math' as math; ...@@ -9,6 +9,6 @@ import 'dart:math' as math;
import 'package:sky/material.dart'; import 'package:sky/material.dart';
import 'package:sky/rendering.dart'; import 'package:sky/rendering.dart';
import 'package:sky/widgets.dart'; import 'package:sky/widgets_next.dart';
part 'src/base.dart'; part 'src/base.dart';
...@@ -38,17 +38,26 @@ const double kIndicatorStrokeWidth = 2.0; ...@@ -38,17 +38,26 @@ const double kIndicatorStrokeWidth = 2.0;
const Color kIndicatorColor = const Color(0xFFFF4081); const Color kIndicatorColor = const Color(0xFFFF4081);
const double kIndicatorMargin = 2.0; const double kIndicatorMargin = 2.0;
class Chart extends LeafRenderObjectWrapper { class Chart extends StatelessComponent {
Chart({ Key key, this.data }) : super(key: key); Chart({ Key key, this.data }) : super(key: key);
final ChartData data; final ChartData data;
RenderChart createNode() => new RenderChart(data: data); Widget build(BuildContext context) {
RenderChart get renderObject => super.renderObject; return new _ChartWrapper(textTheme: Theme.of(context).text, data: data);
}
}
class _ChartWrapper extends LeafRenderObjectWidget {
_ChartWrapper({ Key key, this.textTheme, this.data }) : super(key: key);
final TextTheme textTheme;
final ChartData data;
RenderChart createRenderObject() => new RenderChart(textTheme: textTheme, data: data);
void syncRenderObject(Widget old) { void updateRenderObject(RenderChart renderObject, _ChartWrapper oldWidget) {
super.syncRenderObject(old); renderObject.textTheme = textTheme;
renderObject.textTheme = Theme.of(this).text;
renderObject.data = data; renderObject.data = data;
} }
} }
...@@ -56,9 +65,10 @@ class Chart extends LeafRenderObjectWrapper { ...@@ -56,9 +65,10 @@ class Chart extends LeafRenderObjectWrapper {
class RenderChart extends RenderConstrainedBox { class RenderChart extends RenderConstrainedBox {
RenderChart({ RenderChart({
TextTheme textTheme,
ChartData data ChartData data
}) : _painter = new ChartPainter(data), }) : _painter = new ChartPainter(textTheme: textTheme, data: data),
super(child: null, additionalConstraints: BoxConstraints.expand); super(child: null, additionalConstraints: const BoxConstraints.expand());
final ChartPainter _painter; final ChartPainter _painter;
...@@ -104,7 +114,7 @@ class Indicator { ...@@ -104,7 +114,7 @@ class Indicator {
} }
class ChartPainter { class ChartPainter {
ChartPainter(this._data); ChartPainter({ TextTheme textTheme, ChartData data }) : _data = data, _textTheme = textTheme;
ChartData _data; ChartData _data;
ChartData get data => _data; ChartData get data => _data;
......
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