Ejemplo n.º 1
0
		/// <summary>
		/// Populates the page with sessions, grouped by time slot
		/// that are marked as 'favorite'
		/// </summary>
		protected override void PopulateTable()
		{
			// get the sessions from the database
			var sessions = BL.Managers.SessionManager.GetSessions ();
			var favs = BL.Managers.FavoritesManager.GetFavorites();
			// extract IDs from Favorites query
			List<string> favoriteIDs = new List<string>();
			foreach (var f in favs) favoriteIDs.Add (f.SessionKey);

			// build list, matching the Favorite.SessionKey with actual
			// Session.Key rows - which might have moved if the data changed
			var root = 	new RootElement ("Favorites") {
						from s in sessions
							where favoriteIDs.Contains(s.Key)
							group s by s.Start.Ticks into g
							orderby g.Key
							select new Section (new DateTime (g.Key).ToString ("dddd HH:mm")) {
							from hs in g
							   select (Element) new SessionElement (hs)
			}};	
			
			if(root.Count == 0) {
				var section = new Section("No favorites") {
					new StyledStringElement("Touch the star to favorite a session") 
				};
				root.Add(section);
			}
			Root = root;
		}	
	private void Core()
	{
		var rootStyles = new RootElement ("Add New Styles");

		var styleHeaderElement = new Section ("Style Header");
		var manualEntryRootElement = new RootElement ("Manual Entry");
		styleHeaderElement.Add (manualEntryRootElement);

		var quickFillElement = new Section ("Quick Fill");
		var womenTops = new RootElement ("Womens Tops");
		var womenOutwear = new RootElement ("Womens Outerwear");
		var womenSweaters = new RootElement ("Womens Sweaters");
		quickFillElement.AddAll (new [] { womenTops, womenOutwear, womenSweaters });

		rootStyles.Add (new [] { styleHeaderElement, quickFillElement });

		// DialogViewController derives from UITableViewController, so access all stuff from it
		var rootDialog = new DialogViewController (rootStyles);
		rootDialog.NavigationItem.BackBarButtonItem = new UIBarButtonItem("Back", UIBarButtonItemStyle.Bordered, null);

		EventHandler handler = (s, e) => {
			if(_popover != null)
				_popover.Dismiss(true);
		};

		rootDialog.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, handler), true);
		rootDialog.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Create", UIBarButtonItemStyle.Bordered, null), true);

		NavigationPopoverContentViewController = new UINavigationController (rootDialog);
	}
Ejemplo n.º 3
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);
			}

            _split1.Button1.Text = ViewModel.Issue.Status;
            _split1.Button2.Text = ViewModel.Issue.Priority;
            secDetails.Add(_split1);

            _split2.Button1.Text = ViewModel.Issue.Metadata.Kind;
            _split2.Button2.Text = ViewModel.Issue.Metadata.Component ?? "No Component";
			secDetails.Add(_split2);

            _split3.Button1.Text = ViewModel.Issue.Metadata.Version ?? "No Version";
            _split3.Button2.Text = ViewModel.Issue.Metadata.Milestone ?? "No Milestone";
            secDetails.Add(_split3);

			var assigneeElement = new StyledStringElement("Assigned", ViewModel.Issue.Responsible != null ? ViewModel.Issue.Responsible.Username : "******", UITableViewCellStyle.Value1) {
                Image = AtlassianIcon.User.ToImage(),
				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 = AtlassianIcon.Addcomment.ToImage() };
			addComment.Tapped += AddCommentTapped;
			root.Add(new Section { addComment });
			Root = root;
		}
Ejemplo n.º 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;

		}
Ejemplo n.º 5
0
        private RootElement BuildRoot(string url)
        {
            var root = new RootElement (String.Empty);
            var section = new Section("TodoItems");
            root.Add (section);
            var result = GetAzureResult (url);

            foreach (JsonObject item in result) {
                section.Add (new StringElement(item["text"]));
            }

            return root;
        }
Ejemplo n.º 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // create from view
            var dialogListView = new DialogListView(this);
            SetContentView(dialogListView);

            RootElement root = new RootElement("Elements");
            Section section = new Section();
            root.Add(section);

            foreach (var item in _names) {
                section.Add(new StringElement(item.LastName, item.FirstName, "custom_string_element"));
            }

            dialogListView.Root = root;
        }
