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
Added search bar component #69
Conversation
93b72fd
to
d79c600
Compare
72ffa4c
to
3bb984e
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.
👍
|
||
let searchBar = UISearchBar() | ||
|
||
var textDidChange: Optional<(UISearchBar, String) -> Void> = nil |
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.
Do we really need the UISearchBar
there?
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 decided to follow the signature of the delegate method. also it makes it easier to do things like dismiss keyboard when cancel is pressed (for some reason is not a default behaviour) without jumping through the hoops. it can always be ignored if not needed.
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.
fair enough
public init( | ||
placeholder: String? = nil, | ||
keyboardType: UIKeyboardType = .default, | ||
didBeginEditing: Optional<(UISearchBar) -> Void> = nil, |
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.
dito
|
||
extension Component.Search { | ||
public final class StyleSheet: BaseViewStyleSheet<View> { | ||
public struct SearchBar: StyleSheetProtocol { |
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 should be moved to the StyleSheets
framework. And should be extended from ViewStyleSheet
as UISearchBar
is a subclass of UIView
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.
@sergdort done 👍
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.
Some questions regarding closures and stylesheets 👍
@sergdort I've addressed your comments |
super.apply(to: element) | ||
element.setTextInputBackgroundColor(color: backgroundColor ?? .clear, | ||
height: height, | ||
cornerRadius: cornerRadius) |
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.
Why do we need this
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.
Because on UISearchBar
one can only set the background image, not a colour.
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.
Just couple comments left
@sergdort addressed 😉 |
This PR adds a simple component that contains
UISearchBar
.Motivation
Sometimes it might be needed just to display a search bar in the cell without the luggage of
UISearchViewController
which might be hard sometimes to tweak to fit particular UX, and something that requires less customisation thanUITextField
to make it look likeUISearchBar
.Alternatives considered
There is currently
TextInput
component in BentoKit but it kind of serves a different purpose and also requires quite some tweaking and style additions to make it fit this use case. AlsoUISearchBar
is not a subclass ofUITextField
and have some extra features like showing cancel button and search icon out of the box (still could be done withTextInput
but not without more changes to it).UISearchViewController
also does not fit here very well as it requiresnavigationItem
and it can be tricky to make it work with DrawerKit used here (see screenshot)Example