Esempio n. 1
0
        void UIThread_LoginComplete(System.Net.HttpStatusCode code, string desc)
        {
            BlockerView.Hide(delegate
            {
                switch (code)
                {
                case System.Net.HttpStatusCode.OK:
                    {
                        // see if we should set their viewing campus
                        if (RockMobileUser.Instance.PrimaryFamily.CampusId.HasValue == true)
                        {
                            RockMobileUser.Instance.ViewingCampus = RockMobileUser.Instance.PrimaryFamily.CampusId.Value;
                        }

                        // if they have a profile picture, grab it.
                        RockMobileUser.Instance.TryDownloadProfilePicture(PrivateGeneralConfig.ProfileImageSize, ProfileImageComplete);

                        // update the UI
                        FadeLoginResult(true);
                        LoginResult.Field.Text = string.Format(LoginStrings.Success, RockMobileUser.Instance.PreferredName( ));

                        // start the timer, which will notify the springboard we're logged in when it ticks.
                        LoginSuccessfulTimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e) =>
                        {
                            // when the timer fires, notify the springboard we're done.
                            Rock.Mobile.Threading.Util.PerformOnUIThread(delegate
                            {
                                Springboard.ResignModelViewController(this, null);
                            });
                        };

                        LoginSuccessfulTimer.Start( );

                        break;
                    }

                default:
                    {
                        // if we couldn't get their profile, that should still count as a failed login.
                        SetUIState(LoginState.Out);

                        // failed to login for some reason
                        FadeLoginResult(true);
                        LoginResult.Field.Text = LoginStrings.Error_Unknown;

                        RockMobileUser.Instance.LogoutAndUnbind( );
                        break;
                    }
                }
            });
        }
Esempio n. 2
0
        public void SubmitActionSheetClicked(object sender, UIButtonEventArgs e)
        {
            switch (e.ButtonIndex)
            {
            // submit
            case 0: Dirty = false; SubmitChanges( ); Springboard.ResignModelViewController(this, null); break;

            // No, don't submit
            case 1: Dirty = false; Springboard.ResignModelViewController(this, null); break;

            // cancel
            case 2: break;
            }
        }
Esempio n. 3
0
        void OnResultViewDone( )
        {
            switch (State)
            {
            case RegisterState.Success:
            {
                Springboard.ResignModelViewController(this, null);
                ScrollView.ScrollEnabled = true;
                State = RegisterState.None;
                break;
            }

            case RegisterState.Fail:
            {
                ResultView.Hide( );
                ScrollView.ScrollEnabled = true;
                State = RegisterState.None;
                break;
            }
            }
        }
