Esempio n. 1
0
        public static InputScopeNameValue ConvertInputScope(UIKeyboardType keyboardType)
        {
            switch (keyboardType)
            {
            default:
            case UIKeyboardType.Default:
                return(InputScopeNameValue.Default);

            case UIKeyboardType.NumberPad:
                return(InputScopeNameValue.Number);

            case UIKeyboardType.DecimalPad:
            case UIKeyboardType.NumbersAndPunctuation:
                return(InputScopeNameValue.NumberFullWidth);

            case UIKeyboardType.Url:
                return(InputScopeNameValue.Url);

            case UIKeyboardType.NamePhonePad:
            case UIKeyboardType.PhonePad:
                return(InputScopeNameValue.TelephoneNumber);

            case UIKeyboardType.EmailAddress:
                return(InputScopeNameValue.EmailSmtpAddress);

            case UIKeyboardType.Twitter:
            case UIKeyboardType.WebSearch:
                return(InputScopeNameValue.Search);
            }
        }
Esempio n. 2
0
        public static void UiSetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType)
        {
            var toolbar = new UIToolbar
            {
                BarStyle    = UIBarStyle.Black,
                Translucent = true,
            };

            txt.KeyboardType = keyboardType;
            toolbar.SizeToFit();

            var text = new UITextView(new CGRect(0, 0, 200, 32))
            {
                ContentInset           = UIEdgeInsets.Zero,
                KeyboardType           = keyboardType,
                Text                   = txt.Text,
                UserInteractionEnabled = true
            };

            text.Layer.CornerRadius = 4f;
            text.BecomeFirstResponder();

            var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
                                                 (s, e) =>
            {
                text.ResignFirstResponder();
                txt.ResignFirstResponder();
            });

            toolbar.UserInteractionEnabled = true;
            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            txt.InputAccessoryView = toolbar;
        }
Esempio n. 3
0
        public static void UiSetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType)
        {
            var toolbar = new UIToolbar
            {
                BarStyle = UIBarStyle.Black,
                Translucent = true,
            };
            txt.KeyboardType = keyboardType;
            toolbar.SizeToFit();

            var text = new UITextView(new CGRect(0, 0, 200, 32))
            {
                ContentInset = UIEdgeInsets.Zero,
                KeyboardType = keyboardType,
                Text = txt.Text,
                UserInteractionEnabled = true
            };
            text.Layer.CornerRadius = 4f;
            text.BecomeFirstResponder();

            var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
                                 (s, e) =>
                {
                    text.ResignFirstResponder();
                    txt.ResignFirstResponder();
                });

            toolbar.UserInteractionEnabled = true;
            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            txt.InputAccessoryView = toolbar;
        }
Esempio n. 4
0
        private UIView GetEditText(string name, int textTag, UIKeyboardType keyboardType, UIReturnKeyType returnKeyType, string defaultValue = "optional")
        {
            EditText et = new EditText(this, textTag, name, keyboardType, returnKeyType, defaultValue);

            dicEditItems.Add(name, et as EditItem);

            return(et.View);
        }
Esempio n. 5
0
		public EntryAttribute (string placeholder, UIKeyboardType keyboardType,
		                 UITextAutocapitalizationType autocapitalizationType, UITextAutocorrectionType autocorrectionType)
		{
			Placeholder = placeholder;
			KeyboardType = keyboardType;
			CapitalizationType = autocapitalizationType;
			CorrectionType = autocorrectionType;
		}
Esempio n. 6
0
 public EditText(UIViewController viewController, int textTag, string labelText, UIKeyboardType keyboardType, UIReturnKeyType returnKeyType, string valueText = "optional") : base("EditText")
 {
     label         = labelText;
     defaultvalue  = valueText;
     keyboardtype  = keyboardType;
     returnkeytype = returnKeyType;
     controller    = viewController;
     tag           = textTag;
 }
Esempio n. 7
0
 public STLTextField(string placeholder, int posY = 0, string text = "", UIKeyboardType keyboard = UIKeyboardType.Default) : base()
 {
     Placeholder        = placeholder;
     Frame              = new CGRect(20, posY, UIScreen.MainScreen.Bounds.Width - 40, 30);
     Text               = text;
     Layer.CornerRadius = 10;
     Layer.BorderColor  = UIColor.LightGray.CGColor;
     Layer.BorderWidth  = 1f;
     KeyboardType       = keyboard;
     BackgroundColor    = UIColor.White;
 }
