Exemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var search = (UISearchBar)TableView.TableHeaderView;

            search.TextChanged         += (sender, args) => ViewModel.SearchText = search.Text;
            search.SearchButtonClicked += (sender, e) =>
            {
                search.ResignFirstResponder();
                ViewModel.SearchCommand.ExecuteIfCan();
            };

            this.BindList(ViewModel.Repositories, repo =>
            {
                var description = ViewModel.ShowRepositoryDescription ? repo.Description : string.Empty;
                var imageUrl    = repo.Fork ? Images.GitHubRepoForkUrl : Images.GitHubRepoUrl;
                var sse         = new RepositoryElement(repo.Name, repo.StargazersCount, repo.ForksCount, description, repo.Owner.Login, imageUrl)
                {
                    ShowOwner = true
                };
                sse.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(repo);
                return(sse);
            });
        }
Exemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 80f;

            var vm     = (RepositoriesExploreViewModel)ViewModel;
            var search = (UISearchBar)TableView.TableHeaderView;

            BindCollection(vm.Repositories, repo =>
            {
                var description = vm.ShowRepositoryDescription ? repo.Description : string.Empty;
                var sse         = new RepositoryElement(repo.Name, description, repo.Owner, new Avatar(repo.Logo));
                sse.Tapped     += () => vm.GoToRepositoryCommand.Execute(repo);
                return(sse);
            });

            OnActivation(d =>
            {
                d(vm.Bind(x => x.IsSearching).SubscribeStatus("Searching..."));
                d(vm.Bind(x => x.SearchText).Subscribe(x => search.Text      = x));
                d(search.GetChangedObservable().Subscribe(x => vm.SearchText = x));
                d(search.GetSearchObservable().Subscribe(_ => {
                    search.ResignFirstResponder();
                    vm.SearchCommand.Execute(null);
                }));
            });
        }
Exemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var vm     = (RepositoriesExploreViewModel)ViewModel;
            var search = (UISearchBar)TableView.TableHeaderView;

            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 64f;

            var weakVm = new WeakReference <RepositoriesExploreViewModel>(vm);

            BindCollection(vm.Repositories, repo =>
            {
                var description = vm.ShowRepositoryDescription ? repo.Description : string.Empty;
                var avatar      = new GitHubAvatar(repo.Owner?.AvatarUrl);
                var sse         = new RepositoryElement(repo.Name, repo.StargazersCount, repo.ForksCount, description, repo.Owner.Login, avatar)
                {
                    ShowOwner = true
                };
                sse.Tapped += MakeCallback(weakVm, repo);
                return(sse);
            });

            OnActivation(d =>
            {
                d(search.GetChangedObservable().Subscribe(x => vm.SearchText = x));
                d(vm.Bind(x => x.IsSearching).SubscribeStatus("Searching..."));
                d(search.GetSearchObservable().Subscribe(_ => {
                    search.ResignFirstResponder();
                    vm.SearchCommand.Execute(null);
                }));
            });
        }
 protected Element CreateElement(RepositoryDetailedModel repo)
 {
     var description = Application.Account.HideRepositoryDescriptionInList ? string.Empty : repo.Description;
     var sse = new RepositoryElement(repo.Name, repo.FollowersCount, repo.ForkCount, description, repo.Owner, new Uri(repo.LargeLogo(64))) { ShowOwner = ShowOwner };
     sse.Tapped += () => NavigationController.PushViewController(new RepositoryInfoController(repo), true);
     return sse;
 }
