static Entry CreateEntry <T>(bool shouldUseEffects, ReturnType returnType, string placeholder, string automationId, Expression <Func <T, object> > textPropertyBindingSource) where T : BaseViewModel { Entry entry; switch (shouldUseEffects) { case true: entry = new Entry(); ReturnTypeEffect.SetReturnType(entry, returnType); break; case false: entry = new CustomReturnEntry { ReturnType = returnType, }; break; default: throw new Exception("Invalid Type"); } entry.Placeholder = placeholder; entry.AutomationId = automationId; entry.SetBinding <T>(Entry.TextProperty, textPropertyBindingSource); return(entry); }
void SetKeyboardReturnButton() { var customControl = Control as EntryEditText; var entry = Element as Entry; if (customControl != null && entry != null) { customControl.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(ReturnTypeEffect.GetReturnType(entry)); customControl.EditorAction += HandleEditorAction; } }
void SetKeyboardReturnButton() { var customControl = Control as UITextField; if (customControl == null) { return; } customControl.ReturnKeyType = KeyboardHelpers.GetKeyboardButtonType(ReturnTypeEffect.GetReturnType(Element)); customControl.ShouldReturn += HandleShouldReturn; }
static void ConfigureEntryReturnCommand(bool shouldUseEffects, Entry entry, Action action) { var command = new Command(action); switch (shouldUseEffects) { case true: ReturnTypeEffect.SetReturnCommandProperty(entry, command); break; case false: ((CustomReturnEntry)entry).ReturnCommand = command; break; default: throw new Exception("Invalid Type"); } }
public static View CreatePickEntryReturnTypePaageLayout(bool shouldUseEffects) { Entry customizableEntry; switch (shouldUseEffects) { case true: customizableEntry = new Entry(); ReturnTypeEffect.SetReturnType(customizableEntry, ReturnType.Go); customizableEntry.SetBinding <PickEntryReturnTypeViewModel>(ReturnTypeEffect.ReturnTypeProperty, vm => vm.EntryReturnType); break; case false: customizableEntry = new CustomReturnEntry(); customizableEntry.SetBinding <PickEntryReturnTypeViewModel>(CustomReturnEntry.ReturnTypeProperty, vm => vm.EntryReturnType); break; default: throw new Exception("Invalid Type"); } customizableEntry.AutomationId = AutomationIdConstants.CustomizableEntryAutomationId; customizableEntry.SetBinding <PickEntryReturnTypeViewModel>(Entry.PlaceholderProperty, vm => vm.EntryPlaceHolderText); var entryReturnTypePicker = new Picker { AutomationId = AutomationIdConstants.EntryReturnTypePickerAutomationId }; entryReturnTypePicker.SetBinding <PickEntryReturnTypeViewModel>(Picker.ItemsSourceProperty, vm => vm.EntryReturnTypePickerSource); entryReturnTypePicker.SetBinding <PickEntryReturnTypeViewModel>(Picker.SelectedItemProperty, vm => vm.PickerSelection); return(new StackLayout { Children = { customizableEntry, entryReturnTypePicker } }); }
bool HandleShouldReturn(UITextField textField) { ReturnTypeEffect.GetReturnCommandProperty(Element)?.Execute(null); return(true); }
void HandleEditorAction(object sender, TextView.EditorActionEventArgs e) { ReturnTypeEffect.GetReturnCommandProperty(Element)?.Execute(null); }