-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
feat(android): Add shouldClearOnSubmit-prop to search view #1639
Changes from all commits
618fcab
5f2e45a
a125a47
8038c66
7eb2c95
65d25e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -77,6 +77,13 @@ class SearchBarManager : ViewGroupManager<SearchBarView>() { | |||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
@ReactProp(name = "shouldClearOnSubmit") | ||||||||||
fun setShouldClearOnSubmit(view: SearchBarView, shouldClearOnSubmit: Boolean?) { | ||||||||||
if (shouldClearOnSubmit != null) { | ||||||||||
view.shouldClearOnSubmit = shouldClearOnSubmit | ||||||||||
} | ||||||||||
Comment on lines
+82
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change this into
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
@ReactProp(name = "textColor", customType = "Color") | ||||||||||
fun setTextColor(view: SearchBarView, color: Int?) { | ||||||||||
view.textColor = color | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,6 +10,7 @@ import androidx.appcompat.widget.SearchView | |||||
class SearchViewFormatter(var searchView: SearchView) { | ||||||
private var mDefaultTextColor: Int? = null | ||||||
private var mDefaultTintBackground: Drawable? = null | ||||||
private var mDefaultText: String = "" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is default text needed here? I believe |
||||||
|
||||||
private val searchEditText | ||||||
get() = searchView.findViewById<View>(R.id.search_src_text) as? EditText | ||||||
|
@@ -64,4 +65,8 @@ class SearchViewFormatter(var searchView: SearchView) { | |||||
searchEditText?.hint = placeholder | ||||||
} | ||||||
} | ||||||
|
||||||
fun clearText() { | ||||||
searchEditText?.setText(mDefaultText) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the upper comment, let's change this to
Suggested change
|
||||||
} | ||||||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we don't hold the implementation of the Native Stack v5 anymore, I believe this change of the file is unnecessary. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -684,4 +684,11 @@ export interface SearchBarProps { | |
* @default true | ||
*/ | ||
shouldShowHintSearchIcon?: boolean; | ||
/** | ||
* Clear the search input when search button is pressed. | ||
* | ||
* @plaform android | ||
* @default false | ||
*/ | ||
shouldClearOnSubmit?: boolean; | ||
Comment on lines
+687
to
+693
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I said, I'd suggest changing the name of this prop to |
||
} |
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.
I think
clearOnSubmit
would be a better name for the state and property overall.