Esempio n. 4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            // setup the fake header
            HeaderView = new UIView( );
            View.AddSubview(HeaderView);
            HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            // set the title image for the bar if there's no safe area defined. (A safe area is like, say, the notch for iPhone X)
            nfloat safeAreaTopInset = 0;

            // Make sure they're on iOS 11 before checking for insets. This is only needed for iPhone X anyways, which shipped with iOS 11.
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                safeAreaTopInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top;
            }

            if (safeAreaTopInset == 0)
            {
                string imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS;
                LogoView = new UIImageView(new UIImage(imagePath));
                LogoView.Layer.AnchorPoint = CGPoint.Empty;
                LogoView.SizeToFit( );
                HeaderView.AddSubview(LogoView);
            }

            ScrollView       = new UIScrollViewWrapper();
            ScrollView.Frame = new CGRect(View.Frame.Left, HeaderView.Frame.Bottom, View.Frame.Width, View.Frame.Height - HeaderView.Frame.Height);
            View.AddSubview(ScrollView);
            ScrollView.Parent = this;

            // logged in sanity check.
            //if( RockMobileUser.Instance.LoggedIn == true ) throw new Exception("A user cannot be logged in when registering. How did you do this?" );

            BlockerView = new UIBlockerView(View, View.Frame.ToRectF( ));

            //setup styles
            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            UserNameText = new StyledTextField();
            ScrollView.AddSubview(UserNameText.Background);
            UserNameText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            UserNameText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(UserNameText.Field, RegisterStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(UserNameText.Background);

            PasswordText = new StyledTextField();
            ScrollView.AddSubview(PasswordText.Background);
            PasswordText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            PasswordText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            PasswordText.Field.SecureTextEntry        = true;
            ControlStyling.StyleTextField(PasswordText.Field, RegisterStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(PasswordText.Background);

            ConfirmPasswordText = new StyledTextField();
            ScrollView.AddSubview(ConfirmPasswordText.Background);
            ConfirmPasswordText.Field.SecureTextEntry = true;
            ControlStyling.StyleTextField(ConfirmPasswordText.Field, RegisterStrings.ConfirmPasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(ConfirmPasswordText.Background);

            NickNameText = new StyledTextField();
            ScrollView.AddSubview(NickNameText.Background);
            NickNameText.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            NickNameText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(NickNameText.Field, RegisterStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(NickNameText.Background);

            LastNameText = new StyledTextField();
            ScrollView.AddSubview(LastNameText.Background);
            LastNameText.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            LastNameText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(LastNameText.Field, RegisterStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(LastNameText.Background);

            EmailText = new StyledTextField();
            ScrollView.AddSubview(EmailText.Background);
            EmailText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            EmailText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(EmailText.Field, RegisterStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(EmailText.Background);

            CellPhoneText = new StyledTextField();
            ScrollView.AddSubview(CellPhoneText.Background);
            CellPhoneText.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            CellPhoneText.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(CellPhoneText.Field, RegisterStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(CellPhoneText.Background);

            DoneButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(DoneButton);
            ControlStyling.StyleButton(DoneButton, RegisterStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            DoneButton.SizeToFit( );


            CancelButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(CancelButton);
            CancelButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal);
            CancelButton.SetTitle(GeneralStrings.Cancel, UIControlState.Normal);
            CancelButton.SizeToFit( );


            // Allow the return on username and password to start
            // the login process
            NickNameText.Field.ShouldReturn += TextFieldShouldReturn;
            LastNameText.Field.ShouldReturn += TextFieldShouldReturn;

            EmailText.Field.ShouldReturn += TextFieldShouldReturn;

            // If submit is pressed with dirty changes, prompt the user to save them.
            DoneButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                RegisterUser( );

                HideKeyboard( );
            };

            // On logout, make sure the user really wants to log out.
            CancelButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // if there were changes, create an action sheet for them to confirm.
                UIAlertController actionSheet = UIAlertController.Create(RegisterStrings.ConfirmCancelReg,
                                                                         null,
                                                                         UIAlertControllerStyle.ActionSheet);

                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    actionSheet.PopoverPresentationController.SourceView = CancelButton;
                    actionSheet.PopoverPresentationController.SourceRect = CancelButton.Bounds;
                }

                UIAlertAction yesAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Destructive, delegate
                {
                    Springboard.ResignModelViewController(this, null);
                });
                actionSheet.AddAction(yesAction);


                // let them cancel, too
                UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                actionSheet.AddAction(cancelAction);

                PresentViewController(actionSheet, true, null);
            };

            ResultView = new UIResultView(ScrollView, View.Frame.ToRectF( ), OnResultViewDone);
        }
Esempio n. 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            RefreshProfileTimer           = new System.Timers.Timer();
            RefreshProfileTimer.AutoReset = true;
            RefreshProfileTimer.Interval  = 300 * 1000; // every 5 minutes
            RefreshProfileTimer.Elapsed  += (object sender, System.Timers.ElapsedEventArgs e) =>
            {
                Rock.Mobile.Threading.Util.PerformOnUIThread(
                    delegate
                {
                    RefreshProfile( );
                });
            };

            // setup the fake header
            HeaderView = new UIView( );
            View.AddSubview(HeaderView);

            HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            // set the title image for the bar if there's no safe area defined. (A safe area is like, say, the notch for iPhone X)
            nfloat safeAreaTopInset = 0;

            // Make sure they're on iOS 11 before checking for insets. This is only needed for iPhone X anyways, which shipped with iOS 11.
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                safeAreaTopInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top;
            }

            if (safeAreaTopInset == 0)
            {
                string imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS;
                LogoView = new UIImageView(new UIImage(imagePath));
                LogoView.SizeToFit( );
                LogoView.Layer.AnchorPoint = CGPoint.Empty;
                HeaderView.AddSubview(LogoView);
            }

            ScrollView = new UIScrollViewWrapper();

            View.AddSubview(ScrollView);
            ScrollView.Parent = this;

            BlockerView = new UIBlockerView(ScrollView, View.Bounds.ToRectF( ));

            //setup styles
            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            NickName = new StyledTextField();
            ScrollView.AddSubview(NickName.Background);

            ControlStyling.StyleTextField(NickName.Field, ProfileStrings.NickNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(NickName.Background);
            NickName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            NickName.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            NickName.Field.EditingDidBegin       += (sender, e) => { Dirty = true; };

            LastName = new StyledTextField();

            LastName.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            LastName.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(LastName.Field, ProfileStrings.LastNamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(LastName.Background);
            LastName.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            Email = new StyledTextField();
            ScrollView.AddSubview(Email.Background);
            Email.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            Email.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ScrollView.AddSubview(LastName.Background);
            ControlStyling.StyleTextField(Email.Field, ProfileStrings.EmailPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Email.Background);
            Email.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            CellPhone = new StyledTextField();
            ScrollView.AddSubview(CellPhone.Background);
            CellPhone.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            CellPhone.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(CellPhone.Field, ProfileStrings.CellPhonePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(CellPhone.Background);
            CellPhone.Field.EditingDidBegin += (sender, e) => { Dirty = true; };


            Street = new StyledTextField();
            ScrollView.AddSubview(Street.Background);
            Street.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            Street.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(Street.Field, ProfileStrings.StreetPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Street.Background);
            Street.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            City = new StyledTextField();
            ScrollView.AddSubview(City.Background);
            City.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            City.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(City.Field, ProfileStrings.CityPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(City.Background);
            City.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            State = new StyledTextField();
            ScrollView.AddSubview(State.Background);
            State.Field.AutocapitalizationType = UITextAutocapitalizationType.Words;
            State.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(State.Field, ProfileStrings.StatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(State.Background);
            State.Field.EditingDidBegin += (sender, e) => { Dirty = true; };

            Zip = new StyledTextField();
            ScrollView.AddSubview(Zip.Background);
            Zip.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            Zip.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(Zip.Field, ProfileStrings.ZipPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Zip.Background);
            Zip.Field.EditingDidBegin += (sender, e) => { Dirty = true; };


            // Gender
            Gender = new StyledTextField();
            ScrollView.AddSubview(Gender.Background);
            Gender.Field.UserInteractionEnabled = false;
            ControlStyling.StyleTextField(Gender.Field, ProfileStrings.GenderPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Gender.Background);

            GenderButton = new UIButton( );
            ScrollView.AddSubview(GenderButton);
            GenderButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow multiple pickers
                if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                {
                    HideKeyboard( );

                    // if they have a gender selected, default to that.
                    if (string.IsNullOrWhiteSpace(Gender.Field.Text) == false)
                    {
                        ((UIPickerView)GenderPicker.Picker).Select(RockLaunchData.Instance.Data.Genders.IndexOf(Gender.Field.Text) - 1, 0, false);
                    }

                    GenderPicker.TogglePicker(true);
                }
            };
            //

            // Birthday
            Birthdate = new StyledTextField( );
            ScrollView.AddSubview(Birthdate.Background);
            Birthdate.Field.UserInteractionEnabled = false;
            ControlStyling.StyleTextField(Birthdate.Field, ProfileStrings.BirthdatePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(Birthdate.Background);

            BirthdayButton = new UIButton( );
            ScrollView.AddSubview(BirthdayButton);
            BirthdayButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow multiple pickers
                if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                {
                    HideKeyboard( );

                    // setup the default date time to display
                    DateTime initialDate = DateTime.Now;
                    if (string.IsNullOrWhiteSpace(Birthdate.Field.Text) == false)
                    {
                        initialDate = DateTime.Parse(Birthdate.Field.Text);
                    }

                    ((UIDatePicker)BirthdatePicker.Picker).Date = initialDate.DateTimeToNSDate( );
                    BirthdatePicker.TogglePicker(true);
                }
            };
            //


            // setup the home campus chooser
            HomeCampus = new StyledTextField( );
            ScrollView.AddSubview(HomeCampus.Background);
            HomeCampus.Field.UserInteractionEnabled = false;
            ControlStyling.StyleTextField(HomeCampus.Field, ProfileStrings.CampusPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(HomeCampus.Background);

            HomeCampusButton = new UIButton( );
            ScrollView.AddSubview(HomeCampusButton);
            HomeCampusButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.SelectCampus_SourceTitle,
                                                                         ProfileStrings.SelectCampus_SourceDescription,
                                                                         UIAlertControllerStyle.ActionSheet);

                // if the device is a tablet, anchor the menu
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    actionSheet.PopoverPresentationController.SourceView = HomeCampusButton;
                    actionSheet.PopoverPresentationController.SourceRect = HomeCampusButton.Bounds;
                }

                // for each campus, create an entry in the action sheet, and its callback will assign
                // that campus index to the user's viewing preference
                for (int i = 0; i < RockLaunchData.Instance.Data.Campuses.Count; i++)
                {
                    UIAlertAction campusAction = UIAlertAction.Create(RockLaunchData.Instance.Data.Campuses[i].Name, UIAlertActionStyle.Default, delegate(UIAlertAction obj)
                    {
                        // update the home campus text and flag as dirty
                        HomeCampus.Field.Text = obj.Title;
                        Dirty = true;
                    });

                    actionSheet.AddAction(campusAction);
                }

                // let them cancel, too
                UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                actionSheet.AddAction(cancelAction);

                PresentViewController(actionSheet, true, null);
            };

            DoneButton = new UIButton( );
            ScrollView.AddSubview(DoneButton);
            ControlStyling.StyleButton(DoneButton, ProfileStrings.DoneButtonTitle, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            DoneButton.SizeToFit( );

            LogoutButton = new UIButton( );
            ScrollView.AddSubview(LogoutButton);
            LogoutButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal);
            LogoutButton.SetTitle(ProfileStrings.LogoutButtonTitle, UIControlState.Normal);
            LogoutButton.SizeToFit( );


            // setup the pickers
            UILabel genderPickerLabel = new UILabel( );

            ControlStyling.StyleUILabel(genderPickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            genderPickerLabel.Text = ProfileStrings.SelectGenderLabel;

            GenderPicker = new PickerAdjustManager(View, ScrollView, genderPickerLabel, Gender.Background);
            UIPickerView genderPicker = new UIPickerView();

            genderPicker.Model = new GenderPickerModel()
            {
                Parent = this
            };
            GenderPicker.SetPicker(genderPicker);


            UILabel birthdatePickerLabel = new UILabel( );

            ControlStyling.StyleUILabel(birthdatePickerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            birthdatePickerLabel.Text = ProfileStrings.SelectBirthdateLabel;
            BirthdatePicker           = new PickerAdjustManager(View, ScrollView, birthdatePickerLabel, Birthdate.Background);

            UIDatePicker datePicker = new UIDatePicker();

            datePicker.SetValueForKey(UIColor.White, new NSString("textColor"));
            datePicker.Mode          = UIDatePickerMode.Date;
            datePicker.MinimumDate   = new DateTime(1900, 1, 1).DateTimeToNSDate( );
            datePicker.MaximumDate   = DateTime.Now.DateTimeToNSDate( );
            datePicker.ValueChanged += (object sender, EventArgs e) =>
            {
                NSDate pickerDate = ((UIDatePicker)sender).Date;
                Birthdate.Field.Text = string.Format("{0:MMMMM dd yyyy}", pickerDate.NSDateToDateTime( ));
            };
            BirthdatePicker.SetPicker(datePicker);


            // Allow the return on username and password to start
            // the login process
            NickName.Field.ShouldReturn += TextFieldShouldReturn;
            LastName.Field.ShouldReturn += TextFieldShouldReturn;

            Email.Field.ShouldReturn += TextFieldShouldReturn;

            // If submit is pressed with dirty changes, prompt the user to save them.
            DoneButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // dont' allow changes while the profile is refreshing.
                if (RefreshingProfile == false)
                {
                    if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                    {
                        if (Dirty == true)
                        {
                            // make sure the input is valid before asking them what they want to do.
                            if (ValidateInput( ))
                            {
                                // if there were changes, create an action sheet for them to confirm.
                                UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.SubmitChangesTitle,
                                                                                         null,
                                                                                         UIAlertControllerStyle.ActionSheet);

                                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                                {
                                    actionSheet.PopoverPresentationController.SourceView = DoneButton;
                                    actionSheet.PopoverPresentationController.SourceRect = DoneButton.Bounds;
                                }

                                UIAlertAction submitAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Default, delegate
                                {
                                    Dirty = false; SubmitChanges( ); Springboard.ResignModelViewController(this, null);
                                });
                                actionSheet.AddAction(submitAction);

                                UIAlertAction noSubmitAction = UIAlertAction.Create(GeneralStrings.No, UIAlertActionStyle.Destructive, delegate
                                {
                                    Dirty = false; Springboard.ResignModelViewController(this, null);
                                });
                                actionSheet.AddAction(noSubmitAction);

                                // let them cancel, too
                                UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                                actionSheet.AddAction(cancelAction);

                                PresentViewController(actionSheet, true, null);
                            }
                        }
                        else
                        {
                            Springboard.ResignModelViewController(this, null);
                        }
                    }
                    else
                    {
                        GenderPicker.TogglePicker(false);
                        BirthdatePicker.TogglePicker(false);
                        Dirty = true;
                    }
                }
            };

            // On logout, make sure the user really wants to log out.
            LogoutButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow changes while the profile is refreshing
                if (RefreshingProfile == false)
                {
                    if (GenderPicker.Revealed == false && BirthdatePicker.Revealed == false)
                    {
                        // if they tap logout, and confirm it
                        UIAlertController actionSheet = UIAlertController.Create(ProfileStrings.LogoutTitle,
                                                                                 null,
                                                                                 UIAlertControllerStyle.ActionSheet);

                        if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                        {
                            actionSheet.PopoverPresentationController.SourceView = LogoutButton;
                            actionSheet.PopoverPresentationController.SourceRect = LogoutButton.Bounds;
                        }

                        UIAlertAction logoutAction = UIAlertAction.Create(GeneralStrings.Yes, UIAlertActionStyle.Destructive, delegate
                        {
                            // then log them out.
                            RockMobileUser.Instance.LogoutAndUnbind( );

                            Springboard.ResignModelViewController(this, null);
                        });
                        actionSheet.AddAction(logoutAction);

                        // let them cancel, too
                        UIAlertAction cancelAction = UIAlertAction.Create(GeneralStrings.Cancel, UIAlertActionStyle.Cancel, delegate { });
                        actionSheet.AddAction(cancelAction);

                        PresentViewController(actionSheet, true, null);
                    }
                    else
                    {
                        GenderPicker.TogglePicker(false);
                        BirthdatePicker.TogglePicker(false);
                        Dirty = true;
                    }
                }
            };

            ResultView = new UIResultView(ScrollView, View.Bounds.ToRectF( ),
                                          delegate
            {
                Springboard.ResignModelViewController(this, null);
            });

            Dirty = false;

            // logged in sanity check.
            if (RockMobileUser.Instance.LoggedIn == false)
            {
                throw new Exception("A user must be logged in before viewing a profile. How did you do this?");
            }
        }
