Beispiel #1
0
		public override void ViewDidLoad()
		{
			Title = "Edit Issue";

			base.ViewDidLoad();

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

            var delete = new StyledStringElement("Delete", () => ViewModel.DeleteCommand.Execute(null), AtlassianIcon.Delete.ToImage()) { BackgroundColor = UIColor.FromRGB(1.0f, 0.7f, 0.7f) };
            delete.Accessory = UITableViewCellAccessory.None;

            Root[0].Insert(1, UITableViewRowAnimation.None, status);
            Root.Insert(Root.Count, UITableViewRowAnimation.None, new Section { delete });

            ViewModel.Bind(x => x.Status, x => {
                status.Value = x;
                Root.Reload(status, UITableViewRowAnimation.None);
            }, true);
		}
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            HeaderView.SetImage(null, Images.Avatar);
            Title = ViewModel.Name;

            ViewModel.Bind(x => x.User, x =>
            {
                var name = x.FirstName + " " + x.LastName;
                HeaderView.SubText = string.IsNullOrWhiteSpace(name) ? x.Username : name;
                HeaderView.SetImage(new Avatar(x.Avatar).ToUrl(128), Images.Avatar);
                RefreshHeaderView();

                var followers = new StyledStringElement("Followers", () => ViewModel.GoToFollowersCommand.Execute(null), Images.Heart);
                var events = new StyledStringElement("Events", () => ViewModel.GoToEventsCommand.Execute(null), Images.Event);
                var organizations = new StyledStringElement("Groups", () => ViewModel.GoToGroupsCommand.Execute(null), Images.Group);
                var repos = new StyledStringElement("Repositories", () => ViewModel.GoToRepositoriesCommand.Execute(null), Images.Repo);
                var members = new StyledStringElement("Members", () => ViewModel.GoToMembersCommand.Execute(null), Images.Team);
                var midSec = new Section(new UIView(new CGRect(0, 0, 0, 20f))) { events, organizations, members, followers };
                Root = new RootElement(Title) { midSec, new Section { repos } };
            });
//          if (!ViewModel.IsLoggedInUser)
//              NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, (s, e) => ShowExtraMenu());
        }
Beispiel #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

			var vm = (GroupsViewModel) ViewModel;
			BindCollection(vm.Organizations, x =>
			{
				var e = new StyledStringElement(x.Name);
				e.Tapped += () => vm.GoToGroupCommand.Execute(x);
				return e;
			});
        }
