public TextResultsListPage(IMainThread mainThread,
                                   SignalRService signalRService,
                                   HueBridgeSetupPage hueBridgeSetupPage,
                                   TextResultsListViewModel textResultsListViewModel,
                                   PhilipsHueBridgeSettingsService philipsHueBridgeSettingsService) : base(textResultsListViewModel)
        {
            _mainThread         = mainThread;
            _hueBridgeSetupPage = hueBridgeSetupPage;
            _philipsHueBridgeSettingsService = philipsHueBridgeSettingsService;

            BindingContext.ErrorTriggered += HandleErrorTriggered;
            BindingContext.PhilipsHueBridgeConnectionFailed += HandlePhilipsHueBridgeConnectionFailed;
            signalRService.InitializationFailed             += HandleInitializationFailed;

            ToolbarItems.Add(new ToolbarItem {
                Text = "Setup"
            }
                             .Invoke(setupToolbarItem => setupToolbarItem.Clicked += HandleSetupPageToolbarItemClicked));

            Title = PageTitles.TextResultsPage;

            this.SetBinding(BackgroundColorProperty, nameof(BindingContext.BackgroundColor));

            Content = new RefreshView
            {
                RefreshColor = Device.RuntimePlatform is Device.iOS ? ColorConstants.BarTextColor : ColorConstants.BarBackgroundColor,
                Content      = new CollectionView
                {
                    ItemTemplate    = new TextMoodDataTemplateSelector(),
                    BackgroundColor = Color.Transparent
                }.Bind(CollectionView.ItemsSourceProperty, nameof(BindingContext.TextList))
            }.Bind(RefreshView.IsRefreshingProperty, nameof(BindingContext.IsRefreshing))
            .Bind(RefreshView.CommandProperty, nameof(BindingContext.PullToRefreshCommand));
        }
Example #2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            Device.BeginInvokeOnMainThread(_textModelList.BeginRefresh);

            await SignalRService.Subscribe().ConfigureAwait(false);
        }