Esempio n. 8
0
		public static InputTypes InputTypesFromUIKeyboardType(UIKeyboardType keyboardType)
		{
			switch (keyboardType)
			{
				case UIKeyboardType.DecimalPad: return InputTypes.ClassNumber | InputTypes.NumberFlagDecimal;
				case UIKeyboardType.NumberPad: return InputTypes.ClassNumber;
				case UIKeyboardType.PhonePad: return InputTypes.ClassPhone;
				case UIKeyboardType.NamePhonePad: return InputTypes.TextVariationPersonName | InputTypes.ClassText;
				case UIKeyboardType.ASCIICapable: return InputTypes.TextVariationVisiblePassword | InputTypes.ClassText;
				case UIKeyboardType.NumbersAndPunctuation: return InputTypes.TextVariationVisiblePassword | InputTypes.ClassText;
				case UIKeyboardType.EmailAddress: return InputTypes.TextVariationEmailAddress | InputTypes.ClassText;
			}
			return InputTypes.ClassText;
		}
Esempio n. 9
0
        public static void SetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType     keyboardType, string closeButtonText = "Done")
        {
            UIToolbar toolbar = new UIToolbar ();
            txt.KeyboardType = keyboardType;
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit ();
            UIBarButtonItem doneButton = new UIBarButtonItem (closeButtonText, UIBarButtonItemStyle.Done,
                                                              (s, e) => {
                txt.ResignFirstResponder ();
            });
            toolbar.SetItems (new UIBarButtonItem[]{doneButton}, true);

            txt.InputAccessoryView = toolbar;
        }
Esempio n. 10
0
        public static UITextField SetTextField(this UITextField textField, UIKeyboardType keyboardType, string placeholder)
        {
            textField.Layer.BorderColor   = UIColor.FromRGB(182, 182, 175).CGColor;
            textField.Layer.BorderWidth   = 1f;
            textField.BackgroundColor     = UIColor.White;
            textField.TextColor           = UIColor.Black;
            textField.Layer.CornerRadius  = 2f;
            textField.KeyboardType        = keyboardType;
            textField.Layer.MasksToBounds = false;
            textField.VerticalAlignment   = UIControlContentVerticalAlignment.Center;
            textField.Layer.MasksToBounds = false;
            textField.LeftView            = new UIView(new RectangleF(0f, 0f, 10f, 20f));
            textField.LeftViewMode        = UITextFieldViewMode.Always;
            textField.Placeholder         = placeholder;
            textField.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            textField.ClearButtonMode     = UITextFieldViewMode.Always;

            return(textField);
        }
Esempio n. 11
0
        public void Update(string title, string placeholder, Func <UITextField, bool> validator, string field = null, UIKeyboardType keyboard = UIKeyboardType.Default)
        {
            EditField.Enabled         = true;
            EditField.SecureTextEntry = false;

            TitleLabel.Text        = title;
            EditField.Placeholder  = placeholder;
            EditField.Text         = field;
            EditField.KeyboardType = keyboard;

            Validator = validator;
            Observer  = null;
        }
Esempio n. 12
0
        public void PopulateElements(LoadMoreElement lme, Section section, string typeLable, string valueLabel, UIKeyboardType entryKeyboardType, string deleteLabel, IList<string> labelList)
        {
            lme.Animating = false;

            var type = new StyledStringElement(typeLable) { Accessory = UITableViewCellAccessory.DetailDisclosureButton };
            section.Insert(section.Count - 1, type);
            var value = new EntryElement(null, valueLabel, null);
            value.KeyboardType = entryKeyboardType;
            section.Insert(section.Count - 1, value);

            var deleteButton = new StyledStringElement(deleteLabel)
            {
                TextColor = UIColor.Red,
            };

            deleteButton.Tapped += () =>
            {
                section.Remove(type);
                section.Remove(value);
                section.Remove(deleteButton);
            };

            // Show/Hide Delete Button
            var deleteButtonOn = false;
            type.AccessoryTapped += () =>
            {
                if (!deleteButtonOn)
                {
                    deleteButtonOn = true;
                    section.Insert(type.IndexPath.Row + 2, UITableViewRowAnimation.Bottom, deleteButton);
                }
                else
                {
                    deleteButtonOn = false;
                    section.Remove(deleteButton);
                }
            };

            type.Tapped += () =>
            {
                var labelScreen = new LabelListScreen(labelList);
                var navigation = new UINavigationController(labelScreen);
                NavigationController.PresentViewController(navigation, true, null);
            };
        }
