Beispiel #1
0
            /// <summary>
            /// Construct for either json OR in code.
            /// </summary>
            public Dynamic_UIDatePicker( UIViewController parentViewController, string headerLabel, bool requiredField, string attribKey )
            {
                AttribKey = attribKey;

                if ( DatePicker == null )
                {
                    DatePicker = new UIDatePicker();
                    DatePicker.Mode = UIDatePickerMode.Date;
                    DatePicker.MinimumDate = new DateTime( 1900, 1, 1 ).DateTimeToNSDate( );
                    DatePicker.MaximumDate = DateTime.Now.DateTimeToNSDate( );
                }

                // store our parent and the required flag
                ParentViewController = parentViewController;

                Required = requiredField;

                // the date picker needs to attach itself to the aboslute root controller
                ParentView = UIApplication.SharedApplication.KeyWindow.RootViewController.View;

                // now create the container button that will act as the DatePicker's parent, and attach itself
                // to the Root Controller.
                ContainerButton = new UIButton( ParentView.Bounds );
                ContainerButton.BackgroundColor = UIColor.Clear;
                ContainerButton.TouchUpInside += (object sender, EventArgs e ) =>
                {
                        ToggleDatePickerVisible( false );
                };

                // setup the controls
                Layer.AnchorPoint = CGPoint.Empty;

                DatePicker.Layer.AnchorPoint = CGPoint.Empty;
                DatePicker.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.DatePickerStyle.BackgroundColor );
                DatePicker.SetValueForKey( Theme.GetColor( Config.Instance.VisualSettings.DatePickerStyle.TextColor ), new NSString( "textColor" ) );

                DatePicker.ValueChanged += (object sender, EventArgs e ) =>
                    {
                        if ( IsActive == true )
                        {
                            NSDate pickerDate = ((UIDatePicker) sender).Date;

                            UpdateDateLabel( pickerDate );
                        }
                    };

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

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

                // setup the value and button
                ValueLabel = new UILabel( );
                ValueLabel.Layer.AnchorPoint = CGPoint.Empty;
                ValueLabel.Text = "";
                ValueLabel.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
                ValueLabel.SizeToFit( );
                AddSubview( ValueLabel );

                ValueSymbol = new UILabel( );
                AddSubview( ValueSymbol );
                ValueSymbol.Font = FontManager.GetFont( "Bh", 36 );

                ClearButton = new UIButton();
                ClearButton.Font = FontManager.GetFont( "Bh", 36 );
                AddSubview( ClearButton );
                ClearButton.TouchUpInside += (object sender, EventArgs e ) =>
                    {
                        ValueLabel.Text = string.Empty;
                        UpdateLayout( );
                    };

                Theme.StyleDatePicker( ValueLabel, ValueSymbol, ClearButton, Config.Instance.VisualSettings.DatePickerStyle );

                ButtonOverlay = new UIButton();
                ButtonOverlay.Layer.AnchorPoint = CGPoint.Empty;
                ButtonOverlay.Layer.Opacity = .50f;
                AddSubview( ButtonOverlay );

                // finally, setup the popup when the button is tapped
                ButtonOverlay.TouchUpInside += (object sender, EventArgs e ) =>
                    {
                        ParentView.BringSubviewToFront( DatePicker );

                        bool shouldDisplay = DatePicker.Superview == null ? true : false;

                        ToggleDatePickerVisible( shouldDisplay );
                    };
            }
Beispiel #2
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;
            }
Beispiel #3
0
            void Create( UIViewController parentViewController, UIView parentView, string headerText, string falseText, string trueText, bool requiredField, string attribKey )
            {
                AttribKey = attribKey;

                // store our parent and the required flag
                ParentViewController = parentViewController;
                ParentView = parentView;

                Required = requiredField;

                // populate our values
                FalseText = falseText;

                TrueText = trueText;

                // setup the controls
                Layer.AnchorPoint = CGPoint.Empty;

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

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

                // setup the value and button
                ToggleValue = new UIToggle( falseText, trueText, null );
                ToggleValue.Layer.AnchorPoint = CGPoint.Empty;
                Theme.StyleToggle( ToggleValue, Config.Instance.VisualSettings.ToggleStyle );

                AddSubview( ToggleValue );
            }
Beispiel #4
0
            public void Create( UIViewController parentViewController, UIView parentView, string name, string description, string[] values, bool requiredField, string attribKey )
            {
                AttribKey = attribKey;

                // store our parent and the required flag
                ParentView = parentView;
                ParentViewController = parentViewController;

                Required = requiredField;

                // populate our values list
                Values = values;

                // setup the controls
                Layer.AnchorPoint = CGPoint.Empty;

                // header label
                Header = new UILabel( );
                Header.Layer.AnchorPoint = CGPoint.Empty;
                Header.Text = name; //uiControlAttrib.Name;
                Header.Font = FontManager.GetFont( Settings.General_BoldFont, Config.Instance.VisualSettings.SmallFontSize );
                Theme.StyleLabel( Header, Config.Instance.VisualSettings.LabelStyle );
                AddSubview( Header );

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

                // setup the value and button
                ValueLabel = new UILabel( );
                ValueLabel.Layer.AnchorPoint = CGPoint.Empty;
                ValueLabel.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.MediumFontSize );
                //ValueLabel.Text = Values[ 0 ];
                Theme.StyleLabel( ValueLabel, Config.Instance.VisualSettings.LabelStyle );
                AddSubview( ValueLabel );

                ValueSymbol = new UILabel( );
                AddSubview( ValueSymbol );
                ValueSymbol.Text = "";
                ValueSymbol.Font = FontManager.GetFont( "Bh", 36 );
                ValueSymbol.TextColor = Theme.GetColor( Config.Instance.VisualSettings.LabelStyle.TextColor );
                ValueSymbol.SizeToFit( );

                ButtonOverlay = new UIButton();
                ButtonOverlay.Layer.AnchorPoint = CGPoint.Empty;
                ButtonOverlay.BackgroundColor = UIColor.Clear;
                ButtonOverlay.Layer.Opacity = .50f;
                AddSubview( ButtonOverlay );

                // finally, setup the popup when the button is tapped
                ButtonOverlay.TouchUpInside += (object sender, EventArgs e ) =>
                    {
                        UIAlertController actionSheet = UIAlertController.Create( Header.Text,
                            description,
                            UIAlertControllerStyle.ActionSheet );

                        // the device is a tablet, anchor the menu
                        actionSheet.PopoverPresentationController.SourceView = ButtonOverlay;
                        actionSheet.PopoverPresentationController.SourceRect = ButtonOverlay.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 < Values.Length; i++ )
                        {
                            UIAlertAction valueAction = UIAlertAction.Create( Values[ i ], UIAlertActionStyle.Default, delegate(UIAlertAction obj)
                                {
                                    ValueLabel.Text = obj.Title;

                                    // update the value field and button overlay
                                    ValueLabel.SizeToFit( );
                                    ButtonOverlay.Bounds = ValueLabel.Bounds;
                                    UpdateLayout( );
                                } );

                            actionSheet.AddAction( valueAction );
                        }

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

                        ParentViewController.PresentViewController( actionSheet, true, null );
                    };
            }