Exemplo n.º 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var vm     = (RepositoriesTrendingViewModel)ViewModel;
            var weakVm = new WeakReference <RepositoriesTrendingViewModel>(vm);

            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 64f;
            TableView.SeparatorInset     = new UIEdgeInsets(0, 56f, 0, 0);

            vm.Bind(x => x.Repositories).Subscribe(repos => {
                var repositories = repos ?? Enumerable.Empty <Tuple <string, IList <RepositoryModel> > >();
                Root.Reset(repositories.Select(x => {
                    var s = new Section(CreateHeaderView(x.Item1));
                    s.Reset(x.Item2.Select(repo => {
                        var description = vm.ShowRepositoryDescription ? repo.Description : string.Empty;
                        var avatar      = new GitHubAvatar(repo.Owner?.AvatarUrl);
                        var sse         = new RepositoryElement(repo.Name, repo.StargazersCount, repo.Forks, description, repo.Owner?.Login, avatar)
                        {
                            ShowOwner = true
                        };
                        sse.Tapped += MakeCallback(weakVm, repo);
                        return(sse);
                    }));
                    return(s);
                }));
            });

            OnActivation(d => {
                d(_trendingTitleButton.GetClickedObservable().Subscribe(_ => ShowLanguages()));
                d(vm.Bind(x => x.SelectedLanguage, true).Subscribe(l => _trendingTitleButton.Text = l.Name));
            });
        }
        protected Element CreateElement(RepositoryDetailedModel repo)
        {
            var description = ViewModel.ShowRepositoryDescription ? repo.Description : string.Empty;
            var sse         = new RepositoryElement(repo.Name, description, repo.Owner, new Avatar(repo.Logo));

            sse.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(repo);
            return(sse);
        }
        public void RepositoryFactoryConfigurationCreateWithDefaults()
        {
            RepositoryElement  defaultConfig = new RepositoryElement();
            IRepositoryFactory factory       = new ConfigurationRepositoryFactory(defaultConfig.RepositoryType, defaultConfig.ConnectionStringName);
            IRepository        repository    = factory.Create();

            Assert.IsNotNull(repository);
            Assert.IsInstanceOfType(repository, typeof(SQLiteRepository));
        }
Exemplo n.º 8
0
        protected Element CreateElement(RepositoryModel repo)
        {
            var description = ViewModel.ShowRepositoryDescription ? repo.Description : string.Empty;
            var sse         = new RepositoryElement(repo.Name, repo.Watchers, repo.Forks, description, repo.Owner.Login, new Uri(repo.Owner.AvatarUrl))
            {
                ShowOwner = ViewModel.ShowRepositoryOwner
            };

            sse.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(repo);
            return(sse);
        }
Exemplo n.º 9
0
        protected Element CreateElement(RepositoryDetailedModel repo)
        {
            var description = ViewModel.ShowRepositoryDescription ? repo.Description : string.Empty;
            var sse         = new RepositoryElement(repo.Name, repo.FollowersCount, repo.ForkCount, description, repo.Owner, new Uri(repo.LargeLogo(64)))
            {
                ShowOwner = ViewModel.ShowRepositoryOwner
            };

            sse.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(repo);
            return(sse);
        }
Exemplo n.º 10
0
        protected Element CreateElement(RepositoryModel repo)
        {
            var description = Application.Account.ShowRepositoryDescriptionInList ? repo.Description : string.Empty;
            var imageUrl    = repo.Fork ? CodeHub.Images.GitHubRepoForkUrl : CodeHub.Images.GitHubRepoUrl;
            var sse         = new RepositoryElement(repo.Name, repo.Watchers, repo.Forks, description, repo.Owner.Login, imageUrl)
            {
                ShowOwner = ShowOwner
            };

            sse.Tapped += () => NavigationController.PushViewController(new RepositoryViewController(repo.Owner.Login, repo.Name), true);
            return(sse);
        }
Exemplo n.º 11
0
        protected Element CreateElement(RepositoryModel repo)
        {
            var description = ViewModel.ShowRepositoryDescription ? repo.Description : string.Empty;
            var imageUrl    = repo.Fork ? Images.GitHubRepoForkUrl : Images.GitHubRepoUrl;
            var sse         = new RepositoryElement(repo.Name, repo.Watchers, repo.Forks, description, repo.Owner.Login, imageUrl)
            {
                ShowOwner = ViewModel.ShowRepositoryOwner
            };

            sse.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(repo);
            return(sse);
        }
