void HandleKeyUp(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == Windows.System.VirtualKey.Enter)
     {
         CustomReturnEffect.GetReturnCommand(Element)?.Execute(null);
     }
 }
Ejemplo n.º 2
0
        public static void ChainEntries(params VisualElement[] entries)
        {
            if (entries.Length == 0)
            {
                return;
            }

            for (int i = 0; i < entries.Length - 1; i++)
            {
                var current = entries[i];
                var next    = entries[i + 1];

                CustomReturnEffect.SetReturnType(current, ReturnType.Next);
                CustomReturnEffect.SetReturnCommand(current, new Command(x => next.Focus()));

                if (current is Picker picker)
                {
                    picker.SelectedIndexChanged += (sender, args) => next.Focus();
                }
            }

            var lastEntry = entries.Last();

            CustomReturnEffect.SetReturnType(lastEntry, ReturnType.Done);
        }
Ejemplo n.º 3
0
        static Entry CreateEntry(bool shouldUseEffects, ReturnType returnType, string placeholder, string automationId, string bindingSource)
        {
            Entry entry;

            switch (shouldUseEffects)
            {
            case true:
                entry = new Entry();
                CustomReturnEffect.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(Entry.TextProperty, bindingSource);

            return(entry);
        }
 void SetKeyboardReturnButton()
 {
     if (Control is UITextField uiTextField)
     {
         uiTextField.ReturnKeyType = KeyboardHelpers.GetKeyboardButtonType(CustomReturnEffect.GetReturnType(Element));
         uiTextField.ShouldReturn += HandleShouldReturn;
     }
 }
Ejemplo n.º 5
0
 void SetKeyboardReturnButton()
 {
     if (Control is FormsTextBox formsTextBox)
     {
         KeyboardHelpers.SetKeyboardEnterButton(formsTextBox, CustomReturnEffect.GetReturnType(Element));
         Control.KeyUp += HandleKeyUp;
     }
 }
Ejemplo n.º 6
0
        public MainPage()
        {
            InitializeComponent();

            CustomReturnEntry.ReturnCommand = ReturnCommand;

            CustomReturnEffect.SetReturnCommand(EffectsEntry, ReturnCommand);
        }
Ejemplo n.º 7
0
        void ConfigureCustomReturnEffect()
        {
            CustomReturnEffect.SetReturnType(Player1Entry, ReturnType.Next);
            CustomReturnEffect.SetReturnCommand(Player1Entry, new Command(() => Player2Entry.Focus()));

            CustomReturnEffect.SetReturnType(Player2Entry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(Player2Entry, new Command(() => HandleStartGameButtonClicked(StartGameButton, EventArgs.Empty)));
        }
Ejemplo n.º 8
0
        void ConstructUI()
        {
            _layout = new StackLayout
            {
                Padding         = new Thickness(20, 50, 20, 20),
                VerticalOptions = LayoutOptions.FillAndExpand,
            };

            _usernameEntry = new StyledEntry(1)
            {
                Style                   = StyleConstants.UnderlinedEntry,
                AutomationId            = AutomationIdConstants.NewUserNameEntry,
                Placeholder             = "Username",
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                PlaceholderColor        = Color.FromHex("749FA8"),
            };
            CustomReturnEffect.SetReturnType(_usernameEntry, ReturnType.Next);
            CustomReturnEffect.SetReturnCommand(_usernameEntry, new Command(() => _passwordEntry.Focus()));

            _passwordEntry = new StyledEntry(1)
            {
                Style                   = StyleConstants.UnderlinedEntry,
                AutomationId            = AutomationIdConstants.NewPasswordEntry,
                Placeholder             = "Password",
                IsPassword              = true,
                HorizontalOptions       = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.End,
                VerticalOptions         = LayoutOptions.Fill,
                PlaceholderColor        = Color.FromHex("749FA8")
            };
            CustomReturnEffect.SetReturnType(_passwordEntry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(_passwordEntry, new Command(() => HandleSaveUsernameButtonClicked(_saveUsernameButton, EventArgs.Empty)));

            _saveUsernameButton = new StyledButton(Borders.Thin, 1)
            {
                Style             = StyleConstants.BorderedButton,
                AutomationId      = AutomationIdConstants.SaveUsernameButton,
                Text              = "Save Username",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.EndAndExpand
            };
            _saveUsernameButton.Clicked += HandleSaveUsernameButtonClicked;

            _cancelButton = new StyledButton(Borders.Thin, 1)
            {
                Style             = StyleConstants.BorderedButton,
                AutomationId      = AutomationIdConstants.CancelButton,
                Text              = "Cancel",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.End
            };

            _cancelButton.Clicked += (object sender, EventArgs e) =>
            {
                Navigation.PopModalAsync();
            };
        }
        void HandleEditorAction(object sender, TextView.EditorActionEventArgs e)
        {
            if (e?.Event?.KeyCode == Keycode.Enter)
            {
                return;
            }

            CustomReturnEffect.GetReturnCommand(Element)?.Execute(CustomReturnEffect.GetReturnCommandParameter(Element));
        }
        void HandleKeyPress(object sender, global::Android.Views.View.KeyEventArgs e)
        {
            if (e?.Event?.KeyCode == Keycode.Enter && e?.Event?.Action == KeyEventActions.Up)
            {
                CustomReturnEffect.GetReturnCommand(Element)?.Execute(CustomReturnEffect.GetReturnCommandParameter(Element));
            }

            e.Handled = false;
        }
 void SetKeyboardReturnButton()
 {
     switch (Control)
     {
     case FormsTextBox formsTextBox:
         KeyboardHelpers.SetKeyboardEnterButton(formsTextBox, CustomReturnEffect.GetReturnType(Element));
         Control.KeyUp += HandleKeyUp;
         break;
     }
 }
        public MultipleEffectsEntryPage()
        {
            InitializeComponent();

            CustomReturnEffect.SetReturnCommand(DefaultReturnTypeEntry, new Command(() => NextReturnTypeEntry.Focus()));
            CustomReturnEffect.SetReturnCommand(NextReturnTypeEntry, new Command(() => DoneReturnTypeEntry.Focus()));
            CustomReturnEffect.SetReturnCommand(DoneReturnTypeEntry, new Command(() => SendReturnTypeEntry.Focus()));
            CustomReturnEffect.SetReturnCommand(SendReturnTypeEntry, new Command(() => SearchReturnTypeEntry.Focus()));
            CustomReturnEffect.SetReturnCommand(SearchReturnTypeEntry, new Command(() => GoReturnTypeEntry.Focus()));
        }
Ejemplo n.º 13
0
 void SetKeyboardReturnButton()
 {
     switch (Control)
     {
     case UITextField uiTextField:
         uiTextField.ReturnKeyType = KeyboardHelpers.GetKeyboardButtonType(CustomReturnEffect.GetReturnType(Element));
         uiTextField.ShouldReturn += HandleShouldReturn;
         break;
     }
 }
Ejemplo n.º 14
0
        void SetKeyboardReturnButton()
        {
            if (Element is Entry entry &&
                Control is FormsEditText customControl)
            {
                customControl.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(CustomReturnEffect.GetReturnType(entry));

                customControl.EditorAction += HandleEditorAction;
                customControl.KeyPress     += HandleKeyPress;
            }
        }
        void SetKeyboardReturnButton()
        {
            var customControl = Control as FormsTextBox;

            if (customControl == null)
            {
                return;
            }

            KeyboardHelpers.SetKeyboardEnterButton(customControl, CustomReturnEffect.GetReturnType(Element));
            Control.KeyUp += HandleKeyUp;
        }
Ejemplo n.º 16
0
        void ExecuteCommand()
        {
            var returnCommand          = CustomReturnEffect.GetReturnCommand(Element);
            var returnCommandParameter = CustomReturnEffect.GetReturnCommandParameter(Element);

            var canExecute = returnCommand?.CanExecute(returnCommandParameter) ?? true;

            if (canExecute)
            {
                returnCommand?.Execute(returnCommandParameter);
            }
        }
Ejemplo n.º 17
0
        public EffectsPage()
        {
            var effectsEntry = new Entry
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Placeholder       = EffectsPageConstants.EffectsEntryPlaceholderText,
                AutomationId      = AutomationIdConstants.EffectsEntry
            };

            CustomReturnEffect.SetReturnType(effectsEntry, EntryCustomReturn.Forms.Plugin.Abstractions.ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(effectsEntry, BaseEntryReturnCommand);
            CustomReturnEffect.SetReturnCommandParameter(effectsEntry, EntryConstants.CommandParameterString);

            var canExecuteLabel = new Label
            {
                Text = "Can Execute",
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            };

            var canExecuteSwitch = new Switch {
                AutomationId = AutomationIdConstants.CanExecuteSwitch
            };

            canExecuteSwitch.Toggled += (sender, e) => BaseEntryReturnCommandCanExecute = e.Value;

            var baseCanExecuteStackLayout = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    canExecuteLabel,
                    canExecuteSwitch
                }
            };

            Title = PageTitles.Effects;

            Content = new StackLayout
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Children          =
                {
                    effectsEntry,
                    baseCanExecuteStackLayout
                }
            };
        }
