コード例 #1
0
        private nfloat CalculateHeight(UITableViewCell cell)
        {
            cell.SetNeedsLayout();
            cell.LayoutIfNeeded();

            var size = cell.ContentView.Frame.Size;

            return(NMath.Ceiling(size.Height) + 1);
        }
コード例 #2
0
            public override void ConfigureCell(UITableViewCell cell, Property property)
            {
                cell.TextLabel.Text       = property.FormattedPrice;
                cell.DetailTextLabel.Text = property.Title;
                cell.Accessory            = UITableViewCellAccessory.DisclosureIndicator;
                cell.ImageView.Frame      = new RectangleF(cell.ImageView.Frame.Location, new SizeF(60, 60));

                DispatchQueue.DefaultGlobalQueue.DispatchAsync(() => {
                    UIImage image = UIImage.LoadFromData(NSData.FromUrl(new NSUrl(property.ThumbnailUrl)));
                    DispatchQueue.MainQueue.DispatchAsync(() => {
                        cell.ImageView.Image = image;
                        cell.SetNeedsLayout();
                    });
                });
            }
コード例 #3
0
        public void Update(UITableView tableView, Cell cell, UITableViewCell nativeCell)
        {
            var parentListView = cell.RealParent as ListView;
            var recycling      = parentListView != null && parentListView.CachingStrategy == ListViewCachingStrategy.RecycleElement;

            if (_cell != cell && recycling)
            {
                if (_cell != null)
                {
                    ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged;
                }

                ((INotifyCollectionChanged)cell.ContextActions).CollectionChanged += OnContextItemsChanged;
            }

            var height = Frame.Height;
            var width  = tableView.Frame.Width;

            nativeCell.Frame = new RectangleF(0, 0, width, height);
            nativeCell.SetNeedsLayout();

            var handler = new PropertyChangedEventHandler(OnMenuItemPropertyChanged);

            _tableView = tableView;
            SetupSelection(tableView);

            if (_cell != null)
            {
                if (!recycling)
                {
                    _cell.PropertyChanged -= OnCellPropertyChanged;
                }
                if (_menuItems.Count > 0)
                {
                    if (!recycling)
                    {
                        ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged;
                    }

                    foreach (var item in _menuItems)
                    {
                        item.PropertyChanged -= handler;
                    }
                }

                _menuItems.Clear();
            }

            _menuItems.AddRange(cell.ContextActions);

            _cell = cell;
            if (!recycling)
            {
                cell.PropertyChanged += OnCellPropertyChanged;
                ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged += OnContextItemsChanged;
            }

            var isOpen = false;

            if (_scroller == null)
            {
                _scroller = new UIScrollView(new RectangleF(0, 0, width, height));
                _scroller.ScrollsToTop = false;
                _scroller.ShowsHorizontalScrollIndicator = false;

                if (Forms.IsiOS8OrNewer)
                {
                    _scroller.PreservesSuperviewLayoutMargins = true;
                }

                ContentView.AddSubview(_scroller);
            }
            else
            {
                _scroller.Frame = new RectangleF(0, 0, width, height);
                isOpen          = ScrollDelegate.IsOpen;

                for (var i = 0; i < _buttons.Count; i++)
                {
                    var b = _buttons[i];
                    b.RemoveFromSuperview();
                    b.Dispose();
                }

                _buttons.Clear();

                ScrollDelegate.Unhook(_scroller);
                ScrollDelegate.Dispose();
            }

            if (ContentCell != nativeCell)
            {
                if (ContentCell != null)
                {
                    ContentCell.RemoveFromSuperview();
                    ContentCell = null;
                }

                ContentCell = nativeCell;

                //Hack: if we have a ImageCell the insets are slightly different,
                //the inset numbers user below were taken using the Reveal app from the default cells
                if ((ContentCell as CellTableViewCell)?.Cell is ImageCell)
                {
                    nfloat imageCellInsetLeft  = 57;
                    nfloat imageCellInsetRight = 0;
                    if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                    {
                        imageCellInsetLeft  = 89;
                        imageCellInsetRight = imageCellInsetLeft / 2;
                    }
                    SeparatorInset = new UIEdgeInsets(0, imageCellInsetLeft, 0, imageCellInsetRight);
                }

                _scroller.AddSubview(nativeCell);
            }

            SetupButtons(width, height);

            UIView container = null;

            var totalWidth = width;

            for (var i = _buttons.Count - 1; i >= 0; i--)
            {
                var b = _buttons[i];
                totalWidth += b.Frame.Width;

                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    _scroller.AddSubview(b);
                }
                else
                {
                    if (container == null)
                    {
                        container = new iOS7ButtonContainer(b.Frame.Width);
                        _scroller.InsertSubview(container, 0);
                    }

                    container.AddSubview(b);
                }
            }

            _scroller.Delegate    = new ContextScrollViewDelegate(container, _buttons, isOpen);
            _scroller.ContentSize = new SizeF(totalWidth, height);

            if (isOpen)
            {
                _scroller.SetContentOffset(new PointF(ScrollDelegate.ButtonsWidth, 0), false);
            }
            else
            {
                _scroller.SetContentOffset(new PointF(0, 0), false);
            }
        }
