Skip to content

Commit

Permalink
Add some more documentation for RFW
Browse files Browse the repository at this point in the history
  • Loading branch information
Hixie committed Jul 11, 2023
1 parent b4c3424 commit 3cdf7cf
Show file tree
Hide file tree
Showing 9 changed files with 1,131 additions and 84 deletions.
3 changes: 2 additions & 1 deletion packages/rfw/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.0.10

* Fixes stale ignore: prefer_const_constructors.
* More documentation in the README.md file!
* Fixes stale ignore: `prefer_const_constructors`.
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
* Changes package internals to avoid explicit `as Uint8List` downcast.

Expand Down
876 changes: 795 additions & 81 deletions packages/rfw/README.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions packages/rfw/example/hello/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ void main() {
runApp(const Example());
}

// The "#docregion" comment helps us keep this code in sync with the
// excerpt in the rfw package's README.md file.
//
// #docregion Example
class Example extends StatefulWidget {
const Example({super.key});

Expand Down Expand Up @@ -54,8 +58,11 @@ class _ExampleState extends State<Example> {
@override
void initState() {
super.initState();
// Local widget library:
_runtime.update(coreName, createCoreWidgets());
// Remote widget library:
_runtime.update(mainName, _remoteWidgets);
// Configuration data:
_data.update('greet', <String, Object>{'name': 'World'});
}

Expand All @@ -73,3 +80,4 @@ class _ExampleState extends State<Example> {
);
}
}
// #enddocregion Example
8 changes: 8 additions & 0 deletions packages/rfw/example/local/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ void main() {
runApp(const Example());
}

// The "#docregion" comment helps us keep this code in sync with the
// excerpt in the rfw package's README.md file.
//
// #docregion Example
class Example extends StatefulWidget {
const Example({super.key});

Expand All @@ -35,6 +39,9 @@ class _ExampleState extends State<Example> {

@override
void reassemble() {
// This function causes the Runtime to be updated any time the app is
// hot reloaded, so that changes to _createLocalWidgets can be seen
// during development. This function has no effect in production.
super.reassemble();
_update();
}
Expand Down Expand Up @@ -87,3 +94,4 @@ class _ExampleState extends State<Example> {
);
}
}
// #enddocregion Example
9 changes: 9 additions & 0 deletions packages/rfw/example/wasm/logic/calculator.rfwtxt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ widget CalculatorPad = Column(
children: [
Row(
children: [
// The "#docregion" pragma here allows us to inline this as an example
// in the "rfw" package's README.md file. It is unrelated to what this
// example is otherwise trying to show and can be disregarded.
// #docregion button7
CalculatorButton(label: "7", onPressed: event "digit" { arguments: [7] }),
// #enddocregion button7
CalculatorButton(label: "8", onPressed: event "digit" { arguments: [8] }),
CalculatorButton(label: "9", onPressed: event "digit" { arguments: [9] }),
SizedBox(width: 116.0, height: 116.0),
Expand Down Expand Up @@ -58,6 +63,7 @@ widget CalculatorPad = Column(
],
);

// #docregion CalculatorButton
widget CalculatorButton = Padding(
padding: [8.0],
child: SizedBox(
Expand All @@ -69,7 +75,9 @@ widget CalculatorButton = Padding(
),
),
);
// #enddocregion CalculatorButton

// #docregion Button
widget Button { down: false } = GestureDetector(
onTap: args.onPressed,
onTapDown: set state.down = true,
Expand Down Expand Up @@ -110,6 +118,7 @@ widget Button { down: false } = GestureDetector(
),
),
);
// #enddocregion Button

widget Display = Container(
height: 80.0,
Expand Down
2 changes: 1 addition & 1 deletion packages/rfw/lib/src/dart/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ DynamicMap parseDataFile(String file) {
/// event "..." { }
/// ```
///
/// Tthe string is the name of the event, and the arguments map is the data to
/// The string is the name of the event, and the arguments map is the data to
/// send with the event.
///
/// For example, the event handler in the following sequence sends the event
Expand Down
3 changes: 3 additions & 0 deletions packages/rfw/lib/src/flutter/core_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
);
},

// The "#docregion" pragma below makes this accessible from the README.md file.
// #docregion Row
'Row': (BuildContext context, DataSource source) {
return Row(
mainAxisAlignment: ArgumentDecoders.enumValue<MainAxisAlignment>(MainAxisAlignment.values, source, ['mainAxisAlignment']) ?? MainAxisAlignment.start,
Expand All @@ -548,6 +550,7 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
children: source.childList(['children']),
);
},
// #enddocregion Row

'SafeArea': (BuildContext context, DataSource source) {
return SafeArea(
Expand Down
Loading

0 comments on commit 3cdf7cf

Please sign in to comment.