Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Issue #" + ViewModel.Id;
            HeaderView.SetImage(null, Images.Avatar);

            ViewModel.Bind(x => x.Issue).Subscribe(_ => RenderIssue());
            ViewModel.BindCollection(x => x.Comments).Subscribe(_ => RenderComments());

            var compose = NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Compose)
            {
                Enabled = false
            };

            OnActivation(d => d(compose.GetClickedObservable().BindCommand(ViewModel.GoToEditCommand)));
        }
Esempio n. 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Issue #" + ViewModel.Id;
            HeaderView.SetImage(null, Images.Avatar);

            _descriptionElement = new WebElement("description_webview");
            _descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.Execute;

            _commentsElement = new WebElement("body_webview");
            _commentsElement.UrlRequested = ViewModel.GoToUrlCommand.Execute;

            NavigationItem.RightBarButtonItem         = new UIBarButtonItem(UIBarButtonSystemItem.Compose, (s, e) => ViewModel.GoToEditCommand.Execute(null));
            NavigationItem.RightBarButtonItem.Enabled = false;
            ViewModel.Bind(x => x.Issue, RenderIssue);
            ViewModel.BindCollection(x => x.Comments, (e) => RenderComments());
        }
Esempio n. 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _header = new HeaderView();

            var content = System.IO.File.ReadAllText("WebCell/body.html", System.Text.Encoding.UTF8);

            _descriptionElement = new WebElement(content, "description_webview", false);
            _descriptionElement.UrlRequested = ViewModel.GoToUrlCommand.Execute;

            var content2 = System.IO.File.ReadAllText("WebCell/comments.html", System.Text.Encoding.UTF8);

            _commentsElement = new WebElement(content2, "body_webview", true);
            _commentsElement.UrlRequested = ViewModel.GoToUrlCommand.Execute;

            NavigationItem.RightBarButtonItem         = new UIBarButtonItem(UIBarButtonSystemItem.Compose, (s, e) => ViewModel.GoToEditCommand.Execute(null));
            NavigationItem.RightBarButtonItem.Enabled = false;
            ViewModel.Bind(x => x.Issue, RenderIssue);
            ViewModel.BindCollection(x => x.Comments, (e) => RenderComments());
        }
Esempio n. 4
0
        public IssueViewController(string user, string slug, ulong id)
            : base(false)
        {
            Title     = "Issue #" + id;
            ViewModel = new IssueViewModel(user, slug, id);

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(NavigationButton.Create(Theme.CurrentTheme.EditButton, () => {
                var editController = new IssueEditViewController(ViewModel.Username, ViewModel.Repository)
                {
                    ExistingIssue = ViewModel.Issue,
                    Title         = "Edit Issue",
                    Success       = EditingComplete,
                };
                NavigationController.PushViewController(editController, true);
            }));
            NavigationItem.RightBarButtonItem.Enabled = false;

            ViewModel.Bind(x => x.Issue, RenderIssue);
            ViewModel.BindCollection(x => x.Comments, (e) => RenderComments());

            var path = System.IO.Path.Combine(NSBundle.MainBundle.BundlePath, "Issue.html");

            LoadFile(path);
        }
Esempio n. 5
0
        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));

                var model    = new MarkdownModel(ViewModel.MarkdownDescription, (int)UIFont.PreferredSubheadline.PointSize, true);
                var markdown = new MarkdownWebView {
                    Model = model
                };
                var html = markdown.GenerateString();
                _descriptionElement.SetValue(string.IsNullOrEmpty(ViewModel.MarkdownDescription) ? null : html);

                HeaderView.Text    = x.Title;
                HeaderView.SubText = "Updated " + x.UpdatedAt.Humanize();
                HeaderView.SetImage(x.User?.AvatarUrl, Images.Avatar);
                RefreshHeaderView();

                Render();
            });

            ViewModel.BindCollection(x => x.Comments).Subscribe(_ => RenderComments());
            ViewModel.BindCollection(x => x.Events).Subscribe(_ => RenderComments());
            ViewModel.Bind(x => x.ShouldShowPro).Subscribe(x => {
                if (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));
            });
        }
Esempio n. 6
0
        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());
        }