public EventListController(EKCalendarItem[] events, EKEntityType eventType)
            : base(UITableViewStyle.Plain, null, true)
        {
            this.events    = events;
            this.eventType = eventType;

            Section section;

            if (events == null)
            {
                section = new Section()
                {
                    new StringElement("No calendar events")
                };
            }
            else
            {
                section = new Section();
                section.AddAll(
                    from items in this.events
                    select new StringElement(items.Title)
                    );
            }
            itemListRoot.Add(section);
            // set our element root
            this.InvokeOnMainThread(() => { this.Root = itemListRoot; });
        }
Example #2
0
        protected void PopulateTable()
        {
            const string newPropertyDefaultName = "<new property>";

            _properties = _propertyManager.GetList();

            //Make into a list of MT.D elements to display
            //List<Section> sections = new List<Section>();
            List <Element> elements = new List <Element>();

            foreach (var property in _properties)
            {
                var name = string.IsNullOrEmpty(property.Name) ? newPropertyDefaultName : property.Name;
                elements.Add(new StringElement(name));
            }

            //add to section
            var s = new Section();

            s.AddAll(elements);

            //add as root
            Root = new RootElement("Property Guide")
            {
                s
            };
        }
        private void CreateLoggedInMenuItems()
        {
            var eleBuySubscription = this.BtnBuySubscription();
            var eleShoppingCart    = this.BtnShoppingCart();
            var eleLogout          = this.BtnLogout();

            List <Element> elementsApp = new List <Element>();

            if (!this.ViewModel.Account.Person.IsSubscribed)
            {
                elementsApp.Add(eleBuySubscription);
            }
            elementsApp.Add(eleShoppingCart);

            var section1 = new Section();

            section1.AddAll(elementsApp);
            this.Root = new RootElement($"Velkommen {this.ViewModel.Account.Person.FirstName}")
            {
                section1,
                new Section
                {
                    eleLogout
                }
            };
        }
Example #4
0
        private Section GetSearchSection()
        {
            /*	var header = new UILabel (new RectangleF (0, 0, this.View.Bounds.Width, 40))
             * {
             *      Font = UIFont.SystemFontOfSize(18),
             *      BackgroundColor = UIColor.LightTextColor,
             *      Text = "Live Searches"
             * };*/

            var secSearch = new Section(CreateToolbarView(), null)
            {
                //new UIViewElement("",header,true)
            };

            secSearch.AddAll(
                results.Select
                    (x => {
                var str = new StyledStringElement(
                    x.name,
                    x.newListingsCount.ToString(),
                    UITableViewCellStyle.Value1
                    );

                str.Accessory = UITableViewCellAccessory.DisclosureIndicator;
                str.Tapped   += () => {
                    navigation.Title = x.name;
                };

                return(str);
            })
                );

            return(secSearch);
        }
Example #5
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // open a new storage group with name "Demo" --- this is even possible
            // in code which is shared between Android and iOS because EditGroup is
            // a property holding a delegate which creates a plattform specific
            // instance
            var storage = SimpleStorage.EditGroup("Demo");

            // loading key "app_launches" with an empty string as default value
            var appLaunches = storage.Get("app_launches", "").Split(',').ToList();

            // adding a new timestamp to list to show that SimpleStorage is working
            appLaunches.Add(DateTime.Now.ToString());

            // save the value with key "app_launches" for next application start
            storage.Put("app_launches", String.Join(",", appLaunches));

            // simple presentation of the timestamp list with MonoTouch.Dialog
            var section = new Section();

            section.AddAll(from l in appLaunches where !String.IsNullOrEmpty(l) select new StringElement(l));
            window.RootViewController = new DialogViewController(new RootElement("SimpleStorage Demo")
            {
                section
            });

            window.MakeKeyAndVisible();

            return(true);
        }
        // Load the list of lists and setup their events
        private Task RefreshAsync()
        {
            AppDelegate.AddActivity();

            return(this.db.Table <List>().ToListAsync().ContinueWith(t => {
                if (t.Exception != null)
                {
                    BeginInvokeOnMainThread(ReloadComplete);
                    AppDelegate.FinishActivity();
                    ShowError(t.Exception.Flatten().InnerException);
                    return;
                }

                Section section = new Section();
                section.AddAll(t.Result.Select(l =>
                                               new StringElement(l.Name, () => {
                    var tasks = new TasksViewController(this.db, l);
                    NavigationController.PushViewController(tasks, true);
                })
                                               ).Cast <Element>());

                InvokeOnMainThread(() => {
                    Root.Clear();
                    Root.Add(section);

                    ReloadComplete();

                    AppDelegate.FinishActivity();
                });
            }));
        }
