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 });
        }
예제 #2
0
        protected void UpdateView()
        {
            var root = new RootElement(Title) { UnevenRows = true };
            var section = new Section();
            root.Add(section);

            var desc = new MultilinedElement("Description") { Value = ViewModel.Description };
            desc.Tapped += ChangeDescription;
            section.Add(desc);

            var pub = new TrueFalseElement("Public", ViewModel.Public, (e) => ViewModel.Public = e.Value); 
            section.Add(pub);

            var fileSection = new Section();
            root.Add(fileSection);

            foreach (var file in ViewModel.Files.Keys)
            {
                var key = file;
                if (string.IsNullOrEmpty(ViewModel.Files[file]))
                    continue;

                var size = System.Text.Encoding.UTF8.GetByteCount(ViewModel.Files[file]);
                var el = new StyledStringElement(file, size + " bytes", UITableViewCellStyle.Subtitle) { Accessory = UITableViewCellAccessory.DisclosureIndicator };
                el.Tapped += () => {
                    if (!ViewModel.Files.ContainsKey(key))
                        return;
                    var createController = new ModifyGistFileController(key, ViewModel.Files[key]);
                    createController.Save = (name, content) => {

                        if (string.IsNullOrEmpty(name))
                            throw new InvalidOperationException("Please enter a name for the file");

                        //If different name & exists somewhere else
                        if (!name.Equals(key) && ViewModel.Files.ContainsKey(name))
                            throw new InvalidOperationException("A filename by that type already exists");

                        ViewModel.Files.Remove(key);
                        ViewModel.Files[name] = content;
                        ViewModel.Files = ViewModel.Files; // Trigger refresh
                    };

                    NavigationController.PushViewController(createController, true);
                };
                fileSection.Add(el);
            }

            fileSection.Add(new StyledStringElement("Add New File", AddFile));

            Root = root;
        }
        protected override void OnRender()
        {
            var model = (ChangesetModel)Model;
            var sec = new Section();
            _header.Subtitle = "Commited " + (model.Utctimestamp).ToDaysAgo();

            var d = new MultilinedElement(model.Author, model.Message);
            sec.Add(d);

            if (Repo != null)
            {
                var repo = new StyledElement(Repo.Name, Images.Repo) {
                    Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
                    Lines = 1,
                    Font = StyledElement.DefaultDetailFont,
                    TextColor = StyledElement.DefaultDetailColor,
                };
                repo.Tapped += () => NavigationController.PushViewController(new RepositoryInfoController(Repo), true);
                sec.Add(repo);
            }

            var sec2 = new Section();

            model.Files.ForEach(x =>
                                {
                var file = x.File.Substring(x.File.LastIndexOf('/') + 1);
                var sse = new SubcaptionElement(file, x.Type)
                { Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
                    LineBreakMode = MonoTouch.UIKit.UILineBreakMode.TailTruncation,
                    Lines = 1 };
                sse.Tapped += () => {
                    string parent = null;
                    if (model.Parents != null && model.Parents.Count > 0)
                        parent = model.Parents[0];

                    var type = x.Type.Trim().ToLower();
                    NavigationController.PushViewController(new ChangesetDiffController(User, Slug, model.Node, parent, x.File)
                                                            { Removed = type.Equals("removed"), Added = type.Equals("added") }, true);
                };
                sec2.Add(sse);
            });

            _header.SetNeedsDisplay();
            var root = new RootElement(Title) { UnevenRows = Root.UnevenRows };
            root.Add(new [] { new Section(_header), sec, sec2 });
            Root = root;
        }
