Ejemplo n.º 1
0
        public async Task TestComments ()
        {
            // Test that the comment values are mapped correctly from the viewModel we pass in
            var posts = MockFacebook.GetPosts();
            var viewModel = new FacebookCardViewModel(posts[0]);
            var commentViewModel = new CommentViewModel(viewModel);

            await commentViewModel.DidLoad();

            // We do (+2) because there are always two additional more, the primary comment card and the "Now" header
            Assert.AreEqual(viewModel, commentViewModel.PrimaryCardViewModel);
            Assert.AreEqual(viewModel.CommentViewModels.Count + 2, commentViewModel.CardViewModels.Count);
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            _viewModel = _navigationService.GetAndRemoveParameter(Intent) as CommentViewModel;
            SetContentView(Resource.Layout.Comments);

            SetSupportActionBar(FindViewById<Toolbar>(Resource.Id.CommentsToolbar));
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            Title = _viewModel.Title;

            _commentsList = FindViewById<ListView>(Resource.Id.CommentsListView);

            _replyButton = FindViewById<TextView>(Resource.Id.CommentReplyButton);
            _replyButton.SetCommand("Click", _viewModel.ReplyCommand);
            _replyButton.Enabled = false;

            _comment = FindViewById<EditText>(Resource.Id.CommentReplyText);
            _comment.Hint = _viewModel.CommentPlaceholder;

            _commentsList.Adapter = new ObservableAdapter<IListItem>()
            {
                    DataSource = _viewModel.CardViewModels,
                    GetTemplateDelegate = GetCell,
            };
            var footer = new View(this);
            footer.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)Math.Ceiling(TypedValue.ApplyDimension(ComplexUnitType.Dip, 50f, Application.Context.Resources.DisplayMetrics)));

            _commentsList.AddFooterView(footer);

            _comment.TextChanged += (sender, e) => _viewModel.Comments = _comment.Text;

            _viewModel.RequestDismissKeyboard = () =>
            {
                    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                    imm.HideSoftInputFromWindow(_comment.WindowToken, 0);

            };
            
            _viewModel.RequestCanExecute = (enabled) => _replyButton.Enabled = enabled;
            _viewModel.PropertyChanged += (sender, e) => 
                {
                    switch(e.PropertyName)
                    {
                        case "Comments":
                            if(!_comment.Text.Equals(_viewModel.Comments))
                                _comment.Text = _viewModel.Comments;
                            break;
                    }
                };
        }
Ejemplo n.º 3
0
 private void OnRequestCommentPage(CommentViewModel cVm)
 {
     
     if (RequestCommentPage != null)
     {
         _viewedComment = cVm;
         RequestCommentPage(cVm);
     }
 }
Ejemplo n.º 4
0
		public override async Task DidAppear ()
		{
			await base.DidAppear();

			GetName ();
			await GetSocialAccountDetails ();

			GetHeaderImages ();
			RemoveCardsIfNeeded ();

            //Check if we came back from a comment page, if so, our stolen request noted the comment and will signal Commented by user or not
            if (_viewedComment != null)
            {
                _viewedComment.PrimaryCardViewModel.IsCommentedByUser = _viewedComment.PrimaryCardViewModel.IsCommentedByUser;
                _viewedComment.CardViewModels = null;
            }
            _viewedComment = null;
        }
Ejemplo n.º 5
0
		private void OnRequestCommentPage (CommentViewModel viewModel)
		{
			var storyboard = UIStoryboard.FromName ("Comment", null);
			var controller = storyboard.InstantiateInitialViewController () as CommentController;

			controller.ViewModel = viewModel;

			NavigationController.PushViewController (controller, true);
		}
Ejemplo n.º 6
0
 private async void OnRequestCommentPage(CommentViewModel cVm)
 {
     await cVm.DidLoad();
     _navigationService.NavigateTo(ViewModelLocator.COMMENT_KEY, cVm);
 }