|
1 | 1 | import { Font } from "../styling/font"; |
2 | 2 | import { |
3 | 3 | SearchBarBase, Color, colorProperty, backgroundColorProperty, backgroundInternalProperty, fontInternalProperty, |
4 | | - textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty, fontSizeProperty |
| 4 | + textProperty, hintProperty, textFieldHintColorProperty, textFieldBackgroundColorProperty, fontSizeProperty, |
| 5 | + isEnabledProperty, isUserInteractionEnabledProperty |
5 | 6 | } from "./search-bar-common"; |
6 | 7 | import { ad } from "../../utils/utils"; |
7 | 8 |
|
@@ -76,6 +77,33 @@ function initializeNativeClasses(): void { |
76 | 77 | CloseListener = CompatCloseListenerImpl; |
77 | 78 | } |
78 | 79 |
|
| 80 | +function enableSearchView(nativeView: any, value: boolean) { |
| 81 | + nativeView.setEnabled(value); |
| 82 | + |
| 83 | + if (!(nativeView instanceof android.view.ViewGroup)) { |
| 84 | + return; |
| 85 | + } |
| 86 | + |
| 87 | + for (let i = 0; i < nativeView.getChildCount(); i++) { |
| 88 | + let child = nativeView.getChildAt(i); |
| 89 | + enableSearchView(child, value); |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +function enableUserInteractionSearchView(nativeView: any, value: boolean) { |
| 94 | + nativeView.setClickable(value); |
| 95 | + nativeView.setFocusable(value); |
| 96 | + |
| 97 | + if (!(nativeView instanceof android.view.ViewGroup)) { |
| 98 | + return; |
| 99 | + } |
| 100 | + |
| 101 | + for (let i = 0; i < nativeView.getChildCount(); i++) { |
| 102 | + let child = nativeView.getChildAt(i); |
| 103 | + enableUserInteractionSearchView(child, value); |
| 104 | + } |
| 105 | +} |
| 106 | + |
79 | 107 | export class SearchBar extends SearchBarBase { |
80 | 108 | nativeViewProtected: android.support.v7.widget.SearchView; |
81 | 109 | private _searchTextView: android.widget.TextView; |
@@ -122,6 +150,14 @@ export class SearchBar extends SearchBarBase { |
122 | 150 | super.disposeNativeView(); |
123 | 151 | } |
124 | 152 |
|
| 153 | + [isEnabledProperty.setNative](value: boolean) { |
| 154 | + enableSearchView(this.nativeViewProtected, value); |
| 155 | + } |
| 156 | + |
| 157 | + [isUserInteractionEnabledProperty.setNative](value: boolean) { |
| 158 | + enableUserInteractionSearchView(this.nativeViewProtected, value); |
| 159 | + } |
| 160 | + |
125 | 161 | [backgroundColorProperty.getDefault](): number { |
126 | 162 | // TODO: Why do we get DrawingCacheBackgroundColor but set backgroundColor????? |
127 | 163 | const result = this.nativeViewProtected.getDrawingCacheBackgroundColor(); |
|
0 commit comments