Beispiel #4
0
		private void CreateTable()
		{
			var application = Mvx.Resolve<IApplicationService>();
			var vm = (SettingsViewModel)ViewModel;
			var currentAccount = application.Account;

			var showOrganizationsInEvents = new TrueFalseElement("Show Teams under Events", currentAccount.ShowTeamEvents, e =>
			{ 
				currentAccount.ShowTeamEvents = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var showOrganizations = new TrueFalseElement("List Teams & Groups in Menu", currentAccount.ExpandTeamsAndGroups, e =>
			{ 
				currentAccount.ExpandTeamsAndGroups = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var repoDescriptions = new TrueFalseElement("Show Repo Descriptions", currentAccount.RepositoryDescriptionInList, e =>
			{ 
				currentAccount.RepositoryDescriptionInList = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, UIKit.UITableViewCellStyle.Value1)
			{ 
				Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator,
			};
			startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);

			//Assign the root
			var root = new RootElement(Title);
            root.Add(new Section());
            root.Add(new Section { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
            root.Add(new Section { new StyledStringElement("Source Code", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://github.com/thedillonb/CodeBucket"))) });
            root.Add(new Section(String.Empty, "Thank you for downloading. Enjoy!")
            {
                new StyledStringElement("Follow On Twitter", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/Codebucketapp"))),
                new StyledStringElement("Rate This App", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codebucket/id551531422?mt=8"))),
                new StyledStringElement("App Version", NSBundle.MainBundle.InfoDictionary.ValueForKey(new NSString("CFBundleVersion")).ToString())
            });

            root.UnevenRows = true;
			Root = root;

		}
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var sec = new Section();
			foreach (var val in _values)
			{
				var capture = val;
				var el = new StyledStringElement(val);
				if (string.Equals(val, _selected, StringComparison.OrdinalIgnoreCase))
					el.Accessory = UIKit.UITableViewCellAccessory.Checkmark;
				el.Tapped += () => {
					if (SelectedValue != null)
                        SelectedValue(capture);
					NavigationController.PopViewController(true);
				};
				sec.Add(el);
			}

			Root = new RootElement(Title) { sec };
		}
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			var vm = (DefaultStartupViewModel)ViewModel;
			BindCollection(vm.StartupViews, x => {
				var e = new StyledStringElement(x);
				e.Tapped += () => vm.SelectedStartupView = x;
				if (string.Equals(vm.SelectedStartupView, x))
					e.Accessory = UITableViewCellAccessory.Checkmark;
				return e;
			}, true);

			vm.Bind(x => x.SelectedStartupView, x =>
			{
				if (Root.Count == 0)
					return;
				foreach (var m in Root[0].Elements.Cast<StyledStringElement>())
					m.Accessory = (string.Equals(m.Caption, x)) ? UITableViewCellAccessory.Checkmark : UITableViewCellAccessory.None;
				Root.Reload(Root[0], UITableViewRowAnimation.None);
			}, true);
		}
Beispiel #7
0
		private void CreateTable()
		{
			var application = Mvx.Resolve<IApplicationService>();
			var vm = (SettingsViewModel)ViewModel;
			var currentAccount = application.Account;

			var showOrganizationsInEvents = new TrueFalseElement("Show Teams under Events", currentAccount.ShowTeamEvents, e =>
			{ 
				currentAccount.ShowTeamEvents = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var showOrganizations = new TrueFalseElement("List Teams & Groups in Menu", currentAccount.ExpandTeamsAndGroups, e =>
			{ 
				currentAccount.ExpandTeamsAndGroups = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var repoDescriptions = new TrueFalseElement("Show Repo Descriptions", currentAccount.RepositoryDescriptionInList, e =>
			{ 
				currentAccount.RepositoryDescriptionInList = e.Value;
				application.Accounts.Update(currentAccount);
			});

			var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, UIKit.UITableViewCellStyle.Value1)
			{ 
				Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator,
			};
			startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);

			//Assign the root
			var root = new RootElement(Title);
			root.Add(new Section("Apperance") { showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView });
			Root = root;

		}
Beispiel #8
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;
        }
Beispiel #9
0
        private void UpdateValueOnSelect(string val)
        {
            StyledStringElement str = null;


            switch (actionSheet.Id)
            {
            case "Seller":
                str = Seller;
                searchReq.seller = str.Value;
                break;

            case "Type":
                str            = Type;
                searchReq.type = val;
                break;

            case "Model":
                str             = Model;
                searchReq.model = val;
                break;

            case "Make":
                Make.Value = val;
                UpdateModels();
                str            = Make;
                searchReq.make = val;
                break;

            case "Distance":
                str = Distance;
                val = val.Replace("miles", string.Empty).Trim();
                int.TryParse(val, out searchReq.distance);
                break;

            case "Trim":
                Trim.Value     = val;
                str            = Trim;
                searchReq.trim = val;
                break;

            case "Exterior":
                str = Exterior;
                searchReq.exteriorColor = val;
                break;

            case "Interior":
                str = Interior;
                searchReq.interiorColor = val;
                break;

            case "MileageTo":
                MileageTo.Value   = val;
                searchReq.mileage = searchReq.mileage == null ? new Range() : searchReq.mileage;
                int.TryParse(val, out searchReq.mileage.min);
                MileageTo.Accessory = UITableViewCellAccessory.Checkmark;
                Root.Reload(MileageTo, UITableViewRowAnimation.Automatic);
                break;

            case "MileageFrom":
                MileageFrom.Value = val;
                searchReq.mileage = searchReq.mileage == null ? new Range() : searchReq.mileage;
                int.TryParse(val, out searchReq.mileage.max);
                MileageFrom.Accessory = UITableViewCellAccessory.Checkmark;
                Root.Reload(MileageFrom, UITableViewRowAnimation.Automatic);
                break;

            case "PriceTo":
                PriceTo.Value   = val;
                searchReq.price = searchReq.price == null ? new Range() : searchReq.price;
                val             = val.Replace("$", string.Empty);
                int.TryParse(val, out searchReq.price.min);
                PriceTo.Accessory = UITableViewCellAccessory.Checkmark;
                Root.Reload(PriceTo, UITableViewRowAnimation.Automatic);
                break;

            case "PriceFrom":
                PriceFrom.Value = val;
                searchReq.price = searchReq.price == null ? new Range() : searchReq.price;
                val             = val.Replace("$", string.Empty);
                int.TryParse(val, out searchReq.price.max);
                PriceFrom.Accessory = UITableViewCellAccessory.Checkmark;
                Root.Reload(PriceFrom, UITableViewRowAnimation.Automatic);
                break;

            case "YearTo":
                YearTo.Value = val;
                UpdateMakes();
                searchReq.years = searchReq.years == null ? new Range() : searchReq.years;
                int.TryParse(val, out searchReq.years.min);
                YearTo.Accessory = UITableViewCellAccessory.Checkmark;
                Root.Reload(YearTo, UITableViewRowAnimation.Automatic);
                break;

            case "YearFrom":
                YearFrom.Value = val;
                UpdateMakes();
                searchReq.years = searchReq.years == null ? new Range() : searchReq.years;
                int.TryParse(val, out searchReq.years.max);
                YearFrom.Accessory = UITableViewCellAccessory.Checkmark;
                Root.Reload(YearFrom, UITableViewRowAnimation.Automatic);
                break;
            }

            //update
            if (str != null)
            {
                str.Value     = val;
                str.Accessory = UITableViewCellAccessory.Checkmark;
                Root.Reload(str, UITableViewRowAnimation.Automatic);
            }

            if (this.RequestUpdated != null)
            {
                this.RequestUpdated(this, new PostDataEvent {
                    Data = searchReq
                });
            }
        }
Beispiel #10
0
        public void RenderIssue()
        {
            if (ViewModel.Issue == null)
            {
                return;
            }

            NavigationItem.RightBarButtonItem.Enabled = true;

            var root = new RootElement(Title);

            _header.Title    = ViewModel.Issue.Title;
            _header.Subtitle = "Updated " + ViewModel.Issue.UtcLastUpdated.ToDaysAgo();
            root.Add(new Section(_header));


            var secDetails = new Section();

            if (!string.IsNullOrEmpty(ViewModel.Issue.Content))
            {
                _descriptionElement.Value = ViewModel.MarkdownDescription;
                secDetails.Add(_descriptionElement);
            }

            var split1 = new SplitElement(new SplitElement.Row {
                Image1 = Images.Cog, Image2 = Images.Priority
            });

            split1.Value.Text1 = ViewModel.Issue.Status;
            split1.Value.Text2 = ViewModel.Issue.Priority;
            secDetails.Add(split1);


            var split2 = new SplitElement(new SplitElement.Row {
                Image1 = Images.Flag, Image2 = Images.ServerComponents
            });

            split2.Value.Text1 = ViewModel.Issue.Metadata.Kind;
            split2.Value.Text2 = ViewModel.Issue.Metadata.Component ?? "No Component";
            secDetails.Add(split2);


            var split3 = new SplitElement(new SplitElement.Row {
                Image1 = Images.SitemapColor, Image2 = Images.Milestone
            });

            split3.Value.Text1 = ViewModel.Issue.Metadata.Version ?? "No Version";
            split3.Value.Text2 = ViewModel.Issue.Metadata.Milestone ?? "No Milestone";
            secDetails.Add(split3);

            var assigneeElement = new StyledStringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "******".t(), UITableViewCellStyle.Value1)
            {
                Image     = Images.Person,
                Accessory = UITableViewCellAccessory.DisclosureIndicator
            };

            assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null);
            secDetails.Add(assigneeElement);

            root.Add(secDetails);

            if (ViewModel.Comments.Any(x => !string.IsNullOrEmpty(x.Content)))
            {
                root.Add(new Section {
                    _commentsElement
                });
            }

            var addComment = new StyledStringElement("Add Comment")
            {
                Image = Images.Pencil
            };

            addComment.Tapped += AddCommentTapped;
            root.Add(new Section {
                addComment
            });
            Root = root;
        }
Beispiel #11
0
        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());
        }
Beispiel #12
0
        public void Render()
        {
			if (ViewModel.Commits == null || ViewModel.Commit == null)
				return;

            var titleMsg = (ViewModel.Commit.Message ?? string.Empty).Split(new [] { '\n' }, 2).FirstOrDefault();
            var avatarUrl = ViewModel.Commit.Author?.User?.Links?.Avatar?.Href;
            var node = ViewModel.Node.Substring(0, ViewModel.Node.Length > 10 ? 10 : ViewModel.Node.Length);

            Title = node;
            HeaderView.Text = titleMsg ?? node;
            HeaderView.SubText = "Commited " + (ViewModel.Commit.Date).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.Commit.Participants.Count.ToString());
            split.AddButton("Approvals", ViewModel.Commit.Participants.Count(x => x.Approved).ToString());

            var commitModel = ViewModel.Commits;
            var root = new RootElement(Title) { UnevenRows = Root.UnevenRows };
            root.Add(new Section { split });

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

            var user = ViewModel.Commit.Author?.User?.DisplayName ?? ViewModel.Commit.Author.Raw ?? "Unknown";
			detailSection.Add(new MultilinedElement(user, ViewModel.Commit.Message)
            {
                CaptionColor = Theme.CurrentTheme.MainTextColor,
                ValueColor = Theme.CurrentTheme.MainTextColor,
                BackgroundColor = UIColor.White
            });

            if (ViewModel.ShowRepository)
            {
                var repo = new StyledStringElement(ViewModel.Repository) { 
                    Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator, 
                    Lines = 1, 
                    Font = StyledStringElement.DefaultDetailFont, 
                    TextColor = StyledStringElement.DefaultDetailColor,
                    Image = Images.Repo
                };
                repo.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(null);
                detailSection.Add(repo);
            }

			if (_viewSegment.SelectedSegment == 0)
			{

				var paths = ViewModel.Commits.GroupBy(y =>
				{
					var filename = "/" + y.File;
					return filename.Substring(0, filename.LastIndexOf("/", System.StringComparison.Ordinal) + 1);
				}).OrderBy(y => y.Key);

				foreach (var p in paths)
				{
					var fileSection = new Section(p.Key);
					foreach (var x in p)
					{
						var y = x;
						var file = x.File.Substring(x.File.LastIndexOf('/') + 1);
						var sse = new ChangesetElement(file, x.Type, x.Diffstat.Added, x.Diffstat.Removed);
						sse.Tapped += () => ViewModel.GoToFileCommand.Execute(y);
						fileSection.Add(sse);
					}
					root.Add(fileSection);
				}
			}
			else if (_viewSegment.SelectedSegment == 1)
			{
				var commentSection = new Section();
				foreach (var comment in ViewModel.Comments)
				{
                    var name = comment.User.DisplayName ?? comment.User.Username;
                    var imgUri = new Avatar(comment.User.Links?.Avatar?.Href);
                    commentSection.Add(new NameTimeStringElement(name, comment.Content.Raw, comment.CreatedOn, imgUri.ToUrl(), Images.Avatar));
				}

				if (commentSection.Elements.Count > 0)
					root.Add(commentSection);

				var addComment = new StyledStringElement("Add Comment") { Image = Images.Pencil };
				addComment.Tapped += AddCommentTapped;
				root.Add(new Section { addComment });
			}
			else if (_viewSegment.SelectedSegment == 2)
			{
				var likeSection = new Section();
                likeSection.AddAll(ViewModel.Commit.Participants.Where(x => x.Approved).Select(l => {
                    var el = new UserElement(l.User.DisplayName, string.Empty, string.Empty, l.User.Links.Avatar.Href);
                    el.Tapped += () => ViewModel.GoToUserCommand.Execute(l.User.Username);
					return el;
				}));

				if (likeSection.Elements.Count > 0)
					root.Add(likeSection);

				StyledStringElement approveButton;
                if (ViewModel.Commit.Participants.Any(x => x.User.Username.Equals(ViewModel.GetApplication().Account.Username) && x.Approved))
				{
					approveButton = new StyledStringElement("Unapprove") { Image = Images.Cancel };
					approveButton.Tapped += () => this.DoWorkAsync("Unapproving...", ViewModel.Unapprove);
				}
				else
				{
					approveButton = new StyledStringElement("Approve") { Image = Images.Accept };
					approveButton.Tapped += () => this.DoWorkAsync("Approving...", ViewModel.Approve);
				}
				root.Add(new Section { approveButton });
			}

			Root = root; 
        }
Beispiel #13
0
        public void Render(RepositoryDetailedModel model)
        {
            Title = model.Name;
            var root = new RootElement(Title)
            {
                UnevenRows = true
            };

            _header.Title    = Title;
            _header.Subtitle = "Updated ".t() + (model.UtcLastUpdated).ToDaysAgo();
            _header.ImageUri = ViewModel.ImageUrl;

            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.IsPrivate ? "Private".t() : "Public".t(),
                Image1 = model.IsPrivate ? Images.Locked : Images.Unlocked,
                Text2  = string.IsNullOrEmpty(model.Language) ? "N/A" : model.Language,
                Image2 = Images.Language
            }));


            //Calculate the best representation of the size
            string size;

            if (model.Size / 1024f < 1)
            {
                size = string.Format("{0:0.##}B", model.Size);
            }
            else if ((model.Size / 1024f / 1024f) < 1)
            {
                size = string.Format("{0:0.##}KB", model.Size / 1024f);
            }
            else
            {
                size = string.Format("{0:0.##}MB", model.Size / 1024f / 1024f);
            }
//
//            sec1.Add(new SplitElement(new SplitElement.Row {
//				Text1 = model + (model.HasIssues == 1 ? " Issue".t() : " Issues".t()),
//                Image1 = Images.Flag,
//				Text2 = model.ForkCount.ToString() + (model.ForkCount == 1 ? " Fork".t() : " Forks".t()),
//                Image2 = Images.Fork
//            }));
//
            sec1.Add(new SplitElement(new SplitElement.Row {
                Text1  = (model.UtcCreatedOn).ToString("MM/dd/yy"),
                Image1 = Images.Create,
                Text2  = size,
                Image2 = Images.Size
            }));

            var owner = new StyledStringElement("Owner".t(), model.Owner)
            {
                Image = Images.Person, Accessory = UITableViewCellAccessory.DisclosureIndicator
            };

            owner.Tapped += () => ViewModel.GoToOwnerCommand.Execute(null);
            sec1.Add(owner);

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

            var followers = new StyledStringElement("Watchers".t(), "" + model.FollowersCount)
            {
                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.HasWiki)
            {
                sec2.Add(new StyledStringElement("Wiki".t(), () => ViewModel.GoToWikiCommand.Execute(null), Images.Pencil));
            }

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

            if (ViewModel.HasReadme)
            {
                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(ViewModel.Repository.Website))
            {
                root.Add(new Section
                {
                    new StyledStringElement("Website", () => ViewModel.GoToUrlCommand.Execute(ViewModel.Repository.Website), Images.Webpage)
                });
            }

            Root = root;
        }
Beispiel #14
0
		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;
        }
Beispiel #15
0
        private void CreateTable()
        {
            var application    = IoC.Resolve <IApplicationService>();
            var vm             = (SettingsViewModel)ViewModel;
            var currentAccount = application.Account;
            var accountSection = new Section("Account");

            accountSection.Add(new BooleanElement("Save Credentials", !currentAccount.DontRemember, e =>
            {
//                currentAccount.DontRemember = !e.Value;
//                application.Accounts.Update(currentAccount);
            }));

            var showOrganizationsInEvents = new BooleanElement("Show Organizations in Events", currentAccount.ShowOrganizationsInEvents, e =>
            {
//				currentAccount.ShowOrganizationsInEvents = e.Value;
//				application.Accounts.Update(currentAccount);
            });

            var showOrganizations = new BooleanElement("List Organizations in Menu", currentAccount.ExpandOrganizations, e =>
            {
//				currentAccount.ExpandOrganizations = e.Value;
//				application.Accounts.Update(currentAccount);
            });

            var repoDescriptions = new BooleanElement("Show Repo Descriptions", currentAccount.ShowRepositoryDescriptionInList, e =>
            {
//				currentAccount.ShowRepositoryDescriptionInList = e.Value;
//				application.Accounts.Update(currentAccount);
            });

            var openUrlsInCodeHub = new BooleanElement("Open URLs in CodeHub", currentAccount.OpenUrlsInApp, e =>
            {
                //              currentAccount.ShowRepositoryDescriptionInList = e.Value;
                //              application.Accounts.Update(currentAccount);
            });

            var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, MonoTouch.UIKit.UITableViewCellStyle.Value1)
            {
                Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
            };

            startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);

            //var sidebarOrder = new StyledStringElement("Sidebar Order", () => vm.GoToSidebarOrderCommand.Execute(null));

            accountSection.Add(new BooleanElement("Push Notifications", vm.PushNotificationsEnabled, e => vm.PushNotificationsEnabled = e.Value));

            //Assign the root
            Root.Add(accountSection);
            Root.Add(new Section("Appearance")
            {
                showOrganizationsInEvents, showOrganizations, repoDescriptions, openUrlsInCodeHub, startupView
            });

            Root.Add(new Section("About", "Thank you for downloading. Enjoy!")
            {
                new StyledStringElement("Follow On Twitter", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://twitter.com/CodeHubapp"))),
                new StyledStringElement("Rate This App", () => UIApplication.SharedApplication.OpenUrl(new NSUrl("https://itunes.apple.com/us/app/codehub-github-for-ios/id707173885?mt=8"))),
                new StyledStringElement("Source Code", () => ViewModel.GoToSourceCodeCommand.ExecuteIfCan()),
                new StyledStringElement("App Version", ViewModel.Version)
            });
        }