Ejemplo n.º 18
0
        void SetKeyboardReturnButton()
        {
            var customControl = Control as UITextField;

            if (customControl == null)
            {
                return;
            }

            customControl.ReturnKeyType = KeyboardHelpers.GetKeyboardButtonType(CustomReturnEffect.GetReturnType(Element));

            customControl.ShouldReturn += HandleShouldReturn;
        }
        void SetKeyboardReturnButton()
        {
            var customControl = Control as FormsEditText;
            var entry         = Element as Entry;

            if (customControl != null && entry != null)
            {
                customControl.ImeOptions = KeyboardHelpers.GetKeyboardButtonType(CustomReturnEffect.GetReturnType(entry));

                customControl.EditorAction += HandleEditorAction;
                customControl.KeyPress     += HandleKeyPress;
            }
        }
Ejemplo n.º 20
0
        public EffectsPage()
        {
            var effectsEntry = new Entry
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Placeholder       = "Effects Entry",
            };

            CustomReturnEffect.SetReturnType(effectsEntry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(effectsEntry, new Command(async() => await Navigation.PopAsync()));

            Title = "Effects";

            Content = effectsEntry;
        }
        bool HandleShouldReturn(UITextField textField)
        {
            var returnCommand          = CustomReturnEffect.GetReturnCommand(Element);
            var returnCommandParameter = CustomReturnEffect.GetReturnCommandParameter(Element);

            var canExecute = returnCommand?.CanExecute(returnCommandParameter) ?? true;

            if (canExecute)
            {
                returnCommand?.Execute(returnCommandParameter);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 22
0
        void CreateGlobalChildren()
        {
            logo       = new Image();
            logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            loginEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.UsernameEntry,
                Placeholder  = "Username",
            };
            CustomReturnEffect.SetReturnType(loginEntry, ReturnType.Next);
            CustomReturnEffect.SetReturnCommand(loginEntry, new Command(() => passwordEntry.Focus()));

            passwordEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.PasswordEntry,
                Placeholder  = "Password",
                IsPassword   = true,
            };
            CustomReturnEffect.SetReturnType(passwordEntry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(passwordEntry, new Command(() => HandleLoginButtonClicked(passwordEntry, EventArgs.Empty)));

            loginButton = new StyledButton(Borders.Thin)
            {
                AutomationId = AutomationIdConstants.LoginButton,
                Text         = "Login",
            };
            newUserSignUpButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.NewUserButton,
                Text         = "Sign-up",
            };
            forgotPasswordButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.ForgotPasswordButton,
                Text         = "Forgot Password?",
            };

            loginButton.Clicked += HandleLoginButtonClicked;

            newUserSignUpButton.Clicked  += (object sender, EventArgs e) => NewUserSignUp();
            forgotPasswordButton.Clicked += (object sender, EventArgs e) => ForgotPassword();
        }
        static void ConfigureEntryReturnCommand(Entry entry, Action action)
        {
            var command = new Command(action);

            switch (entry)
            {
            case CustomReturnEntry customReturnEntry:
                customReturnEntry.ReturnCommand = command;
                break;

            case Entry baseEntry:
                CustomReturnEffect.SetReturnCommand(baseEntry, command);
                break;

            default:
                throw new NotSupportedException("Invalid Type");
            }
        }
