public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            if(AppModel!=null){
                loadingOverlay = new LoadingOverlay (UIScreen.MainScreen.Bounds);
                View.Add (loadingOverlay);

                dataSource = new ProviderTableSource(){ ProviderList = new MedicalProvider[0] };
                dataSource.ProviderSelected+=(mp)=>{
                    AppModel.SelectedProvider=mp;
                    var actionSheet = new UIActionSheet (mp.LastName);
                    actionSheet.AddButton ("Cancel");
                    actionSheet.AddButton ("Add Favorites");
                    actionSheet.AddButton ("Call");
                    actionSheet.AddButton ("Directions");
                    actionSheet.CancelButtonIndex = 0;
                    actionSheet.Clicked += delegate(object a, UIButtonEventArgs b) {
                        switch (b.ButtonIndex) {
                        case 0:
                            break;
                        case 1:
                            AppModel.AddFavorite(mp);
                            break;
                        case 2:
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("tel:" + mp.PhoneNumber));
                            break;
                        case 3:
                            var directions = (DirectionsController)this.Storyboard.InstantiateViewController("Directions");
                            directions.AppModel=this.AppModel;
                            this.PresentViewController(directions,true,null);
                            break;
                        }
                    };
                    actionSheet.ShowInView (View);
                };
                this.MedProviderTable.Source= dataSource;
                AppModel.ProviderSearchCompleted+=(e,a)=>{
                    this.BeginInvokeOnMainThread(delegate {
                        dataSource.ProviderList = AppModel.ProviderResults.ToArray();
                        this.MedProviderTable.ReloadData();
                        loadingOverlay.Hide ();
                    });
                };
                AppModel.SelectedProvider=null;
                AppModel.SearchForProviders();
            }
        }
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            loadingOverlay = new LoadingOverlay (UIScreen.MainScreen.Bounds);
            View.Add (loadingOverlay);
            appModel.PropertyChanged+=(s,a)=>{
                if(a.PropertyName=="HasLoadedResources"){
                    this.BeginInvokeOnMainThread(delegate {
                        loadingOverlay.Hide();
                        foreach(AppModelInterface item in this.ViewControllers){
                            item.AppModel=appModel;
                        }
                    });
                }
            };
            appModel.FavoritesUpdated+=(s,e)=>{
                this.TabBar.Items[2].BadgeValue= appModel.Favorites.Count.ToString();
            };

            //put something here for a spinner
            appModel.InitResources();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            if (AppModel != null && AppModel.SelectedProvider != null) {

                loadingOverlay = new LoadingOverlay (UIScreen.MainScreen.Bounds);
                View.Add (loadingOverlay);
                AppModel.CoordinatedUpdated += (e,a) => {
                    this.BeginInvokeOnMainThread(delegate {
                        loadingOverlay.Hide ();
                        CLLocationCoordinate2D coords = new CLLocationCoordinate2D(AppModel.ProviderLocation.Latitude, AppModel.ProviderLocation.Longtitude);
                        MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(5), MilesToLongitudeDegrees(5, coords.Latitude));
                        map.Region = new MKCoordinateRegion(coords, span);
                        var prompt = string.Format("Dr {0} {1}", AppModel.SelectedProvider.FirstName,AppModel.SelectedProvider.LastName);
                        var annotation = new ProviderAnnotation (coords, prompt);
                        map.AddAnnotation(annotation);

                    });
                };

                AppModel.GetProviderLocation ();

            }
        }