Beispiel #16
0
        public RepositoryView()
        {
            HeaderView.Image = Images.LoginUserUnknown;

            _sourceSection = new Section
            {
                new DialogStringElement("Commits", () => ViewModel.GoToCommitsCommand.ExecuteIfCan(), Images.Commit),
                new DialogStringElement("Pull Requests", () => ViewModel.GoToPullRequestsCommand.ExecuteIfCan(), Images.PullRequest),
                new DialogStringElement("Source", () => ViewModel.GoToSourceCommand.ExecuteIfCan(), Images.Code),
            };

            _ownerElement = new StyledStringElement("Owner", string.Empty)
            {
                Image = Images.Person, Accessory = UITableViewCellAccessory.DisclosureIndicator
            };
            _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(Images.Lock, string.Empty);
            _splitElements[0].Button2 = new SplitViewElement.SplitButton(Images.Package, string.Empty);

            _splitElements[1]         = new SplitViewElement();
            _splitElements[1].Button1 = new SplitViewElement.SplitButton(Images.IssueOpened, string.Empty, () => ViewModel.GoToIssuesCommand.ExecuteIfCan());
            _splitElements[1].Button2 = new SplitViewElement.SplitButton(Images.Organization, string.Empty, () => ViewModel.GoToContributors.ExecuteIfCan());

            _splitElements[2]         = new SplitViewElement();
            _splitElements[2].Button1 = new SplitViewElement.SplitButton(Images.Tag, string.Empty, () => ViewModel.GoToReleasesCommand.ExecuteIfCan());
            _splitElements[2].Button2 = new SplitViewElement.SplitButton(Images.Branch, 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 ? Images.Star.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) : 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");
                }
            });
        }
        private void PopulateRoot()
        {
            _title = new InputElement("Title", string.Empty, string.Empty);

            _assignedTo           = new StyledStringElement("Responsible", Unassigned, UITableViewCellStyle.Value1);
            _assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _assignedTo.Tapped   += () => {
                var p = new IssueAssigneesViewController(Username, RepoSlug);
                p.SelectedUser = (x) => {
                    _selectedAssignee = x;
                    NavigationController.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(p, true);
            };

            _milestone           = new StyledStringElement("Milestone".t(), None, UITableViewCellStyle.Value1);
            _milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _milestone.Tapped   += () => {
                var p = new IssueMilestonesViewController(Username, RepoSlug);
                p.MilestoneSelected = (x) => {
                    _selectedMilestone = x;
                    NavigationController.PopViewControllerAnimated(true);
                };
                NavigationController.PushViewController(p, true);
            };

            _labels           = new StyledStringElement("Labels".t(), None, UITableViewCellStyle.Value1);
            _labels.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            _labels.Tapped   += () => {
                var p = new IssueLabelsViewController(Username, RepoSlug)
                {
                    SelectedLabels = _selectedLabels
                };
                NavigationController.PushViewController(p, true);
            };

            _state = new TrueFalseElement("Open", true);

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

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

            //See if it's an existing issue or not...
            if (ExistingIssue != null)
            {
                _title.Value       = ExistingIssue.Title;
                _selectedAssignee  = ExistingIssue.Assignee;
                _selectedMilestone = ExistingIssue.Milestone;
                _selectedLabels    = ExistingIssue.Labels;
                _content.Value     = ExistingIssue.Body;
                _state.Value       = ExistingIssue.State.Equals("open");

                //Insert the status thing inbetween title and assigned to elements
                root.Insert(1, new Section()
                {
                    _state
                });
            }

            Root = root;
        }
Beispiel #18
0
        public override void ViewDidLoad()
        {
            Title = "Edit Issue";

            base.ViewDidLoad();

            _hud = this.CreateHud();
            var vm = (IssueEditViewModel)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();
                });
            };

            var state = new TrueFalseElement("Open", true);

            state.ValueChanged += (sender, e) => vm.IsOpen = state.Value;

            vm.Bind(x => x.Title, x => title.Value = x, true);

            vm.Bind(x => x.Content, x => content.Value = x, true);

            vm.Bind(x => x.AssignedTo, x => {
                assignedTo.Value = x == null ? "Unassigned" : x.Login;
                if (assignedTo.GetImmediateRootElement() != null)
                {
                    Root.Reload(assignedTo, UITableViewRowAnimation.None);
                }
            }, true);

            vm.Bind(x => x.Milestone, x => {
                milestone.Value = x == null ? "None" : x.Title;
                if (assignedTo.GetImmediateRootElement() != null)
                {
                    Root.Reload(milestone, UITableViewRowAnimation.None);
                }
            }, true);

            vm.BindCollection(x => x.Labels, x => {
                labels.Value = vm.Labels.Items.Count == 0 ? "None" : string.Join(", ", vm.Labels.Items.Select(i => i.Name));
                if (assignedTo.GetImmediateRootElement() != null)
                {
                    Root.Reload(labels, UITableViewRowAnimation.None);
                }
            }, true);

            vm.Bind(x => x.IsOpen, x =>
            {
                state.Value = x;
                if (assignedTo.GetImmediateRootElement() != null)
                {
                    Root.Reload(state, UITableViewRowAnimation.None);
                }
            }, true);

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

            Root = new RootElement(Title)
            {
                new Section {
                    title, assignedTo, milestone, labels
                }, new Section {
                    state
                }, new Section {
                    content
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            RootElement root = Root;


            Section examplesSection = new Section();

            StyledStringElement helloWorldElement = new StyledStringElement("Hello world");

            helloWorldElement.Tapped += () => {
                NavigationController.PushViewController(
                    new HelloWorldUIViewController(),
                    true
                    );
            };
            examplesSection.Add(helloWorldElement);

            StyledStringElement planarSubdivisionElement = new StyledStringElement("Planar Subdivision");

            planarSubdivisionElement.Tapped += () => {
                NavigationController.PushViewController(
                    new PlanarSubdivisionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(planarSubdivisionElement);

            StyledStringElement faceDetectionElement = new StyledStringElement("Face Detection");

            faceDetectionElement.Tapped += () => {
                NavigationController.PushViewController(
                    new FaceDetectionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(faceDetectionElement);

            StyledStringElement featureMatchingElement = new StyledStringElement("Feature Matching");

            featureMatchingElement.Tapped += () => {
                NavigationController.PushViewController(
                    new FeatureMatchingDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(featureMatchingElement);

            StyledStringElement pedestrianDetectionElement = new StyledStringElement("Pedestrian Detection");

            pedestrianDetectionElement.Tapped += () => {
                NavigationController.PushViewController(
                    new PedestrianDetectionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(pedestrianDetectionElement);


            StyledStringElement cameraElement = new StyledStringElement("Camera");

            cameraElement.Tapped += () => {
                NavigationController.PushViewController(
                    new CameraDialogViewController(),
                    true);
            };
            examplesSection.Add(cameraElement);

            root.Add(examplesSection);
        }
Beispiel #20
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();
            var imageUrl = model.Fork ? CodeHub.Images.GitHubRepoForkUrl : CodeHub.Images.GitHubRepoUrl;

            _header.Image = ImageLoader.DefaultRequestImage(imageUrl, 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,
                    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,
                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 += () => NavigationController.PushViewController(new ProfileViewController(model.Owner.Login), true);
            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 += () => NavigationController.PushViewController(new RepositoryViewController(model.Parent.Owner.Login, model.Parent.Name), true);
                sec1.Add(parent);
            }

            var followers = new StyledStringElement("Stargazers".t(), "" + model.Watchers)
            {
                Image = Images.Star, Accessory = UITableViewCellAccessory.DisclosureIndicator
            };

            followers.Tapped += () => NavigationController.PushViewController(new StargazersViewController(model.Owner.Login, model.Name), true);
            sec1.Add(followers);


            var events = new StyledStringElement("Events".t(), () => NavigationController.PushViewController(new RepoEventsViewController(model.Owner.Login, model.Name), true), Images.Event);

            var sec2 = new Section {
                events
            };

            if (model.HasIssues)
            {
                sec2.Add(new StyledStringElement("Issues".t(), () => NavigationController.PushViewController(new IssuesViewController(model.Owner.Login, model.Name), true), Images.Flag));
            }

            if (ViewModel.Readme != null)
            {
                sec2.Add(new StyledStringElement("Readme".t(), () => NavigationController.PushViewController(new ReadmeViewController(model.Owner.Login, model.Name), true), Images.File));
            }

            var sec3 = new Section
            {
                new StyledStringElement("Changes".t(), ChangesTapped, Images.Commit),
                new StyledStringElement("Pull Requests".t(), () => NavigationController.PushViewController(new PullRequestsViewController(model.Owner.Login, model.Name), true), Images.Hand),
                new StyledStringElement("Branches".t(), () => NavigationController.PushViewController(new BranchesViewController(model.Owner.Login, model.Name), true), Images.Branch),
                new StyledStringElement("Tags".t(), () => NavigationController.PushViewController(new TagsViewController(model.Owner.Login, model.Name), true), Images.Tag)
            };

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

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

            Root = root;
        }
Beispiel #21
0
        public void Render()
        {
            var commitModel = ViewModel.Changeset;

            if (commitModel == null)
            {
                return;
            }

            var root = new RootElement(Title)
            {
                UnevenRows = Root.UnevenRows
            };

            _header.Subtitle = "Commited ".t() + (commitModel.Commit.Committer.Date).ToDaysAgo();
            var headerSection = new Section(_header);

            root.Add(headerSection);

            var detailSection = new Section();

            root.Add(detailSection);

            var user = "******";

            if (commitModel.Commit.Author != null)
            {
                user = commitModel.Commit.Author.Name;
            }
            if (commitModel.Commit.Committer != null)
            {
                user = commitModel.Commit.Committer.Name;
            }

            detailSection.Add(new MultilinedElement(user, commitModel.Commit.Message)
            {
                CaptionColor    = Theme.CurrentTheme.MainTextColor,
                ValueColor      = Theme.CurrentTheme.MainTextColor,
                BackgroundColor = UIColor.White
            });

            if (ViewModel.ShowRepository)
            {
                var repo = new StyledStringElement(ViewModel.Repository)
                {
                    Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
                    Lines     = 1,
                    Font      = StyledStringElement.DefaultDetailFont,
                    TextColor = StyledStringElement.DefaultDetailColor,
                    Image     = Images.Repo
                };
                repo.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(null);
                detailSection.Add(repo);
            }

            var paths = commitModel.Files.GroupBy(y => {
                var filename = "/" + y.Filename;
                return(filename.Substring(0, filename.LastIndexOf("/", System.StringComparison.Ordinal) + 1));
            }).OrderBy(y => y.Key);

            foreach (var p in paths)
            {
                var fileSection = new Section(p.Key);
                foreach (var x in p)
                {
                    var y    = x;
                    var file = x.Filename.Substring(x.Filename.LastIndexOf('/') + 1);
                    var sse  = new ChangesetElement(file, x.Status, x.Additions, x.Deletions);
                    sse.Tapped += () => ViewModel.GoToFileCommand.Execute(y);
                    fileSection.Add(sse);
                }
                root.Add(fileSection);
            }
//
//			var fileSection = new Section();
//            commitModel.Files.ForEach(x => {
//                var file = x.Filename.Substring(x.Filename.LastIndexOf('/') + 1);
//                var sse = new ChangesetElement(file, x.Status, x.Additions, x.Deletions);
//                sse.Tapped += () => ViewModel.GoToFileCommand.Execute(x);
//                fileSection.Add(sse);
//            });

//            if (fileSection.Elements.Count > 0)
//                root.Add(fileSection);
//

            var commentSection = new Section();

            foreach (var comment in ViewModel.Comments)
            {
                //The path should be empty to indicate it's a comment on the entire commit, not a specific file
                if (!string.IsNullOrEmpty(comment.Path))
                {
                    continue;
                }

                commentSection.Add(new CommentElement {
                    Name            = comment.User.Login,
                    Time            = comment.CreatedAt.ToDaysAgo(),
                    String          = comment.Body,
                    Image           = Images.Anonymous,
                    ImageUri        = new Uri(comment.User.AvatarUrl),
                    BackgroundColor = UIColor.White,
                });
            }

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

            var addComment = new StyledStringElement("Add Comment".t())
            {
                Image = Images.Pencil
            };

            addComment.Tapped += AddCommentTapped;
            root.Add(new Section {
                addComment
            });
            Root = root;
        }
Beispiel #22
0
        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;
        }
Beispiel #23
0
        void CreateUI()
        {
            System.Threading.Thread.Sleep(2000);
            if (spinner != null)
            {
                spinner.RemoveFromSuperview();
                spinner = null;
            }

            var profileRect      = new RectangleF(PadX, 0, View.Bounds.Width - PadX, 100);
            var shortProfileView = new ShortProfileView(profileRect, user.Id, false);

            shortProfileView.PictureTapped += delegate { PictureViewer.Load(this, user.Id); };
            shortProfileView.UrlTapped     += delegate { WebViewController.OpenUrl(this, user.Url); };

            var main = new Section(shortProfileView);

            if (!String.IsNullOrEmpty(user.Description))
            {
                main.Add(new StyledMultilineElement(user.Description)
                {
                    Lines         = 0,
                    LineBreakMode = UILineBreakMode.WordWrap,
                    Font          = UIFont.SystemFontOfSize(14),
                });
            }
            ;

            var tweetsUrl    = String.Format("http://api.twitter.com/1/statuses/user_timeline.json?skip_user=true&id={0}", user.Id);
            var favoritesUrl = String.Format("http://api.twitter.com/1/favorites.json?id={0}", user.Id);
            var followersUrl = String.Format("http://api.twitter.com/1/statuses/followers.json?id={0}", user.Id);
            var friendsUrl   = String.Format("http://api.twitter.com/1/statuses/friends.json?id={0}", user.Id);

#if false
            followButton = new StyledStringElement(FollowText, ToggleFollow)
            {
                Alignment = UITextAlignment.Center,
                TextColor = UIColor.FromRGB(0x32, 0x4f, 0x85)
            };
#endif
            var sfollow = new Section()
            {
                new ActivityElement()
            };

            Root = new RootElement(user.Screenname)
            {
                main,
                new Section()
                {
                    TimelineRootElement.MakeTimeline(user.Screenname, Locale.Format("{0:#,#} tweets", user.StatusesCount), tweetsUrl, user),
                    TimelineRootElement.MakeFavorites(user.Screenname, Locale.Format("{0:#,#} favorites", user.FavCount), favoritesUrl, null),
                    new UserRootElement(user, Locale.Format("{0:#,#} friends", user.FriendsCount), friendsUrl),
                    new UserRootElement(user, Locale.Format("{0:#,#} followers", user.FollowersCount), followersUrl),
                },
                sfollow,
            };
            var created = user.CreatedAt;
            if (created.HasValue)
            {
                Root.Add(new Section(null, Locale.Format("Joined on {0}", created.Value.ToLongDateString())));
            }

            string url = String.Format("http://api.twitter.com/1/friendships/show.json?target_id={0}&source_screen_name={1}",
                                       user.Id,
                                       OAuth.PercentEncode(TwitterAccount.CurrentAccount.Username));
            TwitterAccount.CurrentAccount.Download(url, res => {
                TableView.BeginUpdates();
                Root.Remove(sfollow);
                if (res != null)
                {
                    ParseFollow(res);
                }

                TableView.EndUpdates();
            });
        }
Beispiel #24
0
        private void CreateTable()
        {
            var application    = Mvx.Resolve <IApplicationService>();
            var vm             = (SettingsViewModel)ViewModel;
            var currentAccount = application.Account;
            var accountSection = new Section("Account");

            accountSection.Add(new TrueFalseElement("Save Credentials".t(), !currentAccount.DontRemember, e =>
            {
                currentAccount.DontRemember = !e.Value;
                application.Accounts.Update(currentAccount);
            }));

            var showOrganizationsInEvents = new TrueFalseElement("Show Organizations in Events".t(), currentAccount.ShowOrganizationsInEvents, e =>
            {
                currentAccount.ShowOrganizationsInEvents = e.Value;
                application.Accounts.Update(currentAccount);
            });

            var showOrganizations = new TrueFalseElement("List Organizations in Menu".t(), currentAccount.ExpandOrganizations, e =>
            {
                currentAccount.ExpandOrganizations = e.Value;
                application.Accounts.Update(currentAccount);
            });

            var repoDescriptions = new TrueFalseElement("Show Repo Descriptions".t(), currentAccount.ShowRepositoryDescriptionInList, e =>
            {
                currentAccount.ShowRepositoryDescriptionInList = e.Value;
                application.Accounts.Update(currentAccount);
            });

            var startupView = new StyledStringElement("Startup View", vm.DefaultStartupViewName, MonoTouch.UIKit.UITableViewCellStyle.Value1)
            {
                Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
            };

            startupView.Tapped += () => vm.GoToDefaultStartupViewCommand.Execute(null);

            var sidebarOrder = new StyledStringElement("Sidebar Order", () => vm.GoToSidebarOrderCommand.Execute(null));

            var largeFonts = new TrueFalseElement("Large Fonts", vm.LargeFonts, x =>
            {
                vm.LargeFonts = x.Value;
                Theme.Setup();
                CreateTable();
            });

            accountSection.Add(new TrueFalseElement("Push Notifications".t(), vm.PushNotificationsEnabled, e => vm.PushNotificationsEnabled = e.Value));

            var totalCacheSizeMB = vm.CacheSize.ToString("0.##");
            var deleteCache      = new StyledStringElement("Delete Cache".t(), string.Format("{0} MB", totalCacheSizeMB), MonoTouch.UIKit.UITableViewCellStyle.Value1);

            deleteCache.Tapped += () =>
            {
                vm.DeleteAllCacheCommand.Execute(null);
                deleteCache.Value = string.Format("{0} MB", 0);
                ReloadData();
            };

            var usage = new TrueFalseElement("Send Anonymous Usage".t(), vm.AnalyticsEnabled, e => vm.AnalyticsEnabled = e.Value);

            //Assign the root
            var root = new RootElement(Title);

            root.Add(accountSection);
            root.Add(new Section("Appearance")
            {
                showOrganizationsInEvents, showOrganizations, repoDescriptions, startupView, largeFonts
            });
            root.Add(new Section("Internal")
            {
                deleteCache, usage
            });
            Root = 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());

            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.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)
            {
                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, Images.Fork) });
            }

            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, 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 = Images.Pencil };
            addComment.Tapped += AddCommentTapped;
            root.Add(new Section { addComment });
            Root = root;
        }
Beispiel #26
0
        private void DisplaySecretDetail(Secret s)
        {
            NSError error;

            Analytics.SharedTracker.TrackPageView("/session", out error);

            var subRoot = new RootElement(s.Phrase)
            {
                (shareSection = new Section("Keep on server (1 min)")
                {
                    (pickPhoto = new StyledStringElement("Photo", delegate { ShowImagePicker(); })),
                    (dataEntry = new AdvancedEntryElement("Text", "your message", null))
                }),
                (entriesSection = new Section("History"))
            };

            pickPhoto.Accessory     = UITableViewCellAccessory.DisclosureIndicator;
            dataEntry.ShouldReturn += delegate {
                UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                    dataEntry.GetContainerTableView().EndEditing(true);
                }
                                                                   );

                server.Send(dataEntry.Value.Trim());

                return(true);
            };
            dataEntry.ReturnKeyType = UIReturnKeyType.Send;


            entriesSection.Elements.AddRange(
                from d in s.DataItems
                select((Element)CreateDataItemElement(d))
                );

            subRoot.UnevenRows = true;

            sectionDVC = new StyledDialogViewController(
                subRoot,
                true,
                null,
                backgroundColor
                );
            sectionDVC.HidesBottomBarWhenPushed = false;
            navigation.SetNavigationBarHidden(false, true);
            navigation.PushViewController(sectionDVC, true);

            server.CurrentSecret = s;
            currentSecret        = s;
            server.Listen();

            currentSecret.WatchEvent += (secret) => {
                int    count   = secret.ListenersCount - 1;
                string pattern = "Keep on server (1 min)";
                if (count > 0)
                {
                    pattern = (count) > 1 ? "Share with {0} devices" : "Share with {0} device";
                }
                UIApplication.SharedApplication.InvokeOnMainThread(delegate {
                    shareSection.Caption = string.Format(pattern, count);
                    if (sectionDVC != null)
                    {
                        sectionDVC.ReloadData();
                    }
                }
                                                                   );
            };

            sectionDVC.ViewAppearing += delegate {
                if (navigation.View.ViewWithTag(SHARE_BUTTON_TAG) != null)
                {
                    navigation.View.ViewWithTag(SHARE_BUTTON_TAG).RemoveFromSuperview();
                }
            };

            if (ResharedItem != null)
            {
                ReshareData();
            }
        }
