public RegisterViewController() :
            base(UITableViewStyle.Grouped, new RootElement("Register"), true)
        {
            Root = new RootElement("Register")
            {
                new Section {
                    new EntryElement("First Name", "", "")
                    {
                        AutocorrectionType = UITextAutocorrectionType.No
                    },
                    new EntryElement("Last Name", "", "")
                    {
                        AutocorrectionType = UITextAutocorrectionType.No
                    },
                    new EntryElement("Phone", "123-123-1234", "")
                    {
                        KeyboardType = UIKeyboardType.PhonePad
                    },
                    new EntryElement("Email", "*****@*****.**", "")
                    {
                        KeyboardType       = UIKeyboardType.EmailAddress,
                        AutocorrectionType = UITextAutocorrectionType.No
                    },
                    new EntryElement("Username", "username", "")
                    {
                        AutocorrectionType = UITextAutocorrectionType.No
                    },
                    new EntryElement("Password", "password", "", true)
                    {
                        AutocorrectionType = UITextAutocorrectionType.No
                    },
                    new EntryElement("Confirm", "password", "", true)
                    {
                        AutocorrectionType = UITextAutocorrectionType.No
                    },
                    new StyledStringElement("Register", () => {
                        ProgressHud.Show("Registering");

                        //TODO: Actually register

                        ProgressHud.Dismiss();
                    })
                    {
                        Alignment = UITextAlignment.Center
                    }
                }
            };
        }
        async Task Refresh()
        {
            ProgressHud.Show("Refreshing");

            var sectionActive   = Root [0];
            var sectionInactive = Root [1];

            // Clear existing items
            sectionActive.Clear();
            sectionInactive.Clear();

            volunteer.Enabled = false;

            // Call the web service
            var r = await webService.GetCommitmentsAsync(new CommitmentsRequest {
                Username = AppDelegate.Settings.SignedInUsername,
                Password = AppDelegate.Settings.SignedInPassword
            });

            if (!r.Succeeded)
            {
                Utility.ShowError("Request Failed", "Failed to Fetch Commitments for " + AppDelegate.Settings.SignedInUsername);

                ProgressHud.Dismiss();
                return;
            }

            if (r.Result.Any(c => c.IsActive))
            {
                foreach (var ac in r.Result.Where(c => c.IsActive))
                {
                    var text = ac.DisasterId + " - " + ac.StartDate.ToString("yyyy-MM-dd") + " to " + ac.EndDate.ToString("yyyy-MM-dd");

                    sectionActive.Add(new StyledStringElement(text, () => {
                        //TODO: Go to details
                    })
                    {
                        Accessory = UITableViewCellAccessory.DisclosureIndicator
                    });
                }
                volunteer.Enabled = false;
            }
            else
            {
                volunteer.Enabled = true;
            }

            // Add the inactive / past commitments
            if (r.Result.Any(c => !c.IsActive))
            {
                foreach (var pc in r.Result.Where(c => !c.IsActive))
                {
                    var text = pc.DisasterId + " - " + pc.StartDate.ToString("yyyy-MM-dd") + " to " + pc.EndDate.ToString("yyyy-MM-dd");

                    sectionInactive.Add(new StyledStringElement(text, () => {
                        //TODO: Go to details
                    })
                    {
                        Accessory = UITableViewCellAccessory.DisclosureIndicator
                    });
                }
            }

            ProgressHud.Dismiss();
        }
Example #3
0
        public SignInViewController() :
            base(UITableViewStyle.Grouped, new RootElement("Crisis Checkin"), false)
        {
            webService = WebServiceFactory.Create();

            username = new EntryElement("Email", "*****@*****.**", "")
            {
                KeyboardType       = UIKeyboardType.EmailAddress,
                AutocorrectionType = UITextAutocorrectionType.No
            };
            password = new EntryElement("Password", "password", "", true)
            {
                AutocorrectionType = UITextAutocorrectionType.No
            };


            Root = new RootElement("Crisis Checkin")
            {
                new Section("Already have an account?")
                {
                    username,
                    password,
                    new StyledStringElement("Sign In", async() => {
                        username.ResignFirstResponder(true);
                        password.ResignFirstResponder(true);

                        //TODO: Show progress HUD
                        ProgressHud.Show("Signing In");

                        // You have to fetch values first from MonoTouch.Dialog elements
                        username.FetchValue();
                        password.FetchValue();

                        // Actually sign in
                        var r = await webService.SignInAsync(new SignInRequest {
                            Username = username.Value,
                            Password = password.Value
                        });

                        if (!r.Succeeded)
                        {
                            // Show failure message
                            Utility.ShowError("Sign In Failed", "Invalid Username or Password");
                            return;
                        }

                        // Store our credentials for future web service calls
                        AppDelegate.Settings.SignedInUsername = username.Value;
                        AppDelegate.Settings.SignedInPassword = password.Value;

                        //TODO: Hide progress hud
                        ProgressHud.Dismiss();

                        // Navigate to commitments after successfuly login
                        commitmentsViewController = new CommitmentsViewController();
                        NavigationController.PushViewController(commitmentsViewController, true);
                    })
                    {
                        Alignment = UITextAlignment.Center
                    }
                },
                new Section("Don't have an account yet?")
                {
                    new StyledStringElement("Create an Account", () => {
                        // Navigate to registration controller
                        registerViewController = new RegisterViewController();
                        NavigationController.PushViewController(registerViewController, true);
                    })
                    {
                        Alignment = UITextAlignment.Center
                    }
                }
            };
        }