Beispiel #1
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var c = tv.DequeueReusableCell(GistCellView.Key) as GistCellView ?? GistCellView.Create();

            c.Set(_title, _gist.Description, _gist.CreatedAt, new GitHubAvatar(_gist.Owner?.AvatarUrl));
            return(c);
        }
Beispiel #2
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell(GistCellView.Key) as GistCellView ?? GistCellView.Create();

            if (!string.IsNullOrEmpty(_imageUrl))
            {
                Uri uri;
                cell.Image = Uri.TryCreate(_imageUrl, UriKind.Absolute, out uri) ?
                             ImageLoader.DefaultRequestImage(uri, this) : null;
            }
            else
            {
                cell.Image = _image;
            }

            cell.Time    = _time;
            cell.Content = _description;
            cell.Title   = _name;
            return(cell);
        }
Beispiel #3
0
        public override float GetHeightForRow(MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            if (_usedForHeight == null)
            {
                _usedForHeight = (GistCellView)tableView.DequeueReusableCell(GistCellView.Key);
            }

            var item = ItemAt(indexPath) as GistItemViewModel;

            if (item != null)
            {
                _usedForHeight.ViewModel = item;
                _usedForHeight.SetNeedsUpdateConstraints();
                _usedForHeight.UpdateConstraintsIfNeeded();
                _usedForHeight.Bounds = new System.Drawing.RectangleF(0, 0, tableView.Bounds.Width, tableView.Bounds.Height);
                _usedForHeight.SetNeedsLayout();
                _usedForHeight.LayoutIfNeeded();
                return(_usedForHeight.ContentView.SystemLayoutSizeFittingSize(MonoTouch.UIKit.UIView.UILayoutFittingCompressedSize).Height + 1);
            }

            return(base.GetHeightForRow(tableView, indexPath));
        }
Beispiel #4
0
        public float GetHeight(MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            if (GetRootElement() == null)
            {
                return(44f);
            }

            var cell = GetRootElement().GetOffscreenCell(GistCellView.Key, () => GistCellView.Create());

            cell.Time    = _time;
            cell.Content = _description;
            cell.Title   = _name;

            cell.SetNeedsUpdateConstraints();
            cell.UpdateConstraintsIfNeeded();

            cell.Bounds = new RectangleF(0, 0, tableView.Bounds.Width, tableView.Bounds.Height);

            cell.SetNeedsLayout();
            cell.LayoutIfNeeded();

            return(cell.ContentView.SystemLayoutSizeFittingSize(UIView.UILayoutFittingCompressedSize).Height + 1);
        }
Beispiel #5
0
 public GistTableViewSource(UITableView tableView, IReactiveNotifyCollectionChanged <GistItemViewModel> collection)
     : base(tableView, collection, GistCellView.Key, UITableView.AutomaticDimension, 60f)
 {
     _cache = new TableViewCellHeightCache <GistCellView, GistItemViewModel>(60f, () => GistCellView.Create(true));
     tableView.RegisterNibForCellReuse(GistCellView.Nib, GistCellView.Key);
 }