public SettingsController(MainViewTabBarController model)
     : base(UITableViewStyle.Grouped, null)
 {
     this.Title = "Settings";
     _settingsDialog = new SettingsDialogModel ();
     _settingsModel = new SettingsModel ();
     Initialize (model);
 }
        protected void Initialize(MainViewTabBarController model)
        {
            Root = new RootElement ("Settings") {
            //				new Section () {
            //					new RootElement ("User Account") {
            //						new Section(){
            //							new StringElement ("Username Info"),
            //							new StringElement ("Name info")
            //						}
            //					}
            //				},
                new Section ("Texting while driving") {
                    (_settingsDialog.BlockSMS = new BooleanElement ("Block SMS", _settingsModel.TextMessage)),
                    (_settingsDialog.SMSVoiceUtility = new BooleanElement ("Voice Utility", _settingsModel.VoiceUtility))
                },
                new Section ("Track overspeeding") {
                    (_settingsDialog.NotifyOverspeeding = new BooleanElement ("Track Speed", _settingsModel.OverSpeeding))
                },
                new Section ("Drunk driving prevention") {
                    (_settingsDialog.BlockDrunkDriving = new BooleanElement ("Block Drunk Driving", _settingsModel.DrunkDriving))
                },
                new Section ("Emergency Situation", "Send your personal information and current location to 911 to ask for help.") {
                    (_settingsDialog.EmergencyHelp = new BooleanElement ("Inform 911", _settingsModel.CallForHelp))
                },
                new Section("Save change") {
                    new StringElement("Save", () =>
                        {
                            _settingsModel.TextMessage = _settingsDialog.BlockSMS.Value;
                            _settingsModel.VoiceUtility = _settingsDialog.SMSVoiceUtility.Value;
                            _settingsModel.OverSpeeding = _settingsDialog.NotifyOverspeeding.Value;
                            _settingsModel.DrunkDriving = _settingsDialog.BlockDrunkDriving.Value;
                            _settingsModel.CallForHelp = _settingsDialog.EmergencyHelp.Value;
                            var alert = new UIAlertView("", "Save Succeed!", null, "OK");
                            alert.Show();
                        })
                },
                new Section ("Privacy"){
                    new StringElement("Sign Out", () => {
                        var alert = new UIAlertView("","Are you sure you want to sign out?" , null,"No", "Yes");
                        alert.Show();
                        alert.Clicked += (sender, e) => {
                            if(e.ButtonIndex == 1) {
                                //it works, but I do NOT know if all the views are released or there are still there.
                                //var count = model.NavigationController.ViewControllers.Length;
                                model.ViewControllers = new UIViewController[0];
                                model.TabBar.Hidden = true;
                                NavigationController.PopToRootViewController(true);
                                //var count1 = model.NavigationController.ViewControllers.Length;
                                var loginController = new LoginController();
                                NavigationController.PushViewController(loginController, true);

                            }
                        };
                    })
                }
            };
        }
Ejemplo n.º 3
0
 protected void UserLogin()
 {
     if (usernameTxtField.Text == "" || passwordTxtField.Text == "")
     {
         var message = string.Format("Please enter Username/Password");
         var alert = new UIAlertView("Empty input!", message, null, "Ok");
         alert.Show();
     } else {
         var has = _users.Any (s => s.Name == usernameTxtField.Text.ToString ());
         if (has) {
             var user = _users.First(s => s.Name == usernameTxtField.Text.ToString ());
             if (user.Password == passwordTxtField.Text.ToString ()) {
                 var welcomeMessage = string.Format ("Welcome Back " + usernameTxtField.Text + "!");
                 _mainController = new MainViewTabBarController (welcomeMessage);
                 NavigationController.PushViewController (_mainController, true);
                 ReleaseViewController ();
             } else {
                 Times++;
                 if (Times == 4) {
                     var alert1 = new UIAlertView ("Account locked!", "Send email to reset the password!", null, "Cancel", "Reset");
                     alert1.Show ();
                 } else {
                     var alert = new UIAlertView ("Username/Password is incorrect!", "Please, try again!", null, "Ok");
                     alert.Show ();
                     passwordTxtField.Text = "";
                 }
             }
         } else {
             var alert = new UIAlertView("User does not exist!", "Create a new account?", null, "Cancel", "Create");
             alert.Show();
             /* -- alert view call back -- */
             alert.Clicked += (sender, e) => {
                 if (e.ButtonIndex == 1) {
                     if (_registerController == null)
                         _registerController = new RegisterController();
                     NavigationController.PushViewController(_registerController, true);
                 }
             };
         }
     }
 }
 protected void Initialize()
 {
     _registerDialog = new RegisterDialogModel();
     Root = new RootElement("Register")
         {
             new Section()
                 {
                     (_registerDialog.Name = new EntryElement("Name", "Enter full name", "")),
                     (_registerDialog.Birthday = new DateElement("Date of Birth",DateTime.Now) {BackgroundColor = UIColor.White}),
                     (_registerDialog.BloodGroup = new EntryElement("Blood Group", "Enter blood Group", ""))
                 },
             new Section()
             {
                 (_registerDialog.LicenceNo = new EntryElement("License #", "Enter driver license/ID number", "")),
                 (_registerDialog.Address = new EntryElement("Address", "Enter address", "")),
                 (_registerDialog.IssueState = new EntryElement("Issue State", "Enter driver license/ID issue state", "")),
                 (_registerDialog.ExpireDate = new DateElement("Expire Date", DateTime.Now) {BackgroundColor = UIColor.White})
             },
             new Section()
             {
                 (_registerDialog.Password = new EntryElement("Password", "Enter new password", "", true)),
                 (_registerDialog.RepeatPassword = new EntryElement("Repeat", "Re-enter password", "", true))
             },
             new Section()
             {
                 (_registerDialog.EmailAddress = new EntryElement("Email", "Enter email address", ""))
             },
             new Section()
             {
                 (_registerDialog.PhoneNumber = new EntryElement("Phone Number", "Please enter phone number", ""))
             },
             new Section("Tell me about new features:")
             {
                 (_registerDialog.ReceiveEmail = new BooleanElement("By email", true))
             },
             new Section("Click to register")
                 {
                     new StringElement("Register", () =>
                         {
                             var message = string.Format("Name:{0}\nBirthday:{1}", _registerDialog.Name.Value,
                                                            _registerDialog.Birthday.Value);
                             var alert = new UIAlertView("Succeed!", message, null, "Cancel", "Ok");
                             alert.Show();
                             var item = new RegisterModel()
                                 {
                                     ID = id,
                                     Name = _registerDialog.Name.Value,
                                     Birthday = _registerDialog.Birthday.DateValue
                                 };
                             UploadRegister(item);
                             var welcomeMessage = string.Format("Welcome using App Name " + _registerDialog.Name.Value + "!");
                             _mainController = new MainViewTabBarController(welcomeMessage);
                             NavigationController.PushViewController(_mainController, true);
                             ReleaseViewController();
                         })
                 }
         };
 }