private void AddAccessoryButton(ReturnKeyTypes returnType) { if (returnType == ReturnKeyTypes.Done || returnType == ReturnKeyTypes.Next) { UIToolbar toolbar = new UIToolbar(new CGRect(0.0f, 0.0f, 50.0f, 44.0f)); UIBarButtonItem accessoryButton = null; if (returnType == ReturnKeyTypes.Done) { accessoryButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { this.Control.ResignFirstResponder(); ElementV2?.ReturnCommand?.Execute(null); }); } else { accessoryButton = new UIBarButtonItem("Next", UIBarButtonItemStyle.Bordered, delegate { this.Control.ResignFirstResponder(); ElementV2?.ReturnCommand?.Execute(null); }); } toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), accessoryButton }; this.Control.InputAccessoryView = toolbar; } }
/// <summary> /// Gets the value from description. /// </summary> /// <returns>The value from description.</returns> /// <param name="value">Value.</param> public static UIReturnKeyType GetValueFromDescription(this ReturnKeyTypes value) { var type = typeof(UIReturnKeyType); if (!type.IsEnum) { throw new InvalidOperationException(); } foreach (var field in type.GetFields()) { var attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; if (attribute != null) { if (attribute.Description == value.ToString()) { return((UIReturnKeyType)field.GetValue(null)); } } else { if (field.Name == value.ToString()) { return((UIReturnKeyType)field.GetValue(null)); } } } throw new NotSupportedException($"Not supported on iOS: {value}"); }
/// <summary> /// Gets the value from description. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> /// <exception cref="InvalidOperationException"></exception> /// <exception cref="NotSupportedException"></exception> private static ImeAction getValueFromDescription(ReturnKeyTypes value) { Type type = typeof(ImeAction); if (!type.IsEnum) { throw new InvalidOperationException(); } foreach (FieldInfo field in type.GetFields()) { if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attribute) { if (attribute.Description == value.ToString()) { return((ImeAction)field.GetValue(null)); } } else { if (field.Name == value.ToString()) { return((ImeAction)field.GetValue(null)); } } } throw new NotSupportedException($"Not supported on Android: {value}"); }
public static ImeAction ToImeAction(this ReturnKeyTypes type) { var imeType = ImeAction.Unspecified; switch (type) { case ReturnKeyTypes.Done: imeType = ImeAction.Done; break; case ReturnKeyTypes.Send: imeType = ImeAction.Send; break; case ReturnKeyTypes.Next: imeType = ImeAction.Next; break; case ReturnKeyTypes.Go: imeType = ImeAction.Go; break; case ReturnKeyTypes.Search: imeType = ImeAction.Search; break; default: imeType = ImeAction.Unspecified; break; } return(imeType); }
protected virtual ImeAction GetValueFromDescription(ReturnKeyTypes value) { var type = typeof(ImeAction); if (!type.IsEnum) { throw new InvalidOperationException(); } foreach (var field in type.GetFields()) { var attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; if (attribute != null) { if (attribute.Description == value.ToString()) { return((Android.Views.InputMethods.ImeAction)field.GetValue(null)); } } else { if (field.Name == value.ToString()) { return((ImeAction)field.GetValue(null)); } } } return(ImeAction.Done); }
public static UIReturnKeyType ToUIReturnKey(this ReturnKeyTypes type) { var returnType = UIReturnKeyType.Default; switch (type) { case ReturnKeyTypes.Done: returnType = UIReturnKeyType.Done; break; case ReturnKeyTypes.Send: returnType = UIReturnKeyType.Send; break; case ReturnKeyTypes.Next: returnType = UIReturnKeyType.Next; break; case ReturnKeyTypes.Go: returnType = UIReturnKeyType.Go; break; case ReturnKeyTypes.Search: returnType = UIReturnKeyType.Search; break; case ReturnKeyTypes.Google: returnType = UIReturnKeyType.Google; break; case ReturnKeyTypes.Join: returnType = UIReturnKeyType.Join; break; case ReturnKeyTypes.Route: returnType = UIReturnKeyType.Route; break; case ReturnKeyTypes.Continue: returnType = UIReturnKeyType.Continue; break; case ReturnKeyTypes.EmergencyCall: returnType = UIReturnKeyType.EmergencyCall; break; case ReturnKeyTypes.Yahoo: returnType = UIReturnKeyType.Yahoo; break; } return(returnType); }
public static BorderlessEntry GeneralEntryCell(string text, double width, Keyboard keyboard, string placeholder = "", ReturnKeyTypes returnKey = ReturnKeyTypes.Done, double factor = .6, bool useBold = false, bool isPassword = false) { return(new BorderlessEntry { WidthRequest = width * factor, BackgroundColor = Color.Transparent, Text = text, Keyboard = keyboard, TextColor = Color.White, Placeholder = placeholder, PlaceholderColor = Color.White, FontFamily = useBold ? Helper.BoldFont : Helper.RegFont, HorizontalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center, ReturnType = returnKey, IsPassword = isPassword }); }