예제 #4
0
        private void Render()
        {
            var section = new Section();
            section.AddAll(_items.Select(item =>
            {
                var el = new MultilinedElement(item.Name + " (" + item.Price + ")", item.Description);
                if (_features.IsActivated(item.Id))
                {
                    el.Accessory = MonoTouch.UIKit.UITableViewCellAccessory.Checkmark;
                }
                else
                {
                    el.Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator;
                    el.Tapped += () => Tapped(item);
                }

                return el;
            }));

            var root = new RootElement(Title) { UnevenRows = true };
            root.Add(section);
            Root = root;
        }
        private void PopulateRoot()
        {
            _title = new InputElement("Title", string.Empty, string.Empty);

            _assignedTo = new StyledElement("Responsible", Unassigned, UITableViewCellStyle.Value1)
            {
                Accessory = UITableViewCellAccessory.DisclosureIndicator,
            };
            _assignedTo.Tapped += () =>
            {
                var privileges = new PrivilegesController
                                     {
                                         Username = Username,
                                         RepoSlug = RepoSlug,
                                         Primary = new UserModel { Username = Username },
                                         Title = _assignedTo.Caption,
                                     };
                privileges.SelectedItem += obj =>
                {
                    _assignedTo.Value = obj.Username;
                    NavigationController.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(privileges, true);
            };

            _issueType = CreateEnumElement("Issue Type", Kinds[0], Kinds);
            _priority = CreateEnumElement("Priority", Priorities[0], Priorities);

            _content = new MultilinedElement("Description");
            _content.Tapped += () =>
            {
                var composer = new Composer { Title = "Issue Description", Text = _content.Value, ActionButtonText = "Save" };
                composer.NewComment(this, () =>
                {
                    var text = composer.Text;
                    _content.Value = text;
                    composer.CloseComposer();
                });
            };

            var root = new RootElement(Title) { new Section { _title, _assignedTo, _issueType, _priority }, new Section { _content } };

            //See if it's an existing issue or not...
            if (ExistingIssue != null)
            {
                _title.Value = ExistingIssue.Title;
                if (ExistingIssue.Responsible != null)
                    _assignedTo.Value = ExistingIssue.Responsible.Username;
                _issueType.Value = ExistingIssue.Metadata.Kind;
                _priority.Value = ExistingIssue.Priority;
                if (!string.IsNullOrEmpty(ExistingIssue.Content))
                    _content.Value = ExistingIssue.Content;

                _status = CreateEnumElement("Status", ExistingIssue.Status, Statuses);

                //Insert the status thing inbetween title and assigned to elements
                root[0].Insert(1, _status);

                var deleteButton = new StyledElement("Delete Issue", () =>
                {
                    var alert = new UIAlertView
                                    {
                                        Title = "Are you sure?",
                                        Message = "You are about to permanently delete issue #" + ExistingIssue.LocalId + "."
                                    };
                    alert.CancelButtonIndex = alert.AddButton("Cancel");
                    var ok = alert.AddButton("Delete");

                    alert.Clicked += (sender, e) =>
                    {
                        if (e.ButtonIndex == ok)
                            DeleteIssue();
                    };

                    alert.Show();
                }, Images.BinClosed)
                {
                    Accessory = UITableViewCellAccessory.None,
                    BackgroundColor = UIColor.FromPatternImage(Images.TableCellRed),
                    TextColor = UIColor.FromRGB(0.9f, 0.30f, 0.30f)
                };
                root.Add(new Section { deleteButton });
            }

            Root = root;
        }
예제 #6
0
		public override void ViewDidLoad()
		{
			Title = "New Issue";

			base.ViewDidLoad();

			_hud = this.CreateHud();
			var vm = (IssueAddViewModel)ViewModel;

			NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => {
				View.EndEditing(true);
				vm.SaveCommand.Execute(null);
			});

			var title = new InputElement("Title", string.Empty, string.Empty);
			title.Changed += (object sender, EventArgs e) => vm.Title = title.Value;

			var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
			assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			assignedTo.Tapped += () => vm.GoToAssigneeCommand.Execute(null);

			var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1);
			milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			milestone.Tapped += () => vm.GoToMilestonesCommand.Execute(null);

			var labels = new StyledStringElement("Labels".t(), "None", UITableViewCellStyle.Value1);
			labels.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			labels.Tapped += () => vm.GoToLabelsCommand.Execute(null);

			var content = new MultilinedElement("Description");
			content.Tapped += () =>
			{
                var composer = new MarkdownComposerViewController { Title = "Issue Description", Text = content.Value };
				composer.NewComment(this, (text) => {
					vm.Content = text;
					composer.CloseComposer();
				});
			};

			vm.Bind(x => x.Title, x => title.Value = x);
			vm.Bind(x => x.Content, x => content.Value = x);
			vm.Bind(x => x.AssignedTo, x => {
				assignedTo.Value = x == null ? "Unassigned" : x.Login;
				Root.Reload(assignedTo, UITableViewRowAnimation.None);
			});
			vm.Bind(x => x.Milestone, x => {
				milestone.Value = x == null ? "None" : x.Title;
				Root.Reload(milestone, UITableViewRowAnimation.None);
			});
			vm.BindCollection(x => x.Labels, x => {
				labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name));
				Root.Reload(labels, UITableViewRowAnimation.None);
			});

			vm.Bind(x => x.IsSaving, x =>
			{
				if (x)
					_hud.Show("Saving...");
				else
					_hud.Hide();
			});

			Root = new RootElement(Title) { new Section { title, assignedTo, milestone, labels }, new Section { content } };
		}
