protected override void Dispose(bool disposing) { if (disposing) { if (_scroller != null) { _scroller.Dispose(); _scroller = null; } _tableView = null; if (_leftMoreButton != null) { _leftMoreButton.Dispose(); _leftMoreButton = null; } if (_rightMoreButton != null) { _rightMoreButton.Dispose(); _rightMoreButton = null; } for (var i = 0; i < _leftButtons.Count; i++) { _leftButtons[i].Dispose(); } _leftButtons.Clear(); _leftMenuItems.Clear(); for (var i = 0; i < _rightButtons.Count; i++) { _rightButtons[i].Dispose(); } _rightButtons.Clear(); _rightMenuItems.Clear(); if (_cell != null) { if (_cell.HasContextActions) { ((INotifyCollectionChanged)_cell.ContextActions).CollectionChanged -= OnContextItemsChanged; } if (_cell.HasLeftContextActions) { ((INotifyCollectionChanged)_cell.LeftContextActions).CollectionChanged -= OnContextItemsChanged; } if (_cell.HasRightContextActions) { ((INotifyCollectionChanged)_cell.RightContextActions).CollectionChanged -= OnContextItemsChanged; } _cell = null; } } base.Dispose(disposing); }
public SwipeiOSCell(SwipeCell swipeCell) : base(UITableViewCellStyle.Default, Key) { this.SwipeCell = swipeCell; }
public SwipeiOSCell(string templateId, SwipeCell swipeCell) : base(UITableViewCellStyle.Default, Key + templateId) { this.SwipeCell = swipeCell; }
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); } }