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

YaruSection: simplify headline & remove headerWidget #381

Merged
merged 2 commits into from
Nov 11, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions example/lib/pages/section_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ class DummySection extends StatelessWidget {
@override
Widget build(BuildContext context) {
return YaruSection(
headline: const Text('Headline'),
headerWidget: const SizedBox(
child: YaruCircularProgressIndicator(strokeWidth: 3),
height: 20,
width: 20,
headline: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: const [
Text('Headline'),
SizedBox(
child: YaruCircularProgressIndicator(strokeWidth: 3),
height: 20,
width: 20,
)
],
),
child: const YaruTile(
title: Text('Title'),
Expand Down
38 changes: 13 additions & 25 deletions lib/src/pages/yaru_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class YaruSection extends StatelessWidget {
required this.child,
this.width,
this.height,
this.headerWidget,
this.padding = const EdgeInsets.all(8.0),
this.headlinePadding = const EdgeInsets.all(8.0),
this.margin,
});

/// Widget that is placed above the list of `children`.
/// Widget that is placed above the `child`.
final Widget? headline;

/// The child widget inside the section.
Expand All @@ -27,16 +27,13 @@ class YaruSection extends StatelessWidget {
/// Specifies the [height] of the section.
final double? height;

/// Aligns the widget horizontally along with headline.
///
/// Both `headline` and `headerWidget` will be aligned horizontally
/// with [mainAxisAlignment] as [MainAxisAlignment.spaceBetween].
final Widget? headerWidget;

/// The padding between the section border and its [child] which defaults to
/// `EdgeInsets.only(all: 8.0)`.
Copy link
Member Author

Choose a reason for hiding this comment

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

only all... oops 🤦‍♂️

/// `EdgeInsets.all(8.0)`.
final EdgeInsets padding;

/// The padding around the [headline] which defaults to `EdgeInsets.all(8.0)`.
final EdgeInsets headlinePadding;

/// An optional margin around the section border.
final EdgeInsets? margin;

Expand All @@ -48,25 +45,16 @@ class YaruSection extends StatelessWidget {
padding: padding,
margin: margin,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.all(headline != null ? 8.0 : 0),
child: Align(
alignment: Alignment.topLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (headline != null)
DefaultTextStyle(
style: Theme.of(context).textTheme.titleLarge!,
textAlign: TextAlign.left,
child: headline!,
),
headerWidget ?? const SizedBox()
],
if (headline != null)
Padding(
padding: headlinePadding,
child: DefaultTextStyle(
style: Theme.of(context).textTheme.titleLarge!,
child: headline!,
),
),
),
child,
],
),
Expand Down