예제 #7
0
//        private void ForkRepository()
//        {
//            var repoModel = Controller.Model.RepositoryModel;
//            var alert = new UIAlertView();
//            alert.Title = "Fork".t();
//            alert.Message = "What would you like to name your fork?".t();
//            alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;
//            var forkButton = alert.AddButton("Fork!".t());
//            var cancelButton = alert.AddButton("Cancel".t());
//            alert.CancelButtonIndex = cancelButton;
//            alert.DismissWithClickedButtonIndex(cancelButton, true);
//            alert.GetTextField(0).Text = repoModel.Name;
//            alert.Clicked += (object sender2, UIButtonEventArgs e2) => {
//                if (e2.ButtonIndex == forkButton)
//                {
//                    var text = alert.GetTextField(0).Text;
//                    this.DoWork("Forking...".t(), () => {
//                        //var fork = Application.Client.Users[model.Owner.Login].Repositories[model.Name].Fo(text);
//                        BeginInvokeOnMainThread(() => {
//                            //  NavigationController.PushViewController(new RepositoryInfoViewController(fork), true);
//                        });
//                    }, (ex) => {
//                        //We typically get a 'BAD REQUEST' but that usually means that a repo with that name already exists
//                        MonoTouch.Utilities.ShowAlert("Unable to fork".t(), "A repository by that name may already exist in your collection or an internal error has occured.".t());
//                    });
//                }
//            };
//
//            alert.Show();
//        }

        public void Render(RepositoryModel model)
        {
            Title = model.Name;
            var root = new RootElement(Title) { UnevenRows = true };
            _header.Subtitle = "Updated ".t() + (model.UpdatedAt).ToDaysAgo();
			_header.ImageUri = (model.Fork ? Images.GitHubRepoForkUrl : Images.GitHubRepoUrl).AbsoluteUri;

            root.Add(new Section(_header));
            var sec1 = new Section();

            if (!string.IsNullOrEmpty(model.Description) && !string.IsNullOrWhiteSpace(model.Description))
            {
                var element = new MultilinedElement(model.Description)
                {
                    BackgroundColor = UIColor.White,
                    CaptionColor = Theme.CurrentTheme.MainTitleColor, 
                    ValueColor = Theme.CurrentTheme.MainTextColor
                };
                element.CaptionColor = element.ValueColor;
                element.CaptionFont = element.ValueFont;
                sec1.Add(element);
            }

            sec1.Add(new SplitElement(new SplitElement.Row {
                Text1 = model.Private ? "Private".t() : "Public".t(),
                Image1 = model.Private ? Images.Locked : Images.Unlocked,
				Text2 = model.Language ?? "N/A",
                Image2 = Images.Language
            }));


            //Calculate the best representation of the size
            string size;
            if (model.Size / 1024f < 1)
                size = string.Format("{0:0.##}KB", model.Size);
            else if ((model.Size / 1024f / 1024f) < 1)
                size = string.Format("{0:0.##}MB", model.Size / 1024f);
            else
                size = string.Format("{0:0.##}GB", model.Size / 1024f / 1024f);

            sec1.Add(new SplitElement(new SplitElement.Row {
                Text1 = model.OpenIssues + (model.OpenIssues == 1 ? " Issue".t() : " Issues".t()),
                Image1 = Images.Flag,
                Text2 = model.Forks.ToString() + (model.Forks == 1 ? " Fork".t() : " Forks".t()),
                Image2 = Images.Fork
            }));

            sec1.Add(new SplitElement(new SplitElement.Row {
                Text1 = (model.CreatedAt).ToString("MM/dd/yy"),
                Image1 = Images.Create,
                Text2 = size,
                Image2 = Images.Size
            }));

            var owner = new StyledStringElement("Owner".t(), model.Owner.Login) { Image = Images.Person,  Accessory = UITableViewCellAccessory.DisclosureIndicator };
			owner.Tapped += () => ViewModel.GoToOwnerCommand.Execute(null);
            sec1.Add(owner);

            if (model.Parent != null)
            {
                var parent = new StyledStringElement("Forked From".t(), model.Parent.FullName) { Image = Images.Fork,  Accessory = UITableViewCellAccessory.DisclosureIndicator };
				parent.Tapped += () => ViewModel.GoToForkParentCommand.Execute(model.Parent);
                sec1.Add(parent);
            }

			var followers = new StyledStringElement("Stargazers".t(), "" + model.StargazersCount) { Image = Images.Star, Accessory = UITableViewCellAccessory.DisclosureIndicator };
			followers.Tapped += () => ViewModel.GoToStargazersCommand.Execute(null);
            sec1.Add(followers);

			var events = new StyledStringElement("Events".t(), () => ViewModel.GoToEventsCommand.Execute(null), Images.Event);
            var sec2 = new Section { events };

            if (model.HasIssues)
				sec2.Add(new StyledStringElement("Issues".t(), () => ViewModel.GoToIssuesCommand.Execute(null), Images.Flag));

            if (ViewModel.Readme != null)
				sec2.Add(new StyledStringElement("Readme".t(), () => ViewModel.GoToReadmeCommand.Execute(null), Images.File));

            var sec3 = new Section
            {
				new StyledStringElement("Commits".t(), () => ViewModel.GoToCommitsCommand.Execute(null), Images.Commit),
				new StyledStringElement("Pull Requests".t(), () => ViewModel.GoToPullRequestsCommand.Execute(null), Images.Hand),
				new StyledStringElement("Source".t(), () => ViewModel.GoToSourceCommand.Execute(null), Images.Script),
            };

            root.Add(new[] { sec1, sec2, sec3 });

            if (!string.IsNullOrEmpty(model.Homepage))
            {
				var web = new StyledStringElement("Website".t(), () => ViewModel.GoToUrlCommand.Execute(model.Homepage), Images.Webpage);
                root.Add(new Section { web });
            }

            Root = root;
        }
