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);
            }
        }
Esempio n. 2
0
        public static GistsViewController CreateStarredGistsViewController()
        {
            var viewModel = GistsViewModel.CreateStarredGistsViewModel();

            return(new GistsViewController(viewModel)
            {
                Title = "Starred Gists"
            });
        }
Esempio n. 3
0
        public static GistsViewController CreatePublicGistsViewController()
        {
            var viewModel = GistsViewModel.CreatePublicGistsViewModel();

            return(new GistsViewController(viewModel)
            {
                Title = "Public Gists",
                ShowSearchBar = false
            });
        }
Esempio n. 4
0
        protected GistsViewController(GistsViewModel viewModel)
        {
            SearchPlaceholder = "Search Gists".t();
            NoItemsText       = "No Gists".t();
            ViewModel         = viewModel;

            BindCollection(viewModel.Gists, x => {
                var str = string.IsNullOrEmpty(x.Description) ? "Gist " + x.Id : x.Description;
                var sse = new NameTimeStringElement()
                {
                    Time   = x.UpdatedAt.ToDaysAgo(),
                    String = str,
                    Lines  = 4,
                    Image  = Theme.CurrentTheme.AnonymousUserImage
                };

                sse.Name     = (x.User == null) ? "Anonymous" : x.User.Login;
                sse.ImageUri = (x.User == null) ? null : new Uri(x.User.AvatarUrl);
                sse.Tapped  += () => NavigationController.PushViewController(new GistViewController(x), true);
                return(sse);
            });
        }
Esempio n. 5
0
 public GistsViewController(GistsViewModel viewModel)
     : base(UITableViewStyle.Plain)
 {
     ViewModel = viewModel;
     Title     = "Gists";
 }