Example #7
0
        /// <summary>
        /// Populates the table.
        /// </summary>
        protected async void PopulateTable()
        {
            /////////////////////
            // Load task from Azure Mobile Services
            /////////////////////

            tasks = await TaskManager.Instance.GetTasksForUser("Tim");

            var newTaskDefaultName = MonoTouch.Foundation.NSBundle.MainBundle.LocalizedString("<new task>", "<new task>");
            // make into a list of MT.D elements to display
            List <Element> le = new List <Element>();

            foreach (var t in tasks)
            {
                le.Add(new StringElement((t.Name == "" ? newTaskDefaultName : t.Name), t.Notes));
            }

            // add to section
            var s = new Section();

            s.AddAll(le);
            // add as root
            Root = new RootElement("Tasky Pro")
            {
                s
            };
        }
Example #8
0
        // I don't think this is required
        RootElement MakeHardware()
        {
            int sources      = (int)Midi.SourceCount;
            int destinations = (int)Midi.DestinationCount;

            var sourcesSection = new Section("Sources");

            sourcesSection.AddAll(
                from x in Enumerable.Range(0, sources)
                let source = MidiEndpoint.GetSource(x)
                             select(Element) new StringElement(source.DisplayName, source.IsNetworkSession ? "Network" : "Local")
                );
            var targetsSection = new Section("Targets");

            targetsSection.AddAll(
                from x in Enumerable.Range(0, destinations)
                let target = MidiEndpoint.GetDestination(x)
                             select(Element) new StringElement(target.DisplayName, target.IsNetworkSession ? "Network" : "Local")
                );
            return(new RootElement("Endpoints (" + sources + ", " + destinations + ")")
            {
                sourcesSection,
                targetsSection
            });
        }
        private async Task LoadLanguages()
        {
            var lRepo = new LanguageRepository();
            var langs = await lRepo.GetLanguages();

            var sec = new Section();

            langs.Insert(0, new Language("All Languages", null));
            sec.AddAll(langs.Select(x =>
            {
                var el = new StringElement(x.Name)
                {
                    Accessory = UITableViewCellAccessory.None
                };
                el.Clicked.Subscribe(_ => _languageSubject.OnNext(x));
                return(el);
            }));

            Root.Reset(sec);

            if (SelectedLanguage != null)
            {
                var el = sec.Elements.OfType <StringElement>().FirstOrDefault(x => string.Equals(x.Caption, SelectedLanguage.Name));
                if (el != null)
                {
                    el.Accessory = UITableViewCellAccessory.Checkmark;
                }

                var indexPath = el?.IndexPath;
                if (indexPath != null)
                {
                    TableView.ScrollToRow(indexPath, UITableViewScrollPosition.Middle, false);
                }
            }
        }
Example #10
0
        Element MakeDevice(MidiDevice dev)
        {
            var entities = new Section("Entities");

            foreach (var ex in Enumerable.Range(0, (int)dev.EntityCount))
            {
                var entity        = dev.GetEntity(ex);
                var sourceSection = new Section("Sources");
                sourceSection.AddAll(
                    from sx in Enumerable.Range(0, (int)entity.Sources)
                    let endpoint = entity.GetSource(sx)
                                   select MakeEndpoint(endpoint)
                    );
                var destinationSection = new Section("Destinations");
                destinationSection.AddAll(
                    from sx in Enumerable.Range(0, (int)entity.Destinations)
                    let endpoint = entity.GetDestination(sx)
                                   select MakeEndpoint(endpoint)
                    );
                entities.Add(new RootElement(entity.Name)
                {
                    sourceSection,
                    destinationSection
                });
            }

            return(new RootElement(String.Format("{2} {0} {1}", dev.Manufacturer, dev.Model, dev.EntityCount))
            {
                entities
            });
        }
