Skip to content

Conversation

@samlythemanly
Copy link

@samlythemanly samlythemanly commented Mar 3, 2019

Description

Currently, the search page widget's hint text and keyboard text input action are hardcoded to the material localization of 'Search' and the search text input action, respectively. This prevents further customization where search functionality is desired, but the nuance of the action isn't exactly "searching" (e.g. adding a location via Google Maps Places API autocomplete).

Added a getHintText function (that takes in a BuildContext) and a textInputAction field to SearchDelegate. These default to the previous hardcoded attributes that were present in SearchPage.

These changes are purely aesthetic changes; no additional functionality is provided.
All tests still pass.

Related Issues

N/A

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.
  • My PR includes tests for all changed/updated/fixed behaviors (See Test Coverage).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

@goderbauer goderbauer added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Mar 4, 2019
@justinmc justinmc self-requested a review May 1, 2019 17:20
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

@somarkoe Thanks for submitting this and sorry for the lack of reviewers. Looks like a simple improvement to make Search a lot more useful, I'm all on board.

Just a discussion below to decide the best way to do this. There was a Linux test failing, but I think it was flaky so I reran it. We'll see.

@mikuhl-dev
Copy link

While you're at it, please do keyboardType: #29983
You don't always search with text.

@justinmc
Copy link
Contributor

justinmc commented May 9, 2019

I agree with the idea to add keyboardType to this as well.

Looks like all tests are passing now. @somarkoe are you still available to get this PR in?

@samlythemanly
Copy link
Author

Yes! Sorry, been swamped by work and haven't touched the project that deals with this in a while. I'll add the keyboard type request to it as well.

@justinmc
Copy link
Contributor

Awesome, thank you @somarkoe. Update the PR when you get a chance and I'll be happy to help you get this in.

@mikuhl-dev
Copy link

@justinmc Perhaps will you be able to get #28165 in too? There's so much about the search page that is hard coded and it shouldn't be.

@justinmc
Copy link
Contributor

Yeah that one looks straightforward to me. The original reviewer @HansMuller isn't around today but I'll talk it through with him when he's back.

@mikuhl-dev
Copy link

Abandoned? :(

@samlythemanly
Copy link
Author

Oops, been a while since I've used git.

Reopened and made the relevant changes. Sorry it took so long!

@mikuhl-dev
Copy link

😍 merge this ish!

@mikuhl-dev
Copy link

Only thing that could be added on is #30388 / #28165 (seems like they are the same 1 line of code)

@justinmc
Copy link
Contributor

@somarkoe Thanks for following up and no worries about the delay!

Sorry to drag this out longer, but I realized that this should update the tests as well. This test should probably say "keyboard shows search button by default" now.

Then, could you add a separate test that tests a different textInputAction? Just duplicate that other test and add textInputAction to the TestHomePage parameters.

After that this is good to go and we can merge.

@justinmc
Copy link
Contributor

@MichaelPriebe I'll try to see if we can get things moving on those 2 other PRs you referenced.

@mikuhl-dev mikuhl-dev mentioned this pull request Jun 11, 2019
9 tasks
@mikuhl-dev
Copy link

@justinmc how's this going?

@justinmc
Copy link
Contributor

justinmc commented Jun 17, 2019

Waiting on @somarkoe for the changes mentioned above. Should be quick changes though.

@mikuhl-dev
Copy link

@somarkoe come thru

@samlythemanly samlythemanly force-pushed the master branch 2 times, most recently from e52b10a to 36bb89a Compare June 22, 2019 22:12
@mikuhl-dev
Copy link

@justinmc What do you think?

…action, and keyboard text input type to be customizable.

[Description]
Currently, the search page widget's hint text and keyboard text input action are hardcoded to the material localization of 'Search' and the search text input action, respectively, and the text input type defaults to that defined in `TextField`. This prevents further customization where search functionality is desired, but the nuance of the action isn't exactly "searching" (e.g. adding a location via Google Maps Places API autocomplete).

[Changes]
Added `hintText`, `textInputAction`, and `keyboardType` fields to `SearchDelegate`. These default to the previous hardcoded attributes that were present in `SearchPage` (or `null`).

[Testing]
Added a new unit test to cover the new `textInputAction` case (and modified the existing one's name to indicate it's the default behavior).

All existing tests still pass, as well.
@samlythemanly
Copy link
Author

I made the fields non-final since apparently overriding fields when a class is extended is no bueno, and this abstract class is one meant to be extended and not implemented (since it has functions with default behaviors).

@mikuhl-dev
Copy link

Excited for this, can finally ditch my very hacky extension of the search delegate.

@mikuhl-dev
Copy link

@justinmc Is it ready now?

@mikuhl-dev
Copy link

Lets get this pull a'mergin'!

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

Sorry for the delay! I talked to @HansMuller to get some tips for the non-final problem.

/// for another [showSearch] call.
abstract class SearchDelegate<T> {

/// The type of action button to use for the keyboard.
Copy link
Contributor

Choose a reason for hiding this comment

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

We could keep the fields final by using a constructor instead like this:

  const SearchDelegate({
    this.keyboardType,
    this.hintText,
    this.textInputAction = TextInputAction.search,
  });

Then below, make all of the fields final and remove the default assignment from textInputAction.

if (textInputAction != null) {
this.textInputAction = textInputAction;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Then with the change in my other comment, you can user super here:

...
}) : super(
  textInputAction: textInputAction,
);

@mikuhl-dev
Copy link

@somarkoe What do you think about the suggestions?

@mikuhl-dev
Copy link

@somarkoe Would love to hear what you think about the suggested changes.

@samlythemanly
Copy link
Author

So sorry! Was on vacation and now I'm moving 😅

Ill take a look ASAP!

@shihaohong
Copy link
Contributor

I'm going to close this since #36409 has been merged. Thank you @somarkoe for your initial work with this!

@shihaohong shihaohong closed this Jul 29, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

6 participants