コード例 #4
0
		public void Update(UITableView tableView, Cell cell, UITableViewCell nativeCell)
		{
			var parentListView = cell.RealParent as ListView;
			var recycling = parentListView != null && parentListView.CachingStrategy == ListViewCachingStrategy.RecycleElement;
			if (_cell != cell && recycling)
			{
				if (_cell != null)
					((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged;

				((INotifyCollectionChanged)cell.ContextActions).CollectionChanged += OnContextItemsChanged;
			}

			var height = Frame.Height;
			var width = tableView.Frame.Width;

			nativeCell.Frame = new RectangleF(0, 0, width, height);
			nativeCell.SetNeedsLayout();

			var handler = new PropertyChangedEventHandler(OnMenuItemPropertyChanged);

			_tableView = tableView;
			SetupSelection(tableView);

			if (_cell != null)
			{
				if (!recycling)
					_cell.PropertyChanged -= OnCellPropertyChanged;
				if (_menuItems.Count > 0)
				{
					if (!recycling)
						((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged;

					foreach (var item in _menuItems)
						item.PropertyChanged -= handler;
				}

				_menuItems.Clear();
			}

			_menuItems.AddRange(cell.ContextActions);

			_cell = cell;
			if (!recycling)
			{
				cell.PropertyChanged += OnCellPropertyChanged;
				((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged += OnContextItemsChanged;
			}

			var isOpen = false;

			if (_scroller == null)
			{
				_scroller = new UIScrollView(new RectangleF(0, 0, width, height));
				_scroller.ScrollsToTop = false;
				_scroller.ShowsHorizontalScrollIndicator = false;

				if (Forms.IsiOS8OrNewer)
					_scroller.PreservesSuperviewLayoutMargins = true;

				ContentView.AddSubview(_scroller);
			}
			else
			{
				_scroller.Frame = new RectangleF(0, 0, width, height);
				isOpen = ScrollDelegate.IsOpen;

				for (var i = 0; i < _buttons.Count; i++)
				{
					var b = _buttons[i];
					b.RemoveFromSuperview();
					b.Dispose();
				}

				_buttons.Clear();

				ScrollDelegate.Unhook(_scroller);
				ScrollDelegate.Dispose();
			}

			if (ContentCell != nativeCell)
			{
				if (ContentCell != null)
				{
					ContentCell.RemoveFromSuperview();
					ContentCell = null;
				}

				ContentCell = nativeCell;

				//Hack: if we have a ImageCell the insets are slightly different,
				//the inset numbers user below were taken using the Reveal app from the default cells
				if ((ContentCell as CellTableViewCell)?.Cell is ImageCell)
				{
					nfloat imageCellInsetLeft = 57;
					nfloat imageCellInsetRight = 0;
					if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
					{
						imageCellInsetLeft = 89;
						imageCellInsetRight = imageCellInsetLeft / 2;
					}
					SeparatorInset = new UIEdgeInsets(0, imageCellInsetLeft, 0, imageCellInsetRight);
				}

				_scroller.AddSubview(nativeCell);
			}

			SetupButtons(width, height);

			UIView container = null;

			var totalWidth = width;
			for (var i = _buttons.Count - 1; i >= 0; i--)
			{
				var b = _buttons[i];
				totalWidth += b.Frame.Width;

				if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
					_scroller.AddSubview(b);
				else
				{
					if (container == null)
					{
						container = new iOS7ButtonContainer(b.Frame.Width);
						_scroller.InsertSubview(container, 0);
					}

					container.AddSubview(b);
				}
			}

			_scroller.Delegate = new ContextScrollViewDelegate(container, _buttons, isOpen);
			_scroller.ContentSize = new SizeF(totalWidth, height);

			if (isOpen)
				_scroller.SetContentOffset(new PointF(ScrollDelegate.ButtonsWidth, 0), false);
			else
				_scroller.SetContentOffset(new PointF(0, 0), false);
		}
コード例 #5
0
        public void Update(UITableView tableView, SwipeCell cell, UITableViewCell nativeCell)
        {
            var recycling = tableView.DequeueReusableCell(ReuseIdentifier) != null ? true : false;

            if (_cell != cell && recycling)
            {
                if (_cell != null)
                {
                    ((INotifyCollectionChanged)_cell.LeftContextActions).CollectionChanged  -= OnContextItemsChanged;
                    ((INotifyCollectionChanged)_cell.RightContextActions).CollectionChanged -= OnContextItemsChanged;
                }

                ((INotifyCollectionChanged)cell.LeftContextActions).CollectionChanged  += OnContextItemsChanged;
                ((INotifyCollectionChanged)cell.RightContextActions).CollectionChanged += OnContextItemsChanged;
            }

            var height = Frame.Height;
            var width  = ContentView.Frame.Width;

            nativeCell.Frame = new RectangleF(0, 0, width, height);
            nativeCell.SetNeedsLayout();


            var handler = new PropertyChangedEventHandler(OnMenuItemPropertyChanged);

            _tableView = tableView;
            SetupSelection(tableView);

            if (_cell != null)
            {
                if (!recycling)
                {
                    _cell.PropertyChanged -= OnCellPropertyChanged;
                }

                if (_leftMenuItems.Count > 0)
                {
                    if (!recycling)
                    {
                        ((INotifyCollectionChanged)_cell.LeftContextActions).CollectionChanged -= OnContextItemsChanged;
                    }

                    foreach (var item in _leftMenuItems)
                    {
                        item.PropertyChanged -= handler;
                    }
                }

                _leftMenuItems.Clear();

                if (_rightMenuItems.Count > 0)
                {
                    if (!recycling)
                    {
                        ((INotifyCollectionChanged)_cell.RightContextActions).CollectionChanged -= OnContextItemsChanged;
                    }

                    foreach (var item in _rightMenuItems)
                    {
                        item.PropertyChanged -= handler;
                    }
                }

                _rightMenuItems.Clear();
            }

            _leftMenuItems.AddRange(cell.LeftContextActions);
            _rightMenuItems.AddRange(cell.RightContextActions);

            _cell = cell;

            if (!recycling)
            {
                cell.PropertyChanged += OnCellPropertyChanged;
                ((INotifyCollectionChanged)_cell.LeftContextActions).CollectionChanged  += OnContextItemsChanged;
                ((INotifyCollectionChanged)_cell.RightContextActions).CollectionChanged += OnContextItemsChanged;
            }

            bool isLeftOpen  = false;
            bool isRightOpen = false;

            if (_scroller == null)
            {
                _scroller = new UIScrollView(new RectangleF(0, 0, width, height));
                _scroller.ScrollsToTop = false;
                _scroller.ShowsHorizontalScrollIndicator  = false;
                _scroller.PreservesSuperviewLayoutMargins = true;

                ContentView.AddSubview(_scroller);
            }
            else
            {
                _scroller.Frame = new RectangleF(0, 0, width, height);
                isLeftOpen      = ScrollDelegate.IsLeftOpen;
                isRightOpen     = ScrollDelegate.IsRightOpen;

                for (var i = 0; i < _rightButtons.Count; i++)
                {
                    var b = _rightButtons[i];
                    b.RemoveFromSuperview();
                    b.Dispose();
                }

                _rightButtons.Clear();

                for (var i = 0; i < _leftButtons.Count; i++)
                {
                    var b = _leftButtons[i];
                    b.RemoveFromSuperview();
                    b.Dispose();
                }

                _leftButtons.Clear();

                ScrollDelegate.Unhook(_scroller);
                ScrollDelegate.Dispose();
            }

            if (ContentCell != nativeCell)
            {
                if (ContentCell != null)
                {
                    ContentCell.RemoveFromSuperview();
                    ContentCell = null;
                }

                ContentCell = nativeCell;

                _scroller.AddSubview(nativeCell);
            }

            SetupButtons(width, height);

            UIView container = null;

            var totalWidth = width;

            nfloat leftTotalWidth = .0f;

            for (var i = _leftButtons.Count - 1; i >= 0; i--)
            {
                var b = _leftButtons[i];
                leftTotalWidth += b.Frame.Width;
                totalWidth     += b.Frame.Width;

                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    _scroller.AddSubview(b);
                }
                else
                {
                    if (container == null)
                    {
                        container = new iOS7ButtonContainer(b.Frame.Width);
                        _scroller.InsertSubview(container, 0);
                    }

                    container.AddSubview(b);
                }
            }

            nfloat rightTotalWidth = .0f;

            for (var i = _rightButtons.Count - 1; i >= 0; i--)
            {
                var b = _rightButtons[i];
                totalWidth      += b.Frame.Width;
                rightTotalWidth += b.Frame.Width;

                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
                {
                    _scroller.AddSubview(b);
                }
                else
                {
                    if (container == null)
                    {
                        container = new iOS7ButtonContainer(b.Frame.Width);
                        _scroller.InsertSubview(container, 0);
                    }

                    container.AddSubview(b);
                }
            }

            _scroller.Delegate = new ContextScrollViewDelegate(container, _rightButtons, _leftButtons, isRightOpen, isLeftOpen);
            //slider area reset
            _scroller.ContentInset = new UIEdgeInsets(0.0f, leftTotalWidth, 0.0f, rightTotalWidth);
            _scroller.ContentSize  = new SizeF(totalWidth, height);

            //TODO : if 문 조건이 정확한지 확인해야함.
            if (isRightOpen)
            {
                _scroller.SetContentOffset(new PointF(ScrollDelegate.RightButtonsWidth, 0), false);
            }
            else if (isLeftOpen)
            {
                _scroller.SetContentOffset(new PointF(-ScrollDelegate.LeftButtonsWidth, 0), false);
            }
            else
            {
                _scroller.SetContentOffset(CGPoint.Empty, false);
            }
        }