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 1 commit
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/pages/carousel_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class _CarouselPageState extends State<CarouselPage> {
padding: const EdgeInsets.all(kYaruPagePadding),
children: [
YaruSection(
headline: const Text('Auto scroll: off'),
title: const Text('Auto scroll: off'),
width: 700,
child: YaruCarousel(
children: _getCarouselChildren(),
Expand All @@ -35,7 +35,7 @@ class _CarouselPageState extends State<CarouselPage> {
),
const SizedBox(height: 20),
YaruSection(
headline: const Text('Auto scroll: on'),
title: const Text('Auto scroll: on'),
width: 700,
child: YaruCarousel(
controller: _autoScrollController,
Expand Down
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,
title: 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
42 changes: 15 additions & 27 deletions lib/src/pages/yaru_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ class YaruSection extends StatelessWidget {
/// [Widgets] as children.
const YaruSection({
super.key,
this.headline,
this.title,
required this.child,
this.width,
this.height,
this.headerWidget,
this.padding = const EdgeInsets.all(8.0),
this.titlePadding = const EdgeInsets.all(8.0),
this.margin,
});

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

/// The child widget inside the section.
final Widget child;
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 [title] which defaults to `EdgeInsets.all(8.0)`.
final EdgeInsets titlePadding;

/// 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 (title != null)
Padding(
padding: titlePadding,
child: DefaultTextStyle(
style: Theme.of(context).textTheme.titleLarge!,
child: title!,
),
),
),
child,
],
),
Expand Down