Beispiel #27
0
        public void Render(CommitModel commitModel)
        {
            var headerSection = new Section(HeaderView)
            {
                _split
            };
            var detailSection = new Section();

            Root.Reset(headerSection, detailSection);

            var user = "******";

            if (commitModel.Commit.Author != null)
            {
                user = commitModel.Commit.Author.Name;
            }
            if (commitModel.Commit.Committer != null)
            {
                user = commitModel.Commit.Committer.Name;
            }

            detailSection.Add(new MultilinedElement(user, commitModel.Commit.Message)
            {
                CaptionColor    = Theme.CurrentTheme.MainTextColor,
                ValueColor      = Theme.CurrentTheme.MainTextColor,
                BackgroundColor = UIColor.White
            });

            if (ViewModel.ShowRepository)
            {
                var repo = new StyledStringElement(ViewModel.RepositoryName)
                {
                    Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator,
                    Lines     = 1,
                    Font      = StyledStringElement.DefaultDetailFont,
                    TextColor = StyledStringElement.DefaultDetailColor,
                    Image     = Images.Repo
                };
                repo.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(null);
                detailSection.Add(repo);
            }

            var paths = commitModel.Files.GroupBy(y => {
                var filename = "/" + y.Filename;
                return(filename.Substring(0, filename.LastIndexOf("/", System.StringComparison.Ordinal) + 1));
            }).OrderBy(y => y.Key);

            foreach (var p in paths)
            {
                var fileSection = new Section(p.Key);
                foreach (var x in p)
                {
                    var y    = x;
                    var file = x.Filename.Substring(x.Filename.LastIndexOf('/') + 1);
                    var sse  = new ChangesetElement(file, x.Status, x.Additions, x.Deletions);
                    sse.Tapped += () => ViewModel.GoToFileCommand.Execute(y);
                    fileSection.Add(sse);
                }
                Root.Add(fileSection);
            }

            Root.Add(_commentSection);

            var addComment = new StyledStringElement("Add Comment")
            {
                Image = Images.Pencil
            };

            addComment.Tapped += () => ViewModel.GoToCommentCommand.ExecuteIfCan();
            Root.Add(new Section {
                addComment
            });
        }
