Unverified Commit aa8cc44e authored by Tirth's avatar Tirth Committed by GitHub

[CupertinoListSection] adds new property separatorColor (#124803)

Adds new property `separatorColor` to `CupertinoListSection` widget.

Fixes: #124744

### `separatorColor` property is null

<img src="https://user-images.githubusercontent.com/13456345/231840875-22605c23-ee9f-464f-a005-c9fce1b641a7.png" width=350>

### `separatorColor` property is not-null

| Color.fromARGB(255, 136, 13, 207) | Color.fromARGB(255, 13, 62, 207) | Color.fromARGB(255, 29, 207, 13) |
| --- | --- | --- |
| ![a](https://user-images.githubusercontent.com/13456345/231840832-6027cf86-e9c0-4206-b6f8-23556471c1bd.png) | ![b](https://user-images.githubusercontent.com/13456345/231840862-dcc30212-14f8-44af-a8cb-d04b22b7a078.png) | ![c](https://user-images.githubusercontent.com/13456345/231840870-d9fafe23-e9a4-423a-a25c-b71835991d07.png) |
parent 5dbab866
......@@ -211,6 +211,7 @@ class CupertinoListSection extends StatelessWidget {
double? additionalDividerMargin,
this.topMargin = _kMarginTop,
bool hasLeading = true,
this.separatorColor,
}) : assert((children != null && children.length > 0) || header != null),
type = CupertinoListSectionType.base,
additionalDividerMargin = additionalDividerMargin ??
......@@ -274,6 +275,7 @@ class CupertinoListSection extends StatelessWidget {
double? additionalDividerMargin,
this.topMargin,
bool hasLeading = true,
this.separatorColor,
}) : assert((children != null && children.length > 0) || header != null),
type = CupertinoListSectionType.insetGrouped,
additionalDividerMargin = additionalDividerMargin ??
......@@ -344,9 +346,15 @@ class CupertinoListSection extends StatelessWidget {
/// matches iOS style by default.
final double? topMargin;
/// Sets the color for the dividers between rows, and borders on top and
/// bottom of the rows.
///
/// If null, defaults to [CupertinoColors.separator].
final Color? separatorColor;
@override
Widget build(BuildContext context) {
final Color dividerColor = CupertinoColors.separator.resolveFrom(context);
final Color dividerColor = separatorColor ?? CupertinoColors.separator.resolveFrom(context);
final double dividerHeight = 1.0 / MediaQuery.devicePixelRatioOf(context);
// Long divider is used for wrapping the top and bottom of rows.
......
......@@ -176,4 +176,50 @@ void main() {
expect(find.byType(ClipRRect), findsNothing);
});
testWidgets('CupertinoListSection respects separatorColor', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: CupertinoListSection(
separatorColor: const Color.fromARGB(255, 143, 193, 51),
children: const <Widget>[
CupertinoListTile(title: Text('CupertinoListTile')),
CupertinoListTile(title: Text('CupertinoListTile')),
],
),
),
),
);
final Column childrenColumn = tester.widget(find.byType(Column).at(1));
for (final Widget e in childrenColumn.children) {
if (e is Container) {
expect(e.color, const Color.fromARGB(255, 143, 193, 51));
}
}
});
testWidgets('CupertinoListSection.separatorColor defaults CupertinoColors.separator', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
child: CupertinoListSection(
children: const <Widget>[
CupertinoListTile(title: Text('CupertinoListTile')),
CupertinoListTile(title: Text('CupertinoListTile')),
],
),
),
),
);
final BuildContext context = tester.element(find.byType(CupertinoListSection));
final Column childrenColumn = tester.widget(find.byType(Column).at(1));
for (final Widget e in childrenColumn.children) {
if (e is Container) {
expect(e.color, CupertinoColors.separator.resolveFrom(context));
}
}
});
}
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