예제 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <Picker> e)
        {
            if (e.OldElement != null)
            {
                ((INotifyCollectionChanged)e.OldElement.Items).CollectionChanged -= RowsCollectionChanged;
            }

            if (e.NewElement != null)
            {
                ((INotifyCollectionChanged)e.NewElement.Items).CollectionChanged += RowsCollectionChanged;
                if (Control == null)
                {
                    var textField = CreateNativeControl();

                    textField.SetAccessibilityDelegate(_pickerAccessibilityDelegate = new EntryAccessibilityDelegate(Element));

                    var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement();
                    _textColorSwitcher = new TextColorSwitcher(textField.TextColors, useLegacyColorManagement);

                    SetNativeControl(textField);

                    _originalHintTextColor = Control.CurrentHintTextColor;
                }

                UpdateFont();
                UpdatePicker();
                UpdateTextColor();
                UpdateCharacterSpacing();
            }

            base.OnElementChanged(e);
        }
예제 #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <SearchBar> e)
        {
            base.OnElementChanged(e);

            SearchView searchView = Control;
            var        isDesigner = Context.IsDesignerContext();

            if (searchView == null)
            {
                searchView = CreateNativeControl();
                searchView.SetIconifiedByDefault(false);
                // set Iconified calls onSearchClicked
                // https://github.com/aosp-mirror/platform_frameworks_base/blob/6d891937a38220b0c712a1927f969e74bea3a0f3/core/java/android/widget/SearchView.java#L674-L680
                // which causes requestFocus. The designer does not support focuses.
                if (!isDesigner)
                {
                    searchView.Iconified = false;
                }
                SetNativeControl(searchView);
                _editText = _editText ?? Control.GetChildrenOfType <EditText>().FirstOrDefault();

                if (_editText != null)
                {
                    var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement();
                    _textColorSwitcher = new TextColorSwitcher(_editText.TextColors, useLegacyColorManagement);
                    _hintColorSwitcher = new TextColorSwitcher(_editText.HintTextColors, useLegacyColorManagement);
                }
            }

            if (!isDesigner)
            {
                ClearFocus(searchView);
            }
            UpdateInputType();
            UpdatePlaceholder();
            UpdateText();
            UpdateEnabled();
            UpdateCancelButtonColor();
            UpdateFont();
            UpdateHorizontalTextAlignment();
            UpdateVerticalTextAlignment();
            UpdateTextColor();
            UpdateCharacterSpacing();
            UpdatePlaceholderColor();
            UpdateMaxLength();

            if (e.OldElement == null)
            {
                searchView.SetOnQueryTextListener(this);
                searchView.SetOnQueryTextFocusChangeListener(this);
            }
        }
 public SearchHandlerAppearanceTracker(IShellSearchView searchView)
 {
     _searchHandler = searchView.SearchHandler;
     _control       = searchView.View;
     _searchHandler.PropertyChanged      += SearchHandlerPropertyChanged;
     _searchHandler.FocusChangeRequested += SearchHandlerFocusChangeRequested;
     _editText          = (_control as ViewGroup).GetChildrenOfType <EditText>().FirstOrDefault();
     _textColorSwitcher = new TextColorSwitcher(_editText.TextColors, false);
     _hintColorSwitcher = new TextColorSwitcher(_editText.HintTextColors, false);
     UpdateSearchBarColors();
     UpdateFont();
     UpdateHorizontalTextAlignment();
     UpdateVerticalTextAlignment();
     UpdateInputType();
 }
예제 #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <Button> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                AButton button = Control;
                if (button == null)
                {
                    button = CreateNativeControl();
                    button.SetOnClickListener(ButtonClickListener.Instance.Value);
                    button.SetOnTouchListener(ButtonTouchListener.Instance.Value);
                    button.Tag = this;
                    SetNativeControl(button);

                    var useLegacyColorManagement = e.NewElement.UseLegacyColorManagement();
                    _textColorSwitcher = new TextColorSwitcher(button.TextColors, useLegacyColorManagement);

                    button.AddOnAttachStateChangeListener(this);
                }
            }

            UpdateAll();
        }
예제 #5
0
 protected override void UpdateTextColor(Color color)
 {
     _textColorSwitcher = _textColorSwitcher ?? new TextColorSwitcher(EditText.TextColors, Element.UseLegacyColorManagement());
     _textColorSwitcher.UpdateTextColor(EditText, color);
 }
예제 #6
0
 protected override void UpdatePlaceholderColor()
 {
     _hintColorSwitcher = _hintColorSwitcher ?? new TextColorSwitcher(EditText.HintTextColors, Element.UseLegacyColorManagement());
     _hintColorSwitcher.UpdateTextColor(EditText, Element.PlaceholderColor, EditText.SetHintTextColor);
 }