Beispiel #28
0
        public override void ViewDidLoad()
        {
            Title = "Edit Issue";

            base.ViewDidLoad();

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

            var title = new InputElement("Title", string.Empty, string.Empty);

            title.Changed += (sender, e) => ViewModel.Title = title.Value;

            var assignedTo = new StyledStringElement("Responsible", "Unassigned", UITableViewCellStyle.Value1);

            assignedTo.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            assignedTo.Tapped   += () => ViewModel.GoToAssigneeCommand.Execute(null);

            var milestone = new StyledStringElement("Milestone", "None", UITableViewCellStyle.Value1);

            milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            milestone.Tapped   += () => ViewModel.GoToMilestonesCommand.Execute(null);

            var labels = new StyledStringElement("Labels", "None", UITableViewCellStyle.Value1);

            labels.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            labels.Tapped   += () => ViewModel.GoToLabelsCommand.Execute(null);

            var content = new MultilinedElement("Description");

            content.Tapped += () => ViewModel.GoToDescriptionCommand.ExecuteIfCan();

            var state = new BooleanElement("Open", true);

            state.ValueChanged += (sender, e) => ViewModel.IsOpen = state.Value;

            ViewModel.WhenAnyValue(x => x.Issue.Title).Subscribe(x => title.Value = x);
            ViewModel.WhenAnyValue(x => x.Content).Subscribe(x => content.Value   = x);

            ViewModel.WhenAnyValue(x => x.AssignedTo).Subscribe(x => {
                assignedTo.Value = x == null ? "Unassigned" : x.Login;
                if (assignedTo.GetRootElement() != null)
                {
                    Root.Reload(assignedTo, UITableViewRowAnimation.None);
                }
            });

            ViewModel.WhenAnyValue(x => x.Milestone).Subscribe(x => {
                milestone.Value = x == null ? "None" : x.Title;
                if (assignedTo.GetRootElement() != null)
                {
                    Root.Reload(milestone, UITableViewRowAnimation.None);
                }
            });

            ViewModel.WhenAnyValue(x => x.Labels).Subscribe(x =>
            {
                labels.Value = (ViewModel.Labels == null && ViewModel.Labels.Length == 0) ?
                               "None" : string.Join(", ", ViewModel.Labels.Select(i => i.Name));

                if (assignedTo.GetRootElement() != null)
                {
                    Root.Reload(labels, UITableViewRowAnimation.None);
                }
            });

            ViewModel.WhenAnyValue(x => x.IsOpen).Subscribe(x =>
            {
                state.Value = x;
                if (assignedTo.GetRootElement() != null)
                {
                    Root.Reload(state, UITableViewRowAnimation.None);
                }
            });

            ViewModel.SaveCommand.IsExecuting.Subscribe(x =>
            {
                if (x)
                {
                    _statusIndicatorService.Show("Updating...");
                }
                else
                {
                    _statusIndicatorService.Hide();
                }
            });

            Root.Reset(new Section {
                title, assignedTo, milestone, labels
            }, new Section {
                state
            }, new Section {
                content
            });
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            RootElement root = Root;


            Section examplesSection = new Section();

            StyledStringElement helloWorldElement = new StyledStringElement("Hello world");

            helloWorldElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new HelloWorldUIViewController(),
                    true
                    );
            };
            examplesSection.Add(helloWorldElement);

            StyledStringElement planarSubdivisionElement = new StyledStringElement("Planar Subdivision");

            planarSubdivisionElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new PlanarSubdivisionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(planarSubdivisionElement);

            StyledStringElement faceDetectionElement = new StyledStringElement("Face Detection");

            faceDetectionElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new FaceDetectionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(faceDetectionElement);

            StyledStringElement surfFeatureElement = new StyledStringElement("SURF Feature");

            surfFeatureElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new SURFFeatureDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(surfFeatureElement);

            StyledStringElement pedestrianDetectionElement = new StyledStringElement("Pedestrian Detection");

            pedestrianDetectionElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new PedestrianDetectionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(pedestrianDetectionElement);

            StyledStringElement trafficSignDetectionElement = new StyledStringElement("Stop Sign Detection");

            trafficSignDetectionElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new TrafficSignRecognitionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(trafficSignDetectionElement);

            StyledStringElement licensePlateDetectionElement = new StyledStringElement("License Plate Detection");

            licensePlateDetectionElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new LicensePlateRecognitionDialogViewController(),
                    true
                    );
            };
            examplesSection.Add(licensePlateDetectionElement);

            StyledStringElement cameraElement = new StyledStringElement("Camera");

            cameraElement.Tapped += () =>
            {
                NavigationController.PushViewController(
                    new CameraDialogViewController(),
                    true);
            };
            examplesSection.Add(cameraElement);

            root.Add(examplesSection);
        }
Beispiel #30
0
        public PullRequestView()
        {
            _descriptionElement = new HtmlElement("body");
            _commentsElement    = new HtmlElement("comments");

            _milestoneElement = new StyledStringElement("Milestone", "No Milestone", UITableViewCellStyle.Value1)
            {
                Image = Images.Milestone
            };
            _milestoneElement.Tapped += () => ViewModel.GoToMilestoneCommand.ExecuteIfCan();

            _assigneeElement = new StyledStringElement("Assigned", "Unassigned", UITableViewCellStyle.Value1)
            {
                Image = Images.Person
            };
            _assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.ExecuteIfCan();

            _labelsElement = new StyledStringElement("Labels", "None", UITableViewCellStyle.Value1)
            {
                Image = Images.Tag
            };
            _labelsElement.Tapped += () => ViewModel.GoToLabelsCommand.ExecuteIfCan();

            _addCommentElement = new StyledStringElement("Add Comment")
            {
                Image = Images.Pencil
            };
            _addCommentElement.Tapped += AddCommentTapped;

            _split1 = new SplitViewElement
            {
                Button1 = new SplitViewElement.SplitButton(Images.Gear, string.Empty),
                Button2 = new SplitViewElement.SplitButton(Images.Gear, string.Empty)
            };

            _split2 = new SplitViewElement
            {
                Button1 = new SplitViewElement.SplitButton(Images.Gear, string.Empty),
                Button2 = new SplitViewElement.SplitButton(Images.Gear, string.Empty)
            };

            _commitsElement = new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.ExecuteIfCan(), Images.Commit);
            _filesElement   = new StyledStringElement("Files", () => ViewModel.GoToFilesCommand.ExecuteIfCan(), Images.Code);

            this.WhenViewModel(x => x.GoToUrlCommand).Subscribe(x =>
            {
                _commentsElement.UrlRequested    = x.Execute;
                _descriptionElement.UrlRequested = x.Execute;
            });

            this.WhenViewModel(x => x.MarkdownDescription).Subscribe(x =>
            {
                var markdown = new DescriptionView {
                    Model = x
                };
                var html = markdown.GenerateString();
                _descriptionElement.Value = html;
            });

            this.WhenViewModel(x => x.ShowMenuCommand)
            .Select(x => x.ToBarButtonItem(UIBarButtonSystemItem.Action))
            .Subscribe(x => NavigationItem.RightBarButtonItem = x);
        }
