-
Notifications
You must be signed in to change notification settings - Fork 69
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
Expect material3.SearchBar
and material3.DockedSearchBar
in common
#801
Conversation
material3.SearchBar
in commonmaterial3.SearchBar
and material3.DockedSearchBar
in common
compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/Example1.kt
Show resolved
Hide resolved
@@ -449,6 +456,14 @@ private fun SearchBarInputField( | |||
.fillMaxWidth() | |||
.focusRequester(focusRequester) | |||
.onFocusChanged { if (it.isFocused) onActiveChange(true) } | |||
.onKeyEvent { | |||
if (it.key == Key.Escape) { |
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.
Better to check whether it's a KEY_PRESSED event; otherwise you could call onActiveChange twice.
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.
otherwise you could call onActiveChange twice
The focus will be cleared after first hit, so it's ok to react to any event from Esc
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.
The focus will be cleared after first hit
It seems that it depends on how onActiveChange implemented by the user?
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.
val density = LocalDensity.current | ||
val windowInfo = LocalWindowInfo.current | ||
return with(density) { | ||
windowInfo.containerSize.height.toDp() | ||
} | ||
} |
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.
Very minor stylistic nit, but maybe better looking without the local variables:
return with(LocalDensity.current) {
LocalWindowInfo.current.containerSize.height.toDp()
}
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.
Well, it was my initial implementation. But I introduced var for better looking 😄
## Proposed Changes Addition to #801 ## Testing Test: Don't change the state in `onActiveChange`, press `Esc` - it was called twice
…r` in common (#801) * Move SearchBar to common * Handle platform specifics * Add search bar sample
## Proposed Changes Addition to #801 ## Testing Test: Don't change the state in `onActiveChange`, press `Esc` - it was called twice
…material3.DockedSearchBar` in common (#801) * Move SearchBar to common * Handle platform specifics * Add search bar sample
#801) * Move SearchBar to common * Handle platform specifics * Add search bar sample
## Proposed Changes Addition to #801 ## Testing Test: Don't change the state in `onActiveChange`, press `Esc` - it was called twice
Proposed Changes
material3.SearchBar
andmaterial3.DockedSearchBar
in commonAPI Changes
Testing
Test: Try to use
SearchBar
/DockedSearchBar
from common or look at mpp demoIssues Fixed
JetBrains/compose-multiplatform#3528