Example #11
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            exampleInfoList = ExampleLibrary.Examples.GetList();

            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            navigation = new UINavigationController();

            var root    = new RootElement("OxyPlot Example Browser");
            var section = new Section();

            section.AddAll(exampleInfoList
                           .GroupBy(e => e.Category)
                           .OrderBy(g => g.Key)
                           .Select(g =>
                                   (Element) new StyledStringElement(g.Key, delegate {
                DisplayCategory(g.Key);
            })
            {
                Accessory = UITableViewCellAccessory.DisclosureIndicator
            }));
            root.Add(section);

            var dvc = new DialogViewController(root, true);

            navigation.PushViewController(dvc, true);

            window.RootViewController = navigation;

            // make the window visible
            window.MakeKeyAndVisible();

            return(true);
        }
	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);
	}
        private async Task LoadLanguages()
        {
            var lRepo = new LanguageRepository();
            var langs = await lRepo.GetLanguages();

            var sec = new Section();

            langs.Insert(0, new Language("All Languages", null));
            sec.AddAll(langs.Select(x =>
            {
                var el = new StringElement(x.Name) { Accessory = UITableViewCellAccessory.None };
                el.Clicked.Subscribe(_ => _languageSubject.OnNext(x));
                return el;
            }));

            Root.Reset(sec);

            if (SelectedLanguage != null)
            {
                var el = sec.Elements.OfType<StringElement>().FirstOrDefault(x => string.Equals(x.Caption, SelectedLanguage.Name));
                if (el != null)
                    el.Accessory = UITableViewCellAccessory.Checkmark;

                var indexPath = el?.IndexPath;
                if (indexPath != null)
                    TableView.ScrollToRow(indexPath, UITableViewScrollPosition.Middle, false);
            }
        }
Example #14
0
        private void Render()
        {
            var section = new Section();

            section.AddAll(_items.Select(item =>
            {
                var el = new MultilinedElement(item.Name + " (" + item.Price + ")", item.Description);
                if (_features.IsActivated(item.Id))
                {
                    el.Accessory = MonoTouch.UIKit.UITableViewCellAccessory.Checkmark;
                }
                else
                {
                    el.Accessory = MonoTouch.UIKit.UITableViewCellAccessory.DisclosureIndicator;
                    el.Tapped   += () => Tapped(item);
                }

                return(el);
            }));

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

            root.Add(section);
            Root = root;
        }
Example #15
0
        private RootElement buildImagesElement()
        {
            RootElement element = new RootElement("Images");
            Section     section = new Section("Captured At");

            section.AddAll(getMediaElements(this.rootImagePath, MediaFileType.Image));
            element.Add(section);
            return(element);
        }
Example #16
0
        RootElement BuildImagesElement()
        {
            var element = new RootElement("Images");
            var section = new Section("Captured At");

            section.AddAll(GetMediaElements(rootImagePath, MediaFileType.Image));
            element.Add(section);
            return(element);
        }
Example #17
0
        private RootElement buildMoviesElement()
        {
            RootElement element = new RootElement("Movies");
            Section     section = new Section("Recorded At");

            section.AddAll(getMediaElements(this.rootVideoPath, MediaFileType.Movie));
            element.Add(section);
            return(element);
        }
Example #18
0
        RootElement BuildMoviesElement()
        {
            var element = new RootElement("Movies");
            var section = new Section("Recorded At");

            section.AddAll(GetMediaElements(rootVideoPath, MediaFileType.Movie));
            element.Add(section);
            return(element);
        }
        // Appends the favorites
        void AppendFavorites(Section section, IEnumerable <MonkeySpace.Core.Session> list)
        {
            var favs        = AppDelegate.UserData.GetFavoriteCodes();
            var favsessions = from s in list
                              where favs.Contains(s.Id.ToString())
                              select(Element) new SessionElement(s);

            section.AddAll(favsessions);
        }
Example #20
0
 public static void BindList <T, TItem>(this ViewModelCollectionViewController <T> @this, IReadOnlyReactiveList <TItem> list, Func <TItem, Element> selector) where T : class, IBaseViewModel
 {
     list.Changed
     .Select(_ => list)
     .Subscribe(languages => {
         var sec = new Section();
         sec.AddAll(languages.Select(selector));
         @this.Root.Reset(sec);
     });
 }
Example #21
0
        void PopulateTable()
        {
            var s = new Section();

            s.AddAll(_elements.Values);
            Root = new RootElement("Select crews")
            {
                s
            };
        }
Example #22
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var root           = new RootElement(Title);
            var accountSection = new Section();

            accountSection.AddAll(PopulateAccounts());
            root.Add(accountSection);
            Root = root;
        }
