Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = "";

            ViewModel.LoadDataCommand.Execute(null);
            UIColor lineColor = Theme.MainColor;

            TopSeparatorView.BackgroundColor    = lineColor;
            BottomSeparatorView.BackgroundColor = lineColor;

            _bindings = new object[]
            {
                this.SetBinding(() => ViewModel.CityName, () => CityName.Text, BindingMode.OneWay),
                this.SetBinding(() => ViewModel.CurrentTemperature, () => CurrentTemperature, BindingMode.OneWay),
                this.SetBinding(() => ViewModel.TodayDayName, () => TodayDayNameLabel.Text, BindingMode.OneWay),
                this.SetBinding(() => ViewModel.TodayMaxTemperature, () => TodayMaxTemperatureLabel.Text, BindingMode.OneWay),
                this.SetBinding(() => ViewModel.TodayMinTemperature, () => TodayMinTemperatureLabel.Text, BindingMode.OneWay),
                this.SetBinding(() => ViewModel.IsLoading, () => ActivityIndicator.IsLoading, BindingMode.OneWay),
            };

            DailyWeatherTableView.Source = ViewModel.DailyWeatherList.GetTableViewSource(
                CreateTaskCell,
                BindWeatherDataCell
                );

            HourlyWeatherCollectionView.Source = ViewModel.HourlyWeatherList.GetCollectionViewSource <DetailsViewModel.HourlyWeatherData, HourWeatherCollectionViewCell>(
                BindHourWeatherViewCell,
                null,
                nameof(HourWeatherCollectionViewCell));

            // workaround for sad MVVM light behaviour registering class on it's own
            // force source to register the cell
            HourlyWeatherCollectionView.Source.GetItemsCount(HourlyWeatherCollectionView, 0);
            // override the registration
            HourlyWeatherCollectionView.RegisterNibForCell(HourWeatherCollectionViewCell.Nib, nameof(HourWeatherCollectionViewCell));

            CityName.AccessibilityIdentifier = "CityName";
        }
        void ReleaseDesignerOutlets()
        {
            if (ActivityIndicator != null)
            {
                ActivityIndicator.Dispose();
                ActivityIndicator = null;
            }

            if (BottomSeparatorView != null)
            {
                BottomSeparatorView.Dispose();
                BottomSeparatorView = null;
            }

            if (CityName != null)
            {
                CityName.Dispose();
                CityName = null;
            }

            if (CurrentTemperatureLabel != null)
            {
                CurrentTemperatureLabel.Dispose();
                CurrentTemperatureLabel = null;
            }

            if (CurrentWeatherIconView != null)
            {
                CurrentWeatherIconView.Dispose();
                CurrentWeatherIconView = null;
            }

            if (DailyWeatherTableView != null)
            {
                DailyWeatherTableView.Dispose();
                DailyWeatherTableView = null;
            }

            if (HourlyWeatherCollectionView != null)
            {
                HourlyWeatherCollectionView.Dispose();
                HourlyWeatherCollectionView = null;
            }

            if (TodayDayNameLabel != null)
            {
                TodayDayNameLabel.Dispose();
                TodayDayNameLabel = null;
            }

            if (TodayMaxTemperatureLabel != null)
            {
                TodayMaxTemperatureLabel.Dispose();
                TodayMaxTemperatureLabel = null;
            }

            if (TodayMinTemperatureLabel != null)
            {
                TodayMinTemperatureLabel.Dispose();
                TodayMinTemperatureLabel = null;
            }

            if (TopSeparatorView != null)
            {
                TopSeparatorView.Dispose();
                TopSeparatorView = null;
            }
        }