public RepositoryInfoController(string username, string repo) : base(typeof(RepositoryDetailedModel)) { Username = username; Repo = repo; Title = repo; _header = new HeaderView(View.Bounds.Width) { Title = repo, ShadowImage = false }; }
public IssueInfoController(string user, string slug, int id) : base(typeof(InternalIssueInfoModel)) { User = user; Slug = slug; Id = id; Title = "Issue #" + id; NavigationItem.RightBarButtonItem = new UIBarButtonItem(NavigationButton.Create(CodeFramework.Images.Buttons.Edit, () => { var m = Model as InternalIssueInfoModel; var editController = new IssueEditController { ExistingIssue = m.Issue, Username = User, RepoSlug = Slug, Title = "Edit Issue", Success = EditingComplete, }; NavigationController.PushViewController(editController, true); })); NavigationItem.RightBarButtonItem.Enabled = false; Style = UITableViewStyle.Grouped; Root.UnevenRows = true; _header = new HeaderView(View.Bounds.Width) { ShadowImage = false }; Root.Add(new Section(_header)); _desc = new MultilinedElement("") { BackgroundColor = UIColor.White }; _desc.CaptionFont = _desc.ValueFont; _desc.CaptionColor = _desc.ValueColor; _split1 = new SplitElement(new SplitElement.Row { Image1 = Images.Buttons.Cog, Image2 = Images.Priority }) { BackgroundColor = UIColor.White }; _split2 = new SplitElement(new SplitElement.Row { Image1 = Images.Buttons.Flag, Image2 = Images.ServerComponents }) { BackgroundColor = UIColor.White }; _split3 = new SplitElement(new SplitElement.Row { Image1 = Images.SitemapColor, Image2 = Images.Milestone }) { BackgroundColor = UIColor.White }; _responsible = new StyledElement("Unassigned", Images.Buttons.Person) { Font = StyledElement.DefaultDetailFont, TextColor = StyledElement.DefaultDetailColor, }; _responsible.Tapped += () => { var m = Model as InternalIssueInfoModel; if (m != null && m.Issue.Responsible != null) NavigationController.PushViewController(new ProfileController(m.Issue.Responsible.Username), true); }; var addComment = new StyledElement("Add Comment", Images.Pencil); addComment.Tapped += AddCommentTapped; _comments = new Section(); _details = new Section { _split1, _split2, _split3, _responsible }; Root.Add(_details); Root.Add(_comments); Root.Add(new Section { addComment }); }
public ChangesetInfoController(string user, string slug, string node) : base(typeof(ChangesetModel), true, false) { Node = node; User = user; Slug = slug; Style = MonoTouch.UIKit.UITableViewStyle.Grouped; Title = "Commit"; Root.UnevenRows = true; _header = new HeaderView(0f) { Title = "Commit: " + node.Substring(0, node.Length > 10 ? 10 : node.Length) }; }
public override void ViewDidLoad() { base.ViewDidLoad(); _header = new HeaderView(View.Bounds.Width) { Title = Username }; Root.Add(new Section(_header)); var followers = new StyledElement("Followers", () => NavigationController.PushViewController(new UserFollowersController(Username), true), Images.Heart); var events = new StyledElement("Events", () => NavigationController.PushViewController(new EventsController(Username), true), Images.Buttons.Event); var groups = new StyledElement("Groups", () => NavigationController.PushViewController(new GroupController(Username), true), Images.Buttons.Group); var repos = new StyledElement("Repositories", () => { NavigationController.PushViewController(new RepositoryController(Username) { Model = Model == null ? null : Model.Repositories }, true); }, Images.Repo); Root.Add(new [] { new Section { followers, events, groups }, new Section { repos } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); _splitButton1 = _split.AddButton("Comments", "-"); _splitButton2 = _split.AddButton("Participants", "-"); Title = "Issue #" + ViewModel.Id; HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = Title; Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.2f))) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Select(_ => ViewModel.Bind(x => x.IsClosed, true).Where(x => x.HasValue).Select(x => x.Value)) .Switch() .Subscribe(x => { HeaderView.SubImageView.TintColor = x ? UIColor.FromRGB(0xbd, 0x2c, 0) : UIColor.FromRGB(0x6c, 0xc6, 0x44); HeaderView.SetSubImage((x ? Octicon.IssueClosed :Octicon.IssueOpened).ToImage()); }); _milestoneElement = new StringElement("Milestone", "No Milestone", UITableViewCellStyle.Value1) { Image = Octicon.Milestone.ToImage() }; _assigneeElement = new StringElement("Assigned", "Unassigned", UITableViewCellStyle.Value1) { Image = Octicon.Person.ToImage() }; _labelsElement = new StringElement("Labels", "None", UITableViewCellStyle.Value1) { Image = Octicon.Tag.ToImage() }; _addCommentElement = new StringElement("Add Comment") { Image = Octicon.Pencil.ToImage() }; var actionButton = new UIBarButtonItem(UIBarButtonSystemItem.Action) { Enabled = false }; NavigationItem.RightBarButtonItem = actionButton; ViewModel.Bind(x => x.IsModifying).SubscribeStatus("Loading..."); ViewModel.Bind(x => x.Issue).Subscribe(x => { _assigneeElement.Value = x.Assignee != null ? x.Assignee.Login : "******"; _milestoneElement.Value = x.Milestone != null ? x.Milestone.Title : "No Milestone"; _labelsElement.Value = x.Labels.Count == 0 ? "None" : string.Join(", ", x.Labels.Select(i => i.Name)); HeaderView.Text = x.Title; HeaderView.SubText = "Updated " + x.UpdatedAt.Humanize(); HeaderView.SetImage(x.User?.AvatarUrl, Images.Avatar); RefreshHeaderView(); Render(); }); ViewModel.Bind(x => x.MarkdownDescription).Subscribe(description => { var model = new MarkdownModel(description, (int)UIFont.PreferredSubheadline.PointSize, true); var markdown = new MarkdownWebView { Model = model }; var html = markdown.GenerateString(); _descriptionElement.SetValue(string.IsNullOrEmpty(description) ? null : html); Render(); }); ViewModel .Bind(x => x.Comments) .Select(_ => Unit.Default) .Merge(ViewModel.Bind(x => x.Events).Select(_ => Unit.Default)) .Subscribe(_ => RenderComments().ToBackground()); ViewModel .Bind(x => x.Participants) .Subscribe(x => _splitButton2.Text = x.HasValue ? x.Value.ToString() : "-"); ViewModel .Bind(x => x.ShouldShowPro) .Where(x => x) .Subscribe(x => this.ShowPrivateView()); OnActivation(d => { d(_milestoneElement.Clicked.BindCommand(ViewModel.GoToMilestoneCommand)); d(_assigneeElement.Clicked.BindCommand(ViewModel.GoToAssigneeCommand)); d(_labelsElement.Clicked.BindCommand(ViewModel.GoToLabelsCommand)); d(_addCommentElement.Clicked.Subscribe(_ => AddCommentTapped())); d(_descriptionElement.UrlRequested.BindCommand(ViewModel.GoToUrlCommand)); d(_commentsElement.UrlRequested.BindCommand(ViewModel.GoToUrlCommand)); d(actionButton.GetClickedObservable().Subscribe(ShowExtraMenu)); d(HeaderView.Clicked.BindCommand(ViewModel.GoToOwner)); d(ViewModel.Bind(x => x.IsCollaborator, true).Subscribe(x => { foreach (var i in new [] { _assigneeElement, _milestoneElement, _labelsElement }) { i.Accessory = x ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; } })); d(ViewModel.Bind(x => x.IsLoading).Subscribe(x => actionButton.Enabled = !x)); }); }
void ReleaseDesignerOutlets() { if (BackButton != null) { BackButton.Dispose(); BackButton = null; } if (ButtomKisitlamaa != null) { ButtomKisitlamaa.Dispose(); ButtomKisitlamaa = null; } if (ChatArkaHazne != null) { ChatArkaHazne.Dispose(); ChatArkaHazne = null; } if (ChatTableView != null) { ChatTableView.Dispose(); ChatTableView = null; } if (FavButton != null) { FavButton.Dispose(); FavButton = null; } if (GonderButton != null) { GonderButton.Dispose(); GonderButton = null; } if (HazirMesajlarScroll != null) { HazirMesajlarScroll.Dispose(); HazirMesajlarScroll = null; } if (HeaderView != null) { HeaderView.Dispose(); HeaderView = null; } if (HediyeButton != null) { HediyeButton.Dispose(); HediyeButton = null; } if (MesajBGVieww != null) { MesajBGVieww.Dispose(); MesajBGVieww = null; } if (MesajText != null) { MesajText.Dispose(); MesajText = null; } if (UserImageView != null) { UserImageView.Dispose(); UserImageView = null; } if (UserNameLabel != null) { UserNameLabel.Dispose(); UserNameLabel = null; } }
public override void ViewDidLoad() { Root.UnevenRows = true; base.ViewDidLoad(); _header = new HeaderView(); _hud = this.CreateHud(); var content = System.IO.File.ReadAllText("WebCell/body.html", System.Text.Encoding.UTF8); _descriptionElement = new WebElement(content, "body", false); _descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; var content2 = System.IO.File.ReadAllText("WebCell/comments.html", System.Text.Encoding.UTF8); _commentsElement = new WebElement(content2, "comments", true); _commentsElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; _milestoneElement = new StyledStringElement("Milestone", "No Milestone", UITableViewCellStyle.Value1) { Image = Images.Milestone }; _milestoneElement.Tapped += () => ViewModel.GoToMilestoneCommand.Execute(null); _assigneeElement = new StyledStringElement("Assigned", "Unassigned".t(), UITableViewCellStyle.Value1) { Image = Images.Person }; _assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null); _labelsElement = new StyledStringElement("Labels", "None", UITableViewCellStyle.Value1) { Image = Images.Tag }; _labelsElement.Tapped += () => ViewModel.GoToLabelsCommand.Execute(null); _addCommentElement = new StyledStringElement("Add Comment") { Image = Images.Pencil }; _addCommentElement.Tapped += AddCommentTapped; _split1 = new SplitElement(new SplitElement.Row { Image1 = Images.Cog, Image2 = Images.Merge }); _split2 = new SplitElement(new SplitElement.Row { Image1 = Images.Person, Image2 = Images.Create }); ViewModel.Bind(x => x.PullRequest, x => { var merged = (x.Merged != null && x.Merged.Value); _split1.Value.Text1 = x.State; _split1.Value.Text2 = merged ? "Merged" : "Not Merged"; _split2.Value.Text1 = x.User.Login; _split2.Value.Text2 = x.CreatedAt.ToString("MM/dd/yy"); _descriptionElement.Value = ViewModel.MarkdownDescription; _header.Title = x.Title; _header.Subtitle = "Updated " + x.UpdatedAt.ToDaysAgo(); Render(); }); NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu()); NavigationItem.RightBarButtonItem.Enabled = false; ViewModel.Bind(x => x.IsLoading, x => { if (!x) { NavigationItem.RightBarButtonItem.Enabled = ViewModel.PullRequest != null; } }); ViewModel.Bind(x => x.IsModifying, x => { if (x) { _hud.Show("Loading..."); } else { _hud.Hide(); } }); ViewModel.Bind(x => x.Issue, x => { _assigneeElement.Value = x.Assignee != null ? x.Assignee.Login : "******".t(); _milestoneElement.Value = x.Milestone != null ? x.Milestone.Title : "No Milestone"; _labelsElement.Value = x.Labels.Count == 0 ? "None" : string.Join(", ", x.Labels.Select(i => i.Name)); Render(); }); ViewModel.GoToLabelsCommand.CanExecuteChanged += (sender, e) => { var before = _labelsElement.Accessory; _labelsElement.Accessory = ViewModel.GoToLabelsCommand.CanExecute(null) ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; if (_labelsElement.Accessory != before && _labelsElement.GetImmediateRootElement() != null) { Root.Reload(_labelsElement, UITableViewRowAnimation.Fade); } }; ViewModel.GoToAssigneeCommand.CanExecuteChanged += (sender, e) => { var before = _assigneeElement.Accessory; _assigneeElement.Accessory = ViewModel.GoToAssigneeCommand.CanExecute(null) ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; if (_assigneeElement.Accessory != before && _assigneeElement.GetImmediateRootElement() != null) { Root.Reload(_assigneeElement, UITableViewRowAnimation.Fade); } }; ViewModel.GoToMilestoneCommand.CanExecuteChanged += (sender, e) => { var before = _milestoneElement.Accessory; _milestoneElement.Accessory = ViewModel.GoToMilestoneCommand.CanExecute(null) ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; if (_milestoneElement.Accessory != before && _milestoneElement.GetImmediateRootElement() != null) { Root.Reload(_milestoneElement, UITableViewRowAnimation.Fade); } }; ViewModel.BindCollection(x => x.Comments, e => RenderComments()); ViewModel.BindCollection(x => x.Events, e => RenderComments()); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = ViewModel.Username; HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = ViewModel.RepositoryName; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f)).Take(1)) .Switch() .Select(_ => ViewModel.Bind(x => x.IsStarred, true).Where(x => x.HasValue)) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HeaderView.SetSubImage(x.Value ? Octicon.Star.ToImage() : null)); var actionButton = NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action) { Enabled = false }; _split = new SplitButtonElement(); _stargazers = _split.AddButton("Stargazers", "-"); _watchers = _split.AddButton("Watchers", "-"); _forks = _split.AddButton("Forks", "-"); OnActivation(d => { d(_stargazers.Clicked.BindCommand(ViewModel.GoToStargazersCommand)); d(_watchers.Clicked.BindCommand(ViewModel.GoToWatchersCommand)); d(_forks.Clicked.BindCommand(ViewModel.GoToForkedCommand)); d(actionButton.GetClickedObservable().Subscribe(_ => ShowExtraMenu())); d(_eventsElement.Clicked.BindCommand(ViewModel.GoToEventsCommand)); d(_ownerElement.Clicked.BindCommand(ViewModel.GoToOwnerCommand)); d(_commitsElement.Clicked.BindCommand(ViewModel.GoToCommitsCommand)); d(_pullRequestsElement.Clicked.BindCommand(ViewModel.GoToPullRequestsCommand)); d(_sourceElement.Clicked.BindCommand(ViewModel.GoToSourceCommand)); d(ViewModel.Bind(x => x.Branches, true).Subscribe(_ => Render())); d(ViewModel.Bind(x => x.Readme, true).Subscribe(_ => Render())); d(_forkElement.Value.Clicked.Select(x => ViewModel.Repository.Parent).BindCommand(ViewModel.GoToForkParentCommand)); d(_issuesElement.Value.Clicked.BindCommand(ViewModel.GoToIssuesCommand)); d(_readmeElement.Value.Clicked.BindCommand(ViewModel.GoToReadmeCommand)); d(_websiteElement.Value.Clicked.Select(x => ViewModel.Repository.Homepage).BindCommand(ViewModel.GoToUrlCommand)); d(HeaderView.Clicked.BindCommand(ViewModel.GoToOwnerCommand)); d(ViewModel.Bind(x => x.Repository, true).Where(x => x != null).Subscribe(x => { if (x.Private && !_featuresService.IsProEnabled) { if (_privateView == null) { _privateView = this.ShowPrivateView(); } actionButton.Enabled = false; } else { actionButton.Enabled = true; _privateView?.Dispose(); } ViewModel.ImageUrl = x.Owner?.AvatarUrl; HeaderView.SubText = Emojis.FindAndReplace(x.Description); HeaderView.SetImage(x.Owner?.AvatarUrl, Images.Avatar); Render(); RefreshHeaderView(); })); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.Image = Images.LoginUserUnknown; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); var headerSection = new Section(); var filesSection = new Section(); var split = new SplitButtonElement(); var files = split.AddButton("Files", "-"); var comments = split.AddButton("Comments", "-"); var forks = split.AddButton("Forks", "-"); headerSection.Add(split); var footerButton = new TableFooterButton("Add Comment"); var commentsSection = new Section(null, footerButton); var commentsElement = new HtmlElement("comments"); commentsSection.Add(commentsElement); var splitRow1 = new SplitViewElement(Octicon.Lock.ToImage(), Octicon.Package.ToImage()); var splitRow2 = new SplitViewElement(Octicon.Pencil.ToImage(), Octicon.Star.ToImage()); var ownerElement = new ButtonElement("Owner", Octicon.Person.ToImage()); var detailsSection = new Section { splitRow1, splitRow2, ownerElement }; Root.Reset(headerSection, detailsSection, filesSection, commentsSection); Appeared.Take(1).Delay(TimeSpan.FromSeconds(0.35f)) .ObserveOn(RxApp.MainThreadScheduler) .Select(_ => this.WhenAnyValue(x => x.ViewModel.IsStarred).Where(x => x.HasValue)) .Switch() .Select(x => x.Value ? Octicon.Star.ToImage() : null) .Subscribe(HeaderView.SetSubImage); ViewModel.Comments.Changed.Subscribe(_ => { var commentModels = ViewModel.Comments .Select(x => { var avatarUrl = x?.User?.AvatarUrl; var avatar = new GitHubAvatar(avatarUrl); return(new Comment(avatar.ToUri(), x.User.Login, x.BodyHtml, x.CreatedAt.UtcDateTime.Humanize())); }).ToList(); if (commentModels.Count > 0) { var model = new CommentModel(commentModels, (int)UIFont.PreferredSubheadline.PointSize); var razorView = new CommentsView { Model = model }; var html = razorView.GenerateString(); commentsElement.Value = html; if (!commentsSection.Contains(commentsElement)) { commentsSection.Insert(0, UITableViewRowAnimation.Fade, commentsElement); } } else { commentsSection.Remove(commentsElement); } }); OnActivation(d => { d(footerButton.Clicked.InvokeCommand(ViewModel.AddCommentCommand)); d(HeaderView.Clicked.InvokeCommand(ViewModel.GoToOwnerCommand)); d(commentsElement.UrlRequested.InvokeCommand(ViewModel.GoToUrlCommand)); d(splitRow2.Button2.Clicked.InvokeCommand(ViewModel.ToggleStarCommand)); d(ownerElement.Clicked.InvokeCommand(ViewModel.GoToOwnerCommand)); d(DialogSource.SelectedObservable.OfType <FileElement>().Select(x => x.File).InvokeCommand(ViewModel.GoToFileSourceCommand)); var updatedGistObservable = ViewModel.WhenAnyValue(x => x.Gist).Where(x => x != null); d(updatedGistObservable.SubscribeSafe(x => RefreshHeaderView(subtext: x.Description))); d(updatedGistObservable.Subscribe(x => filesSection.Reset(x.Files.Select(y => new FileElement(y.Value))))); d(ownerElement.BindValue(updatedGistObservable.Select(x => x.Owner?.Login ?? "Anonymous"))); d(files.BindText(updatedGistObservable.Select(x => x.Files?.Count() ?? 0))); d(forks.BindText(updatedGistObservable.Select(x => x.Forks?.Count() ?? 0))); d(comments.BindText(updatedGistObservable.Select(x => x.Comments.ToString()))); d(splitRow1.Button1.BindText(updatedGistObservable.Select(x => x.Public ? "Public" : "Private"))); d(splitRow1.Button2.BindText(updatedGistObservable.Select(x => "Revisions".ToQuantity(x.History?.Count ?? 0)))); d(this.WhenAnyValue(x => x.ViewModel.Gist.Owner).Select(x => x == null) .Subscribe(x => ownerElement.Hidden = x)); d(this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(64), Images.LoginUserUnknown))); d(this.WhenAnyValue(x => x.ViewModel.ShowMenuCommand) .ToBarButtonItem(UIBarButtonSystemItem.Action, x => NavigationItem.RightBarButtonItem = x)); d(this.WhenAnyValue(x => x.ViewModel.IsStarred) .Where(x => x.HasValue) .Select(x => x.Value ? "Starred!" : "Unstarred") .Subscribe(x => splitRow2.Button2.Text = x)); d(splitRow2.Button1.BindText(this.WhenAnyValue(x => x.ViewModel.Gist).Select(x => { var delta = DateTimeOffset.UtcNow.UtcDateTime - x.UpdatedAt.UtcDateTime; return((delta.Days <= 0) ? "Created Today" : string.Format("{0} Days Old", delta.Days)); }))); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Gist"; var editButton = NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action); HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = "Gist #" + ViewModel.Id; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f)).Take(1)) .Switch() .Select(_ => ViewModel.Bind(x => x.IsStarred, true)) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HeaderView.SetSubImage(x ? Octicon.Star.ToImage() : null)); TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 44f; _split = new SplitButtonElement(); var files = _split.AddButton("Files", "-"); var comments = _split.AddButton("Comments", "-"); var forks = _split.AddButton("Forks", "-"); _splitRow1 = new SplitViewElement(Octicon.Lock.ToImage(), Octicon.Package.ToImage()); _splitRow2 = new SplitViewElement(Octicon.Calendar.ToImage(), Octicon.Star.ToImage()); _ownerElement = new StringElement("Owner", string.Empty, UITableViewCellStyle.Value1) { Image = Octicon.Person.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; OnActivation(d => { d(editButton.GetClickedObservable().Subscribe(ShareButtonTap)); d(_ownerElement.Clicked.BindCommand(ViewModel.GoToUserCommand)); d(ViewModel.Bind(x => x.IsStarred, true).Subscribe(isStarred => _splitRow2.Button2.Text = isStarred ? "Starred" : "Not Starred")); d(ViewModel.BindCollection(x => x.Comments, true).Subscribe(_ => RenderGist())); d(HeaderView.Clicked.BindCommand(ViewModel.GoToUserCommand)); d(ViewModel.Bind(x => x.Gist, true).Where(x => x != null).Subscribe(gist => { var daysOld = gist.CreatedAt.TotalDaysAgo(); _splitRow1.Button1.Text = gist.Public ? "Public" : "Private"; _splitRow1.Button2.Text = (gist.History?.Count ?? 0) + " Revisions"; _splitRow2.Button1.Text = daysOld == 0 ? "Created today" : "day".ToQuantity(daysOld) + " old"; _ownerElement.Value = gist.Owner?.Login ?? "Unknown"; files.Text = gist.Files?.Count.ToString() ?? "-"; comments.Text = gist.Comments.ToString(); forks.Text = gist.Forks?.Count.ToString() ?? "-"; HeaderView.SubText = gist.Description; HeaderView.Text = gist.Files?.Select(x => x.Key).FirstOrDefault() ?? HeaderView.Text; HeaderView.SetImage(gist.Owner?.AvatarUrl, Images.Avatar); RenderGist(); RefreshHeaderView(); })); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var split = new SplitButtonElement(); var commentCount = split.AddButton("Comments", "-"); var participants = split.AddButton("Participants", "-"); var approvals = split.AddButton("Approvals", "-"); this.WhenAnyValue(x => x.ViewModel.Title) .Subscribe(x => RefreshHeaderView(x)); ViewModel.WhenAnyValue(x => x.PullRequest).Subscribe(x => { if (x != null) { var avatarUrl = x?.Author?.Links?.Avatar?.Href; HeaderView.SubText = "Updated " + ViewModel.PullRequest.UpdatedOn.Humanize(); HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar); } else { HeaderView.SetImage(null, Images.Avatar); HeaderView.SubText = null; } }); var root = new List <Section>(); root.Add(new Section { split }); var secDetails = new Section(); root.Add(secDetails); this.WhenAnyValue(x => x.ViewModel.Description) .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => new DescriptionModel(x, (int)UIFont.PreferredSubheadline.PointSize, true)) .Select(x => new MarkdownView { Model = x }.GenerateString()) .Subscribe(content => { _descriptionElement.SetValue(content); secDetails.Insert(0, UITableViewRowAnimation.None, _descriptionElement); }); var split1 = new SplitViewElement(AtlassianIcon.Calendar.ToImage(), AtlassianIcon.Devtoolsbranch.ToImage()); secDetails.Add(split1); this.WhenAnyValue(x => x.ViewModel.PullRequest.State) .Select(x => x?.ToLower().Humanize(LetterCasing.Title)) .Subscribe(x => split1.Button2.Text = x ?? "Open"); this.WhenAnyValue(x => x.ViewModel.PullRequest) .Select(x => x?.CreatedOn.ToString("MM/dd/yy")) .Subscribe(x => split1.Button1.Text = x); var commitsElement = new ButtonElement("Commits", AtlassianIcon.Devtoolscommit.ToImage()); commitsElement.Clicked.SelectUnit().BindCommand(ViewModel.GoToCommitsCommand); secDetails.Add(commitsElement); var mergeElement = new ButtonElement("Merge", AtlassianIcon.ListAdd.ToImage()); mergeElement.Accessory = UITableViewCellAccessory.None; var rejectElement = new LoaderButtonElement("Reject", AtlassianIcon.ListRemove.ToImage()); rejectElement.Accessory = UITableViewCellAccessory.None; rejectElement.BindLoader(ViewModel.RejectCommand); var mergeSection = new Section { mergeElement, rejectElement }; var approvalSection = new Section("Approvals"); var approveElement = new LoaderButtonElement("Approve", AtlassianIcon.Approve.ToImage()); approveElement.Accessory = UITableViewCellAccessory.None; approveElement.BindLoader(ViewModel.ToggleApproveButton); approveElement.BindCaption(this.WhenAnyValue(x => x.ViewModel.Approved).Select(x => x ? "Unapprove" : "Approve")); root.Add(approvalSection); this.WhenAnyValue(x => x.ViewModel.Approvals) .Select(x => x.Select(y => new UserElement(y)).OfType <Element>()) .Subscribe(x => approvalSection.Reset(x.Concat(new[] { approveElement }))); var commentsSection = new Section("Comments"); root.Add(commentsSection); var addComment = new ButtonElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; commentsSection.Reset(new[] { addComment }); ViewModel .Comments .ChangedObservable() .Subscribe(x => { if (x.Count > 0) { var comments = x.Select(y => new Comment(y.Avatar.ToUrl(), y.Name, y.Content, y.CreatedOn)).ToList(); var commentModel = new CommentModel(comments, (int)UIFont.PreferredSubheadline.PointSize); var content = new CommentsView { Model = commentModel }.GenerateString(); _commentsElement.SetValue(content); commentsSection.Insert(0, UITableViewRowAnimation.None, _commentsElement); } else { commentsSection.Remove(_commentsElement); } }); Root.Reset(root); this.WhenAnyValue(x => x.ViewModel.IsOpen).Subscribe(x => { if (x) { Root.Insert(root.IndexOf(secDetails) + 1, mergeSection); } else { Root.Remove(mergeSection); } }); OnActivation(disposable => { mergeElement .Clicked .SelectUnit() .BindCommand(this, x => x.ViewModel.MergeCommand) .AddTo(disposable); addComment .Clicked .Subscribe(_ => NewCommentViewController.Present(this, ViewModel.AddComment)) .AddTo(disposable); this.WhenAnyValue(x => x.ViewModel.ParticipantCount) .Subscribe(x => participants.Text = x?.ToString() ?? "-") .AddTo(disposable); this.WhenAnyValue(x => x.ViewModel.ApprovalCount) .Subscribe(x => approvals.Text = x?.ToString() ?? "-") .AddTo(disposable); this.WhenAnyValue(x => x.ViewModel.CommentCount) .Subscribe(x => commentCount.Text = x?.ToString() ?? "-") .AddTo(disposable); this.WhenAnyObservable(x => x.ViewModel.MergeCommand) .Subscribe(_ => { var vc = new PullRequestApproveViewController( ViewModel.Username, ViewModel.Repository, ViewModel.PullRequestId); vc.DeleteSourceBranch = ViewModel.PullRequest.CloseSourceBranch; vc.MergeCommand .Do(x => ViewModel.PullRequest = x) .Do(x => DismissViewController(true, null)) .Subscribe(); this.PresentModal(vc); }) .AddTo(disposable); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.Image = Images.LoginUserUnknown; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); var headerSection = new Section(); var filesSection = new Section(); var split = new SplitButtonElement(); var files = split.AddButton("Files", "-"); var comments = split.AddButton("Comments", "-"); var forks = split.AddButton("Forks", "-"); headerSection.Add(split); var commentsSection = new Section() { FooterView = new TableFooterButton("Add Comment", ViewModel.AddCommentCommand.ExecuteIfCan) }; var commentsElement = new HtmlElement("comments"); commentsElement.UrlRequested = ViewModel.GoToUrlCommand.ExecuteIfCan; commentsSection.Add(commentsElement); var detailsSection = new Section { _splitRow1, _splitRow2 }; Root.Reset(headerSection, detailsSection, filesSection, commentsSection); var updatedGistObservable = ViewModel.WhenAnyValue(x => x.Gist).Where(x => x != null); ViewModel.WhenAnyValue(x => x.Gist) .IsNotNull() .Select(x => x.Owner) .Subscribe(x => { if (x == null) { detailsSection.Remove(_ownerElement); } else if (x != null && !detailsSection.Contains(_ownerElement)) { detailsSection.Add(_ownerElement); } }); updatedGistObservable .Select(x => x?.Owner?.Login ?? "Anonymous") .Subscribe(x => _ownerElement.Value = x); updatedGistObservable .Select(x => x.Owner != null ? () => ViewModel.GoToOwnerCommand.ExecuteIfCan() : (Action)null) .SubscribeSafe(x => _ownerElement.Tapped = x); this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(64), Images.LoginUserUnknown)); updatedGistObservable.SubscribeSafe(x => { HeaderView.SubText = x.Description; RefreshHeaderView(); }); updatedGistObservable.Select(x => x.Files == null ? 0 : x.Files.Count()).SubscribeSafe(x => files.Text = x.ToString()); updatedGistObservable.SubscribeSafe(x => comments.Text = x.Comments.ToString()); updatedGistObservable.Select(x => x.Forks == null ? 0 : x.Forks.Count()).SubscribeSafe(x => forks.Text = x.ToString()); updatedGistObservable.Subscribe(x => { var elements = new List <Element>(); foreach (var file in x.Files.Keys) { var sse = new StringElement(file); sse.Image = Octicon.FileCode.ToImage(); sse.Tapped += () => ViewModel.GoToFileSourceCommand.Execute(x.Files[file]); elements.Add(sse); } filesSection.Reset(elements); }); ViewModel.Comments.Changed.Subscribe(_ => { var commentModels = ViewModel.Comments .Select(x => { var avatarUrl = x?.User?.AvatarUrl; var avatar = new GitHubAvatar(avatarUrl); return(new Comment(avatar.ToUri(), x.User.Login, x.BodyHtml, x.CreatedAt.UtcDateTime.Humanize())); }).ToList(); if (commentModels.Count > 0) { var model = new CommentModel(commentModels, (int)UIFont.PreferredSubheadline.PointSize); var razorView = new CommentsView { Model = model }; var html = razorView.GenerateString(); commentsElement.Value = html; if (!commentsSection.Contains(commentsElement)) { commentsSection.Insert(0, UITableViewRowAnimation.Fade, commentsElement); } } else { commentsSection.Remove(commentsElement); } }); }
void ReleaseDesignerOutlets() { if (AccountImageView != null) { AccountImageView.Dispose(); AccountImageView = null; } if (AccountImageViewTrailingConstraint != null) { AccountImageViewTrailingConstraint.Dispose(); AccountImageViewTrailingConstraint = null; } if (AccountsView != null) { AccountsView.Dispose(); AccountsView = null; } if (HeaderView != null) { HeaderView.Dispose(); HeaderView = null; } if (HeaderViewTopConstraint != null) { HeaderViewTopConstraint.Dispose(); HeaderViewTopConstraint = null; } if (NameLabel != null) { NameLabel.Dispose(); NameLabel = null; } if (PostBarButton != null) { PostBarButton.Dispose(); PostBarButton = null; } if (SortOrderSegmentedControl != null) { SortOrderSegmentedControl.Dispose(); SortOrderSegmentedControl = null; } if (TableViewTopConstraint != null) { TableViewTopConstraint.Dispose(); TableViewTopConstraint = null; } if (SignedOutLabel != null) { SignedOutLabel.Dispose(); SignedOutLabel = null; } }
public void RenderIssue() { if (ViewModel.Issue == null) { return; } var avatar = new Avatar(ViewModel.Issue.ReportedBy?.Avatar); NavigationItem.RightBarButtonItem.Enabled = true; HeaderView.Text = ViewModel.Issue.Title; HeaderView.SetImage(avatar.ToUrl(), Images.Avatar); HeaderView.SubText = ViewModel.Issue.Content ?? "Updated " + ViewModel.Issue.UtcLastUpdated.Humanize(); RefreshHeaderView(); var split = new SplitButtonElement(); split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString()); split.AddButton("Watches", ViewModel.Issue.FollowerCount.ToString()); ICollection <Section> root = new LinkedList <Section>(); root.Add(new Section { split }); var secDetails = new Section(); if (!string.IsNullOrEmpty(ViewModel.Issue.Content)) { _descriptionElement.SetValue(new MarkdownRazorView { Model = ViewModel.Issue.Content }.GenerateString()); secDetails.Add(_descriptionElement); } _split1.Button1.Text = ViewModel.Issue.Status; _split1.Button2.Text = ViewModel.Issue.Priority; secDetails.Add(_split1); _split2.Button1.Text = ViewModel.Issue.Metadata.Kind; _split2.Button2.Text = ViewModel.Issue.Metadata.Component ?? "No Component"; secDetails.Add(_split2); _split3.Button1.Text = ViewModel.Issue.Metadata.Version ?? "No Version"; _split3.Button2.Text = ViewModel.Issue.Metadata.Milestone ?? "No Milestone"; secDetails.Add(_split3); var assigneeElement = new StringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "******", UITableViewCellStyle.Value1) { Image = AtlassianIcon.User.ToImage(), }; assigneeElement.Clicked.BindCommand(ViewModel.GoToAssigneeCommand); secDetails.Add(assigneeElement); root.Add(secDetails); if (ViewModel.Comments.Any(x => !string.IsNullOrEmpty(x.Content))) { root.Add(new Section { _commentsElement }); } var addComment = new StringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; addComment.Clicked.Subscribe(_ => AddCommentTapped()); root.Add(new Section { addComment }); Root.Reset(root); }
public void Render(RepositoryDetailedModel model) { if (model == null) { return; } Title = model.Name; var avatar = new Avatar(model.Logo).ToUrl(128); ICollection <Section> root = new LinkedList <Section>(); HeaderView.SubText = string.IsNullOrWhiteSpace(model.Description) ? "Updated " + model.UtcLastUpdated.Humanize() : model.Description; HeaderView.SetImage(avatar, Images.RepoPlaceholder); RefreshHeaderView(); var sec1 = new Section(); _split1.Button1.Image = model.IsPrivate ? AtlassianIcon.Locked.ToImage() : AtlassianIcon.Unlocked.ToImage(); _split1.Button1.Text = model.IsPrivate ? "Private" : "Public"; _split1.Button2.Text = string.IsNullOrEmpty(model.Language) ? "N/A" : model.Language; sec1.Add(_split1); _split3.Button1.Text = model.Scm.ApplyCase(LetterCasing.Title); _split3.Button2.Text = "Issues".ToQuantity(ViewModel.Issues); sec1.Add(_split3); _split2.Button1.Text = (model.UtcCreatedOn).ToString("MM/dd/yy"); _split2.Button2.Text = model.Size.Bytes().ToString("#.##"); sec1.Add(_split2); var owner = new StringElement("Owner", model.Owner) { Image = AtlassianIcon.User.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; owner.Clicked.BindCommand(ViewModel.GoToOwnerCommand); sec1.Add(owner); if (model.ForkOf != null) { var parent = new StringElement("Forked From", model.ForkOf.Name) { Image = AtlassianIcon.Devtoolsfork.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; parent.Clicked.Select(_ => model.ForkOf).BindCommand(ViewModel.GoToForkParentCommand); sec1.Add(parent); } var events = new StringElement("Events", AtlassianIcon.Blogroll.ToImage()); events.Clicked.BindCommand(ViewModel.GoToEventsCommand); var sec2 = new Section { events }; if (model.HasWiki) { var wiki = new StringElement("Wiki", AtlassianIcon.Edit.ToImage()); wiki.Clicked.BindCommand(ViewModel.GoToWikiCommand); sec2.Add(wiki); } if (model.HasIssues) { var issues = new StringElement("Issues", AtlassianIcon.Flag.ToImage()); issues.Clicked.BindCommand(ViewModel.GoToIssuesCommand); sec2.Add(issues); } if (ViewModel.HasReadme) { var readme = new StringElement("Readme", AtlassianIcon.Pagedefault.ToImage()); readme.Clicked.BindCommand(ViewModel.GoToReadmeCommand); sec2.Add(readme); } var commits = new StringElement("Commits", AtlassianIcon.Devtoolscommit.ToImage()); commits.Clicked.BindCommand(ViewModel.GoToCommitsCommand); var pullRequests = new StringElement("Pull Requests", AtlassianIcon.Devtoolspullrequest.ToImage()); pullRequests.Clicked.BindCommand(ViewModel.GoToPullRequestsCommand); var source = new StringElement("Source", AtlassianIcon.Filecode.ToImage()); source.Clicked.BindCommand(ViewModel.GoToSourceCommand); var sec3 = new Section { commits, pullRequests, source }; foreach (var s in new[] { new Section { _split }, sec1, sec2, sec3 }) { root.Add(s); } if (!String.IsNullOrEmpty(ViewModel.Repository.Website)) { var website = new StringElement("Website", AtlassianIcon.Homepage.ToImage()); website.Clicked.Select(_ => ViewModel.Repository.Website).BindCommand(ViewModel.GoToUrlCommand); root.Add(new Section { website }); } Root.Reset(root); }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.SetImage(null, Images.RepoPlaceholder); var actionButton = new UIBarButtonItem(UIBarButtonSystemItem.Action) { Enabled = false }; NavigationItem.RightBarButtonItem = actionButton; var watchers = _split.AddButton("Watchers", "-"); var forks = _split.AddButton("Forks", "-"); var branches = _split.AddButton("Branches", "-"); _split3.Button2.Text = "- Issues"; var featuresService = Locator.Current.GetService <IFeaturesService>(); OnActivation(d => { watchers.Clicked .BindCommand(ViewModel.GoToStargazersCommand) .AddTo(d); _commitsButton .Clicked .SelectUnit() .BindCommand(ViewModel.GoToCommitsCommand) .AddTo(d); _pullRequestsButton .Clicked .SelectUnit() .BindCommand(ViewModel.GoToPullRequestsCommand) .AddTo(d); _sourceButton .Clicked .SelectUnit() .BindCommand(ViewModel.GoToSourceCommand) .AddTo(d); branches.Clicked .BindCommand(ViewModel.GoToBranchesCommand) .AddTo(d); this.WhenAnyValue(x => x.ViewModel.BranchesCount) .Subscribe(x => branches.Text = x.ToString()) .AddTo(d); this.WhenAnyValue(x => x.ViewModel.Watchers) .Subscribe(x => watchers.Text = x?.ToString() ?? "-") .AddTo(d); this.WhenAnyValue(x => x.ViewModel.Forks) .Subscribe(x => forks.Text = x?.ToString() ?? "-") .AddTo(d); this.WhenAnyValue(x => x.ViewModel.Repository).SelectUnit() .Merge(this.WhenAnyValue(x => x.ViewModel.HasReadme).SelectUnit()) .Where(x => ViewModel.Repository != null) .Subscribe(_ => Render()) .AddTo(d); this.WhenAnyValue(x => x.ViewModel.Issues) .Select(x => "Issues".ToQuantity(x.GetValueOrDefault())) .Subscribe(x => _split3.Button2.Text = x) .AddTo(d); actionButton .Bind(ViewModel.ShowMenuCommand) .AddTo(d); this.WhenAnyValue(x => x.ViewModel.Repository) .Where(x => x != null) .Subscribe(x => { if (x.IsPrivate && !featuresService.IsProEnabled) { if (_privateView == null) { _privateView = this.ShowPrivateView(); } actionButton.Enabled = false; } else { actionButton.Enabled = true; _privateView?.Dispose(); } }) .AddTo(d); }); }
private void DoRender() { var model = ViewModel.Repository; var avatarHref = ViewModel.Repository.Owner?.Links?.Avatar?.Href; var avatar = new Avatar(avatarHref).ToUrl(128); ICollection <Section> root = new LinkedList <Section>(); HeaderView.SubText = string.IsNullOrWhiteSpace(model.Description) ? "Updated " + model.UpdatedOn.Humanize() : model.Description; HeaderView.SetImage(avatar, Images.RepoPlaceholder); RefreshHeaderView(); var sec1 = new Section(); _split1.Button1.Image = model.IsPrivate ? AtlassianIcon.Locked.ToImage() : AtlassianIcon.Unlocked.ToImage(); _split1.Button1.Text = model.IsPrivate ? "Private" : "Public"; _split1.Button2.Text = string.IsNullOrEmpty(model.Language) ? "N/A" : model.Language; sec1.Add(_split1); _split3.Button1.Text = model?.Scm?.ApplyCase(LetterCasing.Title) ?? "-"; sec1.Add(_split3); _split2.Button1.Text = model.UpdatedOn.ToString("MM/dd/yy"); _split2.Button2.Text = model.Size.Bytes().ToString("#.##"); sec1.Add(_split2); var owner = new ButtonElement("Owner", model.Owner.Username) { Image = AtlassianIcon.User.ToImage() }; owner.Clicked.SelectUnit().BindCommand(ViewModel.GoToOwnerCommand); sec1.Add(owner); if (model.Parent != null) { var parent = new ButtonElement("Forked From", model.Parent.Name) { Image = AtlassianIcon.Devtoolsfork.ToImage() }; parent.Clicked.SelectUnit().BindCommand(ViewModel.GoToForkParentCommand); sec1.Add(parent); } var events = new ButtonElement("Events", AtlassianIcon.Blogroll.ToImage()); events.Clicked.SelectUnit().BindCommand(ViewModel.GoToEventsCommand); var sec2 = new Section { events }; if (model.HasWiki) { var wiki = new ButtonElement("Wiki", AtlassianIcon.Edit.ToImage()); wiki.Clicked.SelectUnit().BindCommand(ViewModel.GoToWikiCommand); sec2.Add(wiki); } if (model.HasIssues) { var issues = new ButtonElement("Issues", AtlassianIcon.Flag.ToImage()); issues.Clicked.SelectUnit().BindCommand(ViewModel.GoToIssuesCommand); sec2.Add(issues); } if (ViewModel.HasReadme) { var readme = new ButtonElement("Readme", AtlassianIcon.PageDefault.ToImage()); readme.Clicked.SelectUnit().BindCommand(ViewModel.GoToReadmeCommand); sec2.Add(readme); } var sec3 = new Section { _commitsButton, _pullRequestsButton, _sourceButton }; foreach (var s in new[] { new Section { _split }, sec1, sec2, sec3 }) { root.Add(s); } if (!string.IsNullOrEmpty(ViewModel.Repository.Website)) { var website = new ButtonElement("Website", AtlassianIcon.Weblink.ToImage()); website.Clicked.SelectUnit().BindCommand(ViewModel.GoToWebsiteCommand); root.Add(new Section { website }); } Root.Reset(root); }
public void Render() { if (ViewModel.PullRequest == null) { return; } var avatarUrl = ViewModel.PullRequest.Author?.Links?.Avatar?.Href; HeaderView.Text = ViewModel.PullRequest.Title; HeaderView.SubText = "Updated " + ViewModel.PullRequest.UpdatedOn.Humanize(); HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar); RefreshHeaderView(); var split = new SplitButtonElement(); split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString()); split.AddButton("Participants", ViewModel.PullRequest.Participants.Count.ToString()); ICollection <Section> root = new LinkedList <Section>(); root.Add(new Section { split }); var secDetails = new Section(); if (!string.IsNullOrWhiteSpace(ViewModel.Description)) { var content = new MarkdownRazorView { Model = ViewModel.Description }.GenerateString(); _descriptionElement.SetValue(content); secDetails.Add(_descriptionElement); } var commitsElement = new StringElement("Commits", AtlassianIcon.Devtoolscommit.ToImage()); commitsElement.Clicked.BindCommand(ViewModel.GoToCommitsCommand); var merged = ViewModel.Merged; _split1.Button1.Text = ViewModel.PullRequest.CreatedOn.ToString("MM/dd/yy"); _split1.Button2.Text = merged ? "Merged" : "Not Merged"; secDetails.Add(_split1); secDetails.Add(commitsElement); root.Add(secDetails); if (!merged) { var mergeElement = new StringElement("Merge", AtlassianIcon.Approve.ToImage()); mergeElement.Clicked.Subscribe(_ => MergeClick()); root.Add(new Section { mergeElement }); } var comments = ViewModel.Comments .Where(x => !string.IsNullOrEmpty(x.Content.Raw) && x.Inline == null) .OrderBy(x => (x.CreatedOn)) .Select(x => { var name = x.User.DisplayName ?? x.User.Username ?? "Unknown"; var avatar = new Avatar(x.User.Links?.Avatar?.Href); return(new CommentViewModel(name, x.Content.Html, x.CreatedOn.Humanize(), avatar.ToUrl())); }).ToList(); if (comments.Count > 0) { var content = new CommentsRazorView { Model = comments.ToList() }.GenerateString(); _commentsElement.SetValue(content); root.Add(new Section { _commentsElement }); } var addComment = new StringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; addComment.Clicked.Subscribe(_ => AddCommentTapped()); root.Add(new Section { addComment }); Root.Reset(root); }
void ReleaseDesignerOutlets() { if (AddUserBtn != null) { AddUserBtn.Dispose(); AddUserBtn = null; } if (btnCancel != null) { btnCancel.Dispose(); btnCancel = null; } if (ContentView != null) { ContentView.Dispose(); ContentView = null; } if (HeaderView != null) { HeaderView.Dispose(); HeaderView = null; } if (lblPasswordError != null) { lblPasswordError.Dispose(); lblPasswordError = null; } if (lblTitle != null) { lblTitle.Dispose(); lblTitle = null; } if (mainScrollView != null) { mainScrollView.Dispose(); mainScrollView = null; } if (txtAddressLine1 != null) { txtAddressLine1.Dispose(); txtAddressLine1 = null; } if (txtCity != null) { txtCity.Dispose(); txtCity = null; } if (txtName != null) { txtName.Dispose(); txtName = null; } if (txtPassword != null) { txtPassword.Dispose(); txtPassword = null; } if (txtPhone != null) { txtPhone.Dispose(); txtPhone = null; } if (txtStreetLine2 != null) { txtStreetLine2.Dispose(); txtStreetLine2 = null; } if (txtZipcode != null) { txtZipcode.Dispose(); txtZipcode = null; } }
void ReleaseDesignerOutlets() { if (btnAttachement != null) { btnAttachement.Dispose(); btnAttachement = null; } if (btnBack != null) { btnBack.Dispose(); btnBack = null; } if (btnMore != null) { btnMore.Dispose(); btnMore = null; } if (btnSendMessage != null) { btnSendMessage.Dispose(); btnSendMessage = null; } if (FooterView != null) { FooterView.Dispose(); FooterView = null; } if (HeaderView != null) { HeaderView.Dispose(); HeaderView = null; } if (lblName != null) { lblName.Dispose(); lblName = null; } if (lblStatus != null) { lblStatus.Dispose(); lblStatus = null; } if (ProfilePicture != null) { ProfilePicture.Dispose(); ProfilePicture = null; } if (RevelView != null) { RevelView.Dispose(); RevelView = null; } if (textSendBorder != null) { textSendBorder.Dispose(); textSendBorder = null; } if (textSender != null) { textSender.Dispose(); textSender = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Pull Request #" + ViewModel.Id; HeaderView.SetImage(null, Images.Avatar); HeaderView.Text = Title; Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.2f))) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Select(_ => ViewModel.Bind(x => x.IsClosed, true).Where(x => x.HasValue).Select(x => x.Value)) .Switch() .Subscribe(x => { HeaderView.SubImageView.TintColor = x ? UIColor.FromRGB(0xbd, 0x2c, 0) : UIColor.FromRGB(0x6c, 0xc6, 0x44); HeaderView.SetSubImage((x ? Octicon.IssueClosed :Octicon.IssueOpened).ToImage()); }); _milestoneElement = new StringElement("Milestone", "No Milestone", UITableViewCellStyle.Value1) { Image = Octicon.Milestone.ToImage() }; _assigneeElement = new StringElement("Assigned", "Unassigned", UITableViewCellStyle.Value1) { Image = Octicon.Person.ToImage() }; _labelsElement = new StringElement("Labels", "None", UITableViewCellStyle.Value1) { Image = Octicon.Tag.ToImage() }; _addCommentElement = new StringElement("Add Comment") { Image = Octicon.Pencil.ToImage() }; ViewModel.Bind(x => x.PullRequest).Subscribe(x => { var merged = (x.Merged != null && x.Merged.Value); _split1.Button1.Text = x.State; _split1.Button2.Text = merged ? "Merged" : "Not Merged"; _split2.Button1.Text = x.User.Login; _split2.Button2.Text = x.CreatedAt.ToString("MM/dd/yy"); var model = new DescriptionModel(ViewModel.MarkdownDescription, (int)UIFont.PreferredSubheadline.PointSize, true); var markdown = new MarkdownView { Model = model }; var html = markdown.GenerateString(); _descriptionElement.SetValue(string.IsNullOrEmpty(ViewModel.MarkdownDescription) ? null : html); HeaderView.Text = x.Title ?? Title; HeaderView.SubText = "Updated " + x.UpdatedAt.Humanize(); HeaderView.SetImage(x.User?.AvatarUrl, Images.Avatar); RefreshHeaderView(); Render(); }); var actionButton = NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action) { Enabled = false }; ViewModel.Bind(x => x.IsLoading).Subscribe(x => { if (!x) { actionButton.Enabled = ViewModel.PullRequest != null; } }); ViewModel.Bind(x => x.ShouldShowPro).Subscribe(x => { if (x) { this.ShowPrivateView(); } }); ViewModel.Bind(x => x.CanPush).Subscribe(_ => Render()); ViewModel.GoToLabelsCommand.CanExecuteChanged += (sender, e) => { _labelsElement.Accessory = ViewModel.GoToLabelsCommand.CanExecute(null) ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; }; ViewModel.GoToAssigneeCommand.CanExecuteChanged += (sender, e) => { _assigneeElement.Accessory = ViewModel.GoToAssigneeCommand.CanExecute(null) ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; }; ViewModel.GoToMilestoneCommand.CanExecuteChanged += (sender, e) => { _milestoneElement.Accessory = ViewModel.GoToMilestoneCommand.CanExecute(null) ? UITableViewCellAccessory.DisclosureIndicator : UITableViewCellAccessory.None; }; ViewModel.BindCollection(x => x.Comments).Subscribe(_ => RenderComments()); ViewModel.BindCollection(x => x.Events).Subscribe(_ => RenderComments()); OnActivation(d => { d(_milestoneElement.Clicked.BindCommand(ViewModel.GoToMilestoneCommand)); d(_assigneeElement.Clicked.BindCommand(ViewModel.GoToAssigneeCommand)); d(_labelsElement.Clicked.BindCommand(ViewModel.GoToLabelsCommand)); d(_addCommentElement.Clicked.Subscribe(_ => AddCommentTapped())); d(_descriptionElement.UrlRequested.BindCommand(ViewModel.GoToUrlCommand)); d(_commentsElement.UrlRequested.BindCommand(ViewModel.GoToUrlCommand)); d(actionButton.GetClickedObservable().Subscribe(_ => ShowExtraMenu())); d(HeaderView.Clicked.BindCommand(ViewModel.GoToOwner)); d(ViewModel.Bind(x => x.IsModifying).SubscribeStatus("Loading...")); d(ViewModel.Bind(x => x.Issue, true).Where(x => x != null).Subscribe(x => { _assigneeElement.Value = x.Assignee != null ? x.Assignee.Login : "******"; _milestoneElement.Value = x.Milestone != null ? x.Milestone.Title : "No Milestone"; _labelsElement.Value = x.Labels.Count == 0 ? "None" : string.Join(", ", x.Labels.Select(i => i.Name)); Render(); })); }); }
void ReleaseDesignerOutlets() { if (BackgroundView != null) { BackgroundView.Dispose(); BackgroundView = null; } if (BasicButton != null) { BasicButton.Dispose(); BasicButton = null; } if (CancelButton != null) { CancelButton.Dispose(); CancelButton = null; } if (DefenseButton != null) { DefenseButton.Dispose(); DefenseButton = null; } if (DescriptionButton != null) { DescriptionButton.Dispose(); DescriptionButton = null; } if (FeatsButton != null) { FeatsButton.Dispose(); FeatsButton = null; } if (HeaderLabel != null) { HeaderLabel.Dispose(); HeaderLabel = null; } if (HeaderView != null) { HeaderView.Dispose(); HeaderView = null; } if (OffenseButton != null) { OffenseButton.Dispose(); OffenseButton = null; } if (OKButton != null) { OKButton.Dispose(); OKButton = null; } if (PageBorderView != null) { PageBorderView.Dispose(); PageBorderView = null; } if (PageView != null) { PageView.Dispose(); PageView = null; } if (SpecialButton != null) { SpecialButton.Dispose(); SpecialButton = null; } if (StatisticsButton != null) { StatisticsButton.Dispose(); StatisticsButton = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); _header = new HeaderView(); _hud = this.CreateHud(); var content = System.IO.File.ReadAllText("WebCell/body.html", System.Text.Encoding.UTF8); _descriptionElement = new WebElement(content, "body", false); _descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; //_descriptionElement.HeightChanged = x => Render(); var content2 = System.IO.File.ReadAllText("WebCell/comments.html", System.Text.Encoding.UTF8); _commentsElement = new WebElement(content2, "comments", true); _commentsElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; //_commentsElement.HeightChanged = x => Render(); _milestoneElement = new StyledStringElement("Milestone", "No Milestone", UITableViewCellStyle.Value1) { Image = Images.Milestone, Accessory = UITableViewCellAccessory.DisclosureIndicator }; _milestoneElement.Tapped += () => ViewModel.GoToMilestoneCommand.Execute(null); _assigneeElement = new StyledStringElement("Assigned", "Unassigned".t(), UITableViewCellStyle.Value1) { Image = Images.Person, Accessory = UITableViewCellAccessory.DisclosureIndicator }; _assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null); _labelsElement = new StyledStringElement("Labels", "None", UITableViewCellStyle.Value1) { Image = Images.Tag, Accessory = UITableViewCellAccessory.DisclosureIndicator }; _labelsElement.Tapped += () => ViewModel.GoToLabelsCommand.Execute(null); _addCommentElement = new StyledStringElement("Add Comment") { Image = Images.Pencil }; _addCommentElement.Tapped += AddCommentTapped; NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu()); NavigationItem.RightBarButtonItem.Enabled = false; ViewModel.Bind(x => x.IsLoading, x => { if (!x) { NavigationItem.RightBarButtonItem.Enabled = ViewModel.Issue != null; } }); ViewModel.Bind(x => x.IsModifying, x => { if (x) { _hud.Show("Loading..."); } else { _hud.Hide(); } }); ViewModel.Bind(x => x.Issue, x => { _assigneeElement.Value = x.Assignee != null ? x.Assignee.Login : "******".t(); _milestoneElement.Value = x.Milestone != null ? x.Milestone.Title : "No Milestone"; _labelsElement.Value = x.Labels.Count == 0 ? "None" : string.Join(", ", x.Labels.Select(i => i.Name)); _descriptionElement.Value = ViewModel.MarkdownDescription; _header.Title = x.Title; _header.Subtitle = "Updated " + x.UpdatedAt.ToDaysAgo(); Render(); }); ViewModel.BindCollection(x => x.Comments, (e) => RenderComments()); ViewModel.BindCollection(x => x.Events, (e) => RenderComments()); }
/// <summary> /// Initializes a new instance of the <see cref="PagePresenter"/> class. /// </summary> /// <param name="initial">The initial.</param> /// <param name="textBoxHolder">The text box holder.</param> /// <param name="actionGrid">The action grid.</param> /// <param name="left">The left portraits.</param> /// <param name="right">The right portraits.</param> /// <param name="header">The header.</param> /// <param name="sound">The sound.</param> public PagePresenter(Page initial, TextBoxHolderView textBoxHolder, ActionGridView actionGrid, PortraitHolderView left, PortraitHolderView right, HeaderView header, SoundView sound) { this.textBoxHolder = textBoxHolder; this.actionGrid = actionGrid; this.left = left; this.right = right; this.header = header; this.sound = sound; this.characterPresenters = new List <CharacterPresenter>(); InitializeFunctions(); this.presenters = new Dictionary <Character, CharacterPresenter>(new IdNumberEqualityComparer <Character>()); this.Page = initial; }
void ReleaseDesignerOutlets() { if (BackButton != null) { BackButton.Dispose(); BackButton = null; } if (BekletmeButton != null) { BekletmeButton.Dispose(); BekletmeButton = null; } if (CallButton != null) { CallButton.Dispose(); CallButton = null; } if (CheckinButton != null) { CheckinButton.Dispose(); CheckinButton = null; } if (HeaderView != null) { HeaderView.Dispose(); HeaderView = null; } if (KonumButton != null) { KonumButton.Dispose(); KonumButton = null; } if (Mapview != null) { Mapview.Dispose(); Mapview = null; } if (MekandakilerButton != null) { MekandakilerButton.Dispose(); MekandakilerButton = null; } if (mekanTitle != null) { mekanTitle.Dispose(); mekanTitle = null; } if (MessageButton != null) { MessageButton.Dispose(); MessageButton = null; } if (MessageCount != null) { MessageCount.Dispose(); MessageCount = null; } if (RatingButton != null) { RatingButton.Dispose(); RatingButton = null; } }
public RepositoryView() { HeaderView.Image = Images.LoginUserUnknown; _sourceSection = new Section { new StringElement("Commits", () => ViewModel.GoToCommitsCommand.ExecuteIfCan(), Octicon.GitCommit.ToImage()), new StringElement("Pull Requests", () => ViewModel.GoToPullRequestsCommand.ExecuteIfCan(), Octicon.GitPullRequest.ToImage()), new StringElement("Source", () => ViewModel.GoToSourceCommand.ExecuteIfCan(), Octicon.Code.ToImage()), }; _ownerElement = new StringElement("Owner", string.Empty) { Image = Octicon.Person.ToImage() }; _ownerElement.Tapped += () => ViewModel.GoToOwnerCommand.ExecuteIfCan(); this.WhenAnyValue(x => x.ViewModel.Repository) .Subscribe(x => _ownerElement.Value = x == null ? string.Empty : x.Owner.Login); HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); this.WhenAnyValue(x => x.ViewModel.GoToOwnerCommand).Subscribe(x => HeaderView.ImageButtonAction = x != null ? new Action(() => ViewModel.GoToOwnerCommand.ExecuteIfCan()) : null); _splitElements[0] = new SplitViewElement(); _splitElements[0].Button1 = new SplitViewElement.SplitButton(Octicon.Lock.ToImage(), string.Empty); _splitElements[0].Button2 = new SplitViewElement.SplitButton(Octicon.Package.ToImage(), string.Empty); _splitElements[1] = new SplitViewElement(); _splitElements[1].Button1 = new SplitViewElement.SplitButton(Octicon.IssueOpened.ToImage(), string.Empty, () => ViewModel.GoToIssuesCommand.ExecuteIfCan()); _splitElements[1].Button2 = new SplitViewElement.SplitButton(Octicon.Organization.ToImage(), string.Empty, () => ViewModel.GoToContributors.ExecuteIfCan()); _splitElements[2] = new SplitViewElement(); _splitElements[2].Button1 = new SplitViewElement.SplitButton(Octicon.Tag.ToImage(), string.Empty, () => ViewModel.GoToReleasesCommand.ExecuteIfCan()); _splitElements[2].Button2 = new SplitViewElement.SplitButton(Octicon.GitBranch.ToImage(), string.Empty, () => ViewModel.GoToBranchesCommand.ExecuteIfCan()); var stargazers = _split.AddButton("Stargazers", "-", () => ViewModel.GoToStargazersCommand.ExecuteIfCan()); var watchers = _split.AddButton("Watchers", "-", () => ViewModel.GoToWatchersCommand.ExecuteIfCan()); var forks = _split.AddButton("Forks", "-", () => ViewModel.GoToForksCommand.ExecuteIfCan()); this.WhenAnyValue(x => x.ViewModel.Stargazers) .Select(x => x != null ? x.ToString() : "-") .Subscribe(x => stargazers.Text = x); this.WhenAnyValue(x => x.ViewModel.Watchers) .Select(x => x != null ? x.ToString() : "-") .Subscribe(x => watchers.Text = x); this.WhenAnyValue(x => x.ViewModel.Repository.ForksCount) .Subscribe(x => forks.Text = x.ToString()); this.WhenAnyValue(x => x.ViewModel.Repository) .IsNotNull() .Subscribe(x => { _splitElements[0].Button1.Text = x.Private ? "Private" : "Public"; _splitElements[0].Button2.Text = x.Language ?? "N/A"; _splitElements[1].Button1.Text = x.OpenIssues + (x.OpenIssues == 1 ? " Issue" : " Issues"); }); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f))) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Select(_ => this.WhenAnyValue(x => x.ViewModel.IsStarred).Where(x => x.HasValue)) .Switch() .Subscribe(x => HeaderView.SetSubImage(x.Value ? Octicon.Star.ToImage() : null)); this.WhenAnyValue(x => x.ViewModel.RepositoryName) .Subscribe(x => HeaderView.Text = x); this.WhenAnyValue(x => x.ViewModel.ShowMenuCommand) .Select(x => x.ToBarButtonItem(UIBarButtonSystemItem.Action)) .Subscribe(x => NavigationItem.RightBarButtonItem = x); this.WhenAnyValue(x => x.ViewModel.Branches) .SubscribeSafe(x => { if (x == null) { _splitElements[2].Button2.Text = "- Branches"; } else { _splitElements[2].Button2.Text = (x.Count >= 100 ? "100+" : x.Count.ToString()) + (x.Count == 1 ? " Branch" : " Branches"); } }); this.WhenAnyValue(x => x.ViewModel.Contributors) .SubscribeSafe(x => { if (x == null) { _splitElements[1].Button2.Text = "- Contributors"; } else { _splitElements[1].Button2.Text = (x >= 100 ? "100+" : x.ToString()) + (x == 1 ? " Contributor" : " Contributors"); } }); this.WhenAnyValue(x => x.ViewModel.Releases) .SubscribeSafe(x => { if (x == null) { _splitElements[2].Button1.Text = "- Releases"; } else { _splitElements[2].Button1.Text = (x >= 100 ? "100+" : x.ToString()) + (x == 1 ? " Release" : " Releases"); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var splitButton = new SplitButtonElement(); var splitElements = new SplitViewElement[3]; HeaderView.Image = Images.LoginUserUnknown; HeaderView.SubImageView.TintColor = UIColor.FromRGB(243, 156, 18); Appeared.Take(1) .Select(_ => Observable.Timer(TimeSpan.FromSeconds(0.35f)).Take(1)) .Switch() .Select(_ => this.WhenAnyValue(x => x.ViewModel.IsStarred).Where(x => x.HasValue)) .Switch() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => HeaderView.SetSubImage(x.Value ? Octicon.Star.ToImage() : null)); var events = new StringElement("Events", Octicon.Rss.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var issuesElement = new StringElement("Issues", Octicon.IssueOpened.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var commitsElement = new StringElement("Commits", Octicon.GitCommit.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var pullRequestsElement = new StringElement("Pull Requests", Octicon.GitPullRequest.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var sourceElement = new StringElement("Source", Octicon.Code.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var websiteElement = new StringElement("Website", Octicon.Globe.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var readmeElement = new StringElement("Readme", Octicon.Book.ToImage()) { Accessory = UITableViewCellAccessory.DisclosureIndicator }; var forkedElement = new StringElement("Fork", string.Empty) { Image = Octicon.RepoForked.ToImage(), Font = StringElement.DefaultDetailFont, Accessory = UITableViewCellAccessory.DisclosureIndicator }; splitElements[0] = new SplitViewElement(Octicon.Lock.ToImage(), Octicon.Package.ToImage()); splitElements[1] = new SplitViewElement(Octicon.IssueOpened.ToImage(), Octicon.Organization.ToImage()); splitElements[2] = new SplitViewElement(Octicon.Tag.ToImage(), Octicon.GitBranch.ToImage()); var stargazers = splitButton.AddButton("Stargazers", "-"); var watchers = splitButton.AddButton("Watchers", "-"); var forks = splitButton.AddButton("Forks", "-"); var renderFunc = new Action(() => { var model = ViewModel.Repository; var sec1 = new Section(); sec1.Add(splitElements); if (model.Parent != null) { forkedElement.Value = model.Parent.FullName; sec1.Add(forkedElement); } var sec2 = new Section { events }; if (model.HasIssues) { sec2.Add(issuesElement); } if (ViewModel.Readme != null) { sec2.Add(readmeElement); } Root.Reset(new Section { splitButton }, sec1, sec2, new Section { commitsElement, pullRequestsElement, sourceElement }); if (!string.IsNullOrEmpty(model.Homepage)) { Root.Add(new Section { websiteElement }); } }); OnActivation(d => { d(HeaderView.Clicked.InvokeCommand(ViewModel.GoToOwnerCommand)); d(splitElements[1].Button1.Clicked.InvokeCommand(ViewModel.GoToIssuesCommand)); d(splitElements[1].Button2.Clicked.InvokeCommand(ViewModel.GoToContributors)); d(splitElements[2].Button1.Clicked.InvokeCommand(ViewModel.GoToReleasesCommand)); d(splitElements[2].Button2.Clicked.InvokeCommand(ViewModel.GoToBranchesCommand)); d(events.Clicked.InvokeCommand(ViewModel.GoToEventsCommand)); d(issuesElement.Clicked.InvokeCommand(ViewModel.GoToIssuesCommand)); d(websiteElement.Clicked.InvokeCommand(ViewModel.GoToHomepageCommand)); d(forkedElement.Clicked.InvokeCommand(ViewModel.GoToForkParentCommand)); d(readmeElement.Clicked.InvokeCommand(ViewModel.GoToReadmeCommand)); d(stargazers.Clicked.InvokeCommand(ViewModel.GoToStargazersCommand)); d(watchers.Clicked.InvokeCommand(ViewModel.GoToWatchersCommand)); d(forks.Clicked.InvokeCommand(ViewModel.GoToForksCommand)); d(commitsElement.Clicked.InvokeCommand(ViewModel.GoToCommitsCommand)); d(pullRequestsElement.Clicked.InvokeCommand(ViewModel.GoToPullRequestsCommand)); d(sourceElement.Clicked.InvokeCommand(ViewModel.GoToSourceCommand)); d(this.WhenAnyValue(x => x.ViewModel.Stargazers) .Select(x => x != null ? x.ToString() : "-") .Subscribe(x => stargazers.Text = x)); d(this.WhenAnyValue(x => x.ViewModel.Watchers) .Select(x => x != null ? x.ToString() : "-") .Subscribe(x => watchers.Text = x)); d(this.WhenAnyValue(x => x.ViewModel.Repository.ForksCount) .Subscribe(x => forks.Text = x.ToString())); d(this.WhenAnyValue(x => x.ViewModel.Repository) .IsNotNull() .Subscribe(x => { splitElements[0].Button1.Text = x.Private ? "Private" : "Public"; splitElements[0].Button2.Text = x.Language ?? "N/A"; splitElements[1].Button1.Text = x.OpenIssuesCount + (x.OpenIssuesCount == 1 ? " Issue" : " Issues"); })); d(this.WhenAnyValue(x => x.ViewModel.RepositoryName) .Subscribe(x => HeaderView.Text = x)); d(this.WhenAnyValue(x => x.ViewModel.ShowMenuCommand) .ToBarButtonItem(UIBarButtonSystemItem.Action, x => NavigationItem.RightBarButtonItem = x)); d(this.WhenAnyValue(x => x.ViewModel.Branches) .Select(x => x == null ? "Branches" : (x.Count >= 100 ? "100+" : x.Count.ToString()) + (x.Count == 1 ? " Branch" : " Branches")) .SubscribeSafe(x => splitElements[2].Button2.Text = x)); d(this.WhenAnyValue(x => x.ViewModel.Contributors) .Select(x => x == null ? "Contributors" : (x >= 100 ? "100+" : x.ToString()) + (x == 1 ? " Contributor" : " Contributors")) .SubscribeSafe(x => splitElements[1].Button2.Text = x)); d(this.WhenAnyValue(x => x.ViewModel.Releases) .Select(x => x == null ? "Releases" : (x >= 100 ? "100+" : x.ToString()) + (x == 1 ? " Release" : " Releases")) .SubscribeSafe(x => splitElements[2].Button1.Text = x)); d(this.WhenAnyValue(x => x.ViewModel.Description).Subscribe(x => RefreshHeaderView(subtext: x))); d(this.WhenAnyValue(x => x.ViewModel.Avatar) .Subscribe(x => HeaderView.SetImage(x?.ToUri(128), Images.LoginUserUnknown))); d(this.WhenAnyValue(x => x.ViewModel.Repository) .IsNotNull() .Subscribe(_ => renderFunc())); d(this.WhenAnyValue(x => x.ViewModel.Readme) .Where(x => x != null && ViewModel.Repository != null) .Subscribe(_ => renderFunc())); }); }
void ReleaseDesignerOutlets() { if (AddressView != null) { AddressView.Dispose(); AddressView = null; } if (btnAvailableProducts != null) { btnAvailableProducts.Dispose(); btnAvailableProducts = null; } if (btnBack != null) { btnBack.Dispose(); btnBack = null; } if (btnChat != null) { btnChat.Dispose(); btnChat = null; } if (btnReportProvider != null) { btnReportProvider.Dispose(); btnReportProvider = null; } if (btnReviewbyOther != null) { btnReviewbyOther.Dispose(); btnReviewbyOther = null; } if (divider1 != null) { divider1.Dispose(); divider1 = null; } if (EmailView != null) { EmailView.Dispose(); EmailView = null; } if (HeaderView != null) { HeaderView.Dispose(); HeaderView = null; } if (iconEnvelop != null) { iconEnvelop.Dispose(); iconEnvelop = null; } if (lblAddress != null) { lblAddress.Dispose(); lblAddress = null; } if (lblEmailId != null) { lblEmailId.Dispose(); lblEmailId = null; } if (lblProviderMobileNo != null) { lblProviderMobileNo.Dispose(); lblProviderMobileNo = null; } if (lblProviderName != null) { lblProviderName.Dispose(); lblProviderName = null; } if (lblTitle != null) { lblTitle.Dispose(); lblTitle = null; } if (MarkerIcon != null) { MarkerIcon.Dispose(); MarkerIcon = null; } if (ProviderDisplayPicture != null) { ProviderDisplayPicture.Dispose(); ProviderDisplayPicture = null; } if (ProviderProfileView != null) { ProviderProfileView.Dispose(); ProviderProfileView = null; } if (ProviderWallPicture != null) { ProviderWallPicture.Dispose(); ProviderWallPicture = null; } }
public override void ViewDidLoad() { base.ViewDidLoad(); HeaderView.SetImage(null, Images.Avatar); var detailsSection = new Section(); var diffButton = new ButtonElement(AtlassianIcon.ListAdd.ToImage()); var removedButton = new ButtonElement(AtlassianIcon.ListRemove.ToImage()); var modifiedButton = new ButtonElement(AtlassianIcon.Edit.ToImage()); var allChangesButton = new ButtonElement("All Changes", AtlassianIcon.Devtoolssidediff.ToImage()); detailsSection.Add(new [] { diffButton, removedButton, modifiedButton, allChangesButton }); var additions = ViewModel.WhenAnyValue(x => x.DiffAdditions); diffButton.BindClick(ViewModel.GoToAddedFiles); diffButton.BindDisclosure(additions.Select(x => x > 0)); diffButton.BindCaption(additions.Select(x => $"{x} Added")); var deletions = ViewModel.WhenAnyValue(x => x.DiffDeletions); removedButton.BindClick(ViewModel.GoToRemovedFiles); removedButton.BindDisclosure(deletions.Select(x => x > 0)); removedButton.BindCaption(deletions.Select(x => $"{x} Removed")); var modifications = ViewModel.WhenAnyValue(x => x.DiffModifications); modifiedButton.BindClick(ViewModel.GoToModifiedFiles); modifiedButton.BindDisclosure(modifications.Select(x => x > 0)); modifiedButton.BindCaption(modifications.Select(x => $"{x} Modified")); allChangesButton.BindClick(ViewModel.GoToAllFiles); var split = new SplitButtonElement(); var commentCount = split.AddButton("Comments", "-"); var participants = split.AddButton("Participants", "-"); var approvals = split.AddButton("Approvals", "-"); var headerSection = new Section { split }; var actionButton = new UIBarButtonItem(UIBarButtonSystemItem.Action); NavigationItem.RightBarButtonItem = actionButton; var detailSection = new Section(); var detailsElement = new MultilinedElement(); detailSection.Add(detailsElement); var approvalSection = new Section("Approvals"); var approveElement = new LoaderButtonElement("Approve", AtlassianIcon.Approve.ToImage()); approveElement.Accessory = UITableViewCellAccessory.None; approveElement.BindLoader(ViewModel.ToggleApproveButton); approveElement.BindCaption(ViewModel.WhenAnyValue(x => x.Approved).Select(x => x ? "Unapprove" : "Approve")); var commentsSection = new Section("Comments"); var addCommentElement = new ButtonElement("Add Comment", AtlassianIcon.Addcomment.ToImage()); commentsSection.Add(addCommentElement); if (ViewModel.ShowRepository) { var repo = new ButtonElement(ViewModel.Repository) { TextColor = StringElement.DefaultDetailColor, Image = AtlassianIcon.Devtoolsrepository.ToImage() }; detailSection.Add(repo); repo.Clicked.SelectUnit().BindCommand(ViewModel.GoToRepositoryCommand); } ViewModel.WhenAnyValue(x => x.Commit).Where(x => x != null).Subscribe(x => { participants.Text = x?.Participants?.Count.ToString() ?? "-"; approvals.Text = x?.Participants?.Count(y => y.Approved).ToString() ?? "-"; var titleMsg = (ViewModel.Commit.Message ?? string.Empty).Split(new [] { '\n' }, 2).FirstOrDefault(); var avatarUrl = ViewModel.Commit.Author?.User?.Links?.Avatar?.Href; HeaderView.SubText = titleMsg ?? "Commited " + (ViewModel.Commit.Date).Humanize(); HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar); RefreshHeaderView(); var user = x.Author?.User?.DisplayName ?? x.Author?.Raw ?? "Unknown"; detailsElement.Caption = user; detailsElement.Details = x.Message; }); this.WhenAnyValue(x => x.ViewModel.Approvals) .Select(x => x.Select(y => new UserElement(y)).OfType <Element>()) .Subscribe(x => approvalSection.Reset(x.Concat(new[] { approveElement }))); ViewModel.Comments .CountChanged .Select(x => x.ToString()) .StartWith("-") .Subscribe(x => commentCount.Text = x); ViewModel .Comments .ChangedObservable() .Subscribe(x => { if (x.Count > 0) { var comments = x.Select(y => new Comment(y.Avatar.ToUrl(), y.Name, y.Content, y.CreatedOn)).ToList(); var commentModel = new Views.CommentModel(comments, (int)UIFont.PreferredSubheadline.PointSize); var content = new CommentsView { Model = commentModel }.GenerateString(); _commentsElement.SetValue(content); commentsSection.Insert(0, UITableViewRowAnimation.None, _commentsElement); } else { commentsSection.Remove(_commentsElement); } }); ViewModel.WhenAnyValue(x => x.Commit) .Where(x => x != null) .Take(1) .Subscribe(_ => Root.Reset(headerSection, detailsSection, approvalSection, commentsSection)); ViewModel.GoToAddedFiles.Select(_ => CommitFileType.Added).Subscribe(GoToFiles); ViewModel.GoToRemovedFiles.Select(_ => CommitFileType.Removed).Subscribe(GoToFiles); ViewModel.GoToModifiedFiles.Select(_ => CommitFileType.Modified).Subscribe(GoToFiles); ViewModel.GoToAllFiles.Subscribe(_ => GoToAllFiles()); OnActivation(d => { actionButton .GetClickedObservable() .Select(x => (object)x) .BindCommand(ViewModel.ShowMenuCommand) .AddTo(d); addCommentElement .Clicked .SelectUnit() .BindCommand(ViewModel.AddCommentCommand) .AddTo(d); this.WhenAnyObservable(x => x.ViewModel.AddCommentCommand) .Subscribe(_ => NewCommentViewController.Present(this, ViewModel.AddComment)) .AddTo(d); }); }
public void Render(RepositoryDetailedModel model) { if (model == null) { return; } Title = model.Name; var avatar = new Avatar(model.Logo).ToUrl(128); var root = new RootElement(Title) { UnevenRows = true }; HeaderView.SubText = string.IsNullOrWhiteSpace(model.Description) ? "Updated " + model.UtcLastUpdated.Humanize() : model.Description; HeaderView.SetImage(avatar, Images.RepoPlaceholder); RefreshHeaderView(); var stargazersCommand = ViewModel.GoToStargazersCommand; var split = new SplitButtonElement(); split.AddButton("Watchers", model.FollowersCount.ToString(), () => stargazersCommand.Execute(null)); split.AddButton("Forks", model.ForkCount.ToString()); split.AddButton("Branches", ViewModel.Branches?.Count.ToString() ?? "-"); var sec1 = new Section(); _split1.Button1.Image = model.IsPrivate ? AtlassianIcon.Locked.ToImage() : AtlassianIcon.Unlocked.ToImage(); _split1.Button1.Text = model.IsPrivate ? "Private" : "Public"; _split1.Button2.Text = string.IsNullOrEmpty(model.Language) ? "N/A" : model.Language; sec1.Add(_split1); _split3.Button1.Text = model.Scm.ApplyCase(LetterCasing.Title); _split3.Button2.Text = "Issues".ToQuantity(ViewModel.Issues); sec1.Add(_split3); _split2.Button1.Text = (model.UtcCreatedOn).ToString("MM/dd/yy"); _split2.Button2.Text = model.Size.Bytes().ToString("#.##"); sec1.Add(_split2); var owner = new StyledStringElement("Owner", model.Owner) { Image = AtlassianIcon.User.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; owner.Tapped += () => ViewModel.GoToOwnerCommand.Execute(null); sec1.Add(owner); if (model.ForkOf != null) { var parent = new StyledStringElement("Forked From", model.ForkOf.Name) { Image = AtlassianIcon.Devtoolsfork.ToImage(), Accessory = UITableViewCellAccessory.DisclosureIndicator }; parent.Tapped += () => ViewModel.GoToForkParentCommand.Execute(model.ForkOf); sec1.Add(parent); } var events = new StyledStringElement("Events", () => ViewModel.GoToEventsCommand.Execute(null), AtlassianIcon.Blogroll.ToImage()); var sec2 = new Section { events }; if (model.HasWiki) { sec2.Add(new StyledStringElement("Wiki", () => ViewModel.GoToWikiCommand.Execute(null), AtlassianIcon.Edit.ToImage())); } if (model.HasIssues) { sec2.Add(new StyledStringElement("Issues", () => ViewModel.GoToIssuesCommand.Execute(null), AtlassianIcon.Flag.ToImage())); } if (ViewModel.HasReadme) { sec2.Add(new StyledStringElement("Readme", () => ViewModel.GoToReadmeCommand.Execute(null), AtlassianIcon.Pagedefault.ToImage())); } var sec3 = new Section { new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), AtlassianIcon.Devtoolscommit.ToImage()), new StyledStringElement("Pull Requests", () => ViewModel.GoToPullRequestsCommand.Execute(null), AtlassianIcon.Devtoolspullrequest.ToImage()), new StyledStringElement("Source", () => ViewModel.GoToSourceCommand.Execute(null), AtlassianIcon.Filecode.ToImage()), }; root.Add(new[] { new Section { split }, sec1, sec2, sec3 }); if (!String.IsNullOrEmpty(ViewModel.Repository.Website)) { root.Add(new Section { new StyledStringElement("Website", () => ViewModel.GoToUrlCommand.Execute(ViewModel.Repository.Website), AtlassianIcon.Homepage.ToImage()) }); } Root = root; }
public Control view() { Control v = new HeaderView(); v.DataContext = this; return v; }
public void Render() { if (ViewModel.PullRequest == null) { return; } var avatarUrl = ViewModel.PullRequest.Author?.Links?.Avatar?.Href; HeaderView.Text = ViewModel.PullRequest.Title; HeaderView.SubText = "Updated " + ViewModel.PullRequest.UpdatedOn.Humanize(); HeaderView.SetImage(new Avatar(avatarUrl).ToUrl(128), Images.Avatar); RefreshHeaderView(); var split = new SplitButtonElement(); split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString()); split.AddButton("Participants", ViewModel.PullRequest.Participants.Count.ToString()); var root = new RootElement(Title); root.Add(new Section { split }); var secDetails = new Section(); if (!string.IsNullOrWhiteSpace(ViewModel.Description)) { if (_descriptionElement == null) { _descriptionElement = new WebElement("description"); _descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; } _descriptionElement.LoadContent(new MarkdownRazorView { Model = ViewModel.Description }.GenerateString()); secDetails.Add(_descriptionElement); } var merged = ViewModel.Merged; _split1.Button1.Text = ViewModel.PullRequest.CreatedOn.ToString("MM/dd/yy"); _split1.Button2.Text = merged ? "Merged" : "Not Merged"; secDetails.Add(_split1); secDetails.Add(new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), AtlassianIcon.Devtoolscommit.ToImage())); root.Add(secDetails); if (!merged) { Action mergeAction = async() => { try { await this.DoWorkAsync("Merging...", ViewModel.Merge); } catch (Exception e) { MonoTouch.Utilities.ShowAlert("Unable to Merge", e.Message); } }; root.Add(new Section { new StyledStringElement("Merge", mergeAction, AtlassianIcon.Approve.ToImage()) }); } var comments = ViewModel.Comments .Where(x => !string.IsNullOrEmpty(x.Content.Raw) && x.Inline == null) .OrderBy(x => (x.CreatedOn)) .Select(x => { var name = x.User.DisplayName ?? x.User.Username ?? "Unknown"; var avatar = new Avatar(x.User.Links?.Avatar?.Href); return(new CommentViewModel(name, x.Content.Html, x.CreatedOn.Humanize(), avatar.ToUrl())); }).ToList(); if (comments.Count > 0) { if (_commentsElement == null) { _commentsElement = new WebElement("comments"); _commentsElement.UrlRequested = ViewModel.GoToUrlCommand.Execute; } _commentsElement.LoadContent(new CommentsRazorView { Model = comments.ToList() }.GenerateString()); root.Add(new Section { _commentsElement }); } var addComment = new StyledStringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() }; addComment.Tapped += AddCommentTapped; root.Add(new Section { addComment }); Root = root; }