Ejemplo n.º 7
0
        RootElement InitializeRoot()
        {
            RootElement root = new RootElement("Elements");
            Section section = new Section("Section");
            root.Add(section);

            section.Add(new EntryElement("Label 1", "Value 1"));
            section.Add(new EntryElement("Label 2", "Value 2"));
            section.Add(new EntryElement("Label 3", "Value 3"));
            section.Add(new EntryElement("Label 4", "Value 4"));
            section.Add(new EntryElement("Label 5", "Value 5"));
            section.Add(new EntryElement("Label 6", "Value 6"));

            section.Add(new WebContentElement("http://www.google.com")
            {
                WebContent = "<html><body><h1>My First Heading</h1><p>My first paragraph.</p></body></html>"
            });

            //section.Add(new EntryElement("Label 7", "Value 7"));

            return root;
        }
Ejemplo n.º 8
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;

		}
Ejemplo n.º 9
0
        public PhotoViewController() : base(UITableViewStyle.Grouped, null, true)
        {
            // Add the image that will be publish
            var imageView = new UIImageView(new CGRect(0, 0, View.Frame.Width, 220))
            {
                Image = UIImage.FromFile("wolf.jpg")
            };

            // Add a textbox that where you will be able to add a comment to the photo
            txtMessage = new EntryElement("", "Say something nice!", "");

            Root = new RootElement("Post photo!")
            {
                new Section()
                {
                    new UIViewElement("", imageView, true)
                    {
                        Flags = UIViewElement.CellFlags.DisableSelection | UIViewElement.CellFlags.Transparent,
                    },
                    txtMessage
                }
            };

            // Create the request to post a photo into your wall
            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Post", UIBarButtonItemStyle.Plain, ((sender, e) => {
                // Disable the post button for prevent another untill the actual one finishes
                (sender as UIBarButtonItem).Enabled = false;

                // Add the photo and text that will be publish
                var parameters = new NSDictionary("picture", UIImage.FromFile("wolf.jpg").AsPNG(), "caption", txtMessage.Value);

                // Create the request
                var request = new GraphRequest("/" + Profile.CurrentProfile.UserId + "/photos", parameters, AccessToken.CurrentAccessToken.TokenString, null, HttpMethod.Post);
                var requestConnection = new GraphRequestConnection();
                requestConnection.AddRequest(request, (connection, result, error) => {
                    // Enable the post button
                    (sender as UIBarButtonItem).Enabled = true;

                    // Handle if something went wrong
                    if (error != null)
                    {
                        new UIAlertView("Error...", error.Description, null, "Ok", null).Show();
                        return;
                    }

                    // Do your magic if the request was successful
                    new UIAlertView("Yay!!", "Your photo was published!", null, "Ok", null).Show();

                    photoId = (result as NSDictionary) ["post_id"].ToString();

                    // Add a button to allow to delete the photo posted
                    Root.Add(new Section()
                    {
                        new StyledStringElement("Delete Post", DeletePost)
                        {
                            Alignment = UITextAlignment.Center,
                            TextColor = UIColor.Red
                        }
                    });
                });
                requestConnection.Start();
            }));
        }
Ejemplo n.º 10
0
		public void RenderIssue()
		{
			if (ViewModel.Issue == null)
				return;

			NavigationItem.RightBarButtonItem.Enabled = true;

            HeaderView.Text = ViewModel.Issue.Title;
            HeaderView.SubText = "Updated " + ViewModel.Issue.UtcLastUpdated.Humanize();
            RefreshHeaderView();

            var split = new SplitButtonElement();
            split.AddButton("Comments", ViewModel.Comments.Items.Count.ToString());
            split.AddButton("Watches", 0.ToString());
            split.AddButton("Votes", 0.ToString());

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

			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 : "******", 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;
		}
