Esempio n. 1
0
        public App()
        {
            InitializeComponent();

            Get = this;

            Forum = DependencyService.Get <IServiceForum>();

            var navigationPage = new NavigationPage(new ViewMainMenu());

            MainPage = navigationPage;
        }
Esempio n. 2
0
        public ViewModelPost(IServiceForum serviceForum,
                             IServiceUser serviceUser)
        {
            this._serviceForum = serviceForum;
            this._serviceUser  = serviceUser;

            this.LoadDataCommand = ReactiveCommand.Create <int>(id =>
            {
                SelectedPost = _serviceForum.GetById(id);
                UserName     = _serviceUser.GetUserNameById(SelectedPost.UserId);
            });

            this.WhenAnyValue(x => x.SelectedId)
            .InvokeCommand(LoadDataCommand);
        }
Esempio n. 3
0
        public ViewModelForum(IServiceForum serviceForum,
                              INavigationService navigationService)
        {
            this._serviceForum      = serviceForum;
            this._navigationService = navigationService;
            this.Posts = new ObservableCollection <ModelPost>();

            this.LoadDataCommand = ReactiveCommand.Create <string>(filter =>
            {
                Posts.Clear();
                Posts.AddRange(_serviceForum.GetMatchingPosts(filter));
            });

            this.ItemTappedCommand = ReactiveCommand.CreateFromTask <ModelPost>(async selectedItem =>
            {
                var navigationParams = new NavigationParameters();
                navigationParams.Add($"{nameof(ModelPost)}Id", selectedItem.Id);
                await _navigationService.NavigateAsync("ViewPost", navigationParams);
            });

            this.WhenAnyValue(x => x.SearchText)
            .InvokeCommand(LoadDataCommand);
        }