Esempio n. 13
0
        void ShowAlertType2(CommonDialogStates cds)
        {
            bool           isPresenceGrant = false;
            bool           showEntryText   = true;
            bool           showEntryText2  = false;
            bool           boolval1        = false;
            bool           showBool        = true;
            UIKeyboardType keyboardType    = UIKeyboardType.Default;

            string strHead = "", elementText1 = "", elementText2 = "",
                   elementText3 = "", elementSubText = "", buttonTitle = "", elementText4 = "", elementSubText2 = "";

            if (cds == CommonDialogStates.PresenceGrant)
            {
                strHead         = "Presence Grant";
                elementText1    = "Read";
                elementText2    = "Write";
                elementText3    = "TTL";
                elementSubText  = "Enter TTL (default 1440)";
                elementText4    = "Auth key";
                elementSubText2 = "optional";
                buttonTitle     = "Grant";
                keyboardType    = UIKeyboardType.NumberPad;
                isPresenceGrant = true;
                showEntryText2  = true;
            }
            else if (cds == CommonDialogStates.SubscribeGrant)
            {
                elementText1    = "Read";
                elementText2    = "Write";
                elementText3    = "TTL";
                elementSubText  = "Enter TTL (default 1440)";
                elementText4    = "Auth key";
                elementSubText2 = "optional";
                strHead         = "Subscribe Grant";
                buttonTitle     = "Grant";
                keyboardType    = UIKeyboardType.NumberPad;
                showEntryText2  = true;
            }
            else if (cds == CommonDialogStates.HereNow)
            {
                elementText1   = "Show UUID";
                elementText2   = "Include User State";
                elementText3   = "Channel";
                elementSubText = "Enter channel name";
                strHead        = "Here now";
                buttonTitle    = "Here Now";

                boolval1 = true;
            }
            else if (cds == CommonDialogStates.GlobalHereNow)
            {
                elementText1  = "Show UUID";
                elementText2  = "Include User State";
                strHead       = "Global Here Now";
                buttonTitle   = "Global Here Now";
                showEntryText = false;
                boolval1      = true;
            }
            else if (cds == CommonDialogStates.Publish)
            {
                elementText1    = "Store in history";
                elementText4    = "Channel";
                elementSubText2 = "Enter channel name";
                elementText3    = "Message";
                elementSubText  = "Enter message";
                strHead         = "Publish";
                buttonTitle     = "Publish";
                showEntryText   = true;
                showEntryText2  = true;
                boolval1        = true;
                showBool        = false;
            }

            BooleanElement be1 = new BooleanElement(elementText1, boolval1);
            BooleanElement be2 = null;

            if (showBool)
            {
                be2 = new BooleanElement(elementText2, false);
            }

            EntryElement entryText  = null;
            EntryElement entryText2 = null;

            if (showEntryText)
            {
                entryText = new EntryElement(elementText3, elementSubText, "");
                entryText.KeyboardType           = keyboardType;
                entryText.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText.AutocorrectionType     = UITextAutocorrectionType.No;
            }
            if (showEntryText2)
            {
                entryText2 = new EntryElement(elementText4, elementSubText2, "");
                entryText2.AutocapitalizationType = UITextAutocapitalizationType.None;
                entryText2.AutocorrectionType     = UITextAutocorrectionType.No;
            }

            var newroot = new RootElement(strHead, 0, 0)
            {
                new Section()
                {
                    be1,
                    be2,
                    entryText2,
                    entryText
                },
                new Section("")
                {
                    new StyledStringElement(buttonTitle, () => {
                        bool be1Val = be1.Value;

                        Channel = newChannels.Text;
                        if ((cds == CommonDialogStates.PresenceGrant) || (cds == CommonDialogStates.SubscribeGrant))
                        {
                            string entryTextVal  = entryText.Value;
                            string entryText2Val = entryText2.Value;
                            bool be2Val          = be2.Value;
                            int iTtl;
                            Int32.TryParse(entryTextVal, out iTtl);
                            if (iTtl < 0)
                            {
                                iTtl         = 1440;
                                entryTextVal = "1440";
                            }
                            if (isPresenceGrant)
                            {
                                Display("Running Presence Grant");
                                InvokeInBackground(() => {
                                    pubnub.GrantPresenceAccess <string> (Channel, entryText2Val, be1Val, be2Val, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                            else
                            {
                                Display("Running Subscribe Grant");
                                InvokeInBackground(() => {
                                    pubnub.GrantAccess <string> (Channel, entryText2Val, be1Val, be2Val, iTtl, DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                        }
                        else if (cds == CommonDialogStates.HereNow)
                        {
                            Display("Running Here Now");
                            string entryTextVal = entryText.Value;
                            bool be2Val         = be2.Value;
                            if (entryTextVal.Trim() != "")
                            {
                                string[] channels = entryTextVal.Split(','); //Channel.Split (',');
                                foreach (string channel in channels)
                                {
                                    InvokeInBackground(() => {
                                        pubnub.HereNow <string> (channel.Trim(), be1Val, be2Val, DisplayReturnMessage, DisplayErrorMessage);
                                    });
                                }
                            }
                            else
                            {
                                Display("Channel empty");
                            }
                        }
                        else if (cds == CommonDialogStates.GlobalHereNow)
                        {
                            bool be2Val = be2.Value;
                            InvokeInBackground(() => {
                                pubnub.GlobalHereNow <string> (be1Val, be2Val, DisplayReturnMessage, DisplayErrorMessage);
                            });
                        }
                        else if (cds == CommonDialogStates.Publish)
                        {
                            Display("Running Publish");
                            string entryTextVal  = entryText.Value;
                            string entryText2Val = entryText2.Value;

                            string[] channels = entryText2Val.Split(',');

                            foreach (string channel in channels)
                            {
                                InvokeInBackground(() => {
                                    pubnub.Publish <string> (channel.Trim(), entryTextVal, be1Val, DisplayReturnMessage, DisplayErrorMessage);
                                });
                            }
                        }

                        AppDelegate.navigation.PopViewControllerAnimated(true);
                    })
                    {
                        BackgroundColor = UIColor.Blue,
                        TextColor       = UIColor.White,
                        Alignment       = UITextAlignment.Center
                    },
                },
            };

            dvc = new DialogViewController(newroot, true);
            AppDelegate.navigation.PushViewController(dvc, true);
        }
 public UserPersonalInfoCellModel(string name, string value, bool isEditable = false, UIKeyboardType keyboardType = UIKeyboardType.Default, UIColor labelColor = null)
 {
     FieldName         = name;
     FieldValue        = value;
     this.IsEditable   = isEditable;
     this.KeyboardType = keyboardType;
     LabelTextColor    = labelColor;
 }
Esempio n. 15
0
        public void PopulateElements(LoadMoreElement lme, Section section, string typeLable, string valueLabel, UIKeyboardType entryKeyboardType, string deleteLabel, IList <string> labelList)
        {
            lme.Animating = false;

            var type = new StyledStringElement(typeLable)
            {
                Accessory = UITableViewCellAccessory.DetailDisclosureButton
            };

            section.Insert(section.Count - 1, type);
            var value = new EntryElement(null, valueLabel, null);

            value.KeyboardType = entryKeyboardType;
            section.Insert(section.Count - 1, value);

            var deleteButton = new StyledStringElement(deleteLabel)
            {
                TextColor = UIColor.Red,
            };

            deleteButton.Tapped += () =>
            {
                section.Remove(type);
                section.Remove(value);
                section.Remove(deleteButton);
            };

            // Show/Hide Delete Button
            var deleteButtonOn = false;

            type.AccessoryTapped += () =>
            {
                if (!deleteButtonOn)
                {
                    deleteButtonOn = true;
                    section.Insert(type.IndexPath.Row + 2, UITableViewRowAnimation.Bottom, deleteButton);
                }
                else
                {
                    deleteButtonOn = false;
                    section.Remove(deleteButton);
                }
            };

            type.Tapped += () =>
            {
                var labelScreen = new LabelListScreen(labelList);
                var navigation  = new UINavigationController(labelScreen);
                NavigationController.PresentViewController(navigation, true, null);
            };
        }
 public static InputTypes InputTypesFromUIKeyboardType(this UIKeyboardType keyboardType)
 {
     return(KeyboardTypeMap.ContainsKey(keyboardType) ? KeyboardTypeMap[keyboardType] : InputTypes.ClassText);
 }
Esempio n. 17
0
        string InitializePropsUI()
        {
            var help     = Source as IHelpful;
            var helpText = "";


            var q = from t in SourceType.GetProperties()
                    where t.DeclaringType == SourceType && t.CanWrite
                    select t;
            var props = q.ToArray();

            var rows = new List <Row> ();


            foreach (var p in props)
            {
                var ignoreAttrs = p.GetCustomAttributes(typeof(IgnoreAttribute), true);
                if (ignoreAttrs.Length > 0)
                {
                    continue;
                }

                var isEmail = p.GetCustomAttributes(typeof(EmailInputAttribute), true).Length > 0;
                if (!isEmail && p.Name == "Email")
                {
                    isEmail = true;
                }
                var isChooseEmail = p.GetCustomAttributes(typeof(ChooseEmailInputAttribute), true).Length > 0;

                var title = Theme.GetTitle(p.Name);

                if (help != null)
                {
                    var h = help.HelpForProperty(p.Name);
                    if (h != "")
                    {
                        helpText += title + " " + h + "\n";
                    }
                }

                var label = new UILabel {
                    BackgroundColor = UIColor.Black, TextColor = Lcars.ComponentColors[LcarsComponentType.CriticalFunction], Text = title, TextAlignment = UITextAlignment.Right, BaselineAdjustment = UIBaselineAdjustment.AlignBaselines, Font = Theme.InputFont, AdjustsFontSizeToFitWidth = true
                };

                var row = new Row {
                    Property = p
                };
                rows.Add(row);

                row.Label = label;
                UIKeyboardType kbd = UIKeyboardType.Default;
                if (isEmail || isChooseEmail)
                {
                    kbd = UIKeyboardType.EmailAddress;
                }
                else if (p.Name == "Url")
                {
                    kbd = UIKeyboardType.Url;
                }
                else if (p.PropertyType == typeof(int))
                {
                    kbd = UIKeyboardType.NumberPad;
                }

                var init = p.GetValue(Source, null);

                var text = new UITextField {
                    Placeholder = title, BackgroundColor = UIColor.Black, TextColor = UIColor.White, Font = Theme.InputFont, AdjustsFontSizeToFitWidth = false, AutocapitalizationType = UITextAutocapitalizationType.None, KeyboardType = kbd, Text = init != null?init.ToString() : ""
                };
                row.Text = text;
                if (p.Name.ToLowerInvariant().IndexOf("password") >= 0)
                {
                    text.SecureTextEntry    = true;
                    text.AutocorrectionType = UITextAutocorrectionType.No;
                }
                if (p.Name != "Search")
                {
                    text.AutocorrectionType = UITextAutocorrectionType.No;
                }
                if (text.Text.Length == 0 && !isChooseEmail)
                {
                    text.BecomeFirstResponder();
                }
                label.Hidden = text.Text.Length == 0;
                if (isChooseEmail)
                {
                    text.EditingDidBegin += delegate {
                        try {
                            bool hasPeople = false;
                            using (var adds = new ABAddressBook()) {
                                foreach (var pe in adds.GetPeople())
                                {
                                    var es = pe.GetEmails();
                                    if (es.Count > 0)
                                    {
                                        hasPeople = true;
                                        break;
                                    }
                                }
                            }

                            if (hasPeople)
                            {
                                Sounds.PlayBeep();
                                var em = new ChooseEmail();
                                em.EmailSelected += emailAddress =>
                                {
                                    text.Text = emailAddress;
                                    UpdateUI();
                                };
                                App.Inst.ShowDialog(em);
                                NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds(30), delegate {
                                    try {
                                        HideKeyBoard(this);
                                    } catch (Exception err) {
                                        Log.Error(err);
                                    }
                                });
                            }
                        } catch (Exception error) {
                            Log.Error(error);
                        }
                    };
                }
                text.AllEditingEvents += delegate {
                    try {
                        label.Hidden = string.IsNullOrEmpty(text.Text);
                        UpdateUI();
                    } catch (Exception error) {
                        Log.Error(error);
                    }
                };
                AddSubview(label);
                AddSubview(text);
            }


            _propViews = rows.ToArray();

            return(helpText);
        }
Esempio n. 18
0
        public static Task <string> Input(string title, string message, string button = "Ok", UIKeyboardType type = UIKeyboardType.ASCIICapable, string defValue = "")
        {
            var tcs   = new TaskCompletionSource <string>();
            var alert = new UIAlertView(title, message, null, button, null);

            alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput;

            var txt = alert.GetTextField(0);

            txt.Text         = defValue;
            txt.KeyboardType = type;

            alert.Clicked += (sender, e) => tcs.SetResult(alert.GetTextField(0).Text);

            UIThread.InvokeOnMainThread(alert.Show);

            return(tcs.Task);
        }