Пример #1
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);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set the background view to black so we don't get white aliasing flicker during
            // the pan
            View.BackgroundColor = UIColor.Black;
            View.Layer.AnchorPoint = CGPoint.Empty;


            // scroll view
            ScrollView = new UIScrollViewWrapper( );
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor );
            ScrollView.Parent = this;
            View.AddSubview( ScrollView );



            // create our keyboard adjustment manager, which works to make sure text fields scroll into visible
            // range when a keyboard appears
            KeyboardAdjustManager = new Rock.Mobile.PlatformSpecific.iOS.UI.KeyboardAdjustManager( View );


            // setup the First Name field
            FirstName = new StyledTextField();
            ScrollView.AddSubview( FirstName.Background );
            ControlStyling.StyleTextField( FirstName.Field, PrayerStrings.CreatePrayer_FirstNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            ControlStyling.StyleBGLayer( FirstName.Background );

            LastName = new StyledTextField();
            ScrollView.AddSubview( LastName.Background );
            ControlStyling.StyleTextField( LastName.Field, PrayerStrings.CreatePrayer_LastNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            ControlStyling.StyleBGLayer( LastName.Background );


            PrayerRequestLayer = new UIView();
            ScrollView.AddSubview( PrayerRequestLayer );

            PrayerRequestPlaceholder = new UILabel();
            PrayerRequestLayer.AddSubview( PrayerRequestPlaceholder );

            PrayerRequest = new UITextView();
            PrayerRequestLayer.AddSubview( PrayerRequest );

            // setup the prayer request field, which requires a fake "placeholder" text field
            PrayerRequest.Delegate = new KeyboardAdjustManager.TextViewDelegate( );
            PrayerRequest.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
            PrayerRequest.TextContainerInset = UIEdgeInsets.Zero;
            PrayerRequest.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            PrayerRequest.TextContainer.LineFragmentPadding = 0;
            PrayerRequest.BackgroundColor = UIColor.Clear;
            PrayerRequest.Editable = true;
            PrayerRequest.KeyboardAppearance = UIKeyboardAppearance.Dark;
            PrayerRequestPlaceholder.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
            PrayerRequestPlaceholder.BackgroundColor = UIColor.Clear;
            PrayerRequestPlaceholder.Text = PrayerStrings.CreatePrayer_PrayerRequest;
            PrayerRequestPlaceholder.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            //PrayerRequestPlaceholder.SizeToFit( );
            ControlStyling.StyleBGLayer( PrayerRequestLayer );


            // category layer
            CategoryLayer = new UIView();
            ScrollView.AddSubview( CategoryLayer );

            CategoryButton = new UIButton();
            CategoryLayer.AddSubview( CategoryButton );

            // setup the category picker and selector button
            UILabel categoryLabel = new UILabel( );
            ControlStyling.StyleUILabel( categoryLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            categoryLabel.Text = PrayerStrings.CreatePrayer_SelectCategoryLabel;

            PickerAdjustManager = new PickerAdjustManager( View, ScrollView, categoryLabel, CategoryLayer );
            UIPickerView pickerView = new UIPickerView();
            pickerView.Model = new CategoryPickerModel() { Parent = this };
            pickerView.UserInteractionEnabled = true;
            PickerAdjustManager.SetPicker( pickerView );


            // setup a tap gesture for the picker
            Action action = ( ) =>
                {
                    OnToggleCategoryPicker( false );
                };
            UITapGestureRecognizer uiTap = new UITapGestureRecognizer( action );
            uiTap.NumberOfTapsRequired = 1;
            pickerView.AddGestureRecognizer( uiTap );
            uiTap.Delegate = this;


            CategoryButton.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    OnToggleCategoryPicker( true );
                };
            CategoryButton.SetTitle( PrayerStrings.CreatePrayer_CategoryButtonText, UIControlState.Normal );
            CategoryButton.SetTitleColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ), UIControlState.Normal );
            CategoryButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            CategoryButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            ControlStyling.StyleBGLayer( CategoryLayer );


            // preference switches
            SwitchBackground = new UIView();
            ScrollView.AddSubview( SwitchBackground );
            ControlStyling.StyleBGLayer( SwitchBackground );

            UIPublicSwitch = new UISwitch();
            SwitchBackground.AddSubview( UIPublicSwitch );

            MakePublicLabel = new UILabel();
            SwitchBackground.AddSubview( MakePublicLabel );
            //MakePublicLabel.TextColor = UIColor.White;


            UISwitchAnonymous = new UISwitch();
            SwitchBackground.AddSubview( UISwitchAnonymous );

            PostAnonymouslyLabel = new UILabel();
            SwitchBackground.AddSubview( PostAnonymouslyLabel );
            //PostAnonymouslyLabel.TextColor = UIColor.White;


            // Setup the anonymous switch
            PostAnonymouslyLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            PostAnonymouslyLabel.Text = PrayerStrings.CreatePrayer_PostAnonymously;
            PostAnonymouslyLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
            UISwitchAnonymous.OnTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Switch_OnColor );
            UISwitchAnonymous.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    OnToggleCategoryPicker( false );

                    if( UISwitchAnonymous.On == true )
                    {
                        FirstName.Field.Enabled = false;
                        FirstName.Field.Text = PrayerStrings.CreatePrayer_Anonymous;

                        LastName.Field.Enabled = false;
                        LastName.Field.Text = PrayerStrings.CreatePrayer_Anonymous;
                    }
                    else
                    {
                        FirstName.Field.Enabled = true;
                        FirstName.Field.Text = string.Empty;

                        LastName.Field.Enabled = true;
                        LastName.Field.Text = string.Empty;
                    }

                    // reset the background colors
                    Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, FirstName.Background );
                    Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, LastName.Background );
                };

            // setup the public switch
            MakePublicLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            MakePublicLabel.Text = PrayerStrings.CreatePrayer_MakePublic;
            MakePublicLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
            UIPublicSwitch.OnTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Switch_OnColor );
            //UIPublicSwitch.ThumbTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );


            // setup the submit button
            SubmitButton = UIButton.FromType( UIButtonType.Custom );
            ScrollView.AddSubview( SubmitButton );
            ControlStyling.StyleButton( SubmitButton, PrayerStrings.CreatePrayer_SubmitButtonText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            SubmitButton.SizeToFit( );
            SubmitButton.TouchUpInside += SubmitPrayerRequest;
        }
        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 );

            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 );
        }