Ejemplo n.º 11
0
        private void Populate(object callbacks, object o, RootElement root)
        {
            MemberInfo last_radio_index = null;
            var members = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                 BindingFlags.NonPublic | BindingFlags.Instance);

            Section section = null;

            foreach (var mi in members)
            {
                Type mType = GetTypeForMember(mi);

                if (mType == null)
                    continue;

                string caption = null;
                object[] attrs = mi.GetCustomAttributes(false);
                bool skip = false;
                foreach (var attr in attrs)
                {
                    if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute)
                        skip = true;
                    else if (attr is CaptionAttribute)
                        caption = ((CaptionAttribute)attr).Caption;
                    else if (attr is SectionAttribute)
                    {
                        if (section != null)
                            root.Add(section);
                        var sa = attr as SectionAttribute;
                        section = new Section(sa.Caption, sa.Footer);
                    }
                }
                if (skip)
                    continue;

                if (caption == null)
                    caption = MakeCaption(mi.Name);

                if (section == null)
                    section = new Section();

                Element element = null;
                if (mType == typeof(string))
                {
                    PasswordAttribute pa = null;
                    AlignmentAttribute align = null;
                    EntryAttribute ea = null;
                    object html = null;
                    Action invoke = null;
                    bool multi = false;

                    foreach (object attr in attrs)
                    {
                        if (attr is PasswordAttribute)
                            pa = attr as PasswordAttribute;
                        else if (attr is EntryAttribute)
                            ea = attr as EntryAttribute;
                        else if (attr is MultilineAttribute)
                            multi = true;
                        else if (attr is HtmlAttribute)
                            html = attr;
                        else if (attr is AlignmentAttribute)
                            align = attr as AlignmentAttribute;

                        if (attr is OnTapAttribute)
                        {
                            string mname = ((OnTapAttribute)attr).Method;

                            if (callbacks == null)
                            {
                                throw new Exception(
                                    "Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor");
                            }

                            var method = callbacks.GetType().GetMethod(mname);
                            if (method == null)
                                throw new Exception("Did not find method " + mname);
                            invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); };
                        }
                    }

                    var value = (string)GetValue(mi, o);
                    if (pa != null)
                        element = new EntryElement(caption, pa.Placeholder, value, true);
                    else if (ea != null)
                        element = new EntryElement(caption, ea.Placeholder, value) { KeyboardType = ea.KeyboardType };
                    else if (multi)
                        element = new MultilineElement(caption, value);
                    else if (html != null)
                        element = new HtmlElement(caption, value);
                    else
                    {
                        var selement = new StringElement(caption, value);
                        element = selement;

                        if (align != null)
                            selement.Alignment = align.Alignment;
                    }

                    if (invoke != null)
                        (element).Tapped += invoke;
                }
                else if (mType == typeof(float))
                {
                    var floatElement = new FloatElement(null, null, (float)GetValue(mi, o)) { Caption = caption };
                    element = floatElement;

                    foreach (object attr in attrs)
                    {
                        if (attr is RangeAttribute)
                        {
                            var ra = attr as RangeAttribute;
                            floatElement.MinValue = ra.Low;
                            floatElement.MaxValue = ra.High;
                            floatElement.ShowCaption = ra.ShowCaption;
                        }
                    }
                }
                else if (mType == typeof(bool))
                {
                    bool checkbox = false;
                    foreach (object attr in attrs)
                    {
                        if (attr is CheckboxAttribute)
                            checkbox = true;
                    }

                    if (checkbox)
                        element = new CheckboxElement(caption, (bool)GetValue(mi, o));
                    else
                        element = new BooleanElement(caption, (bool)GetValue(mi, o));
                }
                else if (mType == typeof(DateTime))
                {
                    var dateTime = (DateTime)GetValue(mi, o);
                    bool asDate = false, asTime = false;

                    foreach (object attr in attrs)
                    {
                        if (attr is DateAttribute)
                            asDate = true;
                        else if (attr is TimeAttribute)
                            asTime = true;
                    }

                    if (asDate)
                        element = new DateElement(caption, dateTime);
                    else if (asTime)
                        element = new TimeElement(caption, dateTime);
                    else
                        element = new DateTimeElement(caption, dateTime);
                }
                else if (mType.IsEnum)
                {
                    var csection = new Section();
                    ulong evalue = Convert.ToUInt64(GetValue(mi, o), null);
                    int idx = 0;
                    int selected = 0;

                    foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static))
                    {
                        ulong v = Convert.ToUInt64(GetValue(fi, null));

                        if (v == evalue)
                            selected = idx;

                        var ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute;
                        csection.Add(new RadioElement(ca != null ? ca.Caption : MakeCaption(fi.Name)));
                        idx++;
                    }

                    element = new RootElement(caption, new RadioGroup(null, selected)) { csection };
                }
                else if (mType == typeof(UIImage))
                {
                    element = new ImageElement((UIImage)GetValue(mi, o));
                }
                else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType))
                {
                    var csection = new Section();
                    int count = 0;

                    if (last_radio_index == null)
                        throw new Exception("IEnumerable found, but no previous int found");
                    foreach (var e in (IEnumerable)GetValue(mi, o))
                    {
                        csection.Add(new RadioElement(e.ToString()));
                        count++;
                    }
                    var selected = (int)GetValue(last_radio_index, o);
                    if (selected >= count || selected < 0)
                        selected = 0;
                    element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index))
                        {
                            csection
                        };
                    last_radio_index = null;
                }
                else if (typeof(int) == mType)
                {
                    if (attrs.OfType<RadioSelectionAttribute>().Any())
                    {
                        last_radio_index = mi;
                    }
                }
                else
                {
                    var nested = GetValue(mi, o);
                    if (nested != null)
                    {
                        var newRoot = new RootElement(caption);
                        Populate(callbacks, nested, newRoot);
                        element = newRoot;
                    }
                }

                if (element == null)
                    continue;
                section.Add(element);
                mappings[element] = new MemberAndInstance(mi, o);
            }
            root.Add(section);
        }
