Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            //TODO: not to use local list, use azure
            //Family = AzureHelper.GetFamilyMembers();

            // Perform any additional setup after loading the view, typically from a nib.
            NameTextField.ClearsOnBeginEditing = true;
            NameTextField.EditingChanged      += (sender1, e1) => {
                Name = ((UITextField)sender1).Text.ToString();
                //NameTextField.ResignFirstResponder();
            };
            startButton.TouchUpInside += (sender, e) => {
                NameTextField.ResignFirstResponder();
                if (Name == "")
                {
                    var alert = UIAlertController.Create("Empty Name", "Please Enter Your Name", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
                else
                {
                    CameraViewController cameraView = this.Storyboard.InstantiateViewController("CameraViewController") as CameraViewController;
                    if (cameraView != null)
                    {
                        cameraView.userName = Name;
                        this.NavigationController.PushViewController(cameraView, true);
                    }
                }
            };

            AddMemberButton.TouchUpInside += (sender, e) =>
            {
                NameTextField.ResignFirstResponder();

                FamilyListController family = this.Storyboard.InstantiateViewController("FamilyListController") as FamilyListController;
                if (family != null)
                {
                    family.Family = Family;
                    this.NavigationController.PushViewController(family, true);
                }
            };

            FamilyListButton.TouchUpInside += (object sender, EventArgs e) => {
                Family = AzureHelper.GetFamilyMembers();

                NameTextField.ResignFirstResponder();
                // Launches a new instance of CallHistoryController
                FamilyMemberController familyMember = this.Storyboard.InstantiateViewController("FamilyMemberController") as FamilyMemberController;
                if (familyMember != null)
                {
                    familyMember.Family = Family;
                    this.NavigationController.PushViewController(familyMember, true);
                }
            };

            NameTextField.ResignFirstResponder();
        }
Ejemplo n.º 2
0
 public FamilyMemberDataSource(FamilyMemberController controller)
 {
     this.controller = controller;
 }
Ejemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            string nameChanged  = string.Empty;
            string emailChanged = string.Empty;

            NameField.ClearsOnBeginEditing  = true;
            EmailField.ClearsOnBeginEditing = true;

            NameField.EditingChanged += (sernder2, e2) =>
            {
                nameChanged = ((UITextField)sernder2).Text;
                //NameFamTextField.ResignFirstResponder();
            };
            EmailField.EditingChanged += (s, e) =>
            {
                emailChanged = ((UITextField)s).Text;
                //EmailTextField.ResignFirstResponder();
            };

            AddToListButton.TouchUpInside += (sender, e) => {
                NameField.ResignFirstResponder();
                EmailField.ResignFirstResponder();
                if (String.IsNullOrEmpty(nameChanged))
                {
                    var alert = UIAlertController.Create("Empty Family's Member Name", "Please Enter Name", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
                if (String.IsNullOrEmpty(emailChanged))
                {
                    var alert = UIAlertController.Create("Empty Email", "Please Enter Email adress", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
                else
                {
                    FamilyMemberController familyMemberController = this.Storyboard.InstantiateViewController("FamilyMemberController") as FamilyMemberController;
                    if (familyMemberController != null)
                    {
                        try
                        {
                            Family.Add(new FamilyMember(nameChanged, emailChanged));
                            AzureHelper.AddNewMember(nameChanged, emailChanged);
                            var alert = UIAlertController.Create("Successful", "New family member added", UIAlertControllerStyle.Alert);
                            alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                            PresentViewController(alert, true, null);
                        }
                        catch
                        {
                            var alert = UIAlertController.Create("Failed", "Failed to add new member", UIAlertControllerStyle.Alert);
                            alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                            PresentViewController(alert, true, null);
                        }
                    }
                }
            };

            RemoveButton.TouchUpInside += (sender, e) =>
            {
                NameField.ResignFirstResponder();
                EmailField.ResignFirstResponder();
                if (String.IsNullOrEmpty(nameChanged))
                {
                    var alert = UIAlertController.Create("Empty Family's Member Name", "Please Enter Name", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
                else
                {
                    try
                    {
                        AzureHelper.RemoveFamilyMember(nameChanged);
                        var alert = UIAlertController.Create("Successful", nameChanged + " was removed from family list", UIAlertControllerStyle.Alert);
                        alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                        PresentViewController(alert, true, null);
                    }
                    catch
                    {
                        var alert = UIAlertController.Create("Failed", "Failed to remove member", UIAlertControllerStyle.Alert);
                        alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                        PresentViewController(alert, true, null);
                    }
                }
            };
        }