Example #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Theme.GetColor("#ee7624ff");


            Logo = new UIImageView();
            Logo.Layer.AnchorPoint = CGPoint.Empty;
            Logo.Image             = UIImage.FromBundle("rock-logo.png");
            Logo.SizeToFit( );
            View.AddSubview(Logo);

            RockUrlTitle = new UILabel();
            RockUrlTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlTitle.TextColor         = UIColor.White;
            RockUrlTitle.Text = "Rock Server Address";
            RockUrlTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont("OpenSans-Light", 20);
            RockUrlTitle.SizeToFit( );
            View.AddSubview(RockUrlTitle);

            RockUrlField = new UIInsetTextField( );
            RockUrlField.InputAssistantItem.LeadingBarButtonGroups  = null;
            RockUrlField.InputAssistantItem.TrailingBarButtonGroups = null;
            RockUrlField.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlField.TextColor         = UIColor.White;
            RockUrlField.Text = string.IsNullOrEmpty(Config.Instance.RockURL) == true ? "http://" : Config.Instance.RockURL;
            RockUrlField.Layer.BorderColor      = UIColor.White.CGColor;
            RockUrlField.Layer.BorderWidth      = 1;
            RockUrlField.Layer.CornerRadius     = 4;
            RockUrlField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockUrlField.AutocorrectionType     = UITextAutocorrectionType.No;
            RockUrlField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont("OpenSans-Regular", 32);
            View.AddSubview(RockUrlField);


            RockAuthKeyTitle = new UILabel();
            RockAuthKeyTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyTitle.TextColor         = UIColor.White;
            RockAuthKeyTitle.Text = "Rock Authorization Key";
            RockAuthKeyTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont("OpenSans-Light", 20);
            RockAuthKeyTitle.SizeToFit( );
            View.AddSubview(RockAuthKeyTitle);

            RockAuthKeyField = new UIInsetTextField( );
            RockAuthKeyField.InputAssistantItem.LeadingBarButtonGroups  = null;
            RockAuthKeyField.InputAssistantItem.TrailingBarButtonGroups = null;
            RockAuthKeyField.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyField.TextColor         = UIColor.White;
            RockAuthKeyField.Text = Config.Instance.RockAuthorizationKey;
            RockAuthKeyField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockAuthKeyField.AutocorrectionType     = UITextAutocorrectionType.No;
            RockAuthKeyField.Layer.BorderColor      = UIColor.White.CGColor;
            RockAuthKeyField.Layer.BorderWidth      = 1;
            RockAuthKeyField.Layer.CornerRadius     = 4;
            RockAuthKeyField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont("OpenSans-Regular", 32);
            View.AddSubview(RockAuthKeyField);


            RockUrlDesc = new UILabel();
            RockUrlDesc.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlDesc.TextColor         = UIColor.White;
            RockUrlDesc.Text = "You can update these values at any time from the settings panel.";
            RockUrlDesc.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont("OpenSans-Light", 18);
            RockUrlDesc.SizeToFit( );
            View.AddSubview(RockUrlDesc);



            Submit = UIButton.FromType(UIButtonType.System);
            Submit.Layer.AnchorPoint = CGPoint.Empty;
            Submit.SetTitle("Submit", UIControlState.Normal);
            Submit.SetTitleColor(Theme.GetColor("#ee7624ff"), UIControlState.Normal);
            Submit.SizeToFit( );
            Submit.Layer.CornerRadius = 4;
            Submit.BackgroundColor    = UIColor.White;
            Submit.Font = Submit.Font.WithSize(24);
            View.AddSubview(Submit);

            ResultLabel = new UILabel();
            ResultLabel.Layer.AnchorPoint = CGPoint.Empty;
            ResultLabel.TextColor         = UIColor.White;
            ResultLabel.TextAlignment     = UITextAlignment.Center;
            ResultLabel.Font = ResultLabel.Font.WithSize(24);
            View.AddSubview(ResultLabel);

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


            // setup the Submit action
            Submit.TouchUpInside += (object sender, EventArgs e) =>
            {
                PerformSearch( );
            };

            RockUrlField.ShouldReturn += ( UITextField textField) =>
            {
                PerformSearch( );
                return(true);
            };
            //
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Theme.GetColor( "#ee7624ff" );

            Logo = new UIImageView();
            Logo.Layer.AnchorPoint = CGPoint.Empty;
            Logo.Image = UIImage.FromBundle( "rock-logo.png" );
            Logo.SizeToFit( );
            View.AddSubview( Logo );

            RockUrlTitle = new UILabel();
            RockUrlTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlTitle.TextColor = UIColor.White;
            RockUrlTitle.Text = "Rock Server Address";
            RockUrlTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( "OpenSans-Light", 20 );
            RockUrlTitle.SizeToFit( );
            View.AddSubview( RockUrlTitle );

            RockUrlField = new UIInsetTextField( );
            RockUrlField.InputAssistantItem.LeadingBarButtonGroups = null;
            RockUrlField.InputAssistantItem.TrailingBarButtonGroups = null;
            RockUrlField.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlField.TextColor = UIColor.White;
            RockUrlField.Text = string.IsNullOrEmpty( Config.Instance.RockURL ) == true ? "http://" : Config.Instance.RockURL;
            RockUrlField.Layer.BorderColor = UIColor.White.CGColor;
            RockUrlField.Layer.BorderWidth = 1;
            RockUrlField.Layer.CornerRadius = 4;
            RockUrlField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockUrlField.AutocorrectionType = UITextAutocorrectionType.No;
            RockUrlField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( "OpenSans-Regular", 32 );
            View.AddSubview( RockUrlField );

            RockAuthKeyTitle = new UILabel();
            RockAuthKeyTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyTitle.TextColor = UIColor.White;
            RockAuthKeyTitle.Text = "Rock Authorization Key";
            RockAuthKeyTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( "OpenSans-Light", 20 );
            RockAuthKeyTitle.SizeToFit( );
            View.AddSubview( RockAuthKeyTitle );

            RockAuthKeyField = new UIInsetTextField( );
            RockAuthKeyField.InputAssistantItem.LeadingBarButtonGroups = null;
            RockAuthKeyField.InputAssistantItem.TrailingBarButtonGroups = null;
            RockAuthKeyField.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyField.TextColor = UIColor.White;
            RockAuthKeyField.Text = Config.Instance.RockAuthorizationKey;
            RockAuthKeyField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockAuthKeyField.AutocorrectionType = UITextAutocorrectionType.No;
            RockAuthKeyField.Layer.BorderColor = UIColor.White.CGColor;
            RockAuthKeyField.Layer.BorderWidth = 1;
            RockAuthKeyField.Layer.CornerRadius = 4;
            RockAuthKeyField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( "OpenSans-Regular", 32 );
            View.AddSubview( RockAuthKeyField );

            RockUrlDesc = new UILabel();
            RockUrlDesc.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlDesc.TextColor = UIColor.White;
            RockUrlDesc.Text = "You can update these values at any time from the settings panel.";
            RockUrlDesc.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( "OpenSans-Light", 18 );
            RockUrlDesc.SizeToFit( );
            View.AddSubview( RockUrlDesc );

            Submit = UIButton.FromType( UIButtonType.System );
            Submit.Layer.AnchorPoint = CGPoint.Empty;
            Submit.SetTitle( "Submit", UIControlState.Normal );
            Submit.SetTitleColor( Theme.GetColor( "#ee7624ff" ), UIControlState.Normal );
            Submit.SizeToFit( );
            Submit.Layer.CornerRadius = 4;
            Submit.BackgroundColor = UIColor.White;
            Submit.Font = Submit.Font.WithSize( 24 );
            View.AddSubview( Submit );

            ResultLabel = new UILabel();
            ResultLabel.Layer.AnchorPoint = CGPoint.Empty;
            ResultLabel.TextColor = UIColor.White;
            ResultLabel.TextAlignment = UITextAlignment.Center;
            ResultLabel.Font = ResultLabel.Font.WithSize( 24 );
            View.AddSubview( ResultLabel );

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

            // setup the Submit action
            Submit.TouchUpInside += (object sender, EventArgs e ) =>
            {
                PerformSearch( );
            };

            RockUrlField.ShouldReturn += ( UITextField textField) =>
                {
                    PerformSearch( );
                    return true;
                };
            //
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.BackgroundColor );

            // Rock URL Title
            RockUrlTitle = new UILabel();
            RockUrlTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlTitle.Text = "Rock Server Address";
            Theme.StyleLabel( RockUrlTitle, Config.Instance.VisualSettings.LabelStyle );
            RockUrlTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize );
            RockUrlTitle.SizeToFit( );
            View.AddSubview( RockUrlTitle );

            // Rock URL Address
            RockUrlField = new UIInsetTextField( );
            RockUrlField.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlField.Text = Config.Instance.RockURL;
            RockUrlField.AutocorrectionType = UITextAutocorrectionType.No;
            RockUrlField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockUrlField.InputAssistantItem.LeadingBarButtonGroups = null;
            RockUrlField.InputAssistantItem.TrailingBarButtonGroups = null;
            Theme.StyleTextField( RockUrlField, Config.Instance.VisualSettings.TextFieldStyle );
            RockUrlField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            View.AddSubview( RockUrlField );

            // Rock AuthKey Title
            RockAuthKeyTitle = new UILabel();
            RockAuthKeyTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyTitle.Text = "Rock Authorization Key";
            Theme.StyleLabel( RockAuthKeyTitle, Config.Instance.VisualSettings.LabelStyle );
            RockAuthKeyTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize );
            RockAuthKeyTitle.SizeToFit( );
            View.AddSubview( RockAuthKeyTitle );

            // Rock AuthKey Field
            RockAuthKeyField = new UIInsetTextField( );
            RockAuthKeyField.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyField.TextColor = UIColor.White;
            RockAuthKeyField.Text = Config.Instance.RockAuthorizationKey;
            RockAuthKeyField.AutocorrectionType = UITextAutocorrectionType.No;
            RockAuthKeyField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockAuthKeyField.InputAssistantItem.LeadingBarButtonGroups = null;
            RockAuthKeyField.InputAssistantItem.TrailingBarButtonGroups = null;
            Theme.StyleTextField( RockAuthKeyField, Config.Instance.VisualSettings.TextFieldStyle );
            RockAuthKeyField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            View.AddSubview( RockAuthKeyField );

            // setup the campus switch label
            CampusSwitchLabel = new UILabel( );
            CampusSwitchLabel.Layer.AnchorPoint = CGPoint.Empty;
            CampusSwitchLabel.Text = "Autodetect Campus";
            Theme.StyleLabel( CampusSwitchLabel, Config.Instance.VisualSettings.LabelStyle );
            CampusSwitchLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize );
            CampusSwitchLabel.SizeToFit( );
            View.AddSubview( CampusSwitchLabel );

            // default the campus switch to whatever the autodetect preference is
            CampusSwitch = new UISwitch( );
            CampusSwitch.Layer.AnchorPoint = CGPoint.Empty;
            CampusSwitch.OnTintColor = Theme.GetColor( Config.Instance.VisualSettings.ToggleStyle.ActiveColor );
            CampusSwitch.On = Config.Instance.AutoDetectCampus;
            View.AddSubview( CampusSwitch );

            // Campus Label and Table
            CampusesLabel = new UILabel();
            CampusesLabel.Layer.AnchorPoint = CGPoint.Empty;
            CampusesLabel.Text = "Campus";
            Theme.StyleLabel( CampusesLabel, Config.Instance.VisualSettings.LabelStyle );
            CampusesLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize );
            CampusesLabel.SizeToFit( );
            View.AddSubview( CampusesLabel );

            CampusTableView = new UITableView();
            CampusTableView.Layer.AnchorPoint = CGPoint.Empty;
            CampusTableView.Source = new CampusTableData() { Parent = this };
            CampusTableView.Layer.CornerRadius = 4;
            View.AddSubview( CampusTableView );

            // Template Label and Table
            TemplateLabel = new UILabel();
            TemplateLabel.Layer.AnchorPoint = CGPoint.Empty;
            TemplateLabel.Text = "Theme";
            Theme.StyleLabel( TemplateLabel, Config.Instance.VisualSettings.LabelStyle );
            TemplateLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize );
            TemplateLabel.SizeToFit( );
            View.AddSubview( TemplateLabel );

            TemplateTableView = new UITableView();
            TemplateTableView.Layer.AnchorPoint = CGPoint.Empty;
            TemplateTableView.Source = new TemplateTableData() { Parent = this };
            TemplateTableView.Layer.CornerRadius = 4;
            View.AddSubview( TemplateTableView );

            Sync = UIButton.FromType( UIButtonType.System );
            Sync.Layer.AnchorPoint = CGPoint.Empty;
            Sync.SetTitle( "Sync", UIControlState.Normal );
            Sync.SetTitleColor( UIColor.White, UIControlState.Normal );
            Theme.StyleButton( Sync, Config.Instance.VisualSettings.DefaultButtonStyle );
            Sync.SizeToFit( );
            View.AddSubview( Sync );

            SyncResultLabel = new UILabel();
            SyncResultLabel.Layer.AnchorPoint = CGPoint.Empty;
            SyncResultLabel.TextColor = UIColor.White;
            SyncResultLabel.TextAlignment = UITextAlignment.Center;
            SyncResultLabel.Font = SyncResultLabel.Font.WithSize( 36 );
            Theme.StyleLabel( SyncResultLabel, Config.Instance.VisualSettings.LabelStyle );
            View.AddSubview( SyncResultLabel );

            Cancel = UIButton.FromType( UIButtonType.System );
            Cancel.Layer.AnchorPoint = CGPoint.Empty;
            Cancel.SetTitle( "Cancel", UIControlState.Normal );
            Theme.StyleButton( Cancel, Config.Instance.VisualSettings.DefaultButtonStyle );
            Cancel.SizeToFit( );
            View.AddSubview( Cancel );

            Save = UIButton.FromType( UIButtonType.System );
            Save.Layer.AnchorPoint = CGPoint.Empty;
            Save.SetTitle( "Save", UIControlState.Normal );
            Theme.StyleButton( Save, Config.Instance.VisualSettings.PrimaryButtonStyle );
            Save.SetTitleColor( UIColor.LightGray, UIControlState.Disabled );
            Save.SizeToFit( );
            View.AddSubview( Save );

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

            // setup the Sync action
            Sync.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    DownloadRockValues( );
                };

            RockUrlField.EditingDidBegin += (object sender, EventArgs e) =>
                {
                    // if they start editing the text field, immediatley disable the submit button.
                    // it will be enabled again when they tap Sync and we can verify they connected to Rock.
                    ToggleSaveButton( false );

                    // clear out lists which will effectively force the user to sync
                    ClearLists( );
                    CampusTableView.ReloadData( );
                    TemplateTableView.ReloadData( );
                };

            RockAuthKeyField.EditingDidBegin += (object sender, EventArgs e ) =>
                {
                    ToggleSaveButton( false );

                    // clear out lists which will effectively force the user to sync
                    ClearLists( );
                    CampusTableView.ReloadData( );
                    TemplateTableView.ReloadData( );
                };

            RockUrlField.ShouldReturn += ( UITextField textField) =>
                {
                    DownloadRockValues( );
                    return true;
                };

            Save.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    ToggleSaveButton( false );

                    BlockerView.BringToFront( );
                    BlockerView.Show( delegate
                        {
                            // officially save and switch over the server
                            Config.Instance.CommitRockSync( );

                            // take the new campus
                            if( CampusSwitch.On )
                            {
                                Config.Instance.AutoDetectCampus = true;
                            }
                            else
                            {
                                Config.Instance.AutoDetectCampus = false;
                            }

                            // go ahead and set the campus index to what they chose.
                            // If auto-detect is on, it'll override it next time they run
                            int campusIndex = CampusTableView.IndexPathForSelectedRow.Row;
                            Config.Instance.SelectedCampusIndex = campusIndex;

                            int templateIndex = TemplateTableView.IndexPathForSelectedRow.Row;
                            Config.Instance.SetConfigurationDefinedValue( ConfigurationTemplates[ templateIndex ],
                                delegate(bool result)
                                {
                                    BlockerView.Hide( delegate
                                        {
                                            if( result == true )
                                            {
                                                // it worked, so now apply the campus and URL
                                                Rock.Mobile.Util.Debug.DisplayError( "Settings Updated", "Please restart the app (double tap and flick to quit) to see changes." );

                                                Parent.SettingsComplete( );
                                            }
                                            else
                                            {
                                                // setting the theme failed, but the server switch worked.
                                                ToggleSaveButton( true );
                                                DisplaySyncResult( Strings.General_Rock_ThemeFailed );
                                            }
                                        });
                                });
                        });
                };

            Cancel.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    // restore the rock URL
                    RockApi.SetRockURL( Config.Instance.RockURL );

                    Parent.SettingsComplete( );
                };
            //
        }