Ejemplo n.º 12
0
	    protected override void CreateMenuRoot()
		{
            var username = ViewModel.Account.Username;
			Title = username;
            var root = new RootElement(username);

            root.Add(new Section
            {
                new MenuElement("Profile", () => ViewModel.GoToProfileCommand.Execute(null), AtlassianIcon.User.ToImage()),
            });

            var eventsSection = new Section { HeaderView = new MenuSectionView("Events") };
            eventsSection.Add(new MenuElement(username, () => ViewModel.GoToMyEvents.Execute(null), AtlassianIcon.Blogroll.ToImage()));
			if (ViewModel.Teams != null && ViewModel.Account.ShowTeamEvents)
                ViewModel.Teams.ForEach(team => eventsSection.Add(new MenuElement(team, () => ViewModel.GoToTeamEventsCommand.Execute(team), AtlassianIcon.Blogroll.ToImage())));
            root.Add(eventsSection);

            var repoSection = new Section() { HeaderView = new MenuSectionView("Repositories") };
            repoSection.Add(new MenuElement("Owned", () => ViewModel.GoToOwnedRepositoriesCommand.Execute(null), AtlassianIcon.Devtoolsrepository.ToImage()));
            repoSection.Add(new MenuElement("Shared", () => ViewModel.GoToSharedRepositoriesCommand.Execute(null), AtlassianIcon.Spacedefault.ToImage()));
            repoSection.Add(new MenuElement("Watched", () => ViewModel.GoToStarredRepositoriesCommand.Execute(null), AtlassianIcon.Star.ToImage()));
            repoSection.Add(new MenuElement("Explore", () => ViewModel.GoToExploreRepositoriesCommand.Execute(null), AtlassianIcon.Search.ToImage()));
            root.Add(repoSection);
            
			if (ViewModel.PinnedRepositories.Any())
			{
				_favoriteRepoSection = new Section() { HeaderView = new MenuSectionView("Favorite Repositories") };
				foreach (var pinnedRepository in ViewModel.PinnedRepositories)
					_favoriteRepoSection.Add(new PinnedRepoElement(pinnedRepository, ViewModel.GoToRepositoryCommand));
				root.Add(_favoriteRepoSection);
			}
			else
			{
				_favoriteRepoSection = null;
			}

			if (ViewModel.Account.ExpandTeamsAndGroups)
			{
                if (ViewModel.Groups?.Count > 0)
                {
                    var groupsTeamsSection = new Section { HeaderView = new MenuSectionView("Groups") };
                    ViewModel.Groups.ForEach(x => groupsTeamsSection.Add(new MenuElement(x.Name, () => ViewModel.GoToGroupCommand.Execute(x), AtlassianIcon.Group.ToImage())));
                    root.Add(groupsTeamsSection);
                }
                if (ViewModel.Teams?.Count > 0)
                {
                    var groupsTeamsSection = new Section { HeaderView = new MenuSectionView("Teams") };
                    ViewModel.Teams.ForEach(x => groupsTeamsSection.Add(new MenuElement(x, () => ViewModel.GoToTeamCommand.Execute(x), AtlassianIcon.Userstatus.ToImage())));
                    root.Add(groupsTeamsSection);
                }
			}
			else
			{
                var groupsTeamsSection = new Section() { HeaderView = new MenuSectionView("Collaborations") };
                groupsTeamsSection.Add(new MenuElement("Groups", () => ViewModel.GoToGroupsCommand.Execute(null), AtlassianIcon.Group.ToImage()));
                groupsTeamsSection.Add(new MenuElement("Teams", () => ViewModel.GoToTeamsCommand.Execute(null), AtlassianIcon.Userstatus.ToImage()));
                root.Add(groupsTeamsSection);
			}

            var infoSection = new Section() { HeaderView = new MenuSectionView("Info & Preferences") };
            root.Add(infoSection);
            infoSection.Add(new MenuElement("Settings", () => ViewModel.GoToSettingsCommand.Execute(null), AtlassianIcon.Configure.ToImage()));
            infoSection.Add(new MenuElement("Feedback & Support", () => ViewModel.GoToFeedbackCommand.Execute(null), AtlassianIcon.Comment.ToImage()));
            infoSection.Add(new MenuElement("Accounts", () => ProfileButtonClicked(this, System.EventArgs.Empty), AtlassianIcon.User.ToImage()));
            Root = root;
		}