Exemplo n.º 12
0
        protected Element CreateElement(RepositoryModel repo)
        {
            var description = ViewModel.ShowRepositoryDescription ? Emojis.FindAndReplace(repo.Description) : string.Empty;
            var avatar      = new GitHubAvatar(repo.Owner?.AvatarUrl);
            var vm          = new WeakReference <RepositoriesViewModel>(ViewModel);
            var sse         = new RepositoryElement(repo.Name, repo.Watchers, repo.Forks, description, repo.Owner.Login, avatar)
            {
                ShowOwner = ViewModel.ShowRepositoryOwner
            };

            sse.Tapped += () => vm.Get()?.GoToRepositoryCommand.Execute(repo);
            return(sse);
        }
Exemplo n.º 13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            _hud = new Hud(View);
            var vm     = (RepositoriesExploreViewModel)ViewModel;
            var search = (UISearchBar)TableView.TableHeaderView;

            var set = this.CreateBindingSet <RepositoriesExploreView, RepositoriesExploreViewModel>();

            set.Bind(search).For(x => x.Text).To(x => x.SearchText);
            set.Apply();

            search.SearchButtonClicked += (sender, e) =>
            {
                search.ResignFirstResponder();
                vm.SearchCommand.Execute(null);
            };

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

            BindCollection(vm.Repositories, repo =>
            {
                var description = vm.ShowRepositoryDescription ? repo.Description : string.Empty;
                var imageUrl    = repo.Fork ? Images.GitHubRepoForkUrl : Images.GitHubRepoUrl;
                var sse         = new RepositoryElement(repo.Name, repo.StargazersCount, repo.ForksCount, description, repo.Owner.Login, imageUrl)
                {
                    ShowOwner = true
                };
                sse.Tapped += () => vm.GoToRepositoryCommand.Execute(repo);
                return(sse);
            });
        }
Exemplo n.º 14
0
        public RepositoriesExploreViewController()
        {
            AutoHideSearch = false;
            //EnableFilter = true;
            SearchPlaceholder = "Search Repositories".t();
            NoItemsText       = "No Repositories".t();
            Title             = "Explore".t();
            ViewModel         = new RepositoriesExploreViewModel();

            BindCollection(ViewModel, repo => {
                var description = Application.Account.ShowRepositoryDescriptionInList ? repo.Description : string.Empty;
                var imageUrl    = repo.Fork ? CodeHub.Images.GitHubRepoForkUrl : CodeHub.Images.GitHubRepoUrl;
                var sse         = new RepositoryElement(repo.Name, repo.Watchers, repo.Forks, description, repo.Owner, imageUrl)
                {
                    ShowOwner = true
                };
                sse.Tapped += () => NavigationController.PushViewController(new RepositoryViewController(repo.Owner, repo.Name, repo.Name), true);
                return(sse);
            });
        }