Example #23
0
        public MenuController() : base(UITableViewStyle.Plain, null)
        {
            _localizeService = FactorySingleton.Factory.Get <LocalizeService>();
            InitMenuItem();
            var section = new Section();

            section.AddAll(menuItems);
            Root = new RootElement("....")
            {
                section
            };
        }
Example #24
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ViewModel.Interests.Changed.StartWith((NotifyCollectionChangedEventArgs)null).Subscribe(_ =>
            {
                var sec = new Section();
                sec.AddAll(ViewModel.Interests.Select(x => new InterestElement(x, () => ViewModel.GoToStumbleInterestCommand.ExecuteIfCan(x))));
                Root.Reset(sec);
            });

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add,
                                                                    (s, e) => ViewModel.GoToAddInterestCommand.ExecuteIfCan());
        }
Example #25
0
        protected void PopulateTable()
        {
            tasks = TaskManager.GetTasks().ToList();
            var rows = from t in tasks
                       select(Element) new StringElement((t.Name == "" ? "<new task>" : t.Name), t.Notes);

            var s = new Section();

            s.AddAll(rows);
            Root = new RootElement("Tasky")
            {
                s
            };
        }
        protected async Task PopulateTable()
        {
            tasks = await AppDelegate.Current.TodoContractClient.GetItems();

            // TODO: use this element, which displays a 'tick' when item is completed
            var rows = from t in tasks
                       select(Element) new CheckboxElement((t.Name == "" ? "<new task>" : t.Name), t.Done);

            var s = new Section();

            s.AddAll(rows);
            Root = new RootElement("Tasky")
            {
                s
            };
        }
Example #27
0
        protected async void AsyncPopulateTable()
        {
            var todos = await TodoService.GetTodos();

            tasks = todos.Success.Values.ToList();
            var rows = from t in tasks
                       select(Element) new StringElement((t.Name == "" ? "<new task>" : t.Name), t.Notes);

            var s = new Section();

            s.AddAll(rows);
            Root = new RootElement("Tasky")
            {
                s
            };
        }
        public MenuViewController() : base(null)
        {
            InitMenuItem();
            var                section            = new Section();
            StringElement      stringElement      = new StringElement("Arkadiy Dobkin");
            UIImage            image              = UIImage.FromBundle("Avatar_Ark");
            ImageStringElement imageStringElement = new ImageStringElement("", image);

            section.Add(imageStringElement);
            section.Add(stringElement);
            section.AddAll(menuItems);
            Root = new RootElement("....")
            {
                section
            };
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var accountsService = Mvx.Resolve<IAccountsService>();
            var weakVm = new WeakReference<AccountsViewController>(this);
            var accountSection = new Section();
            accountSection.AddAll(accountsService.Select(account =>
            {
                var t = new AccountElement(account, account.Equals(accountsService.ActiveAccount));
                t.Tapped += () => weakVm.Get()?.SelectAccount(account);
                return t;
            }));
            Root.Reset(accountSection);

            SetCancelButton();
        }
Example #30
0
        protected void PopulateTable()
        {
            tasks = TodoItemManager.GetTasks().ToList();
//			var rows = from t in tasks
//				select (Element)new StringElement ((t.Name == "" ? "<new task>" : t.Name), t.Notes);
            // TODO: use this element, which displays a 'tick' when item is completed
            var rows = from t in tasks
                       select(Element) new CheckboxElement((t.Name == "" ? "<new task>" : t.Name), t.Done);

            var s = new Section();

            s.AddAll(rows);
            Root = new RootElement("Tasky")
            {
                s
            };
        }
Example #31
0
        public void PopulateResults(IEnumerable <Element> elements)
        {
            // Simulate WS call by sleeping for 5 seconds
            Thread.Sleep(5000);

            BeginInvokeOnMainThread(() => {
                Section section = new Section("Search Results");
                section.AddAll(elements);

                Root = new RootElement(Title)
                {
                    section
                };

                TableView.ReloadData();
                TableView.SetNeedsDisplay();
            });
        }
