예제 #1
0
        public async override void ViewDidLoad()
        {
            Title = "10 Day Forecast";

            base.ViewDidLoad();

            var loadingOverlay = new LoadingOverlay(this.View.Bounds);

            Add(loadingOverlay);

            //var statusBarHeight = UIApplication.SharedApplication.StatusBarFrame.Height;

            //tableView = new UITableView(new CGRect(0, statusBarHeight, View.Frame.Width, View.Frame.Height));
            //tableView.RegisterClassForCellReuse(typeof(UITableViewCell), "MyCell");
            //tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;

            var forecastDays = await WeatherService.Instance.Get10DayForecast();

            if (forecastDays != null)
            {
                tableView.Source = new TenDayTableViewSource(forecastDays);
                tableView.ReloadData();
            }

            loadingOverlay.Hide();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            var statusBarHeight = UIApplication.SharedApplication.StatusBarFrame.Height;

            tableView = new UITableView(new CGRect(0, statusBarHeight + 100, View.Frame.Width, View.Frame.Height));
            tableView.RegisterClassForCellReuse(typeof(UITableViewCell), "MyCell");
            tableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;

            View.AddSubview(tableView);

            var loadingOverlay = new LoadingOverlay(this.View.Bounds);

            Add(loadingOverlay);

            Task.Run(async() =>
            {
                var currentConditions = await WeatherService.Instance.GetCurrentConditions();

                if (currentConditions != null)
                {
                    InvokeOnMainThread(() =>
                    {
                        var imageView = new UIImageView(new CGRect((View.Frame.Width / 2) - 24, 100, 48, 48));

                        //ImageService.Instance.LoadUrl(currentConditions.IconUrl).Into(imageView);

                        imageView.Image = FromUrl(currentConditions.IconUrl);

                        View.AddSubview(imageView);

                        var items = new List <Tuple <string, string> >();
                        items.Add(new Tuple <string, string>("Current conditions: ", currentConditions.Weather));
                        items.Add(new Tuple <string, string>("Temperature: ", currentConditions.Temperature));
                        items.Add(new Tuple <string, string>("Feels like: ", currentConditions.FeelsLike));
                        items.Add(new Tuple <string, string>("Wind: ", currentConditions.WindDescription));
                        items.Add(new Tuple <string, string>("Wind Chill: ", currentConditions.Windchill));
                        items.Add(new Tuple <string, string>("Humidity: ", currentConditions.RelativeHumidity));
                        items.Add(new Tuple <string, string>("Dewpoint: ", currentConditions.Dewpoint));
                        items.Add(new Tuple <string, string>("Heat Index: ", currentConditions.HeatIndex));

                        tableView.Source = new CurrentConditionsTableSource(items);
                        tableView.ReloadData();

                        loadingOverlay.Hide();
                    });
                }
            });
        }