This repository was archived by the owner on Jul 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 610
Expand file tree
/
Copy pathCommitCellView.cs
More file actions
62 lines (52 loc) · 1.97 KB
/
CommitCellView.cs
File metadata and controls
62 lines (52 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using Foundation;
using UIKit;
using CodeHub.Core.Utilities;
using ObjCRuntime;
using Humanizer;
namespace CodeHub.iOS.TableViewCells
{
public partial class CommitCellView : UITableViewCell
{
public static readonly UINib Nib = UINib.FromName("CommitCellView", NSBundle.MainBundle);
public static readonly NSString Key = new NSString("CommitCellView");
private static nfloat DefaultContentConstraintSize = 0.0f;
public CommitCellView()
{
}
public CommitCellView(IntPtr handle)
: base(handle)
{
}
public static CommitCellView Create()
{
var cell = new CommitCellView();
var views = NSBundle.MainBundle.LoadNib("CommitCellView", cell, null);
return Runtime.GetNSObject( views.ValueAt(0) ) as CommitCellView;
}
public override void AwakeFromNib()
{
base.AwakeFromNib();
MainImageView.Layer.MasksToBounds = true;
MainImageView.Layer.CornerRadius = MainImageView.Frame.Height / 2f;
SeparatorInset = new UIEdgeInsets(0, TitleLabel.Frame.Left, 0, 0);
TitleLabel.TextColor = Theme.CurrentTheme.MainTitleColor;
TimeLabel.TextColor = UIColor.Gray;
ContentLabel.TextColor = Theme.CurrentTheme.MainTextColor;
DefaultContentConstraintSize = ContentConstraint.Constant;
}
public void Set(string title, string description, DateTimeOffset time, GitHubAvatar avatar)
{
ContentConstraint.Constant = string.IsNullOrEmpty(description) ? 0f : DefaultContentConstraintSize;
TitleLabel.Text = title;
ContentLabel.Text = description;
TimeLabel.Text = time.Humanize();
MainImageView.SetAvatar(avatar);
}
protected override void Dispose(bool disposing)
{
ReleaseDesignerOutlets();
base.Dispose(disposing);
}
}
}