public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell("C") as SWTableViewCell; if (cell == null) { var leftView = new UILabel() { Frame = new RectangleF(0, 0, SWTableViewCell.UtilityButtonsWidthMax, tableView.RowHeight), BackgroundColor = UIColor.Red, Text = "Peekaboo!", TextColor = UIColor.White, TextAlignment = UITextAlignment.Center }; var buttons = new List <UIButton> (); buttons.AddUtilityButton("More", UIColor.LightGray); buttons.AddUtilityButton("Edit", UIColor.Blue); cell = new SWTableViewCell(UITableViewCellStyle.Subtitle, "C", tableView, buttons, leftView); cell.Scrolling += OnScrolling; cell.UtilityButtonPressed += OnButtonPressed; } cell.TextLabel.Text = "Item " + indexPath.Row; cell.DetailTextLabel.Text = "Details " + indexPath.Row; cell.HideSwipedContent(false); //reset cell state cell.SetNeedsDisplay(); return(cell); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { if (UseCustomCells) { string reuseIdentifier = "UMCell"; UMTableViewCell cell = (UMTableViewCell)tableView.DequeueReusableCell(reuseIdentifier); // optionally specify a width that each set of utility buttons will share cell.SetLeftUtilityButtons(LeftButtons(), 32.0f); cell.SetRightUtilityButtons(RightButtons(), 58.0f); cell.Delegate = cellDelegate; cell.Label.Text = string.Format("Section: {0}, Seat: {1}", indexPath.Section, indexPath.Row); return(cell); } else { string cellIdentifier = "Cell"; SWTableViewCell.SWTableViewCell cell = (SWTableViewCell.SWTableViewCell)tableView.DequeueReusableCell(cellIdentifier); if (cell == null) { cell = new SWTableViewCell.SWTableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier); cell.LeftUtilityButtons = LeftButtons(); cell.RightUtilityButtons = RightButtons(); cell.Delegate = cellDelegate; } cell.TextLabel.Text = string.Format("Seat: {0}", testArray [indexPath.Section] [indexPath.Row]); cell.DetailTextLabel.Text = string.Format("Details for seat {1} in section: {0}.", indexPath.Section, indexPath.Row); return(cell); } }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell ("C") as SWTableViewCell; if (cell == null) { var leftView = new UILabel () { Frame = new RectangleF (0, 0, SWTableViewCell.UtilityButtonsWidthMax, tableView.RowHeight), BackgroundColor = UIColor.Red, Text = "Peekaboo!", TextColor = UIColor.White, TextAlignment = UITextAlignment.Center }; var buttons = new List<UIButton> (); buttons.AddUtilityButton ("More", UIColor.LightGray); buttons.AddUtilityButton ("Edit", UIColor.Blue); cell = new SWTableViewCell (UITableViewCellStyle.Subtitle, "C", tableView, buttons, leftView); cell.Scrolling += OnScrolling; cell.UtilityButtonPressed += OnButtonPressed; } cell.TextLabel.Text = "Item " + indexPath.Row; cell.DetailTextLabel.Text = "Details " + indexPath.Row; cell.HideSwipedContent (false);//reset cell state cell.SetNeedsDisplay (); return cell; }
public SWUtilityButtonView(UIButton[] buttons, SWTableViewCell parentCell) { this.utilityButtons = buttons; this.parentCell = parentCell; this.utilityButtonWidth = this.CalculateUtilityButtonWidth(); this.AddSubviews(buttons); }
public override void DidTriggerLeftUtilityButton(SWTableViewCell.SWTableViewCell cell, nint index) { var searchBeerCell = cell as SearchBeerTableViewCell; if (searchBeerCell == null) return; cell.ShowRightUtilityButtons(true); CheckedInAt?.Invoke((int)index); }
public override bool CanSwipeToState(SWTableViewCell.SWTableViewCell cell, SWCellState state) { switch (state) { case SWCellState.Left: // set to false to disable all left utility buttons appearing return(true); case SWCellState.Right: // set to false to disable all right utility buttons appearing return(true); } return(true); }
public override void ScrollingToState(SWTableViewCell.SWTableViewCell cell, SWCellState state) { switch (state) { case SWCellState.Center: Console.WriteLine("utility buttons closed"); break; case SWCellState.Left: Console.WriteLine("left utility buttons open"); break; case SWCellState.Right: Console.WriteLine("right utility buttons open"); break; } }
public override void DidTriggerRightUtilityButton(SWTableViewCell.SWTableViewCell cell, nint index) { Console.WriteLine("Right button {0} was pressed.", index); switch (index) { case 0: Console.WriteLine("More button was pressed"); new UIAlertView("Hello", "More more more", null, "cancel", null).Show(); cell.HideUtilityButtons(true); break; case 1: // Delete button was pressed NSIndexPath cellIndexPath = tableView.IndexPathForCell(cell); testArray[cellIndexPath.Section].RemoveAt(cellIndexPath.Row); tableView.DeleteRows(new[] { cellIndexPath }, UITableViewRowAnimation.Left); break; } }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tableView) { var taskCell = (TaskCell)item; var greenColor = UIColor.FromRGB(43, 182, 115); var done = new UIButton { Frame = new RectangleF(0, 0, (float)tableView.Bounds.Size.Width / 2, (float)tableView.RowHeight), BackgroundColor = UIColor.Gray }; if (taskCell.IsDone) { done.BackgroundColor = greenColor; } else { done.BackgroundColor = UIColor.Gray; } done.SetImage(new UIImage("done.png"), UIControlState.Normal); var buttons = new List <UIButton>(); var box = new UIView { BackgroundColor = taskCell.CategoryColor.ToUIColor(), Frame = new RectangleF(0, 0, 8, (float)tableView.RowHeight) }; var taskName = new UILabel { Font = UIFont.FromName("HelveticaNeue-Light", 14), Frame = new RectangleF(20, 5, (float)tableView.Frame.Width - 100, 20), TextColor = UIColor.DarkGray }; var categoryName = new UILabel { Text = taskCell.CategoryName, Font = UIFont.FromName("HelveticaNeue-Light", 10), Frame = new RectangleF(45, 30, (float)tableView.Frame.Width - 120, 15), TextColor = box.BackgroundColor }; var categoryIcon = new UIImageView { Image = new UIImage(taskCell.CategoryIcon), Frame = new RectangleF(20, 30, 15, 12) }; SetTaskCompleteStatus(taskCell, taskName, categoryName, categoryIcon); tableView.Bounces = false; var mainView = new List <UIView> { box, taskName, categoryIcon, categoryName }; if (taskCell.Date != DateTime.MinValue) { var dueTime = new UILabel { Text = taskCell.Date.ToString("hh:mm tt"), Font = UIFont.FromName("HelveticaNeue-Light", 10), TextAlignment = UITextAlignment.Right, TextColor = UIColor.LightGray, Frame = new RectangleF((float)tableView.Frame.Width - 60, 30, 50, 15) }; mainView.Add(dueTime); } if (taskCell.IsFavorite) { var favorite = new UIImageView { Image = new UIImage("star.png"), Frame = new RectangleF((float)tableView.Frame.Width - 25, 10, 12, 12) }; mainView.Add(favorite); } done.TouchDown += (sender, args) => { taskCell.OnDone.Dispatch(); if (done.BackgroundColor.CGColor == greenColor.CGColor) { SetTaskCompleteStatus(taskCell, taskName, categoryName, categoryIcon); done.BackgroundColor = UIColor.Gray; } else if (done.BackgroundColor == UIColor.Gray) { SetTaskCompleteStatus(taskCell, taskName, categoryName, categoryIcon); done.BackgroundColor = greenColor; } tableView.ReloadData(); }; var OnFavorite = new UIButton(UIButtonType.Custom) { BackgroundColor = UIColor.Gray }; OnFavorite.TouchDown += (sender, args) => { Debug.WriteLine("Favorite hit"); Device.BeginInvokeOnMainThread(() => { Debug.WriteLine("Favorite hit"); taskCell.OnFavorite.Dispatch(); tableView.ReloadData(); }); }; OnFavorite.SetImage(new UIImage("favorite.png"), UIControlState.Normal); var OnEdit = new UIButton(UIButtonType.Custom) { BackgroundColor = UIColor.Gray }; OnEdit.TouchDown += (sender, args) => { Debug.WriteLine("edit hit"); Device.BeginInvokeOnMainThread(() => { Debug.WriteLine("edit hit"); var mainPage = (NavigationPage)Xamarin.Forms.Application.Current.MainPage; var masterDetailPage = (MasterDetailPage)mainPage.CurrentPage; var detailPage = (NavigationPage)masterDetailPage.Detail; var todayPage = (TodayPage)detailPage.CurrentPage; todayPage.ShowPopup(taskCell.Task); tableView.ReloadData(); }); }; OnEdit.SetImage(new UIImage("edit.png"), UIControlState.Normal); var OnDelete = new UIButton(UIButtonType.Custom) { BackgroundColor = UIColor.Gray }; OnDelete.TouchDown += (sender, args) => { Debug.WriteLine("delete hit"); taskCell.OnDelete.Dispatch(); Device.BeginInvokeOnMainThread(() => { var it = TodoApp.Pages.TodayPage.tasksTableView.Root.GetEnumerator(); it.MoveNext(); it.Current.Remove(taskCell); }); }; OnDelete.SetImage(new UIImage("delete.png"), UIControlState.Normal); buttons.Add(OnFavorite); buttons.Add(OnEdit); buttons.Add(OnDelete); var cell = new SWTableViewCell.SWTableViewCell(UITableViewCellStyle.Default, "C", tableView, buttons, done, mainView); return(cell); }
public override void DidTriggerRightUtilityButton(SWTableViewCell.SWTableViewCell cell, nint index) { DeleteBeer(); }
public override void DidTriggerLeftUtilityButton(SWTableViewCell.SWTableViewCell cell, nint index) { var c = cell as SwipeableCocktailCell; switch ((int)index) { case 0: _delete.Execute((Cocktail)c.DataContext); break; case 1: _share.Execute((Cocktail)c.DataContext); break; } }
public override bool ShouldHideUtilityButtonsOnSwipe(SWTableViewCell.SWTableViewCell cell) { // allow just one cell's utility button to be open at once return true; }
public override void DidTriggerLeftUtilityButton(SWTableViewCell.SWTableViewCell cell, nint index) { Console.WriteLine("Left button {0} was pressed.", index); new UIAlertView("Left Utility Buttons", string.Format("Left button {0} was pressed.", index), null, "OK", null).Show(); }
public SWUtilityButtonView(UIButton[] buttons, SWTableViewCell parentCell) { utilityButtons = buttons; this.parentCell = parentCell; utilityButtonWidth = CalculateUtilityButtonWidth(); AddSubviews(buttons); }
public override bool CanSwipeToState(SWTableViewCell.SWTableViewCell cell, SWCellState state) { switch (state) { case SWCellState.Left: // set to false to disable all left utility buttons appearing return true; case SWCellState.Right: // set to false to disable all right utility buttons appearing return true; } return true; }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tableView) { var taskCell = (TaskCell)item; var greenColor = UIColor.FromRGB (43, 182, 115); var done = new UIButton { Frame = new RectangleF(0, 0, (float)tableView.Bounds.Size.Width / 2, (float)tableView.RowHeight), BackgroundColor = UIColor.Gray }; if (taskCell.IsDone) { done.BackgroundColor = greenColor; } else { done.BackgroundColor = UIColor.Gray; } done.SetImage(new UIImage("done.png"), UIControlState.Normal); var buttons = new List<UIButton>(); var box = new UIView { BackgroundColor = taskCell.CategoryColor.ToUIColor(), Frame = new RectangleF(0, 0, 8, (float)tableView.RowHeight) }; var taskName = new UILabel { Font = UIFont.FromName("HelveticaNeue-Light", 14), Frame = new RectangleF(20, 5, (float)tableView.Frame.Width - 100, 20), TextColor = UIColor.DarkGray }; var categoryName = new UILabel { Text = taskCell.CategoryName, Font = UIFont.FromName("HelveticaNeue-Light", 10), Frame = new RectangleF(45, 30, (float)tableView.Frame.Width - 120, 15), TextColor = box.BackgroundColor }; var categoryIcon = new UIImageView { Image = new UIImage(taskCell.CategoryIcon), Frame = new RectangleF(20, 30, 15, 12) }; SetTaskCompleteStatus (taskCell, taskName, categoryName, categoryIcon); tableView.Bounces = false; var mainView = new List<UIView> { box, taskName, categoryIcon, categoryName }; if (taskCell.Date != DateTime.MinValue) { var dueTime = new UILabel { Text = taskCell.Date.ToString("hh:mm tt"), Font = UIFont.FromName("HelveticaNeue-Light", 10), TextAlignment = UITextAlignment.Right, TextColor = UIColor.LightGray, Frame = new RectangleF((float)tableView.Frame.Width - 60, 30, 50, 15) }; mainView.Add(dueTime); } if (taskCell.IsFavorite) { var favorite = new UIImageView { Image = new UIImage("star.png"), Frame = new RectangleF((float)tableView.Frame.Width - 25, 10, 12, 12) }; mainView.Add(favorite); } done.TouchDown += (sender, args) => { taskCell.OnDone.Dispatch(); if(done.BackgroundColor.CGColor == greenColor.CGColor) { SetTaskCompleteStatus (taskCell, taskName, categoryName, categoryIcon); done.BackgroundColor = UIColor.Gray; } else if(done.BackgroundColor == UIColor.Gray) { SetTaskCompleteStatus (taskCell, taskName, categoryName, categoryIcon); done.BackgroundColor = greenColor; } tableView.ReloadData(); }; var OnFavorite = new UIButton(UIButtonType.Custom) { BackgroundColor = UIColor.Gray }; OnFavorite.TouchDown += (sender, args) => { Debug.WriteLine ("Favorite hit"); Device.BeginInvokeOnMainThread(() => { Debug.WriteLine ("Favorite hit"); taskCell.OnFavorite.Dispatch(); tableView.ReloadData(); }); }; OnFavorite.SetImage(new UIImage("favorite.png"), UIControlState.Normal); var OnEdit = new UIButton(UIButtonType.Custom) { BackgroundColor = UIColor.Gray }; OnEdit.TouchDown += (sender, args) => { Debug.WriteLine ("edit hit"); Device.BeginInvokeOnMainThread(() => { Debug.WriteLine ("edit hit"); var mainPage = (NavigationPage) Xamarin.Forms.Application.Current.MainPage; var masterDetailPage = (MasterDetailPage) mainPage.CurrentPage; var detailPage = (NavigationPage) masterDetailPage.Detail; var todayPage = (TodayPage) detailPage.CurrentPage; todayPage.ShowPopup(taskCell.Task); tableView.ReloadData(); }); }; OnEdit.SetImage(new UIImage("edit.png"), UIControlState.Normal); var OnDelete = new UIButton(UIButtonType.Custom) { BackgroundColor = UIColor.Gray }; OnDelete.TouchDown += (sender, args) => { Debug.WriteLine ("delete hit"); taskCell.OnDelete.Dispatch(); Device.BeginInvokeOnMainThread(() => { var it = TodoApp.Pages.TodayPage.tasksTableView.Root.GetEnumerator(); it.MoveNext(); it.Current.Remove(taskCell); }); }; OnDelete.SetImage(new UIImage("delete.png"), UIControlState.Normal); buttons.Add(OnFavorite); buttons.Add(OnEdit); buttons.Add(OnDelete); var cell = new SWTableViewCell.SWTableViewCell(UITableViewCellStyle.Default, "C", tableView, buttons, done, mainView); return cell; }
public SWScrollViewDelegate(SWTableViewCell cell) { this.cell = cell; }
public override bool ShouldHideUtilityButtonsOnSwipe(SWTableViewCell.SWTableViewCell cell) { // allow just one cell's utility button to be open at once return(true); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { if (UseCustomCells) { string reuseIdentifier = "UMCell"; UMTableViewCell cell = (UMTableViewCell)tableView.DequeueReusableCell(reuseIdentifier); // optionally specify a width that each set of utility buttons will share cell.SetLeftUtilityButtons(LeftButtons(), 32.0f); cell.SetRightUtilityButtons(RightButtons(), 58.0f); cell.Delegate = cellDelegate; cell.Label.Text = string.Format("Section: {0}, Seat: {1}", indexPath.Section, indexPath.Row); return cell; } else { string cellIdentifier = "Cell"; SWTableViewCell.SWTableViewCell cell = (SWTableViewCell.SWTableViewCell)tableView.DequeueReusableCell(cellIdentifier); if (cell == null) { cell = new SWTableViewCell.SWTableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier); cell.LeftUtilityButtons = LeftButtons(); cell.RightUtilityButtons = RightButtons(); cell.Delegate = cellDelegate; } cell.TextLabel.Text = string.Format ("Seat: {0}", testArray [indexPath.Section] [indexPath.Row]); cell.DetailTextLabel.Text = string.Format("Details for seat {1} in section: {0}.", indexPath.Section, indexPath.Row); return cell; } }