Esempio n. 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.Black;

            // set the image
            ImageView = new UIImageView( );
            ImageView.BackgroundColor = UIColor.Black;
            ImageView.ContentMode     = UIViewContentMode.ScaleAspectFit;
            View.AddSubview(ImageView);


            // create our cropper
            CropView = new UIView( );
            CropView.BackgroundColor    = UIColor.Clear;
            CropView.Layer.BorderColor  = UIColor.White.CGColor;
            CropView.Layer.BorderWidth  = 1;
            CropView.Layer.CornerRadius = 4;
            View.AddSubview(CropView);


            // create our fullscreen blocker. It needs to be HUGE so we can center the
            // masked part
            FullscreenBlocker = new UIView();
            FullscreenBlocker.BackgroundColor  = UIColor.Black;
            FullscreenBlocker.Layer.Opacity    = 0.00f;
            FullscreenBlocker.Bounds           = new CGRect(0, 0, 10000, 10000);
            FullscreenBlocker.AutoresizingMask = UIViewAutoresizing.None;
            View.AddSubview(FullscreenBlocker);

            FullscreenBlockerMask          = new CAShapeLayer();
            FullscreenBlockerMask.FillRule = CAShapeLayer.FillRuleEvenOdd;
            FullscreenBlocker.Layer.Mask   = FullscreenBlockerMask;


            // create our bottom toolbar
            Toolbar = new UIToolbar( );

            // create the cancel button
            NSString cancelLabel = new NSString(PrivateImageCropConfig.CropCancelButton_Text);

            CancelButton      = new UIButton(UIButtonType.System);
            CancelButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateImageCropConfig.CropCancelButton_Size);
            CancelButton.SetTitle(cancelLabel.ToString( ), UIControlState.Normal);

            CancelButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // if cancel was pressed while editing, cancel this entire operation
                if (CropMode.Editing == Mode)
                {
                    Springboard.ResignModelViewController(this, null);
                    Mode = CropMode.None;
                }
                else
                {
                    SetMode(CropMode.Editing);
                }
            };

            // create the edit button
            NSString editLabel = new NSString(PrivateImageCropConfig.CropOkButton_Text);

            EditButton      = new UIButton(UIButtonType.System);
            EditButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateImageCropConfig.CropOkButton_Size);
            EditButton.SetTitle(editLabel.ToString( ), UIControlState.Normal);
            EditButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;

            EditButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                if (Mode == CropMode.Previewing)
                {
                    // confirm we're done
                    Springboard.ResignModelViewController(this, CroppedImage);
                    Mode = CropMode.None;
                }
                else
                {
                    SetMode(CropMode.Previewing);
                }
            };

            // create a container that will allow us to align the buttons
            ButtonContainer = new UIView( );
            ButtonContainer.AddSubview(EditButton);
            ButtonContainer.AddSubview(CancelButton);

            CancelButton.BackgroundColor = UIColor.Clear;

            EditButton.BackgroundColor = UIColor.Clear;

            Toolbar.SetItems(new UIBarButtonItem[] { new UIBarButtonItem(ButtonContainer) }, false);
            View.AddSubview(Toolbar);
        }