예제 #8
0
        public void Render()
        {
            if (ViewModel.PullRequest == null)
                return;

            var root = new RootElement(Title);
            _header.Title = ViewModel.PullRequest.Title;
            _header.Subtitle = "Updated " + (ViewModel.PullRequest.UpdatedAt).ToDaysAgo();
            _header.SetNeedsDisplay();
            root.Add(new Section(_header));

            var secDetails = new Section();
            if (!string.IsNullOrEmpty(ViewModel.PullRequest.Body))
            {
                var desc = new MultilinedElement(ViewModel.PullRequest.Body.Trim())
                {
                    BackgroundColor = UIColor.White,
                    CaptionColor = Theme.CurrentTheme.MainTitleColor,
                    ValueColor = Theme.CurrentTheme.MainTextColor
                };
                desc.CaptionFont = desc.ValueFont;
                desc.CaptionColor = desc.ValueColor;
                secDetails.Add(desc);
            }

            var merged = (ViewModel.PullRequest.Merged != null && ViewModel.PullRequest.Merged.Value);

            _split1.Value.Text1 = ViewModel.PullRequest.State;
            _split1.Value.Text2 = merged ? "Merged" : "Not Merged";
            secDetails.Add(_split1);
            root.Add(secDetails);

            root.Add(new Section {
                new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), Images.Commit),
                new StyledStringElement("Files", () => ViewModel.GoToFilesCommand.Execute(null), Images.File),
            });

            if (!merged)
            {
                MonoTouch.Foundation.NSAction mergeAction = async () =>
                {
                    try
                    {
                        await this.DoWorkAsync("Merging...", ViewModel.Merge);
                    }
                    catch (Exception e)
                    {
                        MonoTouch.Utilities.ShowAlert("Unable to Merge", e.Message);
                    }
                };

                if (ViewModel.PullRequest.Mergable == null)
                {
                    var el = new StyledStringElement("Merge".t(), mergeAction, Images.Fork);
                    root.Add(new Section(null, "The mergable state is unknown and merging may not be successful.") { el });
                }
                else if (ViewModel.PullRequest.Mergable.Value)
                {
                    root.Add(new Section { new StyledStringElement("Merge".t(), mergeAction, Images.Fork) });
                }
                else
                {
                    root.Add(new Section { new StyledStringElement("Unable to merge!".t()) { Image = Images.Fork } });
                }
            }

            if (ViewModel.Comments.Items.Count > 0)
            {
                var commentsSec = new Section();
                ViewModel.Comments.OrderBy(x => (x.CreatedAt)).ToList().ForEach(x => {
                    if (!string.IsNullOrEmpty(x.Body))
                        commentsSec.Add(new CommentElement {
                            Name = x.User.Login,
                            Time = x.CreatedAt.ToDaysAgo(),
                            String = x.Body,
                            Image = Theme.CurrentTheme.AnonymousUserImage,
                            ImageUri = new Uri(x.User.AvatarUrl),
                            BackgroundColor = UIColor.White,
                        });
                });

                //Load more if there's more comments
            //                if (model.MoreComments != null)
            //                {
            //                    var loadMore = new PaginateElement("Load More".t(), "Loading...".t(),
            //                                                       e => this.DoWorkNoHud(() => model.MoreComments(),
            //                                          x => Utilities.ShowAlert("Unable to load more!".t(), x.Message))) { AutoLoadOnVisible = false, Background = false };
            //                    commentsSec.Add(loadMore);
            //                }

                if (commentsSec.Elements.Count > 0)
                    root.Add(commentsSec);
            }

            var addComment = new StyledStringElement("Add Comment") { Image = Images.Pencil };
            addComment.Tapped += AddCommentTapped;
            root.Add(new Section { addComment });
            Root = root;

            //            if (_scrollToLastComment && _comments.Elements.Count > 0)
            //            {
            //                TableView.ScrollToRow(NSIndexPath.FromRowSection(_comments.Elements.Count - 1, 2), UITableViewScrollPosition.Top, true);
            //                _scrollToLastComment = false;
            //            }
        }
        protected override void OnRender()
        {
            var model = Model;
            var root = new RootElement(Title) { UnevenRows = true };
            _header.Subtitle = "Updated " + (model.UtcLastUpdated).ToDaysAgo();

            if (!string.IsNullOrEmpty(model.Logo))
                _header.Image = ImageLoader.DefaultRequestImage(new Uri(model.LargeLogo(64)), this);

            root.Add(new Section(_header));
            var sec1 = new Section();

            if (!string.IsNullOrEmpty(model.Description) && !string.IsNullOrWhiteSpace(model.Description))
            {
                var element = new MultilinedElement(model.Description)
                {
                    BackgroundColor = UIColor.White
                };
                element.CaptionColor = element.ValueColor;
                element.CaptionFont = element.ValueFont;
                sec1.Add(element);
            }

            sec1.Add(new SplitElement(new SplitElement.Row
                                      {
                Text1 = model.Scm,
                Image1 = Images.ScmType,
                Text2 = model.Language,
                Image2 = Images.Language
            }));

            //Calculate the best representation of the size
            string size;
            if (model.Size / 1024f < 1)
                size = string.Format("{0}B", model.Size);
            else if ((model.Size / 1024f / 1024f) < 1)
                size = string.Format("{0:0.##}KB", model.Size / 1024f);
            else if ((model.Size / 1024f / 1024f / 1024f) < 1)
                size = string.Format("{0:0.##}MB", model.Size / 1024f / 1024f);
            else
                size = string.Format("{0:0.##}GB", model.Size / 1024f / 1024f / 1024f);

            sec1.Add(new SplitElement(new SplitElement.Row
                                      {
                Text1 = model.IsPrivate ? "Private" : "Public",
                Image1 = model.IsPrivate ? Images.Locked : Images.Unlocked,
                Text2 = size,
                Image2 = Images.Size
            }));

            sec1.Add(new SplitElement(new SplitElement.Row
                                      {
                Text1 = (model.UtcCreatedOn).ToString("MM/dd/yy"),
                Image1 = Images.Create,
                Text2 = model.ForkCount.ToString() + (model.ForkCount == 1 ? " Fork" : " Forks"),
                Image2 = Images.Fork
            }));

            var owner = new StyledElement("Owner", model.Owner) { Accessory = UITableViewCellAccessory.DisclosureIndicator };
            owner.Tapped += () => NavigationController.PushViewController(new ProfileController(model.Owner), true);
            sec1.Add(owner);
            var followers = new StyledElement("Followers", "" + model.FollowersCount) { Accessory = UITableViewCellAccessory.DisclosureIndicator };
            followers.Tapped += () => NavigationController.PushViewController(new RepoFollowersController(model.Owner, model.Slug), true);
            sec1.Add(followers);

            var events = new StyledElement("Events", () => NavigationController.PushViewController(new RepoEventsController(model.Owner, model.Slug), true), Images.Buttons.Event);

            var sec2 = new Section { events };

            if (model.HasIssues)
                sec2.Add(new StyledElement("Issues", () => NavigationController.PushViewController(new IssuesController(model.Owner, model.Slug), true), Images.Buttons.Flag));

            if (model.HasWiki)
                sec2.Add(new StyledElement("Wiki", () => NavigationController.PushViewController(new WikiInfoController(model.Owner, model.Slug), true), Images.Pencil));

            var sec3 = new Section
            {
                new StyledElement("Changes", () => NavigationController.PushViewController(new ChangesetController(model.Owner, model.Slug), true), Images.Changes),
                new StyledElement("Branches", () => NavigationController.PushViewController(new BranchController(model.Owner, model.Slug), true), Images.Branch),
                new StyledElement("Tags", () => NavigationController.PushViewController(new TagController(model.Owner, model.Slug), true), Images.Tag)
            };

            root.Add(new[] { sec1, sec2, sec3 });

            if (!string.IsNullOrEmpty(model.Website))
            {
                var web = new StyledElement("Website", () => UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(model.Website)), Images.Webpage);
                root.Add(new Section { web });
            }

            Root = root;
        }
