|
1 | 1 | import { Font } from '../styling/font'; |
2 | | -import { SearchBarBase, textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty } from './search-bar-common'; |
| 2 | +import { SearchBarBase, textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty, clearButtonColorProperty } from './search-bar-common'; |
3 | 3 | import { isUserInteractionEnabledProperty, isEnabledProperty } from '../core/view'; |
4 | 4 | import { ad } from '../../utils'; |
5 | 5 | import { Color } from '../../color'; |
@@ -33,6 +33,7 @@ function initializeNativeClasses(): void { |
33 | 33 | constructor(private owner: SearchBar) { |
34 | 34 | super(); |
35 | 35 |
|
| 36 | + // @ts-ignore |
36 | 37 | return global.__native(this); |
37 | 38 | } |
38 | 39 |
|
@@ -70,6 +71,7 @@ function initializeNativeClasses(): void { |
70 | 71 | constructor(private owner: SearchBar) { |
71 | 72 | super(); |
72 | 73 |
|
| 74 | + // @ts-ignore |
73 | 75 | return global.__native(this); |
74 | 76 | } |
75 | 77 |
|
@@ -272,6 +274,25 @@ export class SearchBar extends SearchBarBase { |
272 | 274 | const color = value instanceof Color ? value.android : value; |
273 | 275 | textView.setHintTextColor(color); |
274 | 276 | } |
| 277 | + [clearButtonColorProperty.setNative](value: Color) { |
| 278 | + if (!this.nativeViewProtected || !value) { |
| 279 | + return; |
| 280 | + } |
| 281 | + |
| 282 | + try { |
| 283 | + // The close (clear) button inside the SearchView can be found by its resource ID |
| 284 | + const closeButtonId = this.nativeViewProtected.getContext().getResources().getIdentifier('android:id/search_close_btn', null, null); |
| 285 | + const closeButton = this.nativeViewProtected.findViewById(closeButtonId) as android.widget.ImageView; |
| 286 | + |
| 287 | + const color = value instanceof Color ? value.android : new Color(value).android; |
| 288 | + |
| 289 | + if (closeButton) { |
| 290 | + closeButton.setColorFilter(color); |
| 291 | + } |
| 292 | + } catch (err) { |
| 293 | + console.log('Error setting clear button color:', err); |
| 294 | + } |
| 295 | + } |
275 | 296 |
|
276 | 297 | private _getTextView(): android.widget.TextView { |
277 | 298 | if (!this._searchTextView) { |
|
0 commit comments