Ejemplo n.º 13
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; 
        }
Ejemplo n.º 14
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;
        }
Ejemplo n.º 15
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.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;
        }
Ejemplo n.º 16
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;
        }
Ejemplo n.º 17
0
        private void Populate(object callbacks, object o, RootElement root)
        {
            MemberInfo last_radio_index = null;
            var        members          = o.GetType().GetMembers(BindingFlags.DeclaredOnly | BindingFlags.Public |
                                                                 BindingFlags.NonPublic | BindingFlags.Instance);

            Section section = null;

            foreach (var mi in members)
            {
                Type mType = GetTypeForMember(mi);

                if (mType == null)
                {
                    continue;
                }

                string   caption = null;
                object[] attrs   = mi.GetCustomAttributes(false);
                bool     skip    = false;
                foreach (var attr in attrs)
                {
                    if (attr is SkipAttribute || attr is System.Runtime.CompilerServices.CompilerGeneratedAttribute)
                    {
                        skip = true;
                    }
                    else if (attr is CaptionAttribute)
                    {
                        caption = ((CaptionAttribute)attr).Caption;
                    }
                    else if (attr is SectionAttribute)
                    {
                        if (section != null)
                        {
                            root.Add(section);
                        }
                        var sa = attr as SectionAttribute;
                        section = new Section(sa.Caption, sa.Footer);
                    }
                }
                if (skip)
                {
                    continue;
                }

                if (caption == null)
                {
                    caption = MakeCaption(mi.Name);
                }

                if (section == null)
                {
                    section = new Section();
                }

                Element element = null;
                if (mType == typeof(string))
                {
                    PasswordAttribute  pa     = null;
                    AlignmentAttribute align  = null;
                    EntryAttribute     ea     = null;
                    object             html   = null;
                    Action             invoke = null;
                    bool multi = false;

                    foreach (object attr in attrs)
                    {
                        if (attr is PasswordAttribute)
                        {
                            pa = attr as PasswordAttribute;
                        }
                        else if (attr is EntryAttribute)
                        {
                            ea = attr as EntryAttribute;
                        }
                        else if (attr is MultilineAttribute)
                        {
                            multi = true;
                        }
                        else if (attr is HtmlAttribute)
                        {
                            html = attr;
                        }
                        else if (attr is AlignmentAttribute)
                        {
                            align = attr as AlignmentAttribute;
                        }

                        if (attr is OnTapAttribute)
                        {
                            string mname = ((OnTapAttribute)attr).Method;

                            if (callbacks == null)
                            {
                                throw new Exception(
                                          "Your class contains [OnTap] attributes, but you passed a null object for `context' in the constructor");
                            }

                            var method = callbacks.GetType().GetMethod(mname);
                            if (method == null)
                            {
                                throw new Exception("Did not find method " + mname);
                            }
                            invoke = delegate { method.Invoke(method.IsStatic ? null : callbacks, new object[0]); };
                        }
                    }

                    var value = (string)GetValue(mi, o);
                    if (pa != null)
                    {
                        element = new EntryElement(caption, pa.Placeholder, value, true);
                    }
                    else if (ea != null)
                    {
                        element = new EntryElement(caption, ea.Placeholder, value)
                        {
                            KeyboardType = ea.KeyboardType
                        }
                    }
                    ;
                    else if (multi)
                    {
                        element = new MultilineElement(caption, value);
                    }
                    else if (html != null)
                    {
                        element = new HtmlElement(caption, value);
                    }
                    else
                    {
                        var selement = new StringElement(caption, value);
                        element = selement;

                        if (align != null)
                        {
                            selement.Alignment = align.Alignment;
                        }
                    }

                    if (invoke != null)
                    {
                        (element).Tapped += invoke;
                    }
                }
                else if (mType == typeof(float))
                {
                    var floatElement = new FloatElement(null, null, (float)GetValue(mi, o))
                    {
                        Caption = caption
                    };
                    element = floatElement;

                    foreach (object attr in attrs)
                    {
                        if (attr is RangeAttribute)
                        {
                            var ra = attr as RangeAttribute;
                            floatElement.MinValue    = ra.Low;
                            floatElement.MaxValue    = ra.High;
                            floatElement.ShowCaption = ra.ShowCaption;
                        }
                    }
                }
                else if (mType == typeof(bool))
                {
                    bool checkbox = false;
                    foreach (object attr in attrs)
                    {
                        if (attr is CheckboxAttribute)
                        {
                            checkbox = true;
                        }
                    }

                    if (checkbox)
                    {
                        element = new CheckboxElement(caption, (bool)GetValue(mi, o));
                    }
                    else
                    {
                        element = new BooleanElement(caption, (bool)GetValue(mi, o));
                    }
                }
                else if (mType == typeof(DateTime))
                {
                    var  dateTime = (DateTime)GetValue(mi, o);
                    bool asDate = false, asTime = false;

                    foreach (object attr in attrs)
                    {
                        if (attr is DateAttribute)
                        {
                            asDate = true;
                        }
                        else if (attr is TimeAttribute)
                        {
                            asTime = true;
                        }
                    }

                    if (asDate)
                    {
                        element = new DateElement(caption, dateTime);
                    }
                    else if (asTime)
                    {
                        element = new TimeElement(caption, dateTime);
                    }
                    else
                    {
                        element = new DateTimeElement(caption, dateTime);
                    }
                }
                else if (mType.IsEnum)
                {
                    var   csection = new Section();
                    ulong evalue   = Convert.ToUInt64(GetValue(mi, o), null);
                    int   idx      = 0;
                    int   selected = 0;

                    foreach (var fi in mType.GetFields(BindingFlags.Public | BindingFlags.Static))
                    {
                        ulong v = Convert.ToUInt64(GetValue(fi, null));

                        if (v == evalue)
                        {
                            selected = idx;
                        }

                        var ca = Attribute.GetCustomAttribute(fi, typeof(CaptionAttribute)) as CaptionAttribute;
                        csection.Add(new RadioElement(ca != null ? ca.Caption : MakeCaption(fi.Name)));
                        idx++;
                    }

                    element = new RootElement(caption, new RadioGroup(null, selected))
                    {
                        csection
                    };
                }
                else if (mType == typeof(UIImage))
                {
                    element = new ImageElement((UIImage)GetValue(mi, o));
                }
                else if (typeof(System.Collections.IEnumerable).IsAssignableFrom(mType))
                {
                    var csection = new Section();
                    int count    = 0;

                    if (last_radio_index == null)
                    {
                        throw new Exception("IEnumerable found, but no previous int found");
                    }
                    foreach (var e in (IEnumerable)GetValue(mi, o))
                    {
                        csection.Add(new RadioElement(e.ToString()));
                        count++;
                    }
                    var selected = (int)GetValue(last_radio_index, o);
                    if (selected >= count || selected < 0)
                    {
                        selected = 0;
                    }
                    element = new RootElement(caption, new MemberRadioGroup(null, selected, last_radio_index))
                    {
                        csection
                    };
                    last_radio_index = null;
                }
                else if (typeof(int) == mType)
                {
                    if (attrs.OfType <RadioSelectionAttribute>().Any())
                    {
                        last_radio_index = mi;
                    }
                }
                else
                {
                    var nested = GetValue(mi, o);
                    if (nested != null)
                    {
                        var newRoot = new RootElement(caption);
                        Populate(callbacks, nested, newRoot);
                        element = newRoot;
                    }
                }

                if (element == null)
                {
                    continue;
                }
                section.Add(element);
                mappings[element] = new MemberAndInstance(mi, o);
            }
            root.Add(section);
        }
