Ejemplo n.º 1
0
        private void OnPivotChanged(GithubService githubService, SelectionChangedEventArgs args)
        {
            var header = ((PivotItem)args.AddedItems[0]).Header as String;

            ShowAppBar = false;
            switch (header)
            {
            case "feed":
                if (EventsRequest == null)
                {
                    EventsRequest = new UserEventsRequests(Username);
                }
                break;

            case "owned repos":
                if (RepositoriesRequest == null)
                {
                    RepositoriesRequest = new RepositoriesRequest(Username);
                }
                break;

            case "watched reps":
                if (RepositoriesWatchedRequest == null)
                {
                    RepositoriesWatchedRequest = new RepositoriesWatchedRequest(Username);
                }
                break;

            case "follower":
                if (FollowersRequest == null)
                {
                    FollowersRequest = new UserFollowersRequest(Username);
                }
                break;

            case "following":
                if (FollowingsRequest == null)
                {
                    FollowingsRequest = new UserFollowingRequest(Username);
                }
                break;

            case "profile":
            case "details":
                if (User == null)
                {
                    User = githubService.Load(new UserRequest(Username), u => User = u);
                    if (githubService.IsAuthenticated)
                    {
                        IsFollowing = githubService.Load(new FollowUserRequest(Username), r => { IsFollowing = r; });
                    }
                }
                ShowAppBar = true;
                break;
            }
        }
Ejemplo n.º 2
0
        public UserViewModel(GithubService githubService, INavigationService navigationService, string user)
        {
            Username = user;
            EventsRequest = new UserEventsRequests(Username);
            ShowAppBar = false;

            ShareCommand = new RelayCommand(() => new ShareLinkTask
            {
                LinkUri = new Uri(User.HtmlUrl),
                Title = User.Name + " is on Github.",
                Message = "I found his profile on Github, you might want to see it.",
            }.Show(), () => User != null);
            FollowCommand = new RelayCommand(() => githubService.Load(new FollowUserRequest(Username, FollowUserRequest.Type.FOLLOW), r => { IsFollowing = true; }), () => IsFollowing.HasValue && !IsFollowing.Value);
            UnFollowCommand = new RelayCommand(() => githubService.Load(new FollowUserRequest(Username, FollowUserRequest.Type.UNFOLLOW), r => { IsFollowing = false; }), () => IsFollowing.HasValue && IsFollowing.Value);
            RepoSelectedCommand = new RelayCommand<Repository>(r => OnRepoSelected(navigationService, r));
            UserSelectedCommand = new RelayCommand<User>(u => OnUserSelected(navigationService, user, u));
            PivotChangedCommand = new RelayCommand<SelectionChangedEventArgs>(args => OnPivotChanged(githubService, args));
        }
Ejemplo n.º 3
0
        public UserViewModel(GithubService githubService, INavigationService navigationService, string user)
        {
            Username      = user;
            EventsRequest = new UserEventsRequests(Username);
            ShowAppBar    = false;

            ShareCommand = new RelayCommand(() => new ShareLinkTask
            {
                LinkUri = new Uri(User.HtmlUrl),
                Title   = User.Name + " is on Github.",
                Message = "I found his profile on Github, you might want to see it.",
            }.Show(), () => User != null);
            FollowCommand       = new RelayCommand(() => githubService.Load(new FollowUserRequest(Username, FollowUserRequest.Type.FOLLOW), r => { IsFollowing = true; }), () => IsFollowing.HasValue && !IsFollowing.Value);
            UnFollowCommand     = new RelayCommand(() => githubService.Load(new FollowUserRequest(Username, FollowUserRequest.Type.UNFOLLOW), r => { IsFollowing = false; }), () => IsFollowing.HasValue && IsFollowing.Value);
            RepoSelectedCommand = new RelayCommand <Repository>(r => OnRepoSelected(navigationService, r));
            UserSelectedCommand = new RelayCommand <User>(u => OnUserSelected(navigationService, user, u));
            PivotChangedCommand = new RelayCommand <SelectionChangedEventArgs>(args => OnPivotChanged(githubService, args));
        }
Ejemplo n.º 4
0
 private void OnPivotChanged(GithubService githubService, SelectionChangedEventArgs args)
 {
     var header = ((PivotItem)args.AddedItems[0]).Header as String;
     ShowAppBar = false;
     switch (header)
     {
         case "feed":
             if (EventsRequest == null)
                 EventsRequest = new UserEventsRequests(Username);
             break;
         case "owned repos":
             if (RepositoriesRequest == null)
                 RepositoriesRequest = new RepositoriesRequest(Username);
             break;
         case "watched reps":
             if (RepositoriesWatchedRequest == null)
                 RepositoriesWatchedRequest = new RepositoriesWatchedRequest(Username);
             break;
         case "follower":
             if (FollowersRequest == null)
                 FollowersRequest = new UserFollowersRequest(Username);
             break;
         case "following":
             if (FollowingsRequest == null)
                 FollowingsRequest = new UserFollowingRequest(Username);
             break;
         case "profile":
         case "details":
             if (User == null)
             {
                 User = githubService.Load(new UserRequest(Username), u => User = u);
                 if (githubService.IsAuthenticated)
                     IsFollowing = githubService.Load(new FollowUserRequest(Username), r => { IsFollowing = r; });
             }
             ShowAppBar = true;
             break;
     }
 }