Skip to content

Commit 40455c0

Browse files
codelessly_api 5.1.0: badge, chip and segmented button nodes (#35)
Port BadgeNode, ChipNode and SegmentedButtonNode from the unmerged migrate-json-serializable branch onto the 5.x conventions: standard json_serializable with the json_defaults_builder omit-defaults step, Equatable props, copyWith, field access, and Material 3 defaults that follow Flutter 3.47's Badge, chip widgets and SegmentedButton. Fields renamed to their Flutter names keep the branch's JSON keys (dotSize, labelStyle, selectedSegments, selectedColor, unselectedColor), so JSON written with the branch still loads. The segment model is ButtonSegmentModel to avoid clashing with Flutter's ButtonSegment. Register the three types with NodeJsonConverter, port the branch's tests and badge fixtures, and add round-trip and branch-JSON tests. Claude-Session: https://claude.ai/code/session_01A67XoQYsLVvoMtiKcXXUxY Co-authored-by: Claude <noreply@anthropic.com>
1 parent 750ae7f commit 40455c0

17 files changed

Lines changed: 4133 additions & 1 deletion

‎CHANGELOG.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
## 5.1.0
2+
3+
### New nodes
4+
5+
- `BadgeNode` (`'badge'`): Material 3 `Badge` as a dot, label or count
6+
(`BadgeType`), optionally anchored to another node through `childID`.
7+
`BadgeProperties` mirrors Flutter's `backgroundColor`, `textColor`,
8+
`textStyle`, `smallSize`, `largeSize`, `padding`, `isLabelVisible` and
9+
`Badge.count`'s `maxCount`, plus `BadgeAlignment` and an `offsetX`/
10+
`offsetY` offset (Flutter's default `Offset(4, -4)`).
11+
- `ChipNode` (`'chip'`): Material 3 `Chip`, `ActionChip`, `ChoiceChip`,
12+
`FilterChip` and `InputChip` (`ChipType`). `ChipProperties` covers the
13+
label and its style, an icon or image avatar, the delete icon and its
14+
color, selection with `showCheckmark`/`checkmarkColor`, colors, border,
15+
corner radius, elevation, paddings (Material 3 defaults: 8 px padding,
16+
8 px horizontal label padding), `tooltip` and `autofocus`. Choice and
17+
filter chips expose a `selected` property variable.
18+
- `SegmentedButtonNode` (`'segmentedButton'`): Material 3
19+
`SegmentedButton<String>` built from `ButtonSegmentModel`s, with
20+
`selected`, `multiSelectionEnabled`, `emptySelectionAllowed`,
21+
`showSelectedIcon`, `selectedIcon`, `direction`, border, foreground and
22+
background colors for both states and a stadium-shaped default corner
23+
radius. The selection is exposed as the `selected` property variable.
24+
- All three are registered with `NodeJsonConverter`.
25+
26+
### JSON
27+
28+
- These nodes first appeared on the unreleased `migrate-json-serializable`
29+
branch. JSON written with it still loads: keys are unchanged where a
30+
field was renamed to its Flutter name (`dotSize` holds
31+
`BadgeProperties.smallSize`, `labelStyle` holds
32+
`BadgeProperties.textStyle`, `selectedSegments` holds
33+
`SegmentedButtonProperties.selected`, `selectedColor`/`unselectedColor`
34+
hold `selectedBackgroundColor`/`backgroundColor`), and field access uses
35+
the same keys.
36+
- As with every other node, fields that equal their defaults are omitted.
37+
138
## 5.0.0
239

340
### Breaking changes

‎lib/src/api/node_json_converter.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class NodeJsonConverter implements JsonConverter<BaseNode?, Map> {
7171
'gridView': GridViewNode.fromJson,
7272
'pageView': PageViewNode.fromJson,
7373
'tabBar': TabBarNode.fromJson,
74+
'badge': BadgeNode.fromJson,
75+
'chip': ChipNode.fromJson,
76+
'segmentedButton': SegmentedButtonNode.fromJson,
7477
'external': ExternalComponentNode.fromJson,
7578
};
7679
}

0 commit comments

Comments
 (0)