-
Notifications
You must be signed in to change notification settings - Fork 72
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
Use page title text by default as source of the top bar title when top bar title is not provided #28
Use page title text by default as source of the top bar title when top bar title is not provided #28
Conversation
3788c6b
to
430ce84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with comments
import 'package:wolt_modal_sheet/wolt_modal_sheet.dart'; | ||
|
||
void main() { | ||
group('WoltModalSheetTopBarTitle tests', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
final topBarTitle = widget.page.topBarTitle; | ||
final pageTitleText = | ||
(widget.page.pageTitle is Text) ? (widget.page.pageTitle as Text).data : this.pageTitleText; | ||
|
||
if (topBarTitle != null) { | ||
return topBarTitle; | ||
} else if (pageTitleText != null) { | ||
return Row( | ||
children: [ | ||
const SizedBox(width: 72), | ||
Expanded( | ||
child: Text( | ||
pageTitleText, | ||
style: Theme.of(context).textTheme.titleSmall, | ||
textAlign: TextAlign.center, | ||
overflow: TextOverflow.ellipsis, | ||
maxLines: 1, | ||
), | ||
), | ||
const SizedBox(width: 72), | ||
], | ||
); | ||
} | ||
return const SizedBox.shrink(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be fine as an initial implementation but this needs to be improved.
I would recommend adding a TODO here and an issue in the repository to improve this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TahaTesser can you please mention how it can be improved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a custom child layout determine the element before the layout happens. Also, it returns a sized box, this widget should. not render at all if there are no conditions met.
The current look-up is only in the init
, so what happens if the title text widget is removed? Does it update the widget?
Text is inside Expanded
which will render the widget too wide. It should align with the text direction and ability to customize padding. Lower level widget like NavigationToolbar
already has these features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TahaTesser Thanks, in my next PR, I will apply your suggestions. Merging this PR for now.
body: WoltModalSheetTopBarTitle( | ||
page: WoltModalSheetPage.withSingleChild( | ||
child: const SizedBox.shrink(), | ||
topBarTitle: const Text('Top Bar Title'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit move these to constants outside so they can be referenced and easily changed in multiple places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arpadhani this is a test file. I don't think there is a reason to move these to outside.
Description
Addresses issue: #26
In many cases, users of this library forget to provide top bar title assuming that their page will never be scrollable. This PR aims to improve the library's usability by providing a default
topBarTitle
widget using thepageTitle
.The key changes include:
pageTitle
widget will be used as the source of the data for thetopBarTitle
Text widget.The following scrollable page produces the attached video. Note that
topBarTitle
is not provided and the source of the title is the descendent of thepageTitle
:trimmed_title.mov