Esempio n. 1
0
        public static GistsViewController CreateUserGistsViewController(string username)
        {
            var applicationService = Locator.Current.GetService <IApplicationService>();
            var mine = applicationService.Account.Username.ToLower().Equals(username.ToLower());

            if (mine)
            {
                var viewModel = new CurrentUserGistsViewModel(username);
                var vc        = new GistsViewController(viewModel)
                {
                    Title = "My Gists"
                };

                var button = new UIBarButtonItem(UIBarButtonSystemItem.Add);
                vc.NavigationItem.RightBarButtonItem = button;
                vc.WhenActivated(d =>
                {
                    d(button.GetClickedObservable()
                      .Subscribe(_ => GistCreateViewController.Show(vc)));
                });

                return(vc);
            }
            else
            {
                var viewModel = GistsViewModel.CreateUserGistsViewModel(username);
                var vc        = new GistsViewController(viewModel)
                {
                    Title = $"{username}'s Gists"
                };
                return(vc);
            }
        }