Ejemplo n.º 18
0
	    protected override void CreateMenuRoot()
		{
            var username = ViewModel.Account.Username;
			Title = username;
            var root = new RootElement(username);

            root.Add(new Section
            {
                new MenuElement("Profile", () => ViewModel.GoToProfileCommand.Execute(null), Images.Person),
            });

            var eventsSection = new Section { HeaderView = new MenuSectionView("Events") };
            eventsSection.Add(new MenuElement(username, () => ViewModel.GoToMyEvents.Execute(null), Images.Event));
			if (ViewModel.Teams != null && ViewModel.Account.ShowTeamEvents)
				ViewModel.Teams.ForEach(team => eventsSection.Add(new MenuElement(team, () => ViewModel.GoToTeamEventsCommand.Execute(team), Images.Event)));
            root.Add(eventsSection);

            var repoSection = new Section() { HeaderView = new MenuSectionView("Repositories") };
			repoSection.Add(new MenuElement("Owned", () => ViewModel.GoToOwnedRepositoriesCommand.Execute(null), Images.Repo));
            repoSection.Add(new MenuElement("Shared", () => ViewModel.GoToSharedRepositoriesCommand.Execute(null), Images.BookLink));
			repoSection.Add(new MenuElement("Watched", () => ViewModel.GoToStarredRepositoriesCommand.Execute(null), Images.Star));
			repoSection.Add(new MenuElement("Explore", () => ViewModel.GoToExploreRepositoriesCommand.Execute(null), Images.Explore));
            root.Add(repoSection);
            
			if (ViewModel.PinnedRepositories.Any())
			{
				_favoriteRepoSection = new Section() { HeaderView = new MenuSectionView("Favorite Repositories") };
				foreach (var pinnedRepository in ViewModel.PinnedRepositories)
					_favoriteRepoSection.Add(new PinnedRepoElement(pinnedRepository, ViewModel.GoToRepositoryCommand));
				root.Add(_favoriteRepoSection);
			}
			else
			{
				_favoriteRepoSection = null;
			}

            var groupsTeamsSection = new Section() { HeaderView = new MenuSectionView("Collaborations") };
			if (ViewModel.Account.ExpandTeamsAndGroups)
			{
				if (ViewModel.Groups != null)
					ViewModel.Groups.ForEach(x => groupsTeamsSection.Add(new MenuElement(x.Name, () => ViewModel.GoToGroupCommand.Execute(x), Images.Group)));
				if (ViewModel.Teams != null)
					ViewModel.Teams.ForEach(x => groupsTeamsSection.Add(new MenuElement(x, () => ViewModel.GoToTeamCommand.Execute(x), Images.Team)));
			}
			else
			{
				groupsTeamsSection.Add(new MenuElement("Groups", () => ViewModel.GoToGroupsCommand.Execute(null), Images.Group));
				groupsTeamsSection.Add(new MenuElement("Teams", () => ViewModel.GoToTeamsCommand.Execute(null), Images.Team));
			}

            //There should be atleast 1 thing...
			if (groupsTeamsSection.Elements.Count > 0)
				root.Add(groupsTeamsSection);

            var infoSection = new Section() { HeaderView = new MenuSectionView("Info & Preferences") };
            root.Add(infoSection);
			infoSection.Add(new MenuElement("Settings", () => ViewModel.GoToSettingsCommand.Execute(null), Images.Cog));
            infoSection.Add(new MenuElement("Feedback & Support", () => ViewModel.GoToFeedbackCommand.Execute(null), Images.Flag));
            infoSection.Add(new MenuElement("Accounts", () => ProfileButtonClicked(this, System.EventArgs.Empty), Images.User));
            Root = root;
		}
Ejemplo n.º 19
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var root = new RootElement(Title);
            var accountSection = new Section();
            var accounts = PopulateAccounts();
            accountSection.AddAll(accounts);
            root.Add(accountSection);
            Root = root;

            CheckEntries();
        }
Ejemplo n.º 20
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;
        }