Esempio n. 1
0
        protected override EvasObject OnGetContent(Cell cell, string part)
        {
            BaseTypeCell typeCell = (BaseTypeCell)cell;

            if (part == _iconPart && typeCell.Icon != null)
            {
                var image = new NImage(TForms.NativeParent);
                SetUpImage(typeCell, image);
                return(image);
            }
            else if (part == _endPart && typeCell.IsCheckVisible)
            {
                var check = new Check(TForms.NativeParent);
                check.SetAlignment(-1, -1);
                check.SetWeight(1, 1);
                check.IsChecked     = typeCell.IsChecked;
                check.StateChanged += (sender, e) =>
                {
                    typeCell.IsChecked = e.NewState;
                };

                //It is a temporary way to prevent that the check of the Cell gets focus until the UX about views in the Cell for TV is defined.
                if (Device.Idiom == TargetIdiom.TV)
                {
                    check.AllowFocus(false);
                }

                return(check);
            }

            return(null);
        }
Esempio n. 2
0
        protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary <string, EvasObject> realizedView)
        {
            BaseTypeCell typeCell = (BaseTypeCell)cell;

            if (property == BaseTypeCell.IconProperty.PropertyName)
            {
                if (!realizedView.ContainsKey(_iconPart) || typeCell.Icon == null)
                {
                    return(true);
                }

                var image = realizedView[_iconPart] as NImage;
                SetUpImage(typeCell, image);
                return(false);
            }
            else if (property == BaseTypeCell.IsCheckedProperty.PropertyName && realizedView.ContainsKey(_endPart))
            {
                var check = realizedView[_endPart] as Check;
                check.IsChecked = typeCell.IsChecked;
                return(false);
            }
            else if (property == BaseTypeCell.IsCheckVisibleProperty.PropertyName ||
                     property == BaseTypeCell.TextProperty.PropertyName ||
                     property == BaseTypeCell.TextEndProperty.PropertyName ||
                     property == BaseTypeCell.SubProperty.PropertyName)
            {
                return(true);
            }

            return(base.OnCellPropertyChanged(cell, property, realizedView));
        }
Esempio n. 3
0
        protected override Span OnGetText(Cell cell, string part)
        {
            BaseTypeCell typeCell = (BaseTypeCell)cell;

            if (part == _textPart)
            {
                return(new Span()
                {
                    Text = typeCell.Text,
                    FontSize = -1
                });
            }
            else if (part == _textEndPart)
            {
                return(new Span()
                {
                    Text = typeCell.TextEnd,
                    FontSize = -1
                });
            }
            else if (part == _textSubPart)
            {
                return(new Span()
                {
                    Text = typeCell.Sub,
                    FontSize = -1
                });
            }

            return(null);
        }
 void SetUpImage(BaseTypeCell cell, NImage image)
 {
     if (cell.IconHeight > 0 && cell.IconWidth > 0)
     {
         image.MinimumWidth  = cell.IconWidth;
         image.MinimumHeight = cell.IconHeight;
     }
     else
     {
         image.LoadingCompleted += (sender, e) =>
         {
             image.MinimumWidth  = image.ObjectSize.Width;
             image.MinimumHeight = image.ObjectSize.Height;
         };
     }
     image.LoadFromImageSourceAsync(cell.Icon);
 }