Example #4
0
            void Create( UIViewController parentViewController, UIView parentView, string labelText, bool numbersOnly, bool requiredField, string attribKey )
            {
                AttribKey = attribKey;

                ParentViewController = parentViewController;
                ParentView = parentView;

                Required = requiredField;

                NumbersOnly = numbersOnly;

                Layer.AnchorPoint = CGPoint.Empty;

                Header = new UILabel( );
                Header.Layer.AnchorPoint = CGPoint.Empty;
                Header.Text = labelText;
                Theme.StyleLabel( Header, Config.Instance.VisualSettings.LabelStyle );
                Header.Font = FontManager.GetFont( Settings.General_BoldFont, Config.Instance.VisualSettings.SmallFontSize );
                Header.SizeToFit( );
                AddSubview( Header );

                RequiredAnchor = new RequiredAnchor( );
                RequiredAnchor.AttachToTarget( Header );
                RequiredAnchor.SyncToTarget( );
                RequiredAnchor.Hidden = !requiredField;

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

                TextField.AutocorrectionType = UITextAutocorrectionType.No;
            }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set our theme
            CoreViewController.ApplyTheme( this );

            // and the busy indicator
            BusyIndicator = PlatformBusyIndicator.Create( );
            BusyIndicator.Color = 0x999999FF;
            BusyIndicator.BackgroundColor = 0;
            BusyIndicator.Opacity = 0;
            BusyIndicator.AddAsSubview( View );

            // setup the header label
            HeaderLabel = new UILabel( );
            View.AddSubview( HeaderLabel );
            Theme.StyleLabel( HeaderLabel, Config.Instance.VisualSettings.LabelStyle );
            HeaderLabel.Font = FontManager.GetFont( Settings.General_RegularFont, 32 );
            HeaderLabel.Text = "Family Manager";
            HeaderLabel.SizeToFit( );
            HeaderLabel.TextAlignment = UITextAlignment.Center;

            UserNameField = new UIInsetTextField();
            View.AddSubview( UserNameField );

            Theme.StyleTextField( UserNameField, Config.Instance.VisualSettings.TextFieldStyle );
            UserNameField.InputAssistantItem.LeadingBarButtonGroups = null;
            UserNameField.InputAssistantItem.TrailingBarButtonGroups = null;
            UserNameField.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            UserNameField.Layer.AnchorPoint = CGPoint.Empty;
            UserNameField.AutocorrectionType = UITextAutocorrectionType.No;
            UserNameField.AutocapitalizationType = UITextAutocapitalizationType.None;
            UserNameField.Placeholder = "Username";
            UserNameField.ShouldReturn += (textField) =>
                {
                    textField.ResignFirstResponder();

                    TryRockBind();
                    return true;
                };

            PasswordField = new UIInsetTextField();
            View.AddSubview( PasswordField );

            Theme.StyleTextField( PasswordField, Config.Instance.VisualSettings.TextFieldStyle );
            PasswordField.InputAssistantItem.LeadingBarButtonGroups = null;
            PasswordField.InputAssistantItem.TrailingBarButtonGroups = null;
            PasswordField.Layer.AnchorPoint = CGPoint.Empty;
            PasswordField.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
            PasswordField.AutocorrectionType = UITextAutocorrectionType.No;
            PasswordField.AutocapitalizationType = UITextAutocapitalizationType.None;
            PasswordField.Placeholder = "Password";
            PasswordField.SecureTextEntry = true;

            PasswordField.ShouldReturn += (textField) =>
                {
                    textField.ResignFirstResponder();

                    TryRockBind();
                    return true;
                };

            // obviously attempt a login if login is pressed
            LoginButton = UIButton.FromType( UIButtonType.System );
            View.AddSubview( LoginButton );

            Theme.StyleButton( LoginButton, Config.Instance.VisualSettings.PrimaryButtonStyle );
            LoginButton.SetTitle( "Login", UIControlState.Normal );
            LoginButton.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
            LoginButton.SizeToFit( );
            LoginButton.Layer.AnchorPoint = CGPoint.Empty;
            LoginButton.TouchUpInside += (object sender, EventArgs e) =>
                {
                    TryRockBind();
                };

            // setup the result
            LoginResult = new UILabel( );
            View.AddSubview( LoginResult );
            Theme.StyleLabel( LoginResult, Config.Instance.VisualSettings.LabelStyle );
            LoginResult.TextAlignment = UITextAlignment.Center;

            // version
            Version = new UILabel();
            Version.Layer.AnchorPoint = CGPoint.Empty;
            Version.TextColor = UIColor.White;
            Version.TextAlignment = UITextAlignment.Center;
            Version.Text = Strings.General_Version;
            Theme.StyleLabel( Version, Config.Instance.VisualSettings.LabelStyle );
            Version.Font = Version.Font.WithSize( 14 );
            View.AddSubview( Version );
        }
        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 );
        }