예제 #10
0
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			_hud = this.CreateHud();

			NavigationItem.RightBarButtonItem = new UIBarButtonItem(Theme.CurrentTheme.SaveButton, UIBarButtonItemStyle.Plain, (s, e) => {
				View.EndEditing(true);
				ViewModel.SaveCommand.Execute(null);
			});

			var title = new InputElement("Title", string.Empty, string.Empty) { TextAlignment = UITextAlignment.Right };
			title.Changed += (object sender, EventArgs e) => ViewModel.Title = title.Value;

			var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);
			assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			assignedTo.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null);

			var kind = new StyledStringElement("Issue Type", ViewModel.Kind, UITableViewCellStyle.Value1);
			kind.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			kind.Tapped += () =>
			{
				var ctrl = new IssueAttributesView(IssueModifyViewModel.Kinds, ViewModel.Kind) { Title = "Issue Type" };
				ctrl.SelectedValue = x => ViewModel.Kind = x.ToLower();
				NavigationController.PushViewController(ctrl, true);
			};

			var priority = new StyledStringElement("Priority", ViewModel.Priority, UITableViewCellStyle.Value1);
			priority.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			priority.Tapped += () => 
			{
				var ctrl = new IssueAttributesView(IssueModifyViewModel.Priorities, ViewModel.Priority) { Title = "Priority" };
				ctrl.SelectedValue = x => ViewModel.Priority = x.ToLower();
				NavigationController.PushViewController(ctrl, true);
			};

			var milestone = new StyledStringElement("Milestone".t(), "None", UITableViewCellStyle.Value1);
			milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			milestone.Tapped += () => ViewModel.GoToMilestonesCommand.Execute(null);

			var component = new StyledStringElement("Component".t(), "None", UITableViewCellStyle.Value1);
			component.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            component.Tapped += () => ViewModel.GoToComponentsCommand.Execute(null);

			var version = new StyledStringElement("Version".t(), "None", UITableViewCellStyle.Value1);
			version.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            version.Tapped += () => ViewModel.GoToVersionsCommand.Execute(null);

			var content = new MultilinedElement("Description");
			content.Tapped += () =>
			{
                var composer = new Composer { Title = "Issue Description", Text = content.Value };
				composer.NewComment(this, (text) => {
					ViewModel.Content = text;
					composer.CloseComposer();
				});
			};

			ViewModel.Bind(x => x.IsSaving, x =>
			{
				if (x)
					_hud.Show("Saving...");
				else
					_hud.Hide();
			});

			Root = new RootElement(Title) { new Section { title, assignedTo, kind, priority }, new Section { milestone, component, version }, new Section { content } };

			ViewModel.Bind(x => x.Title, x => {
				title.Value = x;
				Root.Reload(title, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.AssignedTo, x => {
				assignedTo.Value = x == null ? "Unassigned" : x.Username;
				Root.Reload(assignedTo, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Kind, x => {
				kind.Value = x;
				Root.Reload(kind, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Priority, x => {
				priority.Value = x;
				Root.Reload(priority, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Milestone, x => {
				milestone.Value = x ?? "None";
				Root.Reload(milestone, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Component, x => {
				component.Value = x ?? "None";
				Root.Reload(component, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Version, x => {
				version.Value = x ?? "None";
				Root.Reload(version, UITableViewRowAnimation.None);
			}, true);

			ViewModel.Bind(x => x.Content, x => {
				content.Value = x;
				Root.Reload(content, UITableViewRowAnimation.None);
			}, true);
		}
예제 #11
0
        public void Render()
        {
            if (ViewModel.PullRequest == null)
                return;

            var root = new RootElement(Title);
            _header.Title = ViewModel.PullRequest.Title;
			_header.Subtitle = "Updated " + (ViewModel.PullRequest.UpdatedOn).ToDaysAgo();
            _header.SetNeedsDisplay();
            root.Add(new Section(_header));

            var secDetails = new Section();
			if (!string.IsNullOrEmpty(ViewModel.PullRequest.Description))
            {
				var desc = new MultilinedElement(ViewModel.PullRequest.Description.Trim()) 
                { 
                    BackgroundColor = UIColor.White,
                    CaptionColor = Theme.CurrentTheme.MainTitleColor, 
                    ValueColor = Theme.CurrentTheme.MainTextColor
                };
                desc.CaptionFont = desc.ValueFont;
                desc.CaptionColor = desc.ValueColor;
                secDetails.Add(desc);
            }

			var merged = ViewModel.Merged;

            _split1.Value.Text1 = ViewModel.PullRequest.CreatedOn.ToString("MM/dd/yy");
            _split1.Value.Text2 = merged ? "Merged" : "Not Merged";
            secDetails.Add(_split1);
            root.Add(secDetails);

            root.Add(new Section {
				new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.Execute(null), Images.Commit),
            });

//            if (!merged)
//            {
//                MonoTouch.Foundation.NSAction 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".t(), mergeAction, Images.Fork) });
//            }


            if (ViewModel.Comments.Items.Count > 0)
            {
                var commentsSec = new Section();
                foreach (var x in ViewModel.Comments.Where(x => !string.IsNullOrEmpty(x.Content.Raw) && x.Inline == null).OrderBy(x => (x.CreatedOn)))
                {
                    commentsSec.Add(new CommentElement
                    {
                        Name = x.User.Username,
                        Time = x.CreatedOn.ToDaysAgo(),
                        String = x.Content.Raw,
                        Image = Theme.CurrentTheme.AnonymousUserImage,
                        ImageUri = new Uri(x.User.Links.Avatar.Href),
                        BackgroundColor = UIColor.White,
                    });
                }

                //Load more if there's more comments
//                if (model.MoreComments != null)
//                {
//                    var loadMore = new PaginateElement("Load More".t(), "Loading...".t(), 
//                                                       e => this.DoWorkNoHud(() => model.MoreComments(),
//                                          x => Utilities.ShowAlert("Unable to load more!".t(), x.Message))) { AutoLoadOnVisible = false, Background = false };
//                    commentsSec.Add(loadMore);
//                }

                if (commentsSec.Elements.Count > 0)
                    root.Add(commentsSec);
            }


            var addComment = new StyledStringElement("Add Comment") { Image = Images.Pencil };
            addComment.Tapped += AddCommentTapped;
            root.Add(new Section { addComment });
            Root = root;
        }
예제 #12
0
        protected void UpdateView()
        {
            var root = new RootElement(Title) { UnevenRows = true };
            var section = new Section();
            root.Add(section);

            var desc = new MultilinedElement("Description") { Value = _model.Description };
            desc.Tapped += ChangeDescription;
            section.Add(desc);

            var fileSection = new Section();
            root.Add(fileSection);

            foreach (var file in _model.Files.Keys)
            {
                var key = file;
                if (!_model.Files.ContainsKey(key) || _model.Files[file] == null || _model.Files[file].Content == null)
                    continue;

                var elName = key;
                if (_model.Files[key].Filename != null)
                    elName = _model.Files[key].Filename;

                var el = new FileElement(elName, key, _model.Files[key]);
                el.Tapped += () => {
                    if (!_model.Files.ContainsKey(key))
                        return;
                    var createController = new ModifyGistFileController(key, _model.Files[key].Content);
                    createController.Save = (name, content) => {

                        if (string.IsNullOrEmpty(name))
                            throw new InvalidOperationException("Please enter a name for the file");

                        //If different name & exists somewhere else
                        if (!name.Equals(key))
                            if (IsDuplicateName(name))
                                throw new InvalidOperationException("A filename by that type already exists");

                        if (_originalGist.Files.ContainsKey(key))
                            _model.Files[key] = new GistEditModel.File { Content = content, Filename = name };
                        else
                        {
                            _model.Files.Remove(key);
                            _model.Files[name] = new GistEditModel.File { Content = content };
                        }
                    };

                    NavigationController.PushViewController(createController, true);
                };
                fileSection.Add(el);
            }

            fileSection.Add(new StyledStringElement("Add New File", AddFile));

            Root = root;
        }