public override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

            ScrollView = new UIScrollViewWrapper();
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent = this;
            ScrollView.Bounds = View.Bounds;
            View.AddSubview( ScrollView );

            KeyboardAdjustManager = new KeyboardAdjustManager( View );

            JoinGroupView = new UIJoinGroup();
            JoinGroupView.Create( ScrollView, View.Frame.ToRectF( ) );

            UITextField spouseName = (UITextField)JoinGroupView.SpouseName.PlatformNativeObject;
            spouseName.Delegate = new KeyboardAdjustManager.TextFieldDelegate( );

            UITextField emailName = (UITextField)JoinGroupView.Email.PlatformNativeObject;
            emailName.Delegate = new KeyboardAdjustManager.TextFieldDelegate( );

            // since we're using the platform UI, we need to manually hook up the phone formatting delegate,
            // because that isn't implemented in platform abstracted code.
            CellPhoneTextField = (UITextField)JoinGroupView.CellPhone.PlatformNativeObject;
            CellPhoneTextField.Delegate = new Rock.Mobile.PlatformSpecific.iOS.UI.PhoneNumberFormatterDelegate();
        }
        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 );
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

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

            ScrollView = new UIScrollViewWrapper();
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent = this;
            ScrollView.Bounds = View.Bounds;
            View.AddSubview( ScrollView );

            ScrollView.ScrollEnabled = false;

            // setup everything except positioning, which will happen in LayoutChanged()
            SourceLocation = null;
            GroupEntries = new List<GroupFinder.GroupEntry>();

            SearchAddressButton = UIButton.FromType( UIButtonType.System );
            ScrollView.AddSubview( SearchAddressButton );
            SearchAddressButton.Layer.AnchorPoint = CGPoint.Empty;
            ControlStyling.StyleButton( SearchAddressButton, ConnectStrings.GroupFinder_SearchButtonLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            SearchAddressButton.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    SearchPage.Show( );
                    Task.NavToolbar.Reveal( false );
                };


            MapView = new MKMapView( );
            ScrollView.AddSubview( MapView );

            // set the default position for the map to whatever specified area.
            MKCoordinateRegion region = MKCoordinateRegion.FromDistance( new CLLocationCoordinate2D( 
                ConnectConfig.GroupFinder_DefaultLatitude, 
                ConnectConfig.GroupFinder_DefaultLongitude ), 
                ConnectConfig.GroupFinder_DefaultScale_iOS, 
                ConnectConfig.GroupFinder_DefaultScale_iOS );
            MapView.SetRegion( region, true );

            MapView.Layer.AnchorPoint = new CGPoint( 0, 0 );
            MapView.Delegate = new MapViewDelegate() { Parent = this };

            SearchResultsBGLayer = new UIView();
            ScrollView.AddSubview( SearchResultsBGLayer );
            SearchResultsBGLayer.Layer.AnchorPoint = new CGPoint( 0, 0 );
            SearchResultsBGLayer.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );

            SearchResultsPrefix = new UILabel( );
            ScrollView.AddSubview( SearchResultsPrefix );
            SearchResultsPrefix.Layer.AnchorPoint = new CGPoint( 0, 0 );
            SearchResultsPrefix.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            SearchResultsPrefix.Text = ConnectStrings.GroupFinder_NoGroupsFound;
            SearchResultsPrefix.SizeToFit( );
            SearchResultsPrefix.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
            SearchResultsPrefix.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
            SearchResultsPrefix.TextAlignment = UITextAlignment.Center;

            SearchResultsNeighborhood = new UILabel( );
            ScrollView.AddSubview( SearchResultsNeighborhood );
            SearchResultsNeighborhood.Layer.AnchorPoint = new CGPoint( 0, 0 );
            SearchResultsNeighborhood.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            SearchResultsNeighborhood.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
            SearchResultsNeighborhood.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
            SearchResultsNeighborhood.TextAlignment = UITextAlignment.Center;


            Seperator = new UIView( );
            ScrollView.AddSubview( Seperator );
            Seperator.Layer.BorderWidth = 1;
            Seperator.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ).CGColor;


            GroupFinderTableView = new UITableView();
            ScrollView.AddSubview( GroupFinderTableView );
            GroupTableSource = new GroupFinderViewController.TableSource( this );

            // add the table view and source
            GroupFinderTableView.BackgroundColor = UIColor.Clear;//Rock.Mobile.UI.Util.GetUIColor( App.Shared.Config.ControlStylingConfig.Table_Footer_Color );
            //GroupFinderTableView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( App.Shared.Config.ControlStylingConfig.BG_Layer_Color );
            GroupFinderTableView.Source = GroupTableSource;
            GroupFinderTableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;

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

            SearchPage = new UIGroupFinderSearch();
            SearchPage.Create( ScrollView, ScrollView.Frame.ToRectF( ), 
                delegate
                {
                    SearchPage.Hide( true );
                    GetGroups( SearchPage.Street.Text, SearchPage.City.Text, SearchPage.State.Text, SearchPage.ZipCode.Text );
                    Task.NavToolbar.Reveal( true );
                } );
            SearchPage.SetTitle( ConnectStrings.GroupFinder_SearchPageHeader, ConnectStrings.GroupFinder_SearchPageDetails );
            SearchPage.Hide( false );

            KeyboardAdjustManager = new KeyboardAdjustManager( View );

            // don't allow them to tap the address button until we reveal the search page.
            SearchAddressButton.Enabled = false;

            // wait a couple seconds before revealing the search page.
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.AutoReset = false;
            timer.Interval = 1000;
            timer.Elapsed += (object sender, System.Timers.ElapsedEventArgs e ) =>
                {
                    Rock.Mobile.Threading.Util.PerformOnUIThread( delegate
                        {
                            SearchAddressButton.Enabled = true;
                            SearchPage.Show( );                
                        } );
                };
            timer.Start( );

            // hook in delegates so we can handle return
            ((UITextField)SearchPage.Street.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this };
            ((UITextField)SearchPage.City.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this };
            ((UITextField)SearchPage.State.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this };
            ((UITextField)SearchPage.ZipCode.PlatformNativeObject).Delegate = new AddressDelegate( ) { Parent = this };
        }
        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.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?" );
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Background mask
            BackgroundPanel = new UIView( );
            BackgroundPanel.BackgroundColor = UIColor.Black;
            BackgroundPanel.Layer.Opacity = 0.00f;
            View.AddSubview( BackgroundPanel );

            // Floating "main" UI panel
            MainPanel = new UIView();
            MainPanel.Layer.AnchorPoint = CGPoint.Empty;
            MainPanel.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.SidebarBGColor );//Theme.GetColor( Config.Instance.VisualSettings.TopHeaderBGColor );
            MainPanel.Layer.Opacity = 1.00f;
            MainPanel.ClipsToBounds = true;
            View.AddSubview( MainPanel );

            // Scroll view on the right hand side
            ScrollView = new UIScrollViewWrapper( );
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent = this;
            ScrollView.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.BackgroundColor );
            MainPanel.AddSubview( ScrollView );

            // setup controls that go on the left side
            AdultChildToggle = new UIToggle( Strings.General_Adult, Strings.General_Child,
                delegate(bool wasLeft)
                {
                    if( wasLeft == true )
                    {
                        SwitchActiveMemberView( AdultPanel );
                    }
                    else
                    {
                        SwitchActiveMemberView( ChildPanel );
                    }
                } );
            Theme.StyleToggle( AdultChildToggle, Config.Instance.VisualSettings.ToggleStyle );
            AdultChildToggle.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
            AdultChildToggle.Layer.AnchorPoint = CGPoint.Empty;
            MainPanel.AddSubview( AdultChildToggle );

            // setup our submit button
            SubmitButton = UIButton.FromType( UIButtonType.System );
            SubmitButton.Layer.AnchorPoint = CGPoint.Empty;
            SubmitButton.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
            SubmitButton.SetTitle( Strings.General_Save, UIControlState.Normal );
            SubmitButton.BackgroundColor = UIColor.Blue;
            SubmitButton.SizeToFit( );
            Theme.StyleButton( SubmitButton, Config.Instance.VisualSettings.PrimaryButtonStyle );
            SubmitButton.Bounds = new CGRect( 0, 0, SubmitButton.Bounds.Width * 2.00f, SubmitButton.Bounds.Height );
            MainPanel.AddSubview( SubmitButton );
            SubmitButton.TouchUpInside += (object sender, EventArgs e ) =>
            {
                TrySubmitPerson( );
            };

            // setup the button to tap for editing the picture
            EditPictureButton = new UIButton( new CGRect( 0, 0, 112, 112 )  );
            EditPictureButton.Layer.AnchorPoint = CGPoint.Empty;
            EditPictureButton.Font = FontManager.GetFont( Settings.AddPerson_Icon_Font_Primary, Settings.AddPerson_SymbolFontSize );
            EditPictureButton.SetTitleColor( Theme.GetColor( Config.Instance.VisualSettings.PhotoOutlineColor ), UIControlState.Normal );
            EditPictureButton.Layer.BorderColor = Theme.GetColor( Config.Instance.VisualSettings.PhotoOutlineColor ).CGColor;
            EditPictureButton.Layer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            EditPictureButton.Layer.BorderWidth = 4;
            MainPanel.AddSubview( EditPictureButton );

            EditPictureButton.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    Parent.CaptureImage( delegate(NSData imageBuffer )
                        {
                            // if an image was taken, flag this as dirty so
                            // we know to upload it.
                            if( imageBuffer != null )
                            {
                                ProfileImageViewDirty = true;
                                UpdateProfilePic( imageBuffer );
                            }
                        });
                };

            // set the profile image mask so it's circular
            CALayer maskLayer = new CALayer();
            maskLayer.AnchorPoint = new CGPoint( 0, 0 );
            maskLayer.Bounds = EditPictureButton.Layer.Bounds;
            maskLayer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            maskLayer.BackgroundColor = UIColor.Black.CGColor;
            EditPictureButton.Layer.Mask = maskLayer;
            //

            // setup the image that will display (and note it's a child of EditPictureButton)
            ProfileImageView = new UIImageView( );
            ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFit;

            ProfileImageView.Layer.AnchorPoint = CGPoint.Empty;
            ProfileImageView.Bounds = EditPictureButton.Bounds;
            ProfileImageView.Layer.Position = CGPoint.Empty;
            EditPictureButton.AddSubview( ProfileImageView );

            KeyboardAdjustManager = new KeyboardAdjustManager( MainPanel );

            // setup both types of member view. Adult and Child
            AdultPanel = new AdultMemberPanel( );
            AdultPanel.ViewDidLoad( this );
            ScrollView.AddSubview( AdultPanel.GetRootView( ) );

            ChildPanel = new ChildMemberPanel( );
            ChildPanel.ViewDidLoad( this );
            ScrollView.AddSubview( ChildPanel.GetRootView( ) );

            // add our Close Button
            CloseButton = UIButton.FromType( UIButtonType.System );
            CloseButton.Layer.AnchorPoint = CGPoint.Empty;
            CloseButton.SetTitle( "X", UIControlState.Normal );
            Theme.StyleButton( CloseButton, Config.Instance.VisualSettings.DefaultButtonStyle );
            CloseButton.SizeToFit( );
            CloseButton.BackgroundColor = UIColor.Clear;
            CloseButton.Layer.BorderWidth = 0;
            //CloseButton.Layer.CornerRadius = CloseButton.Bounds.Width / 2;
            MainPanel.AddSubview( CloseButton );
            CloseButton.TouchUpInside += (object sender, EventArgs e ) =>
            {
                ActivePanel.TouchesEnded( );

                if ( ActivePanel.IsInfoDirty( WorkingPerson, WorkingPhoneNumber ) || ProfileImageViewDirty == true )
                {
                    ConfirmCancel( );
                }
                else
                {
                    DismissAnimated( false );
                }
            };

            // default to the adult, and hide the child one
            ActivePanel = AdultPanel;
            ChildPanel.GetRootView( ).Hidden = true;

            View.SetNeedsLayout( );

            ProfileImageView.Image = null;
            EditPictureButton.SetTitle( Settings.AddPerson_NoPhotoSymbol, UIControlState.Normal );

            // remove any existing picture.
            FileCache.Instance.RemoveFile( Settings.AddPerson_PicName );

            // setup the main bounds
            MainPanel.Bounds = new CoreGraphics.CGRect( 0, 0, View.Bounds.Width * .75f, View.Bounds.Height * .75f );

            MainPanel.Layer.CornerRadius = 4;

            // default to hidden until PresentAnimated() is called.
            View.Hidden = true;

            BlockerView = new UIBlockerView( View, View.Bounds.ToRectF( ) );
        }
        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();

            // Background mask
            BackgroundPanel = new UIView( );
            BackgroundPanel.BackgroundColor = UIColor.Black;
            BackgroundPanel.Layer.Opacity   = 0.00f;
            View.AddSubview(BackgroundPanel);

            // Floating "main" UI panel
            MainPanel = new UIView();
            MainPanel.Layer.AnchorPoint = CGPoint.Empty;
            MainPanel.BackgroundColor   = UIColor.Black;
            MainPanel.Layer.Opacity     = 1.00f;
            MainPanel.Bounds            = new CoreGraphics.CGRect(0, 0, View.Bounds.Width * .75f, View.Bounds.Height * .75f);
            View.AddSubview(MainPanel);

            // Scroll view on the right hand side
            ScrollView = new UIScrollViewWrapper( );
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent            = this;
            //ScrollView.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.AddPersonBGColor );
            ScrollView.BackgroundColor = Theme.GetColor(Config.Instance.VisualSettings.BackgroundColor);
            MainPanel.AddSubview(ScrollView);


            KeyboardAdjustManager = new KeyboardAdjustManager(MainPanel);


            SearchPanel = new SearchFamilyPanel();
            SearchPanel.ViewDidLoad(this);

            PeoplePanel = new BrowsePeoplePanel();
            PeoplePanel.ViewDidLoad(this);

            // add both views to the scrollView
            ScrollView.AddSubview(SearchPanel.GetRootView( ));
            ScrollView.AddSubview(PeoplePanel.GetRootView( ));

            // setup the initial panel positions
            SearchPanel.GetRootView( ).Bounds = ScrollView.Bounds;

            // hide the people/family panels until we know which one the user wants
            PeoplePanel.GetRootView( ).Layer.Position = new CGPoint(MainPanel.Bounds.Width, 0);
            PeoplePanel.GetRootView( ).Hidden = true;

            // add our Close Button
            CloseButton = UIButton.FromType(UIButtonType.System);
            CloseButton.Layer.AnchorPoint = CGPoint.Empty;
            CloseButton.SetTitle("X", UIControlState.Normal);
            Theme.StyleButton(CloseButton, Config.Instance.VisualSettings.DefaultButtonStyle);
            CloseButton.SizeToFit( );
            CloseButton.BackgroundColor   = UIColor.Clear;
            CloseButton.Layer.BorderWidth = 0;
            MainPanel.AddSubview(CloseButton);
            CloseButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                ActivePanel.TouchesEnded( );

                //ConfirmCancel( );
                DismissAnimated(false, null);
            };

            // setup the blocker view
            BlockerView = new UIBlockerView(MainPanel, MainPanel.Bounds.ToRectF( ));

            ActivePanel = SearchPanel;

            MainPanel.Layer.CornerRadius = 4;

            // default to hidden until PresentAnimated() is called
            View.Hidden = true;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad( );

            TraitSize = UIScreen.MainScreen.Bounds.Size;
            CurrentTraitCollection = TraitCollection;

            // if we're on an iphone and they're holding it landscape, force a portrait traitsize
            if ( UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone && IsDeviceLandscape( ) )
            {
                UITraitCollection horzTrait = UITraitCollection.FromHorizontalSizeClass( UIUserInterfaceSizeClass.Compact );
                UITraitCollection vertTrait = UITraitCollection.FromVerticalSizeClass( UIUserInterfaceSizeClass.Regular );
                CurrentTraitCollection = UITraitCollection.FromTraitsFromCollections( new UITraitCollection[] { horzTrait, vertTrait } );

                TraitSize = new CGSize( TraitSize.Height, TraitSize.Width );
            }

            View.Layer.AnchorPoint = CGPoint.Empty;
            View.Bounds = new CGRect( View.Bounds.Left, View.Bounds.Top, TraitSize.Width, TraitSize.Height );

            // create the login controller / profile view controllers
            LoginViewController = new LoginViewController( );
            LoginViewController.Springboard = this;

            ProfileViewController = new ProfileViewController( );
            ProfileViewController.Springboard = this;

            ImageCropViewController = new ImageCropViewController( );
            ImageCropViewController.Springboard = this;

            RegisterViewController = new RegisterViewController( );
            RegisterViewController.Springboard = this;

            OOBEViewController = new OOBEViewController( );
            OOBEViewController.Springboard = this;
            OOBEViewController.View.Layer.Position = CGPoint.Empty;

            SplashViewController = new SplashViewController( );
            SplashViewController.Springboard = this;
            SplashViewController.View.Layer.Position = CGPoint.Empty;


            ScrollView = new UIScrollViewWrapper( );
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent = this;
            View.AddSubview( ScrollView );

            // Instantiate all activities
            float elementWidth = 250;
            float elementHeight = 45;

            NewsElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( NewsElement );

            MessagesElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( MessagesElement );

            GiveElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( GiveElement );

            ConnectElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( ConnectElement );

            PrayerElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( PrayerElement );

            MoreElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( MoreElement );
            //

            EditPictureButton = new UIButton( new CGRect( 0, 0, 112, 112 )  );
            ScrollView.AddSubview( EditPictureButton );

            WelcomeField = new UILabel();
            ScrollView.AddSubview( WelcomeField );

            UserNameField = new UILabel();
            ScrollView.AddSubview( UserNameField );


            ViewProfileButton = new UIButton();
            ScrollView.AddSubview( ViewProfileButton );

            ViewProfileLabel = new UILabel();
            ScrollView.AddSubview( ViewProfileLabel );
        

            Elements.Add( new SpringboardElement( this, new NewsTask( "NewsStoryboard_iPhone" )      , NewsElement    , SpringboardConfig.Element_News_Icon    , SpringboardStrings.Element_News_Title ) );
            Elements.Add( new SpringboardElement( this, new NotesTask( "NotesStoryboard_iPhone" )    , MessagesElement, SpringboardConfig.Element_Messages_Icon, SpringboardStrings.Element_Messages_Title ) );
            Elements.Add( new SpringboardElement( this, new GiveTask( "GiveStoryboard_iPhone" )      , GiveElement    , SpringboardConfig.Element_Give_Icon    , SpringboardStrings.Element_Give_Title ) );
            Elements.Add( new SpringboardElement( this, new ConnectTask( "ConnectStoryboard_iPhone" ), ConnectElement , SpringboardConfig.Element_Connect_Icon , SpringboardStrings.Element_Connect_Title ) );
            Elements.Add( new SpringboardElement( this, new PrayerTask( "PrayerStoryboard_iPhone" )  , PrayerElement  , SpringboardConfig.Element_Prayer_Icon  , SpringboardStrings.Element_Prayer_Title ) );
            Elements.Add( new SpringboardElement( this, new AboutTask( "" )                          , MoreElement    , SpringboardConfig.Element_More_Icon    , SpringboardStrings.Element_More_Title ) );

            // add a bottom seperator for the final element
            BottomSeperator = new UIView();
            BottomSeperator.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
            ScrollView.AddSubview( BottomSeperator );
            BottomSeperator.Frame = new CGRect( 0, 0, View.Frame.Width, 1.0f );


            // set the profile image mask so it's circular
            CALayer maskLayer = new CALayer();
            maskLayer.AnchorPoint = new CGPoint( 0, 0 );
            maskLayer.Bounds = EditPictureButton.Layer.Bounds;
            maskLayer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            maskLayer.BackgroundColor = UIColor.Black.CGColor;
            EditPictureButton.Layer.Mask = maskLayer;
            //

            // setup the campus selector and settings button
            CampusSelectionText = new UILabel();
            ControlStyling.StyleUILabel( CampusSelectionText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            CampusSelectionText.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );
            ScrollView.AddSubview( CampusSelectionText );

            CampusSelectionIcon = new UILabel();
            ControlStyling.StyleUILabel( CampusSelectionIcon, PrivateControlStylingConfig.Icon_Font_Primary, ControlStylingConfig.Small_FontSize );
            CampusSelectionIcon.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );
            CampusSelectionIcon.Text = PrivateSpringboardConfig.CampusSelectSymbol;
            CampusSelectionIcon.SizeToFit( );
            ScrollView.AddSubview( CampusSelectionIcon );

            CampusSelectionButton = new UIButton();
            ScrollView.AddSubview( CampusSelectionButton );
            CampusSelectionButton.TouchUpInside += SelectCampus;


            // setup the image that will display when the user is logged in
            ProfileImageView = new UIImageView( );
            ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFit;

            ProfileImageView.Layer.AnchorPoint = CGPoint.Empty;
            ProfileImageView.Bounds = EditPictureButton.Bounds;
            ProfileImageView.Layer.Position = CGPoint.Empty;
            EditPictureButton.AddSubview( ProfileImageView );

            EditPictureButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Primary, PrivateSpringboardConfig.ProfileSymbolFontSize );
            EditPictureButton.SetTitleColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ), UIControlState.Normal );
            EditPictureButton.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ).CGColor;
            EditPictureButton.Layer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            EditPictureButton.Layer.BorderWidth = 4;

            WelcomeField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Light, ControlStylingConfig.Large_FontSize );
            WelcomeField.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );

            UserNameField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize );
            UserNameField.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );

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

            AddChildViewController( NavViewController );
            View.AddSubview( NavViewController.View );

            SetNeedsStatusBarAppearanceUpdate( );

            EditPictureButton.TouchUpInside += (object sender, EventArgs e) => 
                {
                    // don't allow launching a model view controller unless the springboard is open.
                    if ( NavViewController.IsSpringboardOpen( ) )
                    {
                        if( RockMobileUser.Instance.LoggedIn == true )
                        {
                            // they're logged in, so let them set their profile pic
                            ManageProfilePic( );
                        }
                        else
                        {
                            //otherwise this button can double as a login button.
                            PresentModalViewController( LoginViewController );
                        }
                    }
                };
            
            ViewProfileButton.TouchUpInside += (object sender, EventArgs e) => 
                {
                    // don't allow launching a model view controller unless the springboard is open.
                    if ( NavViewController.IsSpringboardOpen( ) )
                    {
                        if( RockMobileUser.Instance.LoggedIn == true )
                        {
                            // Because we aren't syncing RIGHT HERE, Rock data could technically be overwritten.
                            // If WHILE they're running the app, their data is updated in Rock, those changes will
                            // be lost when they submit their profile changes.
                            // But, the odds that Rock data will update WHILE THE APP IS RUNNING, and they then decide to
                            // update their profile without having even backgrounded the app, are extremely low.
                            PresentModalViewController( ProfileViewController );
                        }
                        else
                        {
                            PresentModalViewController( LoginViewController );
                        }
                    }
                };

            // load our objects from disk
            Rock.Mobile.Util.Debug.WriteLine( "Loading objects from device." );
            RockNetworkManager.Instance.LoadObjectsFromDevice( );
            Rock.Mobile.Util.Debug.WriteLine( "Loading objects done." );

            // set the viewing campus now that their profile has loaded (if they have already done the OOBE)
            CampusSelectionText.Text = string.Format( SpringboardStrings.Viewing_Campus, RockGeneralData.Instance.Data.CampusIdToName( RockMobileUser.Instance.ViewingCampus ) ).ToUpper( );
            CampusSelectionText.SizeToFit( );

            // seed the last sync time with now, so that when OnActivated gets called we don't do it again.
            LastRockSync = DateTime.Now;

            // setup the Notification Banner for Taking Notes
            Billboard = new NotificationBillboard( View.Bounds.Width, View.Bounds.Height );
            Billboard.SetLabel( SpringboardStrings.TakeNotesNotificationIcon, 
                                PrivateControlStylingConfig.Icon_Font_Primary,
                                ControlStylingConfig.Small_FontSize,
                                SpringboardStrings.TakeNotesNotificationLabel, 
                                ControlStylingConfig.Font_Light,
                                ControlStylingConfig.Small_FontSize,
                                ControlStylingConfig.TextField_ActiveTextColor, 
                                ControlStylingConfig.Springboard_Element_SelectedColor, 
                delegate 
                {
                    // find the Notes task, activate it, and tell it to jump to the read page.
                    foreach( SpringboardElement element in Elements )
                    {
                        if ( element.Task as NotesTask != null )
                        {
                            ActivateElement( element, true );
                            PerformTaskAction( PrivateGeneralConfig.TaskAction_NotesRead );
                        }
                    }
                } 
            );

            Billboard.Layer.Position = new CGPoint( Billboard.Layer.Position.X, NavViewController.NavigationBar.Frame.Height );


            // only do the OOBE if the user hasn't seen it yet
            if ( RockMobileUser.Instance.OOBEComplete == false )
            //if( RanOOBE == false )
            {
                // sanity check for testers that didn't listen to me and delete / reinstall.
                // This will force them to be logged out so they experience the OOBE properly.
                RockMobileUser.Instance.LogoutAndUnbind( );

                //RanOOBE = true;
                IsOOBERunning = true;
                AddChildViewController( OOBEViewController );
                View.AddSubview( OOBEViewController.View );
            }
            else
            {
                // kick off the splash screen animation
                AddChildViewController( SplashViewController );
                View.AddSubview( SplashViewController.View );
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.Layer.Contents = Parent.View.Layer.Contents;
            View.BackgroundColor = Parent.View.BackgroundColor;

            // setup a scroll view
            ScrollView = new UIScrollViewWrapper();
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent = this;
            ScrollView.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.SidebarBGColor );
            View.AddSubview( ScrollView );

            FamilyName = new Dynamic_UITextField( this, ScrollView, Strings.General_FamilyName, false, true );
            FamilyName.GetTextField( ).AutocorrectionType = UITextAutocorrectionType.No;
            FamilyName.GetTextField( ).AutocapitalizationType = UITextAutocapitalizationType.Words;
            FamilyName.AddToView( ScrollView );

            //TODO: Handle international
            AddressHeader = new UILabel();
            AddressHeader.Layer.AnchorPoint = CGPoint.Empty;
            AddressHeader.Text = Strings.General_HomeAddress;
            AddressHeader.Font = FontManager.GetFont( Settings.General_BoldFont, Config.Instance.VisualSettings.SmallFontSize );
            Theme.StyleLabel( AddressHeader, Config.Instance.VisualSettings.LabelStyle );
            ScrollView.AddSubview( AddressHeader );

            Street = new UIInsetTextField();
            Street.InputAssistantItem.LeadingBarButtonGroups = null;
            Street.InputAssistantItem.TrailingBarButtonGroups = null;
            Street.Layer.AnchorPoint = CGPoint.Empty;
            Street.Placeholder = Strings.General_Street;
            Street.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            Theme.StyleTextField( Street, Config.Instance.VisualSettings.TextFieldStyle );
            Street.AutocorrectionType = UITextAutocorrectionType.No;
            Street.AutocapitalizationType = UITextAutocapitalizationType.Words;
            ScrollView.AddSubview( Street );

            City = new UIInsetTextField();
            City.InputAssistantItem.LeadingBarButtonGroups = null;
            City.InputAssistantItem.TrailingBarButtonGroups = null;
            City.Layer.AnchorPoint = CGPoint.Empty;
            City.Placeholder = Strings.General_City;
            City.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            Theme.StyleTextField( City, Config.Instance.VisualSettings.TextFieldStyle );
            City.AutocorrectionType = UITextAutocorrectionType.No;
            City.AutocapitalizationType = UITextAutocapitalizationType.Words;
            ScrollView.AddSubview( City );

            State = new UIInsetTextField();
            State.InputAssistantItem.LeadingBarButtonGroups = null;
            State.InputAssistantItem.TrailingBarButtonGroups = null;
            State.Layer.AnchorPoint = CGPoint.Empty;
            State.Placeholder = Strings.General_State;
            State.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            Theme.StyleTextField( State, Config.Instance.VisualSettings.TextFieldStyle );
            State.AutocorrectionType = UITextAutocorrectionType.No;
            State.AutocapitalizationType = UITextAutocapitalizationType.Words;
            ScrollView.AddSubview( State );

            PostalCode = new UIInsetTextField();
            PostalCode.InputAssistantItem.LeadingBarButtonGroups = null;
            PostalCode.InputAssistantItem.TrailingBarButtonGroups = null;
            PostalCode.Layer.AnchorPoint = CGPoint.Empty;
            PostalCode.Placeholder = Strings.General_Zip;
            PostalCode.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            Theme.StyleTextField( PostalCode, Config.Instance.VisualSettings.TextFieldStyle );
            ScrollView.AddSubview( PostalCode );
            //

            // build an array with all the campuses
            string[] campuses = new string[ Config.Instance.Campuses.Count ];
            for ( int i = 0; i < Config.Instance.Campuses.Count; i++ )
            {
                campuses[ i ] = Config.Instance.Campuses[ i ].Name;
            }

            FamilyCampus = new Dynamic_UIDropDown( this, ScrollView, Strings.FamilyInfo_Select_Campus_Header, Strings.FamilyInfo_Select_Campus_Message, campuses, false );
            FamilyCampus.AddToView( ScrollView );

            //default the campus to whatever's selected by the app settings.
            FamilyCampus.SetCurrentValue( Config.Instance.Campuses[ Config.Instance.SelectedCampusIndex ].Name );

            // build the dynamic UI controls
            for( int i = 0; i < Config.Instance.FamilyAttributeDefines.Count; i++ )
            {
                // get the required flag and the attribs that define what type of UI control this is.
                bool isRequired = bool.Parse( Config.Instance.FamilyAttributes[ i ][ "required" ] );
                Rock.Client.Attribute uiControlAttrib = Config.Instance.FamilyAttributeDefines[ i ];

                // build it and add it to our UI
                IDynamic_UIView uiView = Dynamic_UIFactory.CreateDynamic_UIControl( this, ScrollView, uiControlAttrib, isRequired, Config.Instance.FamilyAttributeDefines[ i ].Key );
                if ( uiView != null )
                {
                    Dynamic_FamilyControls.Add( uiView );
                    Dynamic_FamilyControls[ Dynamic_FamilyControls.Count - 1 ].AddToView( ScrollView );
                }
            }

            KeyboardAdjustManager = new KeyboardAdjustManager( View );

            // save button goes last, BELOW the dynamic content
            SaveButton = UIButton.FromType( UIButtonType.System );
            SaveButton.Layer.AnchorPoint = CGPoint.Empty;
            SaveButton.SetTitle( Strings.General_Save, UIControlState.Normal );
            SaveButton.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
            Theme.StyleButton( SaveButton, Config.Instance.VisualSettings.PrimaryButtonStyle );
            SaveButton.SetTitleColor( UIColor.LightGray, UIControlState.Disabled );
            SaveButton.SizeToFit( );
            SaveButton.Bounds = new CGRect( 0, 0, SaveButton.Bounds.Width * 2.00f, SaveButton.Bounds.Height );
            ScrollView.AddSubview( SaveButton );

            SaveButton.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    TrySubmitFamilyInfo( );
                };

            TableView = new UITableView( );
            TableView.Layer.AnchorPoint = CGPoint.Empty;
            TableView.BackgroundColor = UIColor.Clear;
            TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
            View.AddSubview( TableView );

            // if there's no family ID this is a new family, so create a table that lets them begin adding people
            if ( Family.Id == 0 )
            {
                TableView.Source = new TableSource( this );
            }

            // create the new person and add person view controllers
            PersonInfoViewController = new PersonInfoViewController( Parent );
            AddChildViewController( PersonInfoViewController );
            View.AddSubview( PersonInfoViewController.View );

            AddPersonViewController = new AddPersonViewController( Parent );
            AddChildViewController( AddPersonViewController );
            View.AddSubview( AddPersonViewController.View );

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

            View.AddSubview( SaveResult );
        }