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