Example #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = Theme.GetColor(Config.Instance.VisualSettings.BackgroundColor);

            // Rock URL Title
            RockUrlTitle = new UILabel();
            RockUrlTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlTitle.Text = "Rock Server Address";
            Theme.StyleLabel(RockUrlTitle, Config.Instance.VisualSettings.LabelStyle);
            RockUrlTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            RockUrlTitle.SizeToFit( );
            View.AddSubview(RockUrlTitle);

            // Rock URL Address
            RockUrlField = new UIInsetTextField( );
            RockUrlField.Layer.AnchorPoint = CGPoint.Empty;
            RockUrlField.Text = Config.Instance.RockURL;
            RockUrlField.AutocorrectionType     = UITextAutocorrectionType.No;
            RockUrlField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockUrlField.InputAssistantItem.LeadingBarButtonGroups  = null;
            RockUrlField.InputAssistantItem.TrailingBarButtonGroups = null;
            Theme.StyleTextField(RockUrlField, Config.Instance.VisualSettings.TextFieldStyle);
            RockUrlField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize);
            View.AddSubview(RockUrlField);

            // Rock AuthKey Title
            RockAuthKeyTitle = new UILabel();
            RockAuthKeyTitle.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyTitle.Text = "Rock Authorization Key";
            Theme.StyleLabel(RockAuthKeyTitle, Config.Instance.VisualSettings.LabelStyle);
            RockAuthKeyTitle.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            RockAuthKeyTitle.SizeToFit( );
            View.AddSubview(RockAuthKeyTitle);

            // Rock AuthKey Field
            RockAuthKeyField = new UIInsetTextField( );
            RockAuthKeyField.Layer.AnchorPoint = CGPoint.Empty;
            RockAuthKeyField.TextColor         = UIColor.White;
            RockAuthKeyField.Text = Config.Instance.RockAuthorizationKey;
            RockAuthKeyField.AutocorrectionType     = UITextAutocorrectionType.No;
            RockAuthKeyField.AutocapitalizationType = UITextAutocapitalizationType.None;
            RockAuthKeyField.InputAssistantItem.LeadingBarButtonGroups  = null;
            RockAuthKeyField.InputAssistantItem.TrailingBarButtonGroups = null;
            Theme.StyleTextField(RockAuthKeyField, Config.Instance.VisualSettings.TextFieldStyle);
            RockAuthKeyField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize);
            View.AddSubview(RockAuthKeyField);

            // setup the campus switch label
            CampusSwitchLabel = new UILabel( );
            CampusSwitchLabel.Layer.AnchorPoint = CGPoint.Empty;
            CampusSwitchLabel.Text = "Autodetect Campus";
            Theme.StyleLabel(CampusSwitchLabel, Config.Instance.VisualSettings.LabelStyle);
            CampusSwitchLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            CampusSwitchLabel.SizeToFit( );
            View.AddSubview(CampusSwitchLabel);

            // default the campus switch to whatever the autodetect preference is
            CampusSwitch = new UISwitch( );
            CampusSwitch.Layer.AnchorPoint = CGPoint.Empty;
            CampusSwitch.OnTintColor       = Theme.GetColor(Config.Instance.VisualSettings.ToggleStyle.ActiveColor);
            CampusSwitch.On = Config.Instance.AutoDetectCampus;
            View.AddSubview(CampusSwitch);


            // Campus Label and Table
            CampusesLabel = new UILabel();
            CampusesLabel.Layer.AnchorPoint = CGPoint.Empty;
            CampusesLabel.Text = "Campus";
            Theme.StyleLabel(CampusesLabel, Config.Instance.VisualSettings.LabelStyle);
            CampusesLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            CampusesLabel.SizeToFit( );
            View.AddSubview(CampusesLabel);

            CampusTableView = new UITableView();
            CampusTableView.Layer.AnchorPoint = CGPoint.Empty;
            CampusTableView.Source            = new CampusTableData()
            {
                Parent = this
            };
            CampusTableView.Layer.CornerRadius = 4;
            View.AddSubview(CampusTableView);


            // Template Label and Table
            TemplateLabel = new UILabel();
            TemplateLabel.Layer.AnchorPoint = CGPoint.Empty;
            TemplateLabel.Text = "Theme";
            Theme.StyleLabel(TemplateLabel, Config.Instance.VisualSettings.LabelStyle);
            TemplateLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont(Settings.General_LightFont, Config.Instance.VisualSettings.MediumFontSize);
            TemplateLabel.SizeToFit( );
            View.AddSubview(TemplateLabel);

            TemplateTableView = new UITableView();
            TemplateTableView.Layer.AnchorPoint = CGPoint.Empty;
            TemplateTableView.Source            = new TemplateTableData()
            {
                Parent = this
            };
            TemplateTableView.Layer.CornerRadius = 4;
            View.AddSubview(TemplateTableView);


            Sync = UIButton.FromType(UIButtonType.System);
            Sync.Layer.AnchorPoint = CGPoint.Empty;
            Sync.SetTitle("Sync", UIControlState.Normal);
            Sync.SetTitleColor(UIColor.White, UIControlState.Normal);
            Theme.StyleButton(Sync, Config.Instance.VisualSettings.DefaultButtonStyle);
            Sync.SizeToFit( );
            View.AddSubview(Sync);

            SyncResultLabel = new UILabel();
            SyncResultLabel.Layer.AnchorPoint = CGPoint.Empty;
            SyncResultLabel.TextColor         = UIColor.White;
            SyncResultLabel.TextAlignment     = UITextAlignment.Center;
            SyncResultLabel.Font = SyncResultLabel.Font.WithSize(36);
            Theme.StyleLabel(SyncResultLabel, Config.Instance.VisualSettings.LabelStyle);
            View.AddSubview(SyncResultLabel);

            Cancel = UIButton.FromType(UIButtonType.System);
            Cancel.Layer.AnchorPoint = CGPoint.Empty;
            Cancel.SetTitle("Cancel", UIControlState.Normal);
            Theme.StyleButton(Cancel, Config.Instance.VisualSettings.DefaultButtonStyle);
            Cancel.SizeToFit( );
            View.AddSubview(Cancel);

            Save = UIButton.FromType(UIButtonType.System);
            Save.Layer.AnchorPoint = CGPoint.Empty;
            Save.SetTitle("Save", UIControlState.Normal);
            Theme.StyleButton(Save, Config.Instance.VisualSettings.PrimaryButtonStyle);
            Save.SetTitleColor(UIColor.LightGray, UIControlState.Disabled);
            Save.SizeToFit( );
            View.AddSubview(Save);

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

            // setup the Sync action
            Sync.TouchUpInside += (object sender, EventArgs e) =>
            {
                DownloadRockValues( );
            };

            RockUrlField.EditingDidBegin += (object sender, EventArgs e) =>
            {
                // if they start editing the text field, immediatley disable the submit button.
                // it will be enabled again when they tap Sync and we can verify they connected to Rock.
                ToggleSaveButton(false);

                // clear out lists which will effectively force the user to sync
                ClearLists( );
                CampusTableView.ReloadData( );
                TemplateTableView.ReloadData( );
            };

            RockAuthKeyField.EditingDidBegin += (object sender, EventArgs e) =>
            {
                ToggleSaveButton(false);

                // clear out lists which will effectively force the user to sync
                ClearLists( );
                CampusTableView.ReloadData( );
                TemplateTableView.ReloadData( );
            };

            RockUrlField.ShouldReturn += ( UITextField textField) =>
            {
                DownloadRockValues( );
                return(true);
            };

            Save.TouchUpInside += (object sender, EventArgs e) =>
            {
                ToggleSaveButton(false);

                BlockerView.BringToFront( );
                BlockerView.Show(delegate
                {
                    // officially save and switch over the server
                    Config.Instance.CommitRockSync( );

                    // take the new campus
                    if (CampusSwitch.On)
                    {
                        Config.Instance.AutoDetectCampus = true;
                    }
                    else
                    {
                        Config.Instance.AutoDetectCampus = false;
                    }

                    // go ahead and set the campus index to what they chose.
                    // If auto-detect is on, it'll override it next time they run
                    int campusIndex = CampusTableView.IndexPathForSelectedRow.Row;
                    Config.Instance.SelectedCampusIndex = campusIndex;

                    int templateIndex = TemplateTableView.IndexPathForSelectedRow.Row;
                    Config.Instance.SetConfigurationDefinedValue(ConfigurationTemplates[templateIndex],
                                                                 delegate(bool result)
                    {
                        BlockerView.Hide(delegate
                        {
                            if (result == true)
                            {
                                // it worked, so now apply the campus and URL
                                Rock.Mobile.Util.Debug.DisplayError("Settings Updated", "Please restart the app (double tap and flick to quit) to see changes.");

                                Parent.SettingsComplete( );
                            }
                            else
                            {
                                // setting the theme failed, but the server switch worked.
                                ToggleSaveButton(true);
                                DisplaySyncResult(Strings.General_Rock_ThemeFailed);
                            }
                        });
                    });
                });
            };

            Cancel.TouchUpInside += (object sender, EventArgs e) =>
            {
                // restore the rock URL
                RockApi.SetRockURL(Config.Instance.RockURL);

                Parent.SettingsComplete( );
            };
            //
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set our theme
            CoreViewController.ApplyTheme(this);

            // and the busy indicator
            BusyIndicator                 = PlatformBusyIndicator.Create( );
            BusyIndicator.Color           = 0x999999FF;
            BusyIndicator.BackgroundColor = 0;
            BusyIndicator.Opacity         = 0;
            BusyIndicator.AddAsSubview(View);

            // setup the header label
            HeaderLabel = new UILabel( );
            View.AddSubview(HeaderLabel);
            Theme.StyleLabel(HeaderLabel, Config.Instance.VisualSettings.LabelStyle);
            HeaderLabel.Font = FontManager.GetFont(Settings.General_RegularFont, 32);
            HeaderLabel.Text = "Family Manager";
            HeaderLabel.SizeToFit( );
            HeaderLabel.TextAlignment = UITextAlignment.Center;


            UserNameField = new UIInsetTextField();
            View.AddSubview(UserNameField);

            Theme.StyleTextField(UserNameField, Config.Instance.VisualSettings.TextFieldStyle);
            UserNameField.InputAssistantItem.LeadingBarButtonGroups  = null;
            UserNameField.InputAssistantItem.TrailingBarButtonGroups = null;
            UserNameField.Font = FontManager.GetFont(Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize);
            UserNameField.Layer.AnchorPoint      = CGPoint.Empty;
            UserNameField.AutocorrectionType     = UITextAutocorrectionType.No;
            UserNameField.AutocapitalizationType = UITextAutocapitalizationType.None;
            UserNameField.Placeholder            = "Username";
            UserNameField.ShouldReturn          += (textField) =>
            {
                textField.ResignFirstResponder();

                TryRockBind();
                return(true);
            };

            PasswordField = new UIInsetTextField();
            View.AddSubview(PasswordField);

            Theme.StyleTextField(PasswordField, Config.Instance.VisualSettings.TextFieldStyle);
            PasswordField.InputAssistantItem.LeadingBarButtonGroups  = null;
            PasswordField.InputAssistantItem.TrailingBarButtonGroups = null;
            PasswordField.Layer.AnchorPoint = CGPoint.Empty;
            PasswordField.Font = FontManager.GetFont(Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize);
            PasswordField.AutocorrectionType     = UITextAutocorrectionType.No;
            PasswordField.AutocapitalizationType = UITextAutocapitalizationType.None;
            PasswordField.Placeholder            = "Password";
            PasswordField.SecureTextEntry        = true;

            PasswordField.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();

                TryRockBind();
                return(true);
            };

            // obviously attempt a login if login is pressed
            LoginButton = UIButton.FromType(UIButtonType.System);
            View.AddSubview(LoginButton);

            Theme.StyleButton(LoginButton, Config.Instance.VisualSettings.PrimaryButtonStyle);
            LoginButton.SetTitle("Login", UIControlState.Normal);
            LoginButton.Font = FontManager.GetFont(Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize);
            LoginButton.SizeToFit( );
            LoginButton.Layer.AnchorPoint = CGPoint.Empty;
            LoginButton.TouchUpInside    += (object sender, EventArgs e) =>
            {
                TryRockBind();
            };

            // setup the result
            LoginResult = new UILabel( );
            View.AddSubview(LoginResult);
            Theme.StyleLabel(LoginResult, Config.Instance.VisualSettings.LabelStyle);
            LoginResult.TextAlignment = UITextAlignment.Center;

            // version
            Version = new UILabel();
            Version.Layer.AnchorPoint = CGPoint.Empty;
            Version.TextColor         = UIColor.White;
            Version.TextAlignment     = UITextAlignment.Center;
            Version.Text = Strings.General_Version;
            Theme.StyleLabel(Version, Config.Instance.VisualSettings.LabelStyle);
            Version.Font = Version.Font.WithSize(14);
            View.AddSubview(Version);
        }