Beispiel #31
0
        private void Render()
        {
            //Wait for the issue to load
            if (ViewModel.PullRequest == null)
            {
                return;
            }

            var root = new RootElement(Title);

            root.Add(new Section(_header));

            var secDetails = new Section();

            if (!string.IsNullOrEmpty(_descriptionElement.Value))
            {
                secDetails.Add(_descriptionElement);
            }

            secDetails.Add(_split1);
            secDetails.Add(_split2);

            secDetails.Add(_assigneeElement);
            secDetails.Add(_milestoneElement);
            secDetails.Add(_labelsElement);
            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 (!(ViewModel.PullRequest.Merged != null && ViewModel.PullRequest.Merged.Value))
            {
                MonoTouch.Foundation.NSAction mergeAction = async() =>
                {
                    try
                    {
                        await this.DoWorkAsync("Merging...", ViewModel.Merge);
                    }
                    catch (Exception e)
                    {
                        MonoTouch.Utilities.ShowAlert("Unable to Merge", e.Message);
                    }
                };

                StyledStringElement el;
                if (ViewModel.PullRequest.Mergable == null)
                {
                    el = new StyledStringElement("Merge".t(), mergeAction, Images.Fork);
                }
                else if (ViewModel.PullRequest.Mergable.Value)
                {
                    el = new StyledStringElement("Merge".t(), mergeAction, Images.Fork);
                }
                else
                {
                    el = new StyledStringElement("Unable to merge!".t())
                    {
                        Image = Images.Fork
                    }
                };

                root.Add(new Section {
                    el
                });
            }

            if (!string.IsNullOrEmpty(_commentsElement.Value))
            {
                root.Add(new Section {
                    _commentsElement
                });
            }

            root.Add(new Section {
                _addCommentElement
            });


            Root = root;
        }
    }
Beispiel #32
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) ? false : true;

            _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", () => NavigationController.PushViewController(new ChangesetsViewController(ViewModel.User, ViewModel.Repo, ViewModel.PullRequestId), true), Images.Commit),
                new StyledStringElement("Files", () => NavigationController.PushViewController(new PullRequestFilesViewController(ViewModel.User, ViewModel.Repo, ViewModel.PullRequestId), true), Images.File),
            });

            if (!merged)
            {
                MonoTouch.Foundation.NSAction mergeAction = async() =>
                {
                    try
                    {
                        await this.DoWorkTest("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;
            //            }
        }
Beispiel #33
0
        public void RenderGist()
        {
            if (ViewModel.Gist == null)
            {
                return;
            }

            var model = ViewModel.Gist;

            _shareButton.Enabled = _userButton.Enabled = model != null;
            var root = new RootElement(Title)
            {
                UnevenRows = true
            };
            var sec = new Section();

            root.Add(sec);


            var str = string.IsNullOrEmpty(model.Description) ? "Gist " + model.Id : model.Description;
            var d   = new NameTimeStringElement()
            {
                Time   = model.UpdatedAt.ToDaysAgo(),
                String = str,
                Image  = Theme.CurrentTheme.AnonymousUserImage
            };

            //Sometimes there's no user!
            d.Name     = (model.User == null) ? "Anonymous" : model.User.Login;
            d.ImageUri = (model.User == null) ? null : new Uri(model.User.AvatarUrl);

            sec.Add(d);

            var sec2 = new Section("Files");

            root.Add(sec2);

            foreach (var file in model.Files.Keys)
            {
                var sse = new StyledStringElement(file, model.Files[file].Size + " bytes", UITableViewCellStyle.Subtitle)
                {
                    Accessory     = UITableViewCellAccessory.DisclosureIndicator,
                    LineBreakMode = UILineBreakMode.TailTruncation,
                    Lines         = 1
                };

                var fileSaved     = file;
                var gistFileModel = model.Files[fileSaved];

//				if (string.Equals(gistFileModel.Language, "markdown", StringComparison.OrdinalIgnoreCase))
//					sse.Tapped += () => ViewModel.GoToViewableFileCommand.Execute(gistFileModel);
//				else
                sse.Tapped += () => ViewModel.GoToFileSourceCommand.Execute(gistFileModel);


                sec2.Add(sse);
            }

            if (ViewModel.Comments.Items.Count > 0)
            {
                var sec3 = new Section("Comments");
                foreach (var comment in ViewModel.Comments)
                {
                    var el = new NameTimeStringElement
                    {
                        Name   = "Anonymous",
                        Image  = Theme.CurrentTheme.AnonymousUserImage,
                        String = comment.Body,
                        Time   = comment.CreatedAt.ToDaysAgo(),
                    };

                    if (comment.User != null)
                    {
                        el.Name     = comment.User.Login;
                        el.ImageUri = new Uri(comment.User.AvatarUrl);
                    }

                    sec3.Add(el);
                }
                root.Add(sec3);
            }

            Root = root;
        }
Beispiel #34
0
        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.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)
            {
                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, 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)))
                {
                    var name = x.User.DisplayName ?? x.User.Username ?? "Unknown";
                    var avatar = new Avatar(x.User.Links?.Avatar?.Href);
                    commentsSec.Add(new NameTimeStringElement(name, x.Content.Raw, x.CreatedOn, avatar.ToUrl(), Images.Avatar));
                }

                //Load more if there's more comments
//                if (model.MoreComments != null)
//                {
//                    var loadMore = new PaginateElement("Load More", "Loading...", 
//                                                       e => this.DoWorkNoHud(() => model.MoreComments(),
//                                          x => Utilities.ShowAlert("Unable to load more!", 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;
        }
Beispiel #35
0
        private Element Generate(StudentGuideModel item)
        {
            var root    = new RootElement(item.Title);
            var section = new Section(item.Title);

            root.Add(section);
            if (item.Phone != "")
            {
                var phoneStyle = new StyledStringElement("Contact Number", item.Phone)
                {
//					BackgroundColor=UIColor.FromRGB(71,165,209),
//					TextColor=UIColor.White,
//					DetailColor=UIColor.White,
                };
                phoneStyle.Tapped += delegate {
                    UIAlertView popup = new UIAlertView("Alert", "Do you wish to send a text or diall a number?", null, "Cancel", "Text", "Call");
                    popup.Show();
                    popup.Dismissed += delegate(object sender, UIButtonEventArgs e) {
                        if (e.ButtonIndex == 1)
                        {
                            MFMessageComposeViewController msg = new MFMessageComposeViewController();
                            msg.Recipients = new string[] { item.Phone };
                            this.NavigationController.PresentViewController(msg, true, null);
                        }
                        else if (e.ButtonIndex == 2)
                        {
                            AppDelegate.getControl.calling(item.Phone);
                        }
                        ;
                    };
                };
                section.Add(phoneStyle);
            }
            ;
            if (item.Email != "")
            {
                var style = new StyledStringElement("Contact Email", item.Email)
                {
//					BackgroundColor=UIColor.FromRGB(71,165,209),
//					TextColor=UIColor.White,
//					DetailColor=UIColor.White,
                };
                style.Tapped += delegate {
                    MFMailComposeViewController email = new MFMailComposeViewController();
                    email.SetToRecipients(new string[] { item.Email });
                    this.NavigationController.PresentViewController(email, true, null);
                };
                section.Add(style);
            }
            if (item.Address != "")
            {
                section.Add(new StyledMultilineElement(item.Address)
                {
//					BackgroundColor=UIColor.FromRGB(71,165,209),
//					TextColor=UIColor.White,
//					DetailColor=UIColor.White,
                });
            }
            if (item.Description != "")
            {
                section.Add(new StyledMultilineElement(item.Description)
                {
//					BackgroundColor=UIColor.FromRGB(71,165,209),
//					TextColor=UIColor.White,
//					DetailColor=UIColor.White,
                    Alignment = UITextAlignment.Center,
                });
            }
            return(root);
        }
