Exemplo n.º 1
0
        public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            DashBoardLeftTableItem tableItem = tableItems [indexPath.Row];
            int rowHeight = 0;

            //In here you could customize how you want to get the height for row. Then
            // just return it.
            if (tableItem.HeaderType == HeaderType.Today || tableItem.HeaderType == HeaderType.Upcoming)
            {
                rowHeight = 120;
            }
            else
            {
                rowHeight = 250;
            }
            return(rowHeight);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called by the TableView to get the actual UITableViewCell to render for the particular section and row
        /// Left Table cell
        /// </summary>
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            DashBoardLeftTableItem tableItem     = tableItems [indexPath.Row];
            DashBoardLeftTableItem tableItemNext = null;
            int inspectionCount = 0;

            if (tableItems.Count > indexPath.Row + 1)
            {
                tableItemNext = tableItems [indexPath.Row + 1];
            }

            if (tableItem.HeaderType == HeaderType.Today || tableItem.HeaderType == HeaderType.Upcoming)
            {
                string textToDisplay = string.Empty;
                string arrowImage    = "";
                string CalDate       = DateTime.Today.Date.ToString("MMM dd");;
                if (indexPath.Row == 0)
                {
                    if (todayInspection.Count() > 0)
                    {
                        CalDate = todayInspection.FirstOrDefault().inspectionDateTime.ToString("MMM dd");
                    }
                    textToDisplay   = "Today";
                    inspectionCount = todayInspection.Count();
                    if (tableItemNext != null && (tableItemNext.Heading == null || tableItemNext.Heading.Trim() == ""))
                    {
                        arrowImage = "greendownward";
                    }
                    else
                    {
                        arrowImage = "greenForward";
                    }
                }
                else
                {
                    textToDisplay = "Upcoming";
                    if (upComingInspection.Count() > 0)
                    {
                        CalDate = upComingInspection.FirstOrDefault().inspectionDateTime.ToString("MMM dd");
                    }
                    else
                    {
                        CalDate = "";
                    }
                    inspectionCount = upComingInspection.Count();
                    if (tableItemNext != null && (tableItemNext.Heading == null || tableItemNext.Heading.Trim() == ""))
                    {
                        arrowImage = "blueDownward";
                    }
                    else
                    {
                        arrowImage = "blueForward";
                    }
                }
                var cell = tableView.DequeueReusableCell(SectionCellIdentifier) as DashBoardLHSSectionCell;
                if (cell == null)
                {
                    cell = new DashBoardLHSSectionCell((NSString)SectionCellIdentifier);
                }
                cell.UpdateCell(tableItem.Heading, tableItem.SubHeading, inspectionCount.ToString(), UIImage.FromBundle(arrowImage), CalDate);
                cell.BackgroundColor = UIColor.Clear;
                return(cell);
            }
            else
            {
                var cell = (DashBoardLHSContentCell)tableView.DequeueReusableCell(ContentCellIdentifier);
                if (cell == null)
                {
                    cell = new DashBoardLHSContentCell((NSString)ContentCellIdentifier);
                }
                cell.UpdateCell(tableItems[indexPath.Row].InspectionContent, DashBoardRowSelected, indexPath.Row);
                cell.AccessoryView   = new UIView();
                cell.BackgroundColor = UIColor.Clear;
                return(cell);
            }
        }
Exemplo n.º 3
0
        //Dictionary<int, bool> indexTrack = new Dictionary<int, bool> ();
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            DashBoardLeftTableItem tableItem = tableItems [indexPath.Row];

            if (tableItem.HeaderType == HeaderType.Today || tableItem.HeaderType == HeaderType.Upcoming)
            {
                DashBoardLeftTableItem nextItem = null;
                if (tableItems.Count > indexPath.Row + 1)
                {
                    nextItem = tableItems [indexPath.Row + 1];
                }
                bool isInsert = ((nextItem == null) || ((nextItem != null) && (nextItem.HeaderType == HeaderType.Today || nextItem.HeaderType == HeaderType.Upcoming)));

                bool isDelete = (nextItem != null) && (nextItem.HeaderType != HeaderType.Today && nextItem.HeaderType != HeaderType.Upcoming);

                UITableViewCell cell = tableView.CellAt(indexPath);

                tableView.Editing = true;
                if (isInsert)
                {
                    cell        = (DashBoardLHSSectionCell)tableView.CellAt(indexPath);
                    cell.Hidden = true;
                    if (tableItem.HeaderType == HeaderType.Today)
                    {
                        cell.AccessoryView = new UIImageView(UIImage.FromBundle("greendownward.png"));
                        tableView.SetEditing(false, true);
                        //if we've half-swiped a row
                        WillBeginTableEditing(tableView, indexPath, todayInspection);
                    }
                    else
                    {
                        cell.AccessoryView = new UIImageView(UIImage.FromBundle("blueDownward.png"));
                        tableView.SetEditing(false, true);
                        //if we've half-swiped a row
                        WillBeginTableEditing(tableView, indexPath, upComingInspection);
                    }
                }
                else if (isDelete)
                {
                    //indexTrack.Add (indexPath.Row, true);
                    if (tableItem.HeaderType == HeaderType.Today)
                    {
                        cell.AccessoryView = new UIImageView(UIImage.FromBundle("greenForward.png"));
                        tableView.SetEditing(false, true);
                        DidFinishTableEditing(tableView, indexPath, todayInspection);
                    }
                    else if (tableItem.HeaderType == HeaderType.Upcoming)
                    {
                        cell.AccessoryView = new UIImageView(UIImage.FromBundle("blueForward.png"));
                        tableView.SetEditing(false, true);
                        DidFinishTableEditing(tableView, indexPath, upComingInspection);
                    }
                }
                if (null != DashBoardRowSelected && dashBoardEvenArgs != null)
                {
                    dashBoardEvenArgs.RowType = RowType.Header;
                    DashBoardRowSelected.Invoke(null, dashBoardEvenArgs);
                }
            }
            else
            {
                if (null != DashBoardRowSelected && dashBoardEvenArgs != null)
                {
                    dashBoardEvenArgs.RowType          = RowType.Content;
                    dashBoardEvenArgs.InspectionDetail = tableItem.InspectionContent;
                    DashBoardRowSelected.Invoke(null, dashBoardEvenArgs);
                }
            }
        }