public CommentViewModel(string title, string content, DateTimeOffset created, string avatarUrl)
 {
     Title = title;
     Content = content;
     Created = created.Humanize();
     AvatarUrl = avatarUrl;
 }
Example #2
0
 public CommentElement(string title, string message, DateTimeOffset date, Avatar avatar)
 {
     _title = title;
     _message = message;
     _date = date.Humanize();
     _avatar = avatar;
 }
Example #3
0
 public CommitElement(string name, string description, DateTimeOffset date, Avatar avatar)
 {
     _name = name;
     _description = description;
     _date = date.Humanize();
     _avatar = avatar;
 }
Example #4
0
 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);
 }
 public PullRequestElement(string name, DateTimeOffset time, Avatar avatar, UIImage image = null)
     : base(null)
 {
     _name = name;
     _time = time.Humanize();
     _avatar = avatar;
     _image = image ?? Images.Avatar;
 }
Example #6
0
 public GistItemViewModel(string title, string avatarUrl, string description, DateTimeOffset updatedAt, Action<GistItemViewModel> gotoAction)
 {
     Title = title;
     Description = description;
     UpdatedAt = updatedAt;
     UpdatedString = UpdatedAt.Humanize();
     GoToCommand = ReactiveCommand.Create().WithSubscription(x => gotoAction(this));
     Avatar = new GitHubAvatar(avatarUrl);
 }
Example #7
0
 public CommitElement(string name, string description, DateTimeOffset time, string imageUri = null, UIImage image = null)
     : base(null)
 {
     _name = name;
     _description = description;
     _time = time.Humanize();
     _imageUri = imageUri;
     _image = image ?? Images.Avatar;
 }
 public NameTimeStringElement(string name, string description, DateTimeOffset time, string imageUri = null, UIImage image = null, int lines = 0)
     : base(null)
 {
     _name = name;
     _description = description;
     _time = time.Humanize();
     _imageUri = imageUri;
     _image = image ?? Images.Avatar;
     _lines = (nint)lines;
 }
        public void PrecisionStrategy_DifferentOffsets()
        {
            Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75);

            var inputTime = new DateTimeOffset(2015, 07, 05, 03, 45, 0, new TimeSpan(2, 0, 0));
            var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new TimeSpan(-5, 0, 0));

            const string expectedResult = "6 hours ago";
            var actualResult = inputTime.Humanize(baseTime);

            Assert.Equal(expectedResult, actualResult);
        }
        public void PrecisionStrategy_SameOffset()
        {
            Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75);

            var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero);
            var baseTime = new DateTimeOffset(2015, 07, 04, 05, 0, 0, TimeSpan.Zero);

            const string expectedResult = "tomorrow";
            var actualResult = inputTime.Humanize(baseTime);

            Assert.Equal(expectedResult, actualResult);
        }
        public void DefaultStrategy_SameOffset()
        {
            Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy();

            var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero);
            var baseTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, TimeSpan.Zero);

            const string expectedResult = "an hour from now";
            var actualResult = inputTime.Humanize(baseTime);

            Assert.Equal(expectedResult, actualResult);
        }
        public void DefaultStrategy_DifferentOffsets()
        {
            Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy();

            var inputTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, new TimeSpan(2, 0, 0));
            var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new TimeSpan(1, 0, 0));

            const string expectedResult = "30 minutes ago";
            var actualResult = inputTime.Humanize(baseTime);

            Assert.Equal(expectedResult, actualResult);
        }
Example #13
0
        public NewsFeedElement(string imageUrl, DateTimeOffset time, IEnumerable<TextBlock> headerBlocks, IEnumerable<TextBlock> bodyBlocks, UIImage littleImage, Action tapped, bool multilined)
        {
            Uri.TryCreate(imageUrl, UriKind.Absolute, out _imageUri);
            _time = time.Humanize();
            _actionImage = littleImage;
            _tapped = tapped;
            _multilined = multilined;

            var header = CreateAttributedStringFromBlocks(UIFont.PreferredBody, Theme.CurrentTheme.MainTextColor, headerBlocks);
            _attributedHeader = header.Item1;
            _headerLinks = header.Item2;

            var body = CreateAttributedStringFromBlocks(UIFont.PreferredSubheadline, Theme.CurrentTheme.MainSubtitleColor, bodyBlocks);
            _attributedBody = body.Item1;
            _bodyLinks = body.Item2;
        }
Example #14
0
        public NewsFeedElement(string imageUrl, DateTimeOffset time, IEnumerable<TextBlock> headerBlocks, IEnumerable<TextBlock> bodyBlocks, UIImage littleImage, Action tapped)
            : base(null)
        {
            Uri.TryCreate(imageUrl, UriKind.Absolute, out _imageUri);
            _time = time.Humanize();
            _actionImage = littleImage;
            _tapped = tapped;

            var header = CreateAttributedStringFromBlocks(headerBlocks);
            _attributedHeader = header.Item1;
            _headerLinks = header.Item2;

            var body = CreateAttributedStringFromBlocks(bodyBlocks);
            _attributedBody = body.Item1;
            _bodyLinks = body.Item2;
        }
Example #15
0
        public void Bind(string title, string status, string priority, string assigned, DateTimeOffset lastUpdated, string id, string kind)
        {
            Caption.Text = title;
            Label1.Text = status;
            Label2.Text = priority;
            Label3.Text = assigned;
            Label4.Text = lastUpdated.Humanize();
            Number.Text = "#" + id;
            IssueType.Text = kind;

            /*
            if (model.CommentCount > 0)
            {
                var ms = model.CommentCount.ToString ();
                var ssize = ms.MonoStringLength(CountFont);
                var boxWidth = Math.Min (22 + ssize, 18);
                AddSubview(new CounterView(model.CommentCount) { Frame = new RectangleF(Bounds.Width-30-boxWidth, Bounds.Height / 2 - 8, boxWidth, 16) });
            }
            */
        }
Example #16
0
 public void Set(string title, DateTimeOffset time, GitHubAvatar avatar)
 {
     TitleLabel.Text = title;
     TimeLabel.Text = time.Humanize();
     MainImageView.SetAvatar(avatar);
 }
        public void Nullable_ExpectSame()
        {
            DateTimeOffset? never = new DateTimeOffset(2015, 12, 7, 9, 0, 0, TimeSpan.FromHours(1));

            Assert.Equal(never.Value.Humanize(), never.Humanize());
        }