Esempio n. 7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            BlockerView = new UIBlockerView(View, View.Frame.ToRectF( ));

            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

            ScrollView                   = new UIScrollViewWrapper();
            ScrollView.Parent            = this;
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Bounds            = View.Bounds;
            //ScrollView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( 0x0000FFFF );
            View.AddSubview(ScrollView);

            UserNameField = new StyledTextField();
            ScrollView.AddSubview(UserNameField.Background);

            UserNameField.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            UserNameField.Field.AutocorrectionType     = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField(UserNameField.Field, LoginStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(UserNameField.Background);
            UserNameField.Field.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();

                TryRockBind();
                return(true);
            };

            PasswordField = new StyledTextField();
            ScrollView.AddSubview(PasswordField.Background);
            PasswordField.Field.AutocorrectionType = UITextAutocorrectionType.No;
            PasswordField.Field.SecureTextEntry    = true;

            ControlStyling.StyleTextField(PasswordField.Field, LoginStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(PasswordField.Background);
            PasswordField.Field.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();

                TryRockBind();
                return(true);
            };

            // obviously attempt a login if login is pressed
            LoginButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(LoginButton);
            ControlStyling.StyleButton(LoginButton, LoginStrings.LoginButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            LoginButton.SizeToFit( );
            LoginButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                if (RockMobileUser.Instance.LoggedIn == true)
                {
                    RockMobileUser.Instance.LogoutAndUnbind( );

                    SetUIState(LoginState.Out);
                }
                else
                {
                    TryRockBind();
                }
            };

            // if they forgot their password, kick them out to the forgot password page
            ForgotPasswordButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(ForgotPasswordButton);
            ControlStyling.StyleButton(ForgotPasswordButton, LoginStrings.ForgotPasswordButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ForgotPasswordButton.SizeToFit( );
            ForgotPasswordButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                TaskWebViewController.HandleUrl(true, true, LoginConfig.ForgotPassword_Url, null, null, false, false, false);
            };

            AdditionalOptions = new UILabel( );
            ScrollView.AddSubview(AdditionalOptions);
            ControlStyling.StyleUILabel(AdditionalOptions, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            AdditionalOptions.Text      = LoginStrings.AdditionalOptions;
            AdditionalOptions.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor);
            AdditionalOptions.SizeToFit( );

            OrSpacerLabel = new UILabel( );
            ScrollView.AddSubview(OrSpacerLabel);
            ControlStyling.StyleUILabel(OrSpacerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            OrSpacerLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor);
            OrSpacerLabel.Text      = LoginStrings.OrString;
            OrSpacerLabel.SizeToFit( );

            RegisterButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(RegisterButton);
            ControlStyling.StyleButton(RegisterButton, LoginStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            //RegisterButton.BackgroundColor = UIColor.Clear;
            RegisterButton.SizeToFit( );
            RegisterButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                Springboard.RegisterNewUser( );
            };

            // setup the result
            LoginResult = new StyledTextField( );
            ScrollView.AddSubview(LoginResult.Background);

            ControlStyling.StyleTextField(LoginResult.Field, "", ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            ControlStyling.StyleBGLayer(LoginResult.Background);
            LoginResult.Field.UserInteractionEnabled = false;
            LoginResult.Field.TextAlignment          = UITextAlignment.Center;

            // setup the facebook button
            FacebookLogin = new UIButton( );
            ScrollView.AddSubview(FacebookLogin);
            string imagePath = NSBundle.MainBundle.BundlePath + "/" + "facebook_login.png";

            FBImageView = new UIImageView(new UIImage(imagePath));

            FacebookLogin.SetTitle("", UIControlState.Normal);
            FacebookLogin.AddSubview(FBImageView);
            FacebookLogin.Layer.CornerRadius = 4;
            FBImageView.Layer.CornerRadius   = 4;

            FacebookLogin.TouchUpInside += (object sender, EventArgs e) =>
            {
                TryFacebookBind();
            };

            // If cancel is pressed, notify the springboard we're done.
            CancelButton = UIButton.FromType(UIButtonType.System);
            ScrollView.AddSubview(CancelButton);
            CancelButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor), UIControlState.Normal);
            CancelButton.SetTitle(GeneralStrings.Cancel, UIControlState.Normal);
            CancelButton.SizeToFit( );
            CancelButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // don't allow canceling while we wait for a web request.
                if (LoginState.Trying != State)
                {
                    Springboard.ResignModelViewController(this, null);
                }
            };


            // set the title image for the bar if there's no safe area defined. (A safe area is like, say, the notch for iPhone X)
            nfloat safeAreaTopInset = 0;

            // Make sure they're on iOS 11 before checking for insets. This is only needed for iPhone X anyways, which shipped with iOS 11.
            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                safeAreaTopInset = UIApplication.SharedApplication.KeyWindow.SafeAreaInsets.Top;
            }

            // setup the fake header if they're not on a device with save zones (iphone x)
            if (safeAreaTopInset == 0)
            {
                HeaderView = new UIView( );
                View.AddSubview(HeaderView);
                HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);

                imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS;
                LogoView  = new UIImageView(new UIImage(imagePath));
                LogoView.SizeToFit( );
                LogoView.Layer.AnchorPoint = CGPoint.Empty;

                HeaderView.AddSubview(LogoView);
                HeaderView.SizeToFit( );
            }
        }