public static void UpdatePlaceholderColor(this SearchView searchView, ISearchBar searchBar, ColorStateList?defaultPlaceholderColor, EditText?editText = null)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();

            if (editText == null)
            {
                return;
            }

            var placeholderTextColor = searchBar.PlaceholderColor;

            if (placeholderTextColor == null)
            {
                editText.SetHintTextColor(defaultPlaceholderColor);
            }
            else
            {
                var androidColor = placeholderTextColor.ToNative();

                if (!editText.HintTextColors.IsOneColor(ColorExtensions.States, androidColor))
                {
                    var acolor = androidColor.ToArgb();
                    editText.SetHintTextColor(new ColorStateList(ColorExtensions.States, new[] { acolor, acolor }));
                }
            }
        }
        public static void UpdateFont(this SearchView searchView, ISearchBar searchBar, IFontManager fontManager, EditText?editText = null)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();

            if (editText == null)
            {
                return;
            }

            editText.UpdateFont(searchBar, fontManager);
        }
Example #3
0
        public async Task SearchViewHasEditTextChild()
        {
            await InvokeOnMainThreadAsync(() =>
            {
                var view = new SearchView(MauiContext.Context);

                var editText = view.GetFirstChildOfType <EditText>();

                Assert.NotNull(editText);
            });
        }
        public static void UpdateVerticalTextAlignment(this SearchView searchView, ISearchBar searchBar, EditText?editText)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();

            if (editText == null)
            {
                return;
            }

            editText.UpdateVerticalAlignment(searchBar.VerticalTextAlignment, TextAlignment.Center.ToVerticalGravityFlags());
        }
        public static void UpdateMaxLength(this SearchView searchView, int maxLength, EditText?editText)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();
            editText?.SetLengthFilter(maxLength);

            var query        = searchView.Query;
            var trimmedQuery = query.TrimToMaxLength(maxLength);

            if (query != trimmedQuery)
            {
                searchView.SetQuery(trimmedQuery, false);
            }
        }
Example #6
0
        public static void UpdateIsEnabled(this SearchView searchView, ISearchBar searchBar, EditText?editText = null)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();

            if (editText == null)
            {
                return;
            }

            if (editText != null)
            {
                editText.Enabled = searchBar.IsEnabled;
            }
        }
        public static void UpdateIsTextPredictionEnabled(this SearchView searchView, ISearchBar searchBar, EditText?editText = null)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();

            if (editText == null)
            {
                return;
            }

            if (searchBar.IsTextPredictionEnabled)
            {
                editText.InputType &= ~InputTypes.TextFlagNoSuggestions;
            }
            else
            {
                editText.InputType |= InputTypes.TextFlagNoSuggestions;
            }
        }
Example #8
0
        public static void UpdatePlaceholderColor(this SearchView searchView, ISearchBar searchBar, ColorStateList?defaultPlaceholderColor, EditText?editText = null)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();

            if (editText == null)
            {
                return;
            }

            var placeholderTextColor = searchBar.PlaceholderColor;

            if (placeholderTextColor == null)
            {
                editText.SetHintTextColor(defaultPlaceholderColor);
            }
            else
            {
                if (PlatformInterop.CreateEditTextColorStateList(editText.HintTextColors, placeholderTextColor.ToPlatform()) is ColorStateList c)
                {
                    editText.SetHintTextColor(c);
                }
            }
        }
Example #9
0
        public static void UpdatePlaceholderColor(this SearchView searchView, ISearchBar searchBar, ColorStateList?defaultPlaceholderColor, EditText?editText = null)
        {
            editText ??= searchView.GetFirstChildOfType <EditText>();

            if (editText == null)
            {
                return;
            }

            var placeholderTextColor = searchBar.PlaceholderColor;

            if (placeholderTextColor == null)
            {
                editText.SetHintTextColor(defaultPlaceholderColor);
            }
            else
            {
                var androidColor = placeholderTextColor.ToPlatform();
                if (!editText.HintTextColors.IsOneColor(ColorStates.EditText, androidColor))
                {
                    editText.SetHintTextColor(ColorStateListExtensions.CreateEditText(androidColor));
                }
            }
        }