Пример #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set the background view to black so we don't get white aliasing flicker during
            // the pan
            View.BackgroundColor   = UIColor.Black;
            View.Layer.AnchorPoint = CGPoint.Empty;


            // scroll view
            ScrollView = new UIScrollViewWrapper( );
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.BackgroundColor   = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor);
            ScrollView.Parent            = this;
            View.AddSubview(ScrollView);



            // create our keyboard adjustment manager, which works to make sure text fields scroll into visible
            // range when a keyboard appears
            KeyboardAdjustManager = new Rock.Mobile.PlatformSpecific.iOS.UI.KeyboardAdjustManager(View);


            // setup the First Name field
            FirstName = new StyledTextField();
            ScrollView.AddSubview(FirstName.Background);
            ControlStyling.StyleTextField(FirstName.Field, PrayerStrings.CreatePrayer_FirstNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(FirstName.Background);

            LastName = new StyledTextField();
            ScrollView.AddSubview(LastName.Background);
            ControlStyling.StyleTextField(LastName.Field, PrayerStrings.CreatePrayer_LastNamePlaceholderText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            ControlStyling.StyleBGLayer(LastName.Background);

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


            PrayerRequestLayer = new UIView();
            ScrollView.AddSubview(PrayerRequestLayer);

            PrayerRequestPlaceholder = new UILabel();
            PrayerRequestLayer.AddSubview(PrayerRequestPlaceholder);

            PrayerRequest = new UITextView();
            PrayerRequestLayer.AddSubview(PrayerRequest);

            // setup the prayer request field, which requires a fake "placeholder" text field
            PrayerRequest.Delegate           = new KeyboardAdjustManager.TextViewDelegate( );
            PrayerRequest.TextColor          = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor);
            PrayerRequest.TextContainerInset = UIEdgeInsets.Zero;
            PrayerRequest.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            PrayerRequest.TextContainer.LineFragmentPadding = 0;
            PrayerRequest.BackgroundColor            = UIColor.Clear;
            PrayerRequest.Editable                   = true;
            PrayerRequest.KeyboardAppearance         = UIKeyboardAppearance.Dark;
            PrayerRequestPlaceholder.TextColor       = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor);
            PrayerRequestPlaceholder.BackgroundColor = UIColor.Clear;
            PrayerRequestPlaceholder.Text            = PrayerStrings.CreatePrayer_PrayerRequest;
            PrayerRequestPlaceholder.Font            = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            //PrayerRequestPlaceholder.SizeToFit( );
            ControlStyling.StyleBGLayer(PrayerRequestLayer);


            // category layer
            CategoryLayer = new UIView();
            ScrollView.AddSubview(CategoryLayer);

            CategoryButton = new UIButton();
            CategoryLayer.AddSubview(CategoryButton);

            // setup the category picker and selector button
            UILabel categoryLabel = new UILabel( );

            ControlStyling.StyleUILabel(categoryLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            categoryLabel.Text = PrayerStrings.CreatePrayer_SelectCategoryLabel;

            PickerAdjustManager = new PickerAdjustManager(View, ScrollView, categoryLabel, CategoryLayer);
            UIPickerView pickerView = new UIPickerView();

            pickerView.Model = new CategoryPickerModel()
            {
                Parent = this
            };
            pickerView.UserInteractionEnabled = true;
            PickerAdjustManager.SetPicker(pickerView);


            // setup a tap gesture for the picker
            Action action = () =>
            {
                OnToggleCategoryPicker(false);
            };
            UITapGestureRecognizer uiTap = new UITapGestureRecognizer(action);

            uiTap.NumberOfTapsRequired = 1;
            pickerView.AddGestureRecognizer(uiTap);
            uiTap.Delegate = this;


            CategoryButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                OnToggleCategoryPicker(true);
            };
            CategoryButton.SetTitle(PrayerStrings.CreatePrayer_CategoryButtonText, UIControlState.Normal);
            CategoryButton.SetTitleColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor), UIControlState.Normal);
            CategoryButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            CategoryButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            ControlStyling.StyleBGLayer(CategoryLayer);


            // preference switches
            SwitchBackground = new UIView();
            ScrollView.AddSubview(SwitchBackground);
            ControlStyling.StyleBGLayer(SwitchBackground);

            UIPublicSwitch = new UISwitch();
            SwitchBackground.AddSubview(UIPublicSwitch);

            MakePublicLabel = new UILabel();
            SwitchBackground.AddSubview(MakePublicLabel);
            //MakePublicLabel.TextColor = UIColor.White;


            UISwitchAnonymous = new UISwitch();
            SwitchBackground.AddSubview(UISwitchAnonymous);

            //PostAnonymouslyLabel = new UILabel();
            //SwitchBackground.AddSubview( PostAnonymouslyLabel );
            //PostAnonymouslyLabel.TextColor = UIColor.White;


            // Setup the anonymous switch

            /*PostAnonymouslyLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
             * PostAnonymouslyLabel.Text = PrayerStrings.CreatePrayer_PostAnonymously;
             * PostAnonymouslyLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
             * UISwitchAnonymous.OnTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Switch_OnColor );
             * UISwitchAnonymous.TouchUpInside += (object sender, EventArgs e ) =>
             *  {
             *      OnToggleCategoryPicker( false );
             *
             *      if( UISwitchAnonymous.On == true )
             *      {
             *          FirstName.Field.Enabled = false;
             *          FirstName.Field.Text = PrayerStrings.CreatePrayer_Anonymous;
             *
             *          LastName.Field.Enabled = false;
             *          LastName.Field.Text = PrayerStrings.CreatePrayer_Anonymous;
             *      }
             *      else
             *      {
             *          FirstName.Field.Enabled = true;
             *          FirstName.Field.Text = string.Empty;
             *
             *          LastName.Field.Enabled = true;
             *          LastName.Field.Text = string.Empty;
             *      }
             *
             *      // reset the background colors
             *      Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, FirstName.Background );
             *      Rock.Mobile.PlatformSpecific.iOS.UI.Util.AnimateViewColor( ControlStylingConfig.BG_Layer_Color, LastName.Background );
             *  };*/

            // setup the public switch
            MakePublicLabel.Font       = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize);
            MakePublicLabel.Text       = PrayerStrings.CreatePrayer_MakePublic;
            MakePublicLabel.TextColor  = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_ActiveTextColor);
            UIPublicSwitch.OnTintColor = Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Switch_OnColor);
            //UIPublicSwitch.ThumbTintColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );


            // setup the submit button
            SubmitButton = UIButton.FromType(UIButtonType.Custom);
            ScrollView.AddSubview(SubmitButton);
            ControlStyling.StyleButton(SubmitButton, PrayerStrings.CreatePrayer_SubmitButtonText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize);
            SubmitButton.SizeToFit( );
            SubmitButton.TouchUpInside += SubmitPrayerRequest;
        }
        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 );

            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;

            //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.IsNullOrEmpty( Gender.Field.Text ) == false )
                        {
                            ((UIPickerView)GenderPicker.Picker).Select( RockGeneralData.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.IsNullOrEmpty( 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 < RockGeneralData.Instance.Data.Campuses.Count; i++ )
                    {
                        UIAlertAction campusAction = UIAlertAction.Create( RockGeneralData.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) => 
                {
                    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) => 
                {
                    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;
                    }
                };

            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?" );
        }
Пример #6
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?");
            }
        }
        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;
            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();
                    }
                };

            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 );
                    }
                };
            
            // setup the fake header
            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 );
        }
Пример #8
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( );
            }
        }