Skip to content

Instantly share code, notes, and snippets.

@nicwise
Created September 4, 2012 11:07
Show Gist options
  • Save nicwise/3620212 to your computer and use it in GitHub Desktop.
Save nicwise/3620212 to your computer and use it in GitHub Desktop.
public class BTBankTransactionLineElement : StyledStringElement, IElementSizing
{
BankAccountTransaction transaction;
public BTBankTransactionLineElement(BankAccountTransaction transaction) : base("")
{
this.transaction = transaction;
}
float cellHeight = 44f;
public float GetHeight(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
return cellHeight;
}
protected override MonoTouch.Foundation.NSString CellKey
{
get
{
return new NSString("BTBankTransactionLineElement");
}
}
public override UITableViewCell GetCell(UITableView tv)
{
var cell = tv.DequeueReusableCell (CellKey);
UILabel descriptionLabel = null;
UILabel amountLabel = null;
UILabel dateLabel = null;
if (cell == null){
cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
cell.SelectionStyle = UITableViewCellSelectionStyle.None;
amountLabel = new UILabel();
//make it
amountLabel.Tag = 102;
cell.ContentView.AddSubview(amountLabel);
descriptionLabel = new UILabel();
//make it
descriptionLabel.Tag = 101;
cell.ContentView.AddSubview(descriptionLabel);
dateLabel = new UILabel();
//make it
dateLabel.Tag = 103;
cell.ContentView.AddSubview(dateLabel);
} else {
descriptionLabel = cell.ViewWithTag(101) as UILabel;
amountLabel = cell.ViewWithTag(102) as UILabel;
dateLabel = cell.ViewWithTag(103) as UILabel;
}
descriptionLabel.Text = "xxxxxxxxxxx";
amountLabel.Text = "yyyyyyyyyyyyy";
amountLabel.TextColor = (transaction.Amount < 0) ? StockImages.UIRed : StockImages.UIGreen;
dateLabel.Text = DateTime.Now.ToShortDateString();
return cell;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment