Exemple #1
0
        void SegmentValueChanged(object sender, EventArgs e)
        {
            var application = Mvx.Resolve <IApplicationService>();

            // If there is searching going on. Finish it.
            FinishSearch();

            if (_viewSegment.SelectedSegment == 0)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateOpenFilter(), true);
            }
            else if (_viewSegment.SelectedSegment == 1)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateClosedFilter(), true);
            }
            else if (_viewSegment.SelectedSegment == 2)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateMineFilter(application.Account.Username), true);
            }
            else if (_viewSegment.SelectedSegment == 3)
            {
                var filter = new IssuesFilterViewController(ViewModel.Username, ViewModel.Repository, ViewModel.Issues);
                var nav    = new UINavigationController(filter);
                PresentViewController(nav, true, null);
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            if (ToolbarItems != null)
            {
                NavigationController.SetToolbarHidden(false, animated);
            }

            //Before we select which one, make sure we detach the event handler or silly things will happen
            _viewSegment.ValueChanged -= SegmentValueChanged;

            var application = Mvx.Resolve <IApplicationService>();

            //Select which one is currently selected
            if (ViewModel.Issues.Filter.Equals(IssuesFilterModel.CreateAllFilter()))
            {
                _viewSegment.SelectedSegment = 0;
            }
            else if (ViewModel.Issues.Filter.Equals(IssuesFilterModel.CreateOpenFilter()))
            {
                _viewSegment.SelectedSegment = 1;
            }
            else if (ViewModel.Issues.Filter.Equals(IssuesFilterModel.CreateMineFilter(application.Account.Username)))
            {
                _viewSegment.SelectedSegment = 2;
            }
            else
            {
                _viewSegment.SelectedSegment = 3;
            }

            _viewSegment.ValueChanged += SegmentValueChanged;
        }
Exemple #3
0
        public IssuesViewModel(IApplicationService applicationService)
        {
            _mineFilter = IssuesFilterModel.CreateMineFilter(applicationService.Account.Username);

            _filterSelection = this.WhenAnyValue(x => x.Filter)
                               .Select(x =>
            {
                if (x == null || _openFilter.Equals(x))
                {
                    return(IssueFilterSelection.Open);
                }
                if (_closedFilter.Equals(x))
                {
                    return(IssueFilterSelection.Closed);
                }
                if (_mineFilter.Equals(x))
                {
                    return(IssueFilterSelection.Mine);
                }
                return(IssueFilterSelection.Custom);
            })
                               .ToProperty(this, Xamarin => Xamarin.FilterSelection);

            GoToNewIssueCommand = ReactiveCommand.Create();
            GoToNewIssueCommand.Subscribe(_ =>
            {
                var vm             = CreateViewModel <IssueAddViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName  = RepositoryName;
                vm.CreatedIssue.IsNotNull().Subscribe(IssuesCollection.Add);
                ShowViewModel(vm);
            });

            GoToCustomFilterCommand = ReactiveCommand.Create();

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
            {
                var direction = Filter.Ascending ? "asc" : "desc";
                var state     = Filter.Open ? "open" : "closed";
                var sort      = Filter.SortType == BaseIssuesFilterModel.Sort.None ? null : Filter.SortType.ToString().ToLower();
                var labels    = string.IsNullOrEmpty(Filter.Labels) ? null : Filter.Labels;
                var assignee  = string.IsNullOrEmpty(Filter.Assignee) ? null : Filter.Assignee;
                var creator   = string.IsNullOrEmpty(Filter.Creator) ? null : Filter.Creator;
                var mentioned = string.IsNullOrEmpty(Filter.Mentioned) ? null : Filter.Mentioned;
                var milestone = Filter.Milestone == null ? null : Filter.Milestone.Value;

                var request = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues.GetAll(
                    sort: sort, labels: labels, state: state, direction: direction,
                    assignee: assignee, creator: creator, mentioned: mentioned, milestone: milestone);
                return(IssuesCollection.SimpleCollectionLoad(request, t as bool?));
            });
        }
Exemple #4
0
        public IssuesViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;
            _mineFilter         = IssuesFilterModel.CreateMineFilter(applicationService.Account.Username);

            Filter = _openFilter;
            Title  = "Issues";

            _filterSelection = this.WhenAnyValue(x => x.Filter)
                               .Select(x =>
            {
                if (x == null || _openFilter.Equals(x))
                {
                    return(IssueFilterSelection.Open);
                }
                if (_closedFilter.Equals(x))
                {
                    return(IssueFilterSelection.Closed);
                }
                if (_mineFilter.Equals(x))
                {
                    return(IssueFilterSelection.Mine);
                }
                return(IssueFilterSelection.Custom);
            })
                               .ToProperty(this, x => x.FilterSelection);

            GoToNewIssueCommand = ReactiveCommand.Create();
            GoToNewIssueCommand.Subscribe(_ =>
            {
                var vm             = this.CreateViewModel <IssueAddViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName  = RepositoryName;
                vm.CreatedIssue.IsNotNull().Subscribe(IssuesBacking.Add);
                NavigateTo(vm);
            });

            this.WhenAnyValue(x => x.Filter).Skip(1).Subscribe(_ =>
            {
                IssuesBacking.Clear();
                LoadCommand.ExecuteIfCan();
            });

            GoToCustomFilterCommand = ReactiveCommand.Create();
        }
        public IssuesViewModel(
            string username, string repository,
            IApplicationService applicationService = null,
            IMessageService messageService         = null)
        {
            Username           = username;
            Repository         = repository;
            applicationService = applicationService ?? Locator.Current.GetService <IApplicationService>();
            messageService     = messageService ?? Locator.Current.GetService <IMessageService>();
            var currentUser = applicationService.Account.Username;

            GoToNewIssueCommand
            .Select(_ => new IssueAddViewModel(username, repository))
            .Subscribe(NavigateTo);

            Title = "Issues";

            this.WhenAnyValue(x => x.SelectedFilter)
            .Subscribe(x =>
            {
                if (x == 0)
                {
                    Filter = IssuesFilterModel.CreateOpenFilter();
                }
                else if (x == 1)
                {
                    Filter = IssuesFilterModel.CreateMineFilter(currentUser);
                }
                else if (x == 2)
                {
                    Filter = IssuesFilterModel.CreateAllFilter();
                }
            });

            this.WhenAnyValue(x => x.Filter)
            .Select(x => new IssueListViewModel(username, repository, x))
            .Do(x => x.LoadMoreCommand.ExecuteNow())
            .Subscribe(x => Issues = x);

            this.WhenAnyValue(x => x.Issues)
            .Select(x => x.IssueSelected)
            .Switch()
            .Select(x => new IssueViewModel(username, repository, x))
            .Subscribe(NavigateTo);
        }
        void SegmentValueChanged(object sender, EventArgs e)
        {
            var application = Mvx.Resolve <IApplicationService>();

            if (_viewSegment.SelectedSegment == 0)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateAllFilter(), true);
            }
            else if (_viewSegment.SelectedSegment == 1)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateOpenFilter(), true);
            }
            else if (_viewSegment.SelectedSegment == 2)
            {
                ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateMineFilter(application.Account.Username), true);
            }
            else if (_viewSegment.SelectedSegment == 3)
            {
                ViewModel.GoToFiltersCommand.Execute(null);
            }
        }
Exemple #7
0
 void SegmentValueChanged(object sender, EventArgs e)
 {
     if (_viewSegment.SelectedSegment == 0)
     {
         ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateOpenFilter(), true);
     }
     else if (_viewSegment.SelectedSegment == 1)
     {
         ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateClosedFilter(), true);
     }
     else if (_viewSegment.SelectedSegment == 2)
     {
         ViewModel.Issues.ApplyFilter(IssuesFilterModel.CreateMineFilter(Application.Account.Username), true);
     }
     else if (_viewSegment.SelectedSegment == 3)
     {
         var filter = new IssuesFilterViewController(ViewModel.User, ViewModel.Slug, ViewModel.Issues);
         var nav    = new UINavigationController(filter);
         PresentViewController(nav, true, null);
     }
 }
Exemple #8
0
        void SegmentValueChanged(object sender, EventArgs e)
        {
            // If there is searching going on. Finish it.
            //FinishSearch();

            if (_viewSegment.SelectedSegment == 0)
            {
                ViewModel.Filter = IssuesFilterModel.CreateOpenFilter();
            }
            else if (_viewSegment.SelectedSegment == 1)
            {
                ViewModel.Filter = IssuesFilterModel.CreateClosedFilter();
            }
            else if (_viewSegment.SelectedSegment == 2)
            {
                ViewModel.Filter = IssuesFilterModel.CreateMineFilter(_applicationService.Account.Username);
            }
            else if (_viewSegment.SelectedSegment == 3)
            {
                //ShowFilterController(new IssuesFilterViewController(ViewModel.RepositoryOwner, ViewModel.RepositoryName, ViewModel.Issues));
            }
        }
Exemple #9
0
 public IssuesView(IApplicationService applicationService)
 {
     _applicationService = applicationService;
     _mineFilter         = IssuesFilterModel.CreateMineFilter(_applicationService.Account.Username);
 }