Exemplo n.º 15
0
        public override void ViewDidLoad()
        {
            TableView.RegisterNibForCellReuse(RepositoryCellView.Nib, RepositoryCellView.Key);
            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 80f;

            base.ViewDidLoad();
            _hud = new Hud(View);
            var vm     = (RepositoriesExploreViewModel)ViewModel;
            var search = (UISearchBar)TableView.TableHeaderView;

            search.TextChanged += (sender, e) => vm.SearchText = search.Text;
            vm.Bind(x => x.SearchText, x => search.Text = x);
            search.SearchButtonClicked += (sender, e) =>
            {
                search.ResignFirstResponder();
                vm.SearchCommand.Execute(null);
            };

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

            BindCollection(vm.Repositories, repo =>
            {
                var description = vm.ShowRepositoryDescription ? repo.Description : string.Empty;
                var avatarUrl   = new Avatar(repo.Logo).ToUrl();
                var sse         = new RepositoryElement(repo.Name, description, repo.Owner, avatarUrl, Images.RepoPlaceholder);
                sse.Tapped     += () => vm.GoToRepositoryCommand.Execute(repo);
                return(sse);
            });
        }
        public override void ViewDidLoad()
        {
            //NoItemsText = "No Repositories";

            base.ViewDidLoad();

            this.BindList(ViewModel.Repositories, repo =>
            {
                var description = ViewModel.ShowRepositoryDescription ? repo.Description : string.Empty;
                var imageUrl    = new Uri(repo.AvatarUrl);
                var sse         = new RepositoryElement(repo.Name, repo.Stars, repo.Forks, description, repo.Owner, imageUrl)
                {
                    ShowOwner = true
                };
                sse.Tapped += () => ViewModel.GoToRepositoryCommand.Execute(repo);
                return(sse);
            });

            var button = new UIBarButtonItem("Time", UIBarButtonItemStyle.Plain, (s, e) =>
            {
                var index = ViewModel.SelectedTime == null ? 0 : ViewModel.Times.ToList().IndexOf(ViewModel.SelectedTime);
                if (index < 0)
                {
                    index = 0;
                }
                new PickerAlertView(ViewModel.Times.Select(x => x.Name).ToArray(), index, x =>
                {
                    var selectedTime = ViewModel.Times.ElementAtOrDefault(x);
                    if (selectedTime != null)
                    {
                        ViewModel.SelectedTime = selectedTime;
                    }
                }).Show();
            });

            var button2 = new UIBarButtonItem("Language", UIBarButtonItemStyle.Plain, (s, e) =>
            {
                var index = ViewModel.SelectedLanguage == null ? 0 : ViewModel.Languages.ToList().IndexOf(ViewModel.SelectedLanguage);
                if (index < 0)
                {
                    index = 0;
                }
                new PickerAlertView(ViewModel.Languages.Select(x => x.Name).ToArray(), index, x =>
                {
                    var selectedlanguage = ViewModel.Languages.ElementAtOrDefault(x);
                    if (selectedlanguage != null)
                    {
                        ViewModel.SelectedLanguage = selectedlanguage;
                    }
                }).Show();
            });

            ViewModel.WhenAnyValue(x => x.SelectedTime)
            .Where(x => x != null)
            .Subscribe(x => button.Title = x.Name);

            ViewModel.WhenAnyValue(x => x.SelectedLanguage)
            .Where(x => x != null)
            .Subscribe(x => button2.Title = x.Name);

            ToolbarItems = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                button2,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                button,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
            };
        }
Exemplo n.º 17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var vm = (RepositoriesTrendingViewModel)ViewModel;

            BindCollection(vm.Repositories, repo =>
            {
                var description = vm.ShowRepositoryDescription ? repo.Description : string.Empty;
                var imageUrl    = Images.GitHubRepoUrl;
                var sse         = new RepositoryElement(repo.Name, repo.Stars, repo.Forks, description, repo.Owner, imageUrl)
                {
                    ShowOwner = true
                };
                sse.Tapped += () => vm.GoToRepositoryCommand.Execute(repo);
                return(sse);
            });

            var button = new UIBarButtonItem("Time", UIBarButtonItemStyle.Plain, (s, e) =>
            {
                var index = vm.SelectedTime == null ? 0 : vm.Times.ToList().IndexOf(vm.SelectedTime);
                if (index < 0)
                {
                    index = 0;
                }
                new PickerAlert(vm.Times.Select(x => x.Name).ToArray(), index, x =>
                {
                    var selectedTime = vm.Times.ElementAtOrDefault(x);
                    if (selectedTime != null)
                    {
                        vm.SelectedTime = selectedTime;
                    }
                }).Show();
            });

            var button2 = new UIBarButtonItem("Language", UIBarButtonItemStyle.Plain, (s, e) =>
            {
                var index = vm.SelectedLanguage == null ? 0 : vm.Languages.ToList().IndexOf(vm.SelectedLanguage);
                if (index < 0)
                {
                    index = 0;
                }
                new PickerAlert(vm.Languages.Select(x => x.Name).ToArray(), index, x =>
                {
                    var selectedlanguage = vm.Languages.ElementAtOrDefault(x);
                    if (selectedlanguage != null)
                    {
                        vm.SelectedLanguage = selectedlanguage;
                    }
                }).Show();
            });

            vm.Bind(x => x.SelectedTime, x => button.Title      = x.Name, true);
            vm.Bind(x => x.SelectedLanguage, x => button2.Title = x.Name, true);

            ToolbarItems = new UIBarButtonItem[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                button2,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                button,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
            };
        }
 /// <summary>
 /// Initializes a new instance of the DatabaseSearchProvider class.
 /// The class is created by the Script Explorer framework when a Search or Save operation
 /// is performed, either by a client GUI or through a REST URL access. A fresh object
 /// is created for each operation.
 /// </summary>
 /// <param name="name">The Name of the search provider.</param>
 /// <param name="configuration">The configuration from app/web.config<see cref="IConfiguration"/>.</param>
 /// <param name="host">The host<see cref="IHost"/>.</param>
 /// <param name="logger">The logger.</param>
 /// <param name="settings">The settings.</param>
 public SearchProvider(string name, RepositoryElement configurationElement, IHost host, ILogger logger, ISettingsManager settings)
     : base(name, configurationElement, host, logger, settings)
 {
     this.connectionStringSettings = GetConnectionStringSettings(ConfigurationElement.Attributes["connectionString"]);
 }
