Commit 547c324d authored by Hixie's avatar Hixie

fn3 review

- adds dartdocs
- replaces config setter with didUpdateConfig() so that you can't replace
the config outside of the system
- renames didUnmount() with destroy().
- rename Component to StatelessComponent, ComponentConfiguration to
StatefulComponent
- move debug dump to end of file
- renamed _holder to _element
parent d27f3d52
This diff is collapsed.
...@@ -4,7 +4,7 @@ import 'package:test/test.dart'; ...@@ -4,7 +4,7 @@ import 'package:test/test.dart';
import 'widget_tester.dart'; import 'widget_tester.dart';
class TestComponentConfig extends ComponentConfiguration { class TestComponentConfig extends StatefulComponent {
TestComponentConfig({ this.left, this.right }); TestComponentConfig({ this.left, this.right });
final Widget left; final Widget left;
...@@ -13,9 +13,7 @@ class TestComponentConfig extends ComponentConfiguration { ...@@ -13,9 +13,7 @@ class TestComponentConfig extends ComponentConfiguration {
TestComponentState createState() => new TestComponentState(); TestComponentState createState() => new TestComponentState();
} }
class TestComponentState extends ComponentState { class TestComponentState extends ComponentState<TestComponentConfig> {
TestComponentConfig get config => super.config;
bool _showLeft = true; bool _showLeft = true;
void flip() { void flip() {
...@@ -32,7 +30,7 @@ class TestComponentState extends ComponentState { ...@@ -32,7 +30,7 @@ class TestComponentState extends ComponentState {
final BoxDecoration kBoxDecorationA = new BoxDecoration(); final BoxDecoration kBoxDecorationA = new BoxDecoration();
final BoxDecoration kBoxDecorationB = new BoxDecoration(); final BoxDecoration kBoxDecorationB = new BoxDecoration();
class TestBuildCounter extends Component { class TestBuildCounter extends StatelessComponent {
static int buildCount = 0; static int buildCount = 0;
Widget build() { Widget build() {
...@@ -42,8 +40,8 @@ class TestBuildCounter extends Component { ...@@ -42,8 +40,8 @@ class TestBuildCounter extends Component {
} }
void flipStatefulComponent(WidgetTester tester) { void flipStatefulComponent(WidgetTester tester) {
ComponentStateElement stateElement = StatefulComponentElement stateElement =
tester.findElement((element) => element is ComponentStateElement); tester.findElement((element) => element is StatefulComponentElement);
(stateElement.state as TestComponentState).flip(); (stateElement.state as TestComponentState).flip();
} }
......
import 'package:sky/src/fn3/framework.dart'; import 'package:sky/src/fn3/framework.dart';
class TestComponent extends Component { class TestComponent extends StatelessComponent {
TestComponent({ this.child }); TestComponent({ this.child });
final Widget child; final Widget child;
Widget build() => child; Widget build() => child;
...@@ -9,7 +9,7 @@ class TestComponent extends Component { ...@@ -9,7 +9,7 @@ class TestComponent extends Component {
final Object _rootSlot = new Object(); final Object _rootSlot = new Object();
class WidgetTester { class WidgetTester {
ComponentElement _rootElement; StatelessComponentElement _rootElement;
void walkElements(ElementVisitor visitor) { void walkElements(ElementVisitor visitor) {
void walk(Element element) { void walk(Element element) {
...@@ -36,7 +36,7 @@ class WidgetTester { ...@@ -36,7 +36,7 @@ class WidgetTester {
void pumpFrame(Widget widget) { void pumpFrame(Widget widget) {
if (_rootElement == null) { if (_rootElement == null) {
_rootElement = new ComponentElement(new TestComponent(child: widget)); _rootElement = new StatelessComponentElement(new TestComponent(child: widget));
_rootElement.mount(_rootSlot); _rootElement.mount(_rootSlot);
} else { } else {
_rootElement.update(new TestComponent(child: widget)); _rootElement.update(new TestComponent(child: widget));
......
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