Skip to content

Commit

Permalink
YaruSection: allow without headline (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Feb 18, 2022
1 parent 98a61b3 commit 4b887ee
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
9 changes: 3 additions & 6 deletions example/lib/pages/section_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ class _SectionPageState extends State<SectionPage> {
Widget build(BuildContext context) {
return YaruPage(
children: [
YaruSection(children: [
YaruSingleInfoRow(infoLabel: 'infoLabel', infoValue: 'infoValue')
]),
DummySection(),
DummySection(width: 300),
YaruSection(
width: sectionWidth,
headline: 'Headline',
headerWidget: SizedBox(
child: CircularProgressIndicator(),
height: 20,
width: 20,
),
children: [
YaruRow(
enabled: true,
Expand Down
60 changes: 30 additions & 30 deletions lib/src/yaru_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ class YaruSection extends StatelessWidget {
/// [Widgets] as children.
const YaruSection({
Key? key,
required this.headline,
this.headline,
required this.children,
this.width,
this.headerWidget,
}) : super(key: key);

/// Text that is placed above the list of `children`.
final String headline;
final String? headline;

/// Creates a vertical list of widgets.
/// All children will be of type [Widget],
Expand All @@ -35,37 +35,37 @@ class YaruSection extends StatelessWidget {
child: SizedBox(
width: width,
child: Container(
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border.all(
color:
Theme.of(context).colorScheme.onSurface.withOpacity(0.15),
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border.all(
color:
Theme.of(context).colorScheme.onSurface.withOpacity(0.15),
),
borderRadius: BorderRadius.circular(6.0),
),
borderRadius: BorderRadius.circular(6.0),
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Align(
alignment: Alignment.topLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
headline,
style: Theme.of(context).textTheme.headline6,
textAlign: TextAlign.left,
),
headerWidget ?? const SizedBox()
],
child: Column(
children: [
Padding(
padding: EdgeInsets.all(headline != null ? 8.0 : 0),
child: Align(
alignment: Alignment.topLeft,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
if (headline != null)
Text(
headline!,
style: Theme.of(context).textTheme.headline6,
textAlign: TextAlign.left,
),
headerWidget ?? const SizedBox()
],
),
),
),
),
Column(children: children)
],
),
)),
Column(children: children)
],
))),
);
}
}

0 comments on commit 4b887ee

Please sign in to comment.