Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2599faa
add rfw widgets
peixinli Dec 13, 2023
2fee2ad
add changelog
peixinli Dec 13, 2023
ba01940
revert format change
peixinli Dec 22, 2023
77b49b9
add tests
peixinli Dec 26, 2023
61bd40d
add golden file
peixinli Dec 26, 2023
9518814
uncomment runGoldens line
peixinli Dec 26, 2023
de5232c
Fix comments and add more test
peixinli Dec 27, 2023
e3248a6
Fix comments
peixinli Dec 27, 2023
06b3677
test value type
peixinli Dec 27, 2023
d5bcb37
Merge branch 'main' into rfw
peixinli Jan 2, 2024
5f031e1
add rfw widgets
peixinli Dec 13, 2023
ad6f552
add changelog
peixinli Dec 13, 2023
74c6c81
revert format change
peixinli Dec 22, 2023
9d00cea
add tests
peixinli Dec 26, 2023
7f8f5f2
add golden file
peixinli Dec 26, 2023
5976859
uncomment runGoldens line
peixinli Dec 26, 2023
d67a477
Fix comments and add more test
peixinli Dec 27, 2023
456a887
Fix comments
peixinli Dec 27, 2023
2ec30a2
test value type
peixinli Dec 27, 2023
a345557
Merge branch 'flutter:main' into rfw
peixinli Jan 6, 2024
7ac2967
fix comments
peixinli Jan 17, 2024
a23eeb1
Merge branch 'flutter:main' into rfw
peixinli Jan 17, 2024
751aedc
Merge branch 'rfw' of https://github.com/peixinli/packages into rfw
peixinli Jan 17, 2024
a92cfcd
fix comments
peixinli Jan 17, 2024
372e27f
merge main
peixinli Jan 24, 2024
32b8312
add line
peixinli Jan 24, 2024
43352e7
fix golden
peixinli Jan 24, 2024
53a8a5b
fix web
peixinli Jan 24, 2024
1f1db46
fix
peixinli Jan 24, 2024
16d1253
fix
peixinli Jan 24, 2024
e097047
fix
peixinli Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix comments and add more test
  • Loading branch information
peixinli committed Jan 6, 2024
commit d67a477e5da089a3feee685c817e047a32c96dec
1 change: 1 addition & 0 deletions packages/rfw/lib/src/flutter/core_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ Map<String, LocalWidgetBuilder> get _coreWidgetsDefinitions => <String, LocalWid
// not implemented: clipper
return ClipRRect(
borderRadius: ArgumentDecoders.borderRadius(source, ['borderRadius']) ?? BorderRadius.zero,
// clipper,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the convention for skipped parameters in this file is to give the type as well (see line 441)

clipBehavior: ArgumentDecoders.enumValue<Clip>(Clip.values, source, ['clipBehavior']) ?? Clip.antiAlias,
child: source.optionalChild(['child']),
);
Expand Down
25 changes: 14 additions & 11 deletions packages/rfw/lib/src/flutter/material_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ import 'runtime.dart';
/// * The [Scaffold]'s floating action button position and animation features
/// are not supported.
///
/// * [DropdownButton] takes a list of items object with the key of params
/// * [DropdownButton] takes a list of objects representing the [DropdownMenuItem].
/// Each object could contain `onTap`, `value`, `enabled` and `child`. The `child` param is required to
/// there should with the key of params
/// names and value of the param values to represent [DropdownMenuItem].
///
/// In general, the trend will all of these unsupported features is that this
Expand Down Expand Up @@ -193,20 +195,21 @@ Map<String, LocalWidgetBuilder> get _materialWidgetsDefinitions => <String, Loca
},

'DropdownButton': (BuildContext context, DataSource source) {
final length = source.length(['items']);
final dropdownMenuItems = List<DropdownMenuItem<Object>>.generate(
length,
(i) => DropdownMenuItem<Object>(
onTap: source.voidHandler(['items', i, 'onTap']),
value: source.v<String>(['items', i, 'value']),
enabled: source.v<bool>(['items', i, 'enabled']) ?? true,
alignment: ArgumentDecoders.alignment(source, ['items', i, 'alignment']) ?? AlignmentDirectional.centerStart,
child: source.child(['items', i, 'child'])));
final int length = source.length(['items']);
final List<DropdownMenuItem<Object>> dropdownMenuItems = List<DropdownMenuItem<Object>>.generate(
length,
(int index) => DropdownMenuItem<Object>(
onTap: source.voidHandler(['items', index, 'onTap']),
value: source.v<String>(['items', index, 'value']) ?? source.v<int>(['items', index, 'value']) ?? source.v<double>(['items', index, 'value']) ?? source.v<bool>(['items', index, 'value']),
enabled: source.v<bool>(['items', index, 'enabled']) ?? true,
alignment: ArgumentDecoders.alignment(source, ['items', index, 'alignment']) ?? AlignmentDirectional.centerStart,
child: source.child(['items', index, 'child']),
),
);

return DropdownButton<Object>(
items: dropdownMenuItems,
value: source.v<String>(['value']) ?? source.v<int>(['value']) ?? source.v<double>(['value']) ?? source.v<bool>(['value']),
hint: source.optionalChild(['hint']),
disabledHint: source.optionalChild(['disabledHint']),
onChanged: source.handler(<Object>['onChanged'], (HandlerTrigger trigger) => (Object? value) => trigger(<String, Object?>{'value': value})),
onTap: source.voidHandler(['onTap']),
Expand Down
Binary file modified packages/rfw/test/goldens/material_test.drawer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/rfw/test/goldens/material_test.dropdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/rfw/test/goldens/material_test.scaffold.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions packages/rfw/test/material_widgets_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ void main() {
child: Center(
child: DropdownButton(
value: 'foo',
elevation: 14,
dropdownColor: 0xFF9E9E9E,
underline: Container(
height: 2,
color: 0xFF7C4DFF,
),
style: {
color:0xFF7C4DFF,
},
items: [
{
value: 'foo',
Expand All @@ -141,6 +150,7 @@ void main() {
onTap: event 'menu_item' {},
},
],
borderRadius:[{x: 8.0, y: 8.0}, {x: 8.0, y: 8.0}, {x: 8.0, y: 8.0}, {x: 8.0, y: 8.0}],
onChanged: event 'dropdown' {},
),
),
Expand All @@ -162,15 +172,16 @@ void main() {

await tester.tap(find.byType(DropdownButton<Object>));
await tester.pumpAndSettle();
expect(find.text('bar'), findsOneWidget);
await expectLater(
find.byType(MaterialApp),
matchesGoldenFile('goldens/material_test.dropdown.png'),
skip: !runGoldens,
);
// Dismiss dropdown.
await tester.tapAt(Offset.zero);
// Tap on the second item.
await tester.tap(find.text('bar'));
await tester.pumpAndSettle();
expect(eventLog, contains('menu_item {}'));
expect(eventLog, contains('dropdown {value: bar}'));

await tester.tapAt(const Offset(20.0, 20.0));
await tester.pump();
Expand Down