Exemplo n.º 19
0
 protected override void Because()
 {
     _repositoryElement = new RepositoryElement(RepositoryName, IncludePath, ExportPath);
 }
 /// <summary>
 /// Initializes a new instance of the SearchProvider class.
 /// The class is created by the Script Explorer framework when a Search is performed, 
 /// either by a client GUI or through a REST URL access. A fresh object
 /// is created for each operation.
 /// </summary>
 /// <param name="name">The Provider name</param>
 /// <param name="configurationElement">The configuration from app/web.config<</param>
 /// <param name="host">The configured host</param>
 /// <param name="logger">The configured logger</param>
 /// <param name="settings">The settings.</param>
 public SearchProvider(string name, RepositoryElement configurationElement, IHost host, ILogger logger, ISettingsManager settings)
     : this(name, configurationElement, host, logger, settings, new WebRequestor())
 {
 }
        /// <summary>
        /// Initializes a new instance of the SearchProvider class.
        /// The class is created by the Script Explorer framework when a Search is performed, 
        /// either by a client GUI or through a REST URL access. A fresh object
        /// is created for each operation.
        /// </summary>
        /// <param name="name">The Provider name</param>
        /// <param name="configurationElement">The configuration from app/web.config<</param>
        /// <param name="host">The configured host</param>
        /// <param name="logger">The configured logger</param>
        /// <param name="settings">The settings.</param>
        /// <param name="webRequestor">A web requestor implementation for making http requests</param>
        public SearchProvider(string name, RepositoryElement configurationElement, IHost host, ILogger logger, ISettingsManager settings, IWebRequestor webRequestor)
            : base(name, configurationElement, host, logger, settings)
        {
            Guard.NotNull(() => webRequestor, webRequestor);

            this.ApiKey = ConfigurationElement.Attributes[ApiKeyAttributeName];

            if(string.IsNullOrEmpty(this.ApiKey))
            {
                throw new ArgumentNullException(string.Format(CultureInfo.CurrentCulture, Resources.KeyMissing, name));
            }

            var maxResultsValue = ConfigurationElement.Attributes[MaxResultsAttributeName];
            int maxResults;

            if (int.TryParse(maxResultsValue, out maxResults))
            {
                if (maxResults > DefaultMaxResults)
                {
                    this.MaxResults = DefaultMaxResults;
                }
                else
                {
                    this.MaxResults = maxResults;
                }
            }
            else
            {
                this.MaxResults = DefaultMaxResults;
            }

            this.CustomSearchId = ConfigurationElement.Attributes[CustomSearchIdAttributeName];
            this.CustomSearchReference = ConfigurationElement.Attributes[CustomSearchReferenceAttributeName];

            if (string.IsNullOrEmpty(this.CustomSearchId) && string.IsNullOrEmpty(this.CustomSearchReference))
            {
                throw new ArgumentNullException(string.Format(CultureInfo.CurrentCulture, Resources.CustomSearchMissing, name));
            }

            this.webRequestor = webRequestor;
        }