Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Updated SearchDelegate to follow custom InputDecorationTheme #55209

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

Merged
merged 25 commits into from
Oct 27, 2020

Conversation

gildaswise
Copy link
Contributor

@gildaswise gildaswise commented Apr 20, 2020

Description

Currently, if you start using InputDecorationTheme in your app, SearchDelegate will follow it and work as intended, but if you're using something like a OutlineInputBorder, it fails to display it properly, and even overwriting appBarTheme with another InputDecorationTheme doesn't help, because the current version of SearchDelegate does not apply it as a Theme widget.

This PR makes it so AppBar is inside a Theme widget that applies the appBarTheme property to the whole tree. It also moves the InputDecorationTheme changes to that property, so the only thing in decoration: is hintText, and every other theming property should be added to appBarTheme or searchFieldDecoration instead of directly there.

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [Handling breaking changes].

  • No, no existing tests failed, so this is not a breaking change.

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Apr 20, 2020
@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@gildaswise gildaswise changed the title Updated SearchDelegate to follow InputDecorationTheme Updated SearchDelegate to follow custom InputDecorationTheme Apr 20, 2020
@HansMuller HansMuller requested a review from darrenaustin April 24, 2020 18:51
@gildaswise
Copy link
Contributor Author

gildaswise commented May 13, 2020

Just a heads-up, this is different from #58970, that one just adds more properties coming from theme.inputDecorationTheme instead of completely using it, as it should be. This one fixes the issue of a changed InputDecoration not working at all with the SearchDelegate, and makes it so we don't have to keep adding properties manually like that.

@hawkinsjb1
Copy link

hawkinsjb1 commented Jul 6, 2020

What's the status of this? The current SearchDelegate implementation seems to cherry-pick specific theme params as opposed to wrapping in a ThemeData like this fix does

@gildaswise
Copy link
Contributor Author

@hawkinsjb1 Still waiting on something too, I believe it's still up-to-date with the latest delegate.

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

@gildaswise, so sorry it has taken me a while to get to this. Thanks for your contribution.

It looks like this has been here long enough to get out of sync with the master branch, so this will need to be updated.

The change itself looks reasonable, but we will also need a test added that verifies that this works so that no one will break this in the future.

If you are no longer interested in working on this, just let us know and we can find someone to take it on. Thx.

@gildaswise
Copy link
Contributor Author

@darrenaustin Starting to work on this again right now, thanks for looking into it!

@gildaswise
Copy link
Contributor Author

gildaswise commented Sep 10, 2020

@darrenaustin Just finished, had to change my approach to this. Before, it was meant to be a PR that fixed custom InputDecorationTheme usage when that's defined way back in MaterialApp's theme property, but that messed things up when you tried to just change something manually, or wanted to only customize a single screen.

I changed it to add the searchFieldDecoration property that should handle all InputDecorationTheme stuff and still manages to apply your default InputDecorationTheme if available.

I had to update two tests that relied on checking TextField's decoration property because since I changed it to only use the Theme version, they started to fail searching for properties that aren't there anymore. So now those tests and the new one check the Widget's ThemeData instead.

@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

Sorry it took a while to get to this. Thanks so much for the contribution. There are several PRs that are attempting to solve various parts of this issue, but yours seems the most robust. I have a few issues though.

First, there are a lot of unrelated style changes here that make it hard to see what the actual fix is that you are proposing. The Flutter framework uses a different style guide from dart. Can you please revert these style changes to make it easier to review your fix?

I have other code specific comments below. Thanks again.

@gildaswise
Copy link
Contributor Author

@gildaswise, thanks again for continuing to work on this PR. Apologies it has taken me a while to review your latest updates. It still looks like a fair amount of changes here that aren't related to just fixing the problem. I have noted them below.

There are also a couple of suggestions I have for the tests.

Otherwise this looks good. We have an internal user that is keen to get this fix, so I would like to expedite getting this merged. If you don't have the time or desire to continue with this, I can take it from here and build a new PR with what we need (giving you credit of course). Just let me know. Thanks again!

Finally removed all unrelated changes, so sorry about that. I checked the file diff and everything should be on point now. Just let me know about the last test comment I made and it should be fine now. Thanks for reviewing and I understand the internal user, haha.

@gildaswise
Copy link
Contributor Author

gildaswise commented Oct 26, 2020

I just fixed the merge conflict, but the two new tests from #67679 are not working. I tried just removing my changes to see if would go fine, but it didn't. It says that AppBar.backgroundColor is null, so it fails on both lines 728 and 753.

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure object was thrown running a test:
  Expected: Color:<Color(0xff212121)>
  Actual: <null>

I also just added a quick print('is appBar.backgroundColor null: ${appBar.backgroundColor}') check before the expect call and: is appBar.backgroundColor null: null was the return. Not really sure what's going on here and would appreciate help, @darrenaustin or @justinmc.

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

Making good progress. Thanks. I still have a few requests below. The tests are breaking due to the removal of some settings on the AppBar. I have pointed them out below as well.

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

Looks good, and the tests are passing. However, I steered you the wrong way on putting those AppBar parameters back. We need to remove them, as you had it right the first time. Really sorry about that.

For the new tests that will break with them missing, we can adjust them to look at the underlying Material widget instead of the AppBar itself. I can't seem to put a comment on the code itself, but in the test code for 'text in search bar contrasts background (light mode)', you can change the appBar color check to:

    final Material appBarBackground = tester.widget<Material>(find.descendant(
      of: find.byType(AppBar),
      matching: find.byType(Material),
    ));
    expect(appBarBackground.color, Colors.white);

And the equivalent for the dark mode test.

Again, thanks for your patience and work here. I think it is really close.

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

Thanks for all the work on this @gildaswise!

@gildaswise
Copy link
Contributor Author

Thanks for reviewing, @darrenaustin! Hope everyone benefits from this asap, too.

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gildaswise
Copy link
Contributor Author

@darrenaustin Let me know what exactly I need to change here, unfortunately the "Details" button on Google testing doesn't really help.

@darrenaustin
Copy link
Contributor

@darrenaustin Let me know what exactly I need to change here, unfortunately the "Details" button on Google testing doesn't really help.

Yeah, it tripped an internal test. Looking at the results I don't think it is related to your change. I am trying to figure out what is going on and will get back to you and hopefully we can land this soon. Thx.

@darrenaustin darrenaustin merged commit 48a9fc1 into flutter:master Oct 27, 2020
@darrenaustin
Copy link
Contributor

It was an unrelated dependency issue with the tests. I marked it as passed on the internal side and just pushed to master. Thanks again for all the time and work on this one.

@gildaswise gildaswise deleted the gildaswise-search-delegate branch October 27, 2020 22:10
@vasilich6107
Copy link
Contributor

vasilich6107 commented Oct 27, 2020

Congrats @gildaswise and @darrenaustin for not giving up and finishing this PR after 6 month!

@juliavi
Copy link

juliavi commented Feb 23, 2021

Still not resolved in the latest version

@intraector
Copy link

Same issue

@justinmc
Copy link
Contributor

justinmc commented Apr 2, 2021

@juliavi @intraector What Flutter version specifically are you seeing this problem on? Can you open a new issue with repro instructions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unable to override theme of SearchDelegate
9 participants