Example #32
0
        protected BaseRepositoriesViewController()
            : base(unevenRows: true)
        {
            SearchTextChanging.Where(x => ViewModel != null).Subscribe(x => ViewModel.SearchKeyword = x);

            this.WhenAnyValue(x => x.ViewModel)
            .Where(x => x != null)
            .Select(x => x.Repositories.Changed.StartWith(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)))
            .Switch()
            .Subscribe(_ =>
            {
                var sec = new Section();
                sec.AddAll(
                    from x in ViewModel.Repositories
                    select new RepositoryElement(x.Owner, x.Name, x.Description, x.ImageUrl, () => ViewModel.GoToRepositoryCommand.ExecuteIfCan(x)));
                Root.Reset(sec);
            });
        }
Example #33
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var accountsService = Mvx.Resolve <IAccountsService>();
            var weakVm          = new WeakReference <AccountsViewController>(this);
            var accountSection  = new Section();

            accountSection.AddAll(accountsService.Select(account =>
            {
                var t     = new AccountElement(account, account.Equals(accountsService.ActiveAccount));
                t.Tapped += () => weakVm.Get()?.SelectAccount(account);
                return(t);
            }));
            Root.Reset(accountSection);

            SetCancelButton();
        }
Example #34
0
        public void RenderGist()
        {
            if (ViewModel.Gist == null) return;
            var model = ViewModel.Gist;

            ICollection<Section> sections = new LinkedList<Section>();
            sections.Add(new Section { _split });
            sections.Add(new Section { _splitRow1, _splitRow2, _ownerElement });
            var sec2 = new Section();
            sections.Add(sec2);

            var weakVm = new WeakReference<GistViewModel>(ViewModel);
            foreach (var file in model.Files.Keys)
            {
                var sse = new ButtonElement(file, Octicon.FileCode.ToImage())
                { 
                    LineBreakMode = UILineBreakMode.TailTruncation,
                };

                var fileSaved = file;
                var gistFileModel = model.Files[fileSaved];
                sse.Clicked.Subscribe(MakeCallback(weakVm, gistFileModel));
                sec2.Add(sse);
            }

            if (ViewModel.Comments.Items.Count > 0)
            {
                var sec3 = new Section("Comments");
                sec3.AddAll(ViewModel.Comments.Select(x => new CommentElement(x.User?.Login ?? "Anonymous", x.Body, x.CreatedAt, x.User?.AvatarUrl)));
                sections.Add(sec3);
            }

            Root.Reset(sections);
        }
Example #35
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; 
        }
Example #36
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;
            ICollection<Section> root = new LinkedList<Section>();
            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));

            if (ViewModel.ShowRepository)
            {
                var repo = new StringElement(ViewModel.Repository) { 
                    Accessory = UIKit.UITableViewCellAccessory.DisclosureIndicator, 
                    Lines = 1, 
                    TextColor = StringElement.DefaultDetailColor,
                    Image = AtlassianIcon.Devtoolsrepository.ToImage()
                };
                repo.Clicked.BindCommand(ViewModel.GoToRepositoryCommand);
                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.Clicked.Select(_ => y).BindCommand(ViewModel.GoToFileCommand);
						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 avatar = new Avatar(comment.User.Links?.Avatar?.Href);
                    commentSection.Add(new CommentElement(name, comment.Content.Raw, comment.CreatedOn, avatar));
				}

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

                var addComment = new StringElement("Add Comment") { Image = AtlassianIcon.Addcomment.ToImage() };
                addComment.Clicked.Subscribe(_ => 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 avatar = new Avatar(l.User?.Links?.Avatar?.Href);
                    var el = new UserElement(l.User.DisplayName, string.Empty, string.Empty, avatar);
                    el.Clicked.Select(_ => l.User.Username).BindCommand(ViewModel.GoToUserCommand);
					return el;
				}));

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

				StringElement approveButton;
                if (ViewModel.Commit.Participants.Any(x => x.User.Username.Equals(ViewModel.GetApplication().Account.Username) && x.Approved))
				{
                    approveButton = new StringElement("Unapprove") { Image = AtlassianIcon.Approve.ToImage() };
                    approveButton.Clicked.Subscribe(_ => this.DoWorkAsync("Unapproving...", ViewModel.Unapprove));
				}
				else
				{
                    approveButton = new StringElement("Approve") { Image = AtlassianIcon.Approve.ToImage() };
                    approveButton.Clicked.Subscribe(_ => this.DoWorkAsync("Approving...", ViewModel.Approve));
				}
				root.Add(new Section { approveButton });
			}

            Root.Reset(root); 
        }
Example #37
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();
        }