Skip to content

Commit 8bb0dc2

Browse files
committed
chore: cleanup
1 parent d3bdb64 commit 8bb0dc2

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

packages/core/ui/search-bar/index.android.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export class SearchBar extends SearchBarBase {
275275
textView.setHintTextColor(color);
276276
}
277277
[clearButtonColorProperty.setNative](value: Color) {
278-
if (!this.nativeViewProtected) {
278+
if (!this.nativeViewProtected || !value) {
279279
return;
280280
}
281281

@@ -284,8 +284,10 @@ export class SearchBar extends SearchBarBase {
284284
const closeButtonId = this.nativeViewProtected.getContext().getResources().getIdentifier('android:id/search_close_btn', null, null);
285285
const closeButton = this.nativeViewProtected.findViewById(closeButtonId) as android.widget.ImageView;
286286

287-
if (closeButton && value) {
288-
closeButton.setColorFilter(value.android);
287+
const color = value instanceof Color ? value.android : new Color(value).android;
288+
289+
if (closeButton) {
290+
closeButton.setColorFilter(color);
289291
}
290292
} catch (err) {
291293
console.log('Error setting clear button color:', err);

packages/core/ui/search-bar/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ export class SearchBar extends View {
6161
*/
6262
textFieldHintColor: Color;
6363

64+
/**
65+
* Gets or sets the Clear Button color of the SearchBar component.
66+
*
67+
* @nsProperty
68+
*/
69+
clearButtonColor: Color | string;
70+
6471
/**
6572
* Adds a listener for the specified event name.
6673
*

packages/core/ui/search-bar/index.ios.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,11 @@ export class SearchBar extends SearchBarBase {
222222
}
223223
[clearButtonColorProperty.setNative](value: Color | UIColor) {
224224
const textField = this._getTextField();
225+
if (!textField) return;
225226
// Check if clear button is available in the text field
226-
if (textField && textField.valueForKey('clearButton')) {
227-
const button = textField.valueForKey('clearButton');
228-
const color = value instanceof Color ? value.ios : value;
229-
button.tintColor = color;
230-
}
227+
const clearButton = textField.valueForKey('clearButton');
228+
if (!clearButton) return;
229+
230+
clearButton.tintColor = value instanceof Color ? value.ios : value;
231231
}
232232
}

packages/core/ui/search-bar/search-bar-common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export abstract class SearchBarBase extends View implements SearchBarDefinition
1212
public hint: string;
1313
public textFieldBackgroundColor: Color;
1414
public textFieldHintColor: Color;
15+
public clearButtonColor: Color | string;
1516

1617
public abstract dismissSoftInput();
1718
}

0 commit comments

Comments
 (0)