Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            addButton.TouchUpInside += delegate {
                UIAlertController cont = UIAlertController.Create("Añadir", "¿Que quieres añadir?", UIAlertControllerStyle.ActionSheet);
                cont.AddAction(UIAlertAction.Create("Peso", UIAlertActionStyle.Default, (obj) => {
                    WeightController newController = (WeightController)this.Storyboard.InstantiateViewController("weightID");
                    WeightController.Weight        = null;
                    newController.OnAddWeight     += async(sender, args) =>
                    {
                        //SaveWeightIntoHealthStore(args.Weight.Value,args.Weight.Date);
                        await service.SaveWeightIntoHealthStore(args.Weight);
                        UpdateUsersWeight();
                    };
                    PresentViewController(newController, true, null);
                }));

                cont.AddAction(UIAlertAction.Create("Ejercicio", UIAlertActionStyle.Default, (obj) => {
                    PresentViewController(new AddExerciseViewController(), true, null);
                }));

                PresentViewController(cont, true, null);
            };
        }
Ejemplo n.º 2
0
        async Task UpdateUsersWeight()
        {
            data = await service.GetWeigths();

            if (data != null)
            {
                InvokeOnMainThread(delegate
                {
                    TableWeight.SeparatorStyle = UITableViewCellSeparatorStyle.None;
                    TableWeight.Hidden         = true;
                    WeightTableSource source   = new WeightTableSource(data);
                    TableWeight.Source         = source;
                    source.OnWeightSelected   += (sender, args) =>
                    {
                        WeightController newController = (WeightController)this.Storyboard.InstantiateViewController("weightID");
                        WeightController.Weight        = args.Weight;
                        newController.OnDeleteWeight  += async(sender2, args2) =>
                        {
                            if (await service.DeleteWeightIntoHealthStore(args2.Weight))
                            {
                                UpdateUsersWeight();
                            }
                            else
                            {
                                InvokeOnMainThread(delegate
                                {
                                    new UIAlertView("HealthKit", "No puede borrar este registro, ha sido creado por otra app", null, "OK", null).Show();
                                });
                            }
                        };
                        PresentViewController(newController, true, null);
                    };
                    TableWeight.ReloadData();
                    TableWeight.Hidden = false;
                    WeightGraph.SetData(data, 75, 66);
                    //WeightGraph.SetData(data, 95, 96);
                });
            }
        }