Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YaruRow: rename child properties to match ListTile #233

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class _HomeState extends State<Home> {
),
if (_compactMode)
YaruRow(
trailingWidget: Text('YaruPageItem amount'),
actionWidget: Row(
title: Text('YaruPageItem amount'),
trailing: Row(
children: [
TextButton(
onPressed: () {
Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/section_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class _SectionPageState extends State<SectionPage> {
width: sectionWidth,
children: [
YaruRow(
trailingWidget: Text("Trailing Widget"),
actionWidget: Text("Action Widget"),
description: Text("Description"),
title: Text('Title'),
subtitle: Text('Subtitle'),
trailing: Text('Trailing'),
),
YaruSliderRow(
actionLabel: "YaruSection width",
Expand Down
6 changes: 3 additions & 3 deletions example/lib/widgets/dummy_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class DummySection extends StatelessWidget {
),
children: [
YaruRow(
trailingWidget: Text("Trailing Widget"),
actionWidget: Text("Action Widget"),
description: Text("Description"),
title: Text('Title'),
subtitle: Text('Subtitle'),
trailing: Text('Trailing'),
),
],
width: width,
Expand Down
8 changes: 4 additions & 4 deletions example/lib/widgets/row_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ class RowList extends StatelessWidget {
return ListView.builder(
shrinkWrap: true,
itemBuilder: (context, index) => const YaruRow(
trailingWidget: Text("Trailing Widget"),
actionWidget: Text("Action Widget"),
leadingWidget: Icon(YaruIcons.audio),
description: Text("Description"),
title: Text("Trailing Widget"),
trailing: Text("Action Widget"),
leading: Icon(YaruIcons.audio),
subtitle: Text("Description"),
),
itemCount: 20,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/pages/rows/yaru_extra_option_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ class YaruExtraOptionRow extends StatelessWidget {
return YaruRow(
width: width,
enabled: enabled,
trailingWidget: Text(actionLabel),
description: actionDescription != null ? Text(actionDescription!) : null,
title: Text(actionLabel),
subtitle: actionDescription != null ? Text(actionDescription!) : null,
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment,
textDirection: textDirection,
verticalDirection: verticalDirection,
textBaseline: textBaseline,
actionWidget: Row(
trailing: Row(
children: [
Switch(
value: value ?? false,
Expand Down
47 changes: 22 additions & 25 deletions lib/src/pages/rows/yaru_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ class YaruRow extends StatelessWidget {
///
/// for example:
/// ```dart
/// YaruRow(
/// trailingWidget: Text('trailingWidget'),
/// actionWidget: Text('actionWidget'),
/// description: 'description',
/// );
/// YaruRow(
/// title: Text('title'),
/// subtitle: Text('subtitle'),
/// trailing: Text('trailing'),
/// )
/// ```
const YaruRow({
super.key,
this.leadingWidget,
required this.trailingWidget,
this.description,
required this.actionWidget,
this.leading,
required this.title,
this.subtitle,
this.trailing,
this.enabled = true,
this.width,
this.padding = const EdgeInsets.all(8.0),
Expand All @@ -29,19 +29,19 @@ class YaruRow extends StatelessWidget {
});

/// The [Widget] placed at the leading position.
/// A widget to display before the [trailingWidget].
/// A widget to display before the [title].
///
/// Typically an [Icon] or a [CircleAvatar] widget.
final Widget? leadingWidget;
final Widget? leading;

/// The [Widget] placed at trailing position.
final Widget trailingWidget;
/// The [Widget] placed at title position.
final Widget title;

/// The [Widget] placed below [trailingWidget].
final Widget? description;
/// The [Widget] placed below [title].
final Widget? subtitle;

/// The [Widget] placed after the [trailingWidget].
final Widget actionWidget;
/// The [Widget] placed after the [title].
final Widget? trailing;

/// Whether or not we can interact with the widget
final bool enabled;
Expand Down Expand Up @@ -90,17 +90,14 @@ class YaruRow extends StatelessWidget {
verticalDirection: verticalDirection,
textBaseline: textBaseline,
children: [
if (leadingWidget != null) ...[
leadingWidget!,
const SizedBox(width: 8)
],
if (leading != null) ...[leading!, const SizedBox(width: 8)],
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
trailingWidget,
if (description != null)
title,
if (subtitle != null)
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: DefaultTextStyle(
Expand All @@ -109,13 +106,13 @@ class YaruRow extends StatelessWidget {
: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Theme.of(context).disabledColor,
),
child: description!,
child: subtitle!,
),
),
],
),
),
actionWidget,
if (trailing != null) ...[const SizedBox(width: 8), trailing!],
],
),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/src/pages/rows/yaru_single_info_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class YaruSingleInfoRow extends StatelessWidget {
textDirection: textDirection,
verticalDirection: verticalDirection,
textBaseline: textBaseline,
trailingWidget: Text(infoLabel),
actionWidget: Expanded(
title: Text(infoLabel),
trailing: Expanded(
flex: 2,
child: SelectableText(
infoValue,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/pages/rows/yaru_slider_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ class YaruSliderRow extends StatelessWidget {
return YaruRow(
width: width,
enabled: enabled,
trailingWidget: Text(actionLabel),
description: actionDescription != null ? Text(actionDescription!) : null,
title: Text(actionLabel),
subtitle: actionDescription != null ? Text(actionDescription!) : null,
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment,
textDirection: textDirection,
verticalDirection: verticalDirection,
textBaseline: textBaseline,
actionWidget: Expanded(
trailing: Expanded(
flex: 2,
child: Row(
children: [
Expand Down
6 changes: 3 additions & 3 deletions lib/src/pages/rows/yaru_switch_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ class YaruSwitchRow extends StatelessWidget {
return YaruRow(
width: width,
enabled: enabled,
trailingWidget: trailingWidget,
description: actionDescription != null ? Text(actionDescription!) : null,
title: trailingWidget,
subtitle: actionDescription != null ? Text(actionDescription!) : null,
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment,
textDirection: textDirection,
verticalDirection: verticalDirection,
textBaseline: textBaseline,
actionWidget: Switch(
trailing: Switch(
value: value ?? false,
onChanged: enabled ? onChanged : null,
),
Expand Down
6 changes: 3 additions & 3 deletions lib/src/pages/rows/yaru_toggle_buttons_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ class YaruToggleButtonsRow extends StatelessWidget {
return YaruRow(
width: width,
enabled: enabled,
trailingWidget: Text(actionLabel),
description: actionDescription != null ? Text(actionDescription!) : null,
title: Text(actionLabel),
subtitle: actionDescription != null ? Text(actionDescription!) : null,
mainAxisAlignment: mainAxisAlignment,
mainAxisSize: mainAxisSize,
crossAxisAlignment: crossAxisAlignment,
textDirection: textDirection,
verticalDirection: verticalDirection,
textBaseline: textBaseline,
actionWidget: ToggleButtons(
trailing: ToggleButtons(
constraints: const BoxConstraints(minHeight: 40.0),
isSelected:
selectedValues ?? List.generate(labels.length, (_) => false),
Expand Down
14 changes: 7 additions & 7 deletions test/pages/rows/yaru_row_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ void main() {
theme: ThemeData(primarySwatch: Colors.red),
home: const Scaffold(
body: YaruRow(
leadingWidget: Text('Foo Leading'),
actionWidget: Text('Foo Text'),
trailingWidget: Icon(Icons.add),
description: Text('Foo Description'),
leading: Text('Foo Leading'),
trailing: Text('Foo Text'),
title: Icon(Icons.add),
subtitle: Text('Foo Description'),
),
),
),
Expand All @@ -36,9 +36,9 @@ void main() {
theme: ThemeData(primarySwatch: Colors.red),
home: const Scaffold(
body: YaruRow(
leadingWidget: null,
actionWidget: Text('Foo Text'),
trailingWidget: Icon(Icons.add),
leading: null,
trailing: Text('Foo Text'),
title: Icon(Icons.add),
),
),
),
Expand Down