Beispiel #36
0
        public void showAbount()
        {
            DialogViewController searchBoxDialog;

            searchBoxEntry = new EntryElement("Subject", "Type Here", "");

            StyledStringElement developerName = new StyledStringElement("Sviluppatore", "Alessandro Facchini");

            UIFont fontLeftSide   = UIFont.FromName("HelveticaNeue-Bold", 14f);
            UIFont fontRighttSide = UIFont.FromName("Helvetica Neue", 14f);

            developerName.Font         = fontLeftSide;
            developerName.SubtitleFont = fontRighttSide;

            //
            StyledStringElement develoerEmail = new StyledStringElement("Email", "*****@*****.**");

            develoerEmail.Font         = fontLeftSide;
            develoerEmail.SubtitleFont = fontRighttSide;

            StyledStringElement develoerWeb = new StyledStringElement("Web Site", "http://www.facchini-ts.net");

            develoerWeb.Font         = fontLeftSide;
            develoerWeb.SubtitleFont = fontRighttSide;

            develoerWeb.Tapped += delegate {
                string urlStr = "http://www.facchini-ts.net/";
                NSUrl  url    = new NSUrl(urlStr);
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                }
            };


            develoerEmail.Tapped += delegate {
                sendMail("*****@*****.**");
            };

            StyledStringElement ideamail_a = new StyledStringElement("Marco Piccolo", "*****@*****.**");
            StyledStringElement ideamail_b = new StyledStringElement("Giovanni Gobesso", "*****@*****.**");
            StyledStringElement ideamail_c;

            if (UserInterfaceIdiomIsPhone)
            {
                ideamail_c = new StyledStringElement("Pigo - " + Environment.NewLine
                                                     + "Soluzioni Tecnologiche",
                                                     "info@" + Environment.NewLine + "iportogruaro.it");
            }
            else
            {
                ideamail_c = new StyledStringElement("Pigo - Soluzioni Tecnologiche",
                                                     "*****@*****.**");
            }

            ideamail_a.Font         = fontLeftSide;
            ideamail_a.SubtitleFont = fontRighttSide;
            ideamail_a.Lines        = 2;

            ideamail_c.Tapped += delegate {
                sendMail("*****@*****.**");
            };

            ideamail_a.Tapped += delegate {
                sendMail("*****@*****.**");
            };

            ideamail_b.Tapped += delegate {
                sendMail("*****@*****.**");
            };

            ideamail_b.Font          = fontLeftSide;   //UIFont.FromName ("HelveticaNeue-Bold", 12f);;
            ideamail_b.SubtitleFont  = fontRighttSide; //UIFont.FromName ("Helvetica Neue", 12f);;
            ideamail_b.LineBreakMode = UILineBreakMode.WordWrap;


            ideamail_c.SubtitleFont = fontRighttSide;
            //ideamail_c.Lines = 2;

            ideamail_c.Font          = fontLeftSide;   //UIFont.FromName ("HelveticaNeue-Bold", 12f);;
            ideamail_c.SubtitleFont  = fontRighttSide; //UIFont.FromName ("Helvetica Neue", 12f);;
            ideamail_c.LineBreakMode = UILineBreakMode.WordWrap;

            //UIFont fontLeftSide = UIFont.FromName ("HelveticaNeue-Bold", 14f);
            //UIFont fontRighttSide = UIFont.FromName ("Helvetica Neue", 14f);

            StyledStringElement colaboracion_a = new StyledStringElement("Comune di Portogruaro", "");
            StyledStringElement colaboracion_b = new StyledStringElement("ASCOM", "");
            StyledStringElement colaboracion_c = new StyledStringElement("Confartigianato", "");
            StyledStringElement colaboracion_d = new StyledStringElement("CNA", "");
            StyledStringElement colaboracion_e = new StyledStringElement("Coldiretti", "");

            colaboracion_a.Font         = fontLeftSide;
            colaboracion_a.SubtitleFont = fontRighttSide;

            colaboracion_b.Font         = fontLeftSide;
            colaboracion_b.SubtitleFont = fontRighttSide;

            colaboracion_c.Font         = fontLeftSide;
            colaboracion_c.SubtitleFont = fontRighttSide;

            colaboracion_d.Font         = fontLeftSide;
            colaboracion_d.SubtitleFont = fontRighttSide;

            colaboracion_e.Font         = fontLeftSide;
            colaboracion_e.SubtitleFont = fontRighttSide;

            colaboracion_a.Tapped += delegate {
                string urlStr = "http://www.comune.portogruaro.ve.it/";
                NSUrl  url    = new NSUrl(urlStr);
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                }
            };


            colaboracion_b.Tapped += delegate {
                string urlStr = "http://www.ascomportogruaro.it/";
                NSUrl  url    = new NSUrl(urlStr);
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                }
            };

            colaboracion_c.Tapped += delegate {
                string urlStr = "http://www.confartigianato.it/";
                NSUrl  url    = new NSUrl(urlStr);
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                }
            };

            colaboracion_d.Tapped += delegate {
                string urlStr = "http://www.cna.it/";
                NSUrl  url    = new NSUrl(urlStr);
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                }
            };

            colaboracion_e.Tapped += delegate {
                string urlStr = "http://www.coldiretti.it/Pagine/default.aspx";
                NSUrl  url    = new NSUrl(urlStr);
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                }
            };



            //comune di..
            //ascom
            //confartia..
            //CNA
            //coldiretti

            colaboracion_a.Image = UIImage.FromFile("images/about/portogruaro.png");
            colaboracion_b.Image = UIImage.FromFile("images/about/confcommercio.png");
            colaboracion_c.Image = UIImage.FromFile("images/about/Confartigianato.png");
            colaboracion_d.Image = UIImage.FromFile("images/about/CNA.png");
            colaboracion_e.Image = UIImage.FromFile("images/about/coldiretti.png");

            developerName.Image = UIImage.FromFile("images/about/TS.png");
            //developerName.Value = string.Empty;
            developerName.Caption = String.Empty;
            //developerName.su
            develoerEmail.Image = null;
            develoerWeb.Image   = null;

            searchBoxDialog = new DialogViewController(new RootElement("Iportuaro")
            {
                new Section(TopsectionHeaderTitle("Realizzata da"))
                {
                    developerName, develoerEmail, develoerWeb
                },
                new Section(sectionHeaderTitle("Da un'idea di"))
                {
                    ideamail_c
                },


                new Section(sectionHeaderTitle("In collaborazione con"))
                {
                    colaboracion_a, colaboracion_b, colaboracion_c, colaboracion_d
                }
                //colaboracion_e
            });

            //flightNumerEntry.KeyboardType = UIKeyboardType.Default;
            //searchBoxDialog.Root.UnevenRows = true;
            searchBoxDialog.TableView.BackgroundView  = null;
            searchBoxDialog.TableView.BackgroundColor = UIColor.White;
            UINavigationController nav = new UINavigationController(searchBoxDialog);

            nav.NavigationBar.TintColor = UIColor.FromRGB(9, 76, 107);


            //this.PresentViewController (nav, true, null);
            searchBoxEntry.ReturnKeyType = UIReturnKeyType.Done;


            this.Add(searchBoxDialog.View);
        }
        public void Render()
        {
            var commitModel = ViewModel.Changeset;

            if (commitModel == null)
            {
                return;
            }

            var root = new RootElement(Title)
            {
                UnevenRows = Root.UnevenRows
            };

            _header.Subtitle = "Commited ".t() + (commitModel.Commit.Committer.Date).ToDaysAgo();
            var headerSection = new Section(_header);

            root.Add(headerSection);

            var detailSection = new Section();

            root.Add(detailSection);

            var user = "******";

            if (commitModel.Author != null)
            {
                user = commitModel.Author.Login;
            }
            if (commitModel.Commit.Author != null)
            {
                user = commitModel.Commit.Author.Name;
            }

            detailSection.Add(new MultilinedElement(user, commitModel.Commit.Message)
            {
                CaptionColor    = Theme.CurrentTheme.MainTextColor,
                ValueColor      = Theme.CurrentTheme.MainTextColor,
                BackgroundColor = UIColor.White
            });

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

            if (_viewSegment.SelectedSegment == 0)
            {
                var fileSection = new Section();
                commitModel.Files.ForEach(x => {
                    var file    = x.Filename.Substring(x.Filename.LastIndexOf('/') + 1);
                    var sse     = new ChangesetElement(file, x.Status, x.Additions, x.Deletions);
                    sse.Tapped += () => {
                        string parent = null;
                        if (commitModel.Parents != null && commitModel.Parents.Count > 0)
                        {
                            parent = commitModel.Parents[0].Sha;
                        }

                        // This could mean it's a binary or it's just been moved with no changes...
                        if (x.Patch == null)
                        {
                            NavigationController.PushViewController(new RawContentViewController(x.RawUrl, x.BlobUrl), true);
                        }
                        else
                        {
                            NavigationController.PushViewController(new ChangesetDiffViewController(ViewModel.User, ViewModel.Repository, commitModel.Sha, x)
                            {
                                Comments = ViewModel.Comments.Items.ToList()
                            }, true);
                        }
                    };
                    fileSection.Add(sse);
                });

                if (fileSection.Elements.Count > 0)
                {
                    root.Add(fileSection);
                }
            }
            else if (_viewSegment.SelectedSegment == 1)
            {
                var commentSection = new Section();
                foreach (var comment in ViewModel.Comments)
                {
                    //The path should be empty to indicate it's a comment on the entire commit, not a specific file
                    if (!string.IsNullOrEmpty(comment.Path))
                    {
                        continue;
                    }

                    commentSection.Add(new CommentElement {
                        Name            = comment.User.Login,
                        Time            = comment.CreatedAt.ToDaysAgo(),
                        String          = comment.Body,
                        Image           = Images.Anonymous,
                        ImageUri        = new Uri(comment.User.AvatarUrl),
                        BackgroundColor = UIColor.White,
                    });
                }

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

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

            Root = root;
        }
Beispiel #38
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());
        }
		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", "None", UITableViewCellStyle.Value1);
			milestone.Accessory = UITableViewCellAccessory.DisclosureIndicator;
			milestone.Tapped += () => ViewModel.GoToMilestonesCommand.Execute(null);

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

			var version = new StyledStringElement("Version", "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);
		}
Beispiel #40
0
        public override void ViewDidLoad()
        {
            NoItemsText = "No Notifications".t();
            Title       = "Notifications".t();

            base.ViewDidLoad();

            _markHud = new Hud(View);
            _segmentBarButton.Width = View.Frame.Width - 10f;
            ToolbarItems            = new [] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), _segmentBarButton, new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) };

            var vm = (NotificationsViewModel)ViewModel;

            NavigationItem.RightBarButtonItem    = new UIBarButtonItem(Theme.CurrentTheme.CheckButton, UIBarButtonItemStyle.Plain, (s, e) => vm.ReadAllCommand.Execute(null));
            vm.ReadAllCommand.CanExecuteChanged += (sender, e) => NavigationItem.RightBarButtonItem.Enabled = vm.ReadAllCommand.CanExecute(null);

            vm.Bind(x => x.IsMarking, x =>
            {
                if (x)
                {
                    _markHud.Show("Marking...");
                }
                else
                {
                    _markHud.Hide();
                }
            });

            BindCollection(vm.Notifications, x =>
            {
                var el = new StyledStringElement(x.Subject.Title, x.UpdatedAt.ToDaysAgo(), UITableViewCellStyle.Subtitle)
                {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                };

                var subject = x.Subject.Type.ToLower();
                if (subject.Equals("issue"))
                {
                    el.Image = Images.Flag;
                }
                else if (subject.Equals("pullrequest"))
                {
                    el.Image = Images.Hand;
                }
                else if (subject.Equals("commit"))
                {
                    el.Image = Images.Commit;
                }
                else if (subject.Equals("release"))
                {
                    el.Image = Images.Tag;
                }
                else
                {
                    el.Image = Images.Notifications;
                }

                el.Tapped += () => vm.GoToNotificationCommand.Execute(x);
                return(el);
            });

            var set = this.CreateBindingSet <NotificationsView, NotificationsViewModel>();

            set.Bind(_viewSegment).To(x => x.ShownIndex);
            set.Apply();
        }
