| OLD | NEW |
| 1 Sky Widgets | 1 Sky Widgets |
| 2 =========== | 2 =========== |
| 3 | 3 |
| 4 Sky widgets are built using a functional-reactive framework, which takes | 4 Sky widgets are built using a functional-reactive framework, which takes |
| 5 inspiration from [React](http://facebook.github.io/react/). The central idea is | 5 inspiration from [React](http://facebook.github.io/react/). The central idea is |
| 6 that you build your UI out of components. Components describe what their view | 6 that you build your UI out of components. Components describe what their view |
| 7 should look like given their current configuration and state. When a component's | 7 should look like given their current configuration and state. When a component's |
| 8 state changes, the component rebuilds its description, which the framework diffs | 8 state changes, the component rebuilds its description, which the framework diffs |
| 9 against the previous description in order to determine the minial changes needed | 9 against the previous description in order to determine the minial changes needed |
| 10 in the underlying render tree to transition from one state to the next. | 10 in the underlying render tree to transition from one state to the next. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 onGestureTap: (_) => onChanged(!value), | 247 onGestureTap: (_) => onChanged(!value), |
| 248 child: new Container( | 248 child: new Container( |
| 249 height: 25.0, | 249 height: 25.0, |
| 250 width: 25.0, | 250 width: 25.0, |
| 251 decoration: new BoxDecoration(backgroundColor: color) | 251 decoration: new BoxDecoration(backgroundColor: color) |
| 252 ) | 252 ) |
| 253 ); | 253 ); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 class MyDialog extends Component { | 257 class MyDialog extends StatefulComponent { |
| 258 MyDialog({ this.onDismissed }) : super(stateful: true); | 258 MyDialog({ this.onDismissed }); |
| 259 | 259 |
| 260 Function onDismissed; | 260 Function onDismissed; |
| 261 bool _checkboxValue = false; | 261 bool _checkboxValue = false; |
| 262 | 262 |
| 263 void _handleCheckboxValueChanged(bool value) { | 263 void _handleCheckboxValueChanged(bool value) { |
| 264 setState(() { | 264 setState(() { |
| 265 _checkboxValue = value; | 265 _checkboxValue = value; |
| 266 }); | 266 }); |
| 267 } | 267 } |
| 268 | 268 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 291 which it then uses during its `build` function. Notice that when the user taps | 291 which it then uses during its `build` function. Notice that when the user taps |
| 292 on the checkbox, the checkbox itself doesn't use `value`. Instead, the checkbox | 292 on the checkbox, the checkbox itself doesn't use `value`. Instead, the checkbox |
| 293 calls a function it received from its parent component. This pattern lets you | 293 calls a function it received from its parent component. This pattern lets you |
| 294 store state higher in the component hierarchy, which causes the state to persist | 294 store state higher in the component hierarchy, which causes the state to persist |
| 295 for longer periods of time. In the extreme, the state stored on the `App` | 295 for longer periods of time. In the extreme, the state stored on the `App` |
| 296 component persists for the lifetime of the application. | 296 component persists for the lifetime of the application. |
| 297 | 297 |
| 298 The `MyDialog` component is more complicated because it is a stateful component. | 298 The `MyDialog` component is more complicated because it is a stateful component. |
| 299 Let's walk through the differences in `MyDialog` caused by its being stateful: | 299 Let's walk through the differences in `MyDialog` caused by its being stateful: |
| 300 | 300 |
| 301 * `MyDialog` passes `stateful: true` to the `Component` constructor, marking | 301 * `MyDialog` extends StatefulComponent instead of Component. |
| 302 the component stateful. | |
| 303 | 302 |
| 304 * `MyDialog` has non-`final` member variables. Over the lifetime of the dialog, | 303 * `MyDialog` has non-`final` member variables. Over the lifetime of the dialog, |
| 305 we'll need to modify the values of these member variables, which means we | 304 we'll need to modify the values of these member variables, which means we |
| 306 cannot mark them `final`. | 305 cannot mark them `final`. |
| 307 | 306 |
| 308 * `MyDialog` has private member variables. By convention, components store | 307 * `MyDialog` has private member variables. By convention, components store |
| 309 values they receive from their parent in public member variables and store | 308 values they receive from their parent in public member variables and store |
| 310 their own internal, transient state in private member variables. There's no | 309 their own internal, transient state in private member variables. There's no |
| 311 requirement to follow this convention, but we've found that it helps keep us | 310 requirement to follow this convention, but we've found that it helps keep us |
| 312 organized. | 311 organized. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 413 |
| 415 Dependencies | 414 Dependencies |
| 416 ------------ | 415 ------------ |
| 417 | 416 |
| 418 * `package:vector_math` | 417 * `package:vector_math` |
| 419 * [`package:sky/animation`](../animation) | 418 * [`package:sky/animation`](../animation) |
| 420 * [`package:sky/base`](../base) | 419 * [`package:sky/base`](../base) |
| 421 * [`package:sky/painting`](../painting) | 420 * [`package:sky/painting`](../painting) |
| 422 * [`package:sky/rendering`](../rendering) | 421 * [`package:sky/rendering`](../rendering) |
| 423 * [`package:sky/theme`](../theme) | 422 * [`package:sky/theme`](../theme) |
| OLD | NEW |