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

Yaru~~Dialog~~TitleBar: add support for leading & trailing widgets #298

Merged
merged 5 commits into from
Oct 17, 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
4 changes: 2 additions & 2 deletions example/lib/example_page_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ final examplePageItems = <PageItem>[
pageBuilder: (_) => const TilePage(),
),
PageItem(
titleBuilder: (context) => const Text('YaruDialogTitle'),
tooltipMessage: 'YaruDialogTitle',
titleBuilder: (context) => const Text('YaruTitleBar'),
tooltipMessage: 'YaruTitleBar',
iconBuilder: (context, selected) => selected
? const Icon(YaruIcons.information_filled)
: const Icon(YaruIcons.information),
Expand Down
24 changes: 9 additions & 15 deletions example/lib/pages/dialog_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,17 @@ class _DialogPageState extends State<DialogPage> {
)
],
titlePadding: EdgeInsets.zero,
title: YaruDialogTitle(
title: Row(
mainAxisSize: MainAxisSize.min,
children: const [
Text('The Title'),
SizedBox(
width: 10,
title: YaruTitleBar(
leading: const Center(
child: SizedBox.square(
dimension: 25,
child: YaruCircularProgressIndicator(
strokeWidth: 3,
),
SizedBox(
height: 25,
child: YaruCircularProgressIndicator(
strokeWidth: 3,
),
)
],
),
),
isCloseable: isCloseable,
title: const Text('The Title'),
trailing: YaruCloseButton(enabled: isCloseable),
),
content: SizedBox(
height: 100,
Expand Down
1 change: 1 addition & 0 deletions lib/src/constants.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const kYaruPagePadding = 20.0;
const kYaruDialogTitleHeight = 72.0;
const kYaruDialogTitlePadding = 0.0;
const kYaruPageWidth = 500.0;
const kYaruContainerRadius = 8.0;
Expand Down
53 changes: 53 additions & 0 deletions lib/src/controls/yaru_title_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';

import '../constants.dart';
import 'yaru_close_button.dart';

/// A [Stack] of a [Widget] as [title] with a close button
/// which pops the top-most route off the navigator
/// that most tightly encloses the given context.
///
class YaruTitleBar extends StatelessWidget {
const YaruTitleBar({
super.key,
this.leading,
this.title,
this.trailing,
this.centerTitle = true,
});

/// The primary title widget.
final Widget? title;

/// A widget to display before the [title] widget.
final Widget? leading;

/// A widget to display after the [title] widget.
final Widget? trailing;

/// Whether the title should be centered.
final bool? centerTitle;

@override
Widget build(BuildContext context) {
return AppBar(
elevation: 0,
leading: leading,
automaticallyImplyLeading: false,
title: title,
centerTitle: centerTitle,
toolbarHeight: kYaruDialogTitleHeight,
backgroundColor: Colors.transparent,
titleTextStyle: Theme.of(context).dialogTheme.titleTextStyle,
actions: [
Padding(
padding: const EdgeInsets.all(5),
child: Align(
alignment: Alignment.topRight,
child: trailing ?? const YaruCloseButton(),
),
),
],
);
}
}
47 changes: 0 additions & 47 deletions lib/src/dialogs/yaru_dialog_title.dart

This file was deleted.

3 changes: 1 addition & 2 deletions lib/yaru_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ export 'src/controls/yaru_icon_button.dart';
export 'src/controls/yaru_option_button.dart';
export 'src/controls/yaru_progress_indicator.dart';
export 'src/controls/yaru_radio_button.dart';
export 'src/controls/yaru_title_bar.dart';
export 'src/controls/yaru_toggle_button.dart';
export 'src/controls/yaru_toggle_button_theme.dart';
// Dialogs
export 'src/dialogs/yaru_dialog_title.dart';
// Extensions
export 'src/extensions/border_radius_extension.dart';
// Layouts
Expand Down