Beispiel #41
0
        public void DemoStyled()
        {
            var imageBackground = new Uri("file://" + Path.GetFullPath("background.png"));
            var image           = ImageLoader.DefaultRequestImage(imageBackground, null);
            var small           = image.Scale(new SizeF(32, 32));

            var imageIcon = new StyledStringElement("Local image icon")
            {
                Image = small
            };
            var backgroundImage = new StyledStringElement("Image downloaded")
            {
                BackgroundUri = new Uri("http://www.google.com/images/logos/ps_logo2.png")
            };
            var localImage = new StyledStringElement("Local image")
            {
                BackgroundUri = imageBackground
            };

            var backgroundSolid = new StyledStringElement("Solid background")
            {
                BackgroundColor = UIColor.Green
            };
            var colored = new StyledStringElement("Colored", "Detail in Green")
            {
                TextColor       = UIColor.Yellow,
                BackgroundColor = UIColor.Red,
                DetailColor     = UIColor.Green,
            };
            var root = new RootElement("Styled Elements")
            {
                new Section("Image icon")
                {
                    imageIcon
                },
                new Section("Background")
                {
                    backgroundImage, backgroundSolid, localImage
                },
                new Section("Text Color")
                {
                    colored
                },
                new Section("Cell Styles")
                {
                    new StyledStringElement("Default", "Invisible value", UITableViewCellStyle.Default),
                    new StyledStringElement("Value1", "Aligned on each side", UITableViewCellStyle.Value1),
                    new StyledStringElement("Value2", "Like the Addressbook", UITableViewCellStyle.Value2),
                    new StyledStringElement("Subtitle", "Makes it sound more important", UITableViewCellStyle.Subtitle),
                    new StyledStringElement("Subtitle", "Brown subtitle", UITableViewCellStyle.Subtitle)
                    {
                        DetailColor = UIColor.Brown
                    }
                },
                new Section("Accessories")
                {
                    new StyledStringElement("DisclosureIndicator")
                    {
                        Accessory = UITableViewCellAccessory.DisclosureIndicator
                    },
                    new StyledStringElement("Checkmark")
                    {
                        Accessory = UITableViewCellAccessory.Checkmark
                    },
                    new StyledStringElement("DetailDisclosureIndicator")
                    {
                        Accessory = UITableViewCellAccessory.DetailDisclosureButton
                    },
                }
            };

            var dvc = new DialogViewController(root, true);

            navigation.PushViewController(dvc, true);
        }
Beispiel #42
0
		public void Render(RepositoryDetailedModel model)
        {
			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 split = new SplitButtonElement();
            split.AddButton("Followers", model.FollowersCount.ToString());
            split.AddButton("Forks", model.ForkCount.ToString());

            var sec1 = new Section();

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


            //Calculate the best representation of the size
            string size;
            if (model.Size / 1024f < 1)
                size = string.Format("{0:0.##}B", model.Size);
            else if ((model.Size / 1024f / 1024f) < 1)
                size = string.Format("{0:0.##}KB", model.Size / 1024f);
            else
                size = string.Format("{0:0.##}MB", model.Size / 1024f / 1024f);
//
//            sec1.Add(new SplitElement(new SplitElement.Row {
//				Text1 = model + (model.HasIssues == 1 ? " Issue" : " Issues"),
//                Image1 = Images.Flag,
//				Text2 = model.ForkCount.ToString() + (model.ForkCount == 1 ? " Fork" : " Forks"),
//                Image2 = Images.Fork
//            }));
//
            sec1.Add(new SplitElement(new SplitElement.Row {
				Text1 = (model.UtcCreatedOn).ToString("MM/dd/yy"),
                Image1 = Images.Create,
                Text2 = size,
                Image2 = Images.Size
            }));

            var owner = new StyledStringElement("Owner", model.Owner) { Image = Images.Person,  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 = Images.Fork,  Accessory = UITableViewCellAccessory.DisclosureIndicator };
				parent.Tapped += () => ViewModel.GoToForkParentCommand.Execute(model.ForkOf);
                sec1.Add(parent);
            }

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

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

			if (model.HasWiki)
				sec2.Add(new StyledStringElement("Wiki", () => ViewModel.GoToWikiCommand.Execute(null), Images.Pencil));

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

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

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

            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), Images.Webpage)
                });
            }

            Root = root;
        }
Beispiel #43
0
		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());

            var root = new RootElement(Title);
            root.Add(new Section { split });

			var secDetails = new Section();

			if (!string.IsNullOrEmpty(ViewModel.Issue.Content))
			{
                _descriptionElement.LoadContent(new MarkdownRazorView { Model = ViewModel.Issue.Content }.GenerateString());
				secDetails.Add(_descriptionElement);
			}

			var split1 = new SplitElement(new SplitElement.Row { Image1 = Images.Cog, Image2 = Images.Priority });
			split1.Value.Text1 = ViewModel.Issue.Status;
			split1.Value.Text2 = ViewModel.Issue.Priority;
			secDetails.Add(split1);


			var split2 = new SplitElement(new SplitElement.Row { Image1 = Images.Flag, Image2 = Images.ServerComponents });
			split2.Value.Text1 = ViewModel.Issue.Metadata.Kind;
			split2.Value.Text2 = ViewModel.Issue.Metadata.Component ?? "No Component";
			secDetails.Add(split2);


			var split3 = new SplitElement(new SplitElement.Row { Image1 = Images.SitemapColor, Image2 = Images.Milestone });
			split3.Value.Text1 = ViewModel.Issue.Metadata.Version ?? "No Version";
			split3.Value.Text2 = ViewModel.Issue.Metadata.Milestone ?? "No Milestone";
			secDetails.Add(split3);

			var assigneeElement = new StyledStringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "******", UITableViewCellStyle.Value1) {
				Image = Images.Person,
				Accessory = UITableViewCellAccessory.DisclosureIndicator
			};
			assigneeElement.Tapped += () => ViewModel.GoToAssigneeCommand.Execute(null);
			secDetails.Add(assigneeElement);

			root.Add(secDetails);

            if (ViewModel.Comments.Any(x => !string.IsNullOrEmpty(x.Content)))
			{
				root.Add(new Section { _commentsElement });
			}

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

            Root = new RootElement(string.Format("Pull Request #{0}", ViewModel.PullRequestId))
            {
                UnevenRows = true
            };

            var description = new StyledMultilineElement(string.Empty);

            description.Font = UIFont.SystemFontOfSize(12f);

            var statusElement = new SplitElement
            {
                Button1 = new SplitElement.SplitButton(Images.Status.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "Open")
                {
                    Enabled = false
                },
                Button2 = new SplitElement.SplitButton(Images.Group.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "0 Participants", () => ViewModel.GoToParticipantsCommand.ExecuteIfCan()),
            };

            var buildElement = new SplitElement
            {
                Button1 = new SplitElement.SplitButton(Images.Build.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "0 Builds", () => ViewModel.GoToBuildStatusCommand.ExecuteIfCan()),
                Button2 = new SplitElement.SplitButton(Images.Comment.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), "0 Comments", () => ViewModel.GoToCommentsCommand.ExecuteIfCan()),
            };

            Root.Add(new Section {
                statusElement, buildElement
            });

            var changesElement = new StyledStringElement("Changes", () => ViewModel.GoToChangesCommand.ExecuteIfCan(), Images.File.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));
            var commitsElement = new StyledStringElement("Commits", () => ViewModel.GoToCommitsCommand.ExecuteIfCan(), Images.Commit.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));

            Root.Add(new Section {
                changesElement, commitsElement
            });

            var mergeElement = new StyledStringElement("Merge", string.Empty);

            mergeElement.Image = Images.Merge;

            var commentsElement = new WebElement("comments");
            var commentsSection = new Section()
            {
                commentsElement
            };

            var header = new ImageAndTitleHeaderView
            {
                BackgroundColor = UIColor.GroupTableViewBackgroundColor,
                Image           = Images.Avatar,
                Text            = " "
            };

            TableView.TableHeaderView     = header;
            TableView.SectionFooterHeight = 0.3f;

            ViewModel.GoToCommentsCommand.Subscribe(_ =>
            {
                if (commentsElement.GetImmediateRootElement() != null)
                {
                    TableView.ScrollToRow(commentsElement.IndexPath, UITableViewScrollPosition.Middle, true);
                }
            });

            ViewModel.WhenAnyValue(x => x.PullRequest).Where(x => x != null).Subscribe(x =>
            {
                header.Text = x.Title;
                statusElement.Button1.Text = x.State;
                description.Caption        = x.Description;
                if (description.GetImmediateRootElement() == null)
                {
                    Root[0].Insert(0, UITableViewRowAnimation.Fade, description);
                }

                var selfLink = x.Author.User.Links["self"].FirstOrDefault();
                if (selfLink != null && !string.IsNullOrEmpty(selfLink.Href))
                {
                    header.ImageUri = selfLink.Href + "/avatar.png";
                }
                TableView.TableHeaderView = header;
            });

            ViewModel.Participants.Changed.Subscribe(_ =>
            {
                statusElement.Button2.Text = string.Format("{0} Participant{1}", ViewModel.Participants.Count, ViewModel.Participants.Count != 1 ? "s" : string.Empty);
            });

            ViewModel.WhenAnyValue(x => x.BuildStatus).Where(x => x != null && x.Length > 0).Subscribe(x =>
            {
                var first = x.FirstOrDefault();
                if (string.Equals(first.State, "SUCCESSFUL", StringComparison.OrdinalIgnoreCase))
                {
                    buildElement.Button1.Image = Images.BuildOk.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                }
                else if (string.Equals(first.State, "FAILED", StringComparison.OrdinalIgnoreCase))
                {
                    buildElement.Button1.Image = Images.Error.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                }
                else
                {
                    buildElement.Button1.Image = Images.Update.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                }

                buildElement.Button1.Text = string.Format("{0} Build{1}", x.Length, x.Length == 1 ? string.Empty : "s");
            });

            ViewModel.Activities.Changed.Subscribe(_ =>
            {
                var commentCount          = ViewModel.Activities.Where(x => x.Comment != null).Sum(x => CommentCount(x.Comment));
                buildElement.Button2.Text = string.Format("{0} Comment{1}", commentCount, commentCount != 1 ? "s" : string.Empty);

                if (ViewModel.Activities.Count > 0)
                {
                    if (commentsSection.GetImmediateRootElement() == null)
                    {
                        Root.Add(commentsSection);
                    }

                    var template = new CommentCellView {
                        Model = ViewModel.Activities.ToList()
                    };
                    commentsElement.Value = template.GenerateString();
                }
                else
                {
                    if (commentsSection.GetImmediateRootElement() != null)
                    {
                        Root.Remove(commentsSection, UITableViewRowAnimation.Fade);
                    }
                }
            });
        }