Ejemplo n.º 24
0
        public EffectsPage()
        {
            var effectsEntry = new Entry
            {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Placeholder       = EffectsPageConstants.EffectsEntryPlaceholderText,
                AutomationId      = AutomationIdConstants.EffectsEntry
            };

            CustomReturnEffect.SetReturnType(effectsEntry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(effectsEntry, new Command <string>(async title => await ExecuteEntryCommand(title)));
            CustomReturnEffect.SetReturnCommandParameter(effectsEntry, EntryConstants.CommandParameterString);

            Title = PageTitles.Effects;

            Content = effectsEntry;
        }
Ejemplo n.º 25
0
        static void ConfigureEntryReturnCommand(bool shouldUseEffects, Entry entry, Action action)
        {
            var command = new Command(action);

            switch (shouldUseEffects)
            {
            case true:
                CustomReturnEffect.SetReturnCommand(entry, command);
                break;

            case false:
                ((CustomReturnEntry)entry).ReturnCommand = command;
                break;

            default:
                throw new Exception("Invalid Type");
            }
        }
Ejemplo n.º 26
0
        public static View CreatePickEntryReturnTypePageLayout(bool shouldUseEffects, PickEntryReturnTypeViewModel pickEntryReturnTypeViewModel)
        {
            Entry customizableEntry;

            switch (shouldUseEffects)
            {
            case true:
                customizableEntry = new Entry();
                CustomReturnEffect.SetReturnType(customizableEntry, ReturnType.Go);
                customizableEntry.SetBinding(CustomReturnEffect.ReturnTypeProperty, nameof(pickEntryReturnTypeViewModel.EntryReturnType));
                break;

            case false:
                customizableEntry = new CustomReturnEntry();
                customizableEntry.SetBinding(CustomReturnEntry.ReturnTypeProperty, nameof(pickEntryReturnTypeViewModel.EntryReturnType));
                break;

            default:
                throw new Exception("Invalid Type");
            }

            customizableEntry.AutomationId = AutomationIdConstants.CustomizableEntryAutomationId;
            customizableEntry.SetBinding(Entry.PlaceholderProperty, nameof(pickEntryReturnTypeViewModel.EntryPlaceHolderText));

            var entryReturnTypePicker = new Picker
            {
                AutomationId = AutomationIdConstants.EntryReturnTypePickerAutomationId
            };

            entryReturnTypePicker.SetBinding(Picker.ItemsSourceProperty, nameof(pickEntryReturnTypeViewModel.EntryReturnTypePickerSource));
            entryReturnTypePicker.SetBinding(Picker.SelectedItemProperty, nameof(pickEntryReturnTypeViewModel.PickerSelection));

            return(new StackLayout
            {
                Children =
                {
                    customizableEntry,
                    entryReturnTypePicker
                }
            });
        }
Ejemplo n.º 27
0
        static Entry CreateEntry(bool shouldUseEffects, EntryCustomReturn.Forms.Plugin.Abstractions.ReturnType returnType, string placeholder, string automationId, string bindingSource)
        {
            Entry entry;

            if (shouldUseEffects)
            {
                entry = new Entry();
                CustomReturnEffect.SetReturnType(entry, returnType);
            }
            else
            {
                entry = new CustomReturnEntry {
                    ReturnType = returnType
                };
            }
            entry.Placeholder  = placeholder;
            entry.AutomationId = automationId;
            entry.SetBinding(Entry.TextProperty, bindingSource);

            return(entry);
        }
Ejemplo n.º 28
0
        void CreateGlobalChildren()
        {
            _logoSlogan = new StyledLabel
            {
                Opacity = 0,
                Text    = "Delighting Developers."
            };
            _loginEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.LoginPage_UsernameEntry,
                Placeholder  = "Username",
            };
            CustomReturnEffect.SetReturnType(_loginEntry, ReturnType.Next);
            CustomReturnEffect.SetReturnCommand(_loginEntry, new Command(() => _passwordEntry.Focus()));

            _passwordEntry = new StyledEntry
            {
                AutomationId = AutomationIdConstants.LoginPage_PasswordEntry,
                Placeholder  = "Password",
                IsPassword   = true,
            };
            CustomReturnEffect.SetReturnType(_passwordEntry, ReturnType.Go);
            CustomReturnEffect.SetReturnCommand(_passwordEntry, new Command(() => HandleLoginButtonClicked(_passwordEntry, EventArgs.Empty)));

            _loginButton = new StyledButton(Borders.Thin)
            {
                AutomationId = AutomationIdConstants.LoginPage_LoginButton,
                Text         = "Login",
            };
            _newUserSignUpButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.LoginPage_NewUserSignUpButton,
                Text         = "Sign-up",
            };
            _forgotPasswordButton = new StyledButton(Borders.None)
            {
                AutomationId = AutomationIdConstants.LoginPage_ForgotPasswordButton,
                Text         = "Forgot Password?",
            };
        }
Ejemplo n.º 29
0
 bool HandleShouldReturn(UITextField textField)
 {
     CustomReturnEffect.GetReturnCommand(Element)?.Execute(CustomReturnEffect.GetReturnCommandParameter(Element));
     return(true);
 }
Ejemplo n.º 30
0
        public FirstPage() : base(PageTitleConstants.FirstPage)
        {
            const string entryTextPaceHolder = "Enter text and click 'Go'";

            _goButton = new StyledButton(Borders.Thin, 1)
            {
                Text         = "Go",
                AutomationId = AutomationIdConstants.GoButton, // This provides an ID that can be referenced in UITests
            };
            _goButton.SetBinding(Button.CommandProperty, nameof(ViewModel.GoButtonCommand));

            var textEntry = new StyledEntry(1)
            {
                Placeholder             = entryTextPaceHolder,
                AutomationId            = AutomationIdConstants.TextEntry, // This provides an ID that can be referenced in UITests
                PlaceholderColor        = Color.FromHex("749FA8"),
                HorizontalTextAlignment = TextAlignment.Center
            };

            CustomReturnEffect.SetReturnType(textEntry, ReturnType.Go);
            textEntry.SetBinding(CustomReturnEffect.ReturnCommandProperty, nameof(ViewModel.GoButtonCommand));
            textEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.EntryText));

            var textLabel = new StyledLabel
            {
                AutomationId      = AutomationIdConstants.TextLabel, // This provides an ID that can be referenced in UITests
                HorizontalOptions = LayoutOptions.Center
            };

            textLabel.SetBinding(Label.TextProperty, nameof(ViewModel.LabelText));

            _listPageButton = new StyledButton(Borders.Thin, 1)
            {
                Text         = "Go to List Page",
                AutomationId = AutomationIdConstants.ListViewButton // This provides an ID that can be referenced in UITests
            };

            var activityIndicator = new ActivityIndicator
            {
                AutomationId = AutomationIdConstants.BusyActivityIndicator, // This provides an ID that can be referenced in UITests
                Color        = Color.White
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsActiityIndicatorRunning));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsActiityIndicatorRunning));

            Func <RelativeLayout, double> getTextEntryWidth         = (p) => textEntry.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getGoButtonWidth          = (p) => _goButton.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getActivityIndicatorWidth = (p) => activityIndicator.Measure(p.Width, p.Height).Request.Width;
            Func <RelativeLayout, double> getTextLabelWidth         = (p) => textLabel.Measure(p.Width, p.Height).Request.Width;

            var relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(textEntry,
                                        Constraint.RelativeToParent((parent) => parent.X),
                                        Constraint.RelativeToParent((parent) => parent.Y),
                                        Constraint.RelativeToParent((parent) => parent.Width - 20));
            relativeLayout.Children.Add(_goButton,
                                        Constraint.RelativeToParent((parent) => parent.X),
                                        Constraint.RelativeToView(textEntry, (parent, view) => view.Y + view.Height + _relativeLayoutPadding),
                                        Constraint.RelativeToParent((parent) => parent.Width - 20));
            relativeLayout.Children.Add(activityIndicator,
                                        Constraint.RelativeToParent((parent) => parent.Width / 2 - getActivityIndicatorWidth(parent) / 2),
                                        Constraint.RelativeToView(_goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding));
            relativeLayout.Children.Add(textLabel,
                                        Constraint.RelativeToParent((parent) => parent.Width / 2 - getTextLabelWidth(parent) / 2),
                                        Constraint.RelativeToView(_goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding));
            relativeLayout.Children.Add(_listPageButton,
                                        Constraint.RelativeToParent((parent) => parent.X),
                                        Constraint.RelativeToView(_goButton, (parent, view) => view.Y + view.Height + _relativeLayoutPadding * 15),
                                        Constraint.RelativeToParent((parent) => parent.Width - 20));

            Padding = GetPagePadding();
            Content = relativeLayout;
        }