protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            CustomEntry entry = (CustomEntry)this.Element;

            if (this.Control != null)
            {
                if (entry != null)
                {
                    SetReturnType(entry);

                    // Editor Action is called when the return button is pressed
                    Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) =>
                    {
                        if (entry.ReturnType != Models.ReturnType.Next)
                        {
                            entry.Unfocus();
                        }

                        // Call all the methods attached to custom_entry event handler Completed
                        entry.InvokeCompleted();
                    };
                }
            }
        }
        private void RenameCancelButton_Tapped(object sender, EventArgs e)
        {
            GroupsPageItem groupItem = (GroupsPageItem)(sender as Image).BindingContext;

            if (groupItem != null)
            {
                CustomEntry entry = ((sender as Image).Parent as Grid).Children[0] as CustomEntry;
                entry.Unfocus();
            }
        }
Ejemplo n.º 3
0
        // Handler del click en el botón Return del teclado
        private void Control_EditorAction(object sender, TextView.EditorActionEventArgs e)
        {
            CustomEntry customEntry = (CustomEntry)Element;

            if (customEntry?.ReturnKeyType != ReturnKeyTypes.Next)
            {
                customEntry?.Unfocus();
            }

            customEntry?.InvokeCompleted();
        }
        // Handler del click en el botón Return del teclado
        private bool TextFieldShouldReturn(UITextField textField)
        {
            CustomEntry customEntry = (CustomEntry)Element;

            if (customEntry?.ReturnKeyType != ReturnKeyTypes.Next)
            {
                customEntry?.Unfocus();
            }

            customEntry?.InvokeCompleted();

            return(true);
        }
Ejemplo n.º 5
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || e.NewElement == null)
            {
                return;
            }

            element = (CustomEntry)this.Element;

            /*******************IMAGE*******************/
            var editText = this.Control;

            if (!string.IsNullOrEmpty(element.Image))
            {
                switch (element.ImageAlignment)
                {
                case EnumImageAlignment.Left:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null);
                    break;

                case EnumImageAlignment.Right:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null);
                    break;
                }
            }
            editText.CompoundDrawablePadding = 25;
            Control.Background.SetColorFilter(element.LineColor.ToAndroid(), PorterDuff.Mode.SrcAtop);

            /*******************RETURN TYPE*******************/
            SetReturnType(element);
            // Editor Action is called when the return button is pressed
            Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) =>
            {
                if (element?.ReturnType != EnumReturnType.Next)
                {
                    element?.Unfocus();
                }

                // Call all the methods attached to base_entry event handler Completed
                element?.InvokeCompleted();
            };
        }
Ejemplo n.º 6
0
        void SetReturnType(CustomEntry entry)
        {
            if (entry != null && Control != null)
            {
                var type = entry.ReturnType;

                switch (type)
                {
                case KeyboardReturnType.Go:
                    Control.ImeOptions = ImeAction.Go;
                    Control.SetImeActionLabel("Go", ImeAction.Go);
                    break;

                case KeyboardReturnType.Next:
                    Control.ImeOptions = ImeAction.Next;
                    Control.SetImeActionLabel("Next", ImeAction.Next);
                    break;

                case KeyboardReturnType.Send:
                    Control.ImeOptions = ImeAction.Send;
                    Control.SetImeActionLabel("Send", ImeAction.Send);
                    break;

                case KeyboardReturnType.Search:
                    Control.ImeOptions = ImeAction.Search;
                    Control.SetImeActionLabel("Search", ImeAction.Search);
                    break;

                default:
                    Control.ImeOptions = ImeAction.Done;
                    Control.SetImeActionLabel("Done", ImeAction.Done);
                    break;
                }

                if (entry.ReturnType == KeyboardReturnType.Next)
                {
                    //Control.ImeOptions = ImeAction.Next;
                    Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) =>
                    {
                        entry.OnNext();
                    };
                }

                if (entry.ReturnType == KeyboardReturnType.Done)
                {
                    //Control.ImeOptions = ImeAction.Done;
                    //Control.SetImeActionLabel("Done", ImeAction.Done);

                    Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) =>
                    {
                        entry.Unfocus();
                        if (entry.ReturnKeyClickCommand != null)
                        {
                            entry.ReturnKeyClickCommand.Execute(null);
                        }
                    };
                }

                if (entry.ReturnType == KeyboardReturnType.Search)
                {
                    //Control.ImeOptions = ImeAction.Send;
                    //Control.SetImeActionLabel("Search", ImeAction.Search);

                    Control.EditorAction += (object sender, TextView.EditorActionEventArgs args) =>
                    {
                        entry.Unfocus();
                        if (entry.ReturnKeyClickCommand != null)
                        {
                            entry.ReturnKeyClickCommand.Execute(null);
                        }
                    };
                }
            }
        }
Ejemplo n.º 7
0
 public void SearchBarFocus(ref CustomEntry txt)
 {
     txtPais = txt;
     txt.Unfocus();
     // SearchBar.Focus();
 }
Ejemplo n.º 8
0
        private void Build()
        {
            Shell.SetFlyoutBehavior(this, FlyoutBehavior.Disabled);

            Shell.SetBackButtonBehavior(this, new BackButtonBehavior
            {
                Command = new Command(async() =>
                {
                    if (ViewModel.IsSaving)
                    {
                        toastService.ShortAlert("Aguarde a operação de salvar!");
                    }
                    else
                    {
                        await Shell.Current.Navigation.PopAsync(true);
                    }
                }),
            });

            Title = "Ata";

            var app = App.Current;
            var vm  = ViewModel = app.minuteViewModel;

            Content = new AbsoluteLayout
            {
                Children =
                {
                    // Page Content
                    new Grid
                    {
                        RowDefinitions = Rows.Define(
                            (Row.Minute, Star),
                            (Row.Banner, 50)),

                        ColumnDefinitions = Columns.Define(
                            (Col.TopicList, 70),
                            (Col.Information, Star)),

                        Children =
                        {
                            // Topic Collection
                            new CollectionView
                            {
                                BackgroundColor = Colors.Primary,

                                GestureRecognizers =
                                {
                                    new TapGestureRecognizer   {
                                    }.Invoke(c => c.Tapped += (s, e) =>
                                    {
                                        topicEntry.Unfocus();
                                    }),
                                },

                                // BODY - List of topics
                                ItemTemplate = TopicTemplate.New(vm),

                                // FOOTER - Action
                                Footer = new ContentView
                                {
                                    Padding = 5,

                                    Content = new Button       {
                                        ImageSource = Images.Add
                                    }.Standard().Round(40).Center()
                                    .Bind(nameof(vm.CreateTopic)),
                                },
                            }.VerticalListStyle().SingleSelection()
                            .Row(Row.Minute).Col(Col.TopicList)
                            .Bind(CollectionView.ItemsSourceProperty, nameof(vm.Topics))
                            .Bind(CollectionView.SelectionChangedCommandProperty, nameof(vm.SelectTopic), source: vm)
                            .Invoke(c =>
                            {
                                c.Bind(CollectionView.SelectionChangedCommandParameterProperty, nameof(CollectionView.SelectedItem), source: c);
                            }),

                            // Information Collection
                            new CollectionView
                            {
                                // BODY - List of information
                                ItemTemplate = InformationTemplate.New(vm),
                                Behaviors    =
                                {
                                    new FadingBehavior         {
                                    }
                                    .BindBehavior(FadingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool()),
                                },

                                // HEADER - Topic title with a button to delete the topic
                                Header = new ContentView
                                {
                                    Padding = 5,

                                    Content = new Frame
                                    {
                                        Padding = 5, CornerRadius = 6, BackgroundColor = Colors.Accent,

                                        Behaviors =
                                        {
                                            new MovingBehavior {
                                                MoveTo = EMoveTo.Top
                                            }
                                            .BindBehavior(MovingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool())
                                        },

                                        Content = new StackLayout
                                        {
                                            Spacing = 10, Orientation = StackOrientation.Horizontal,

                                            Children =
                                            {
                                                new Frame      {
                                                }.FramedCustomEntry(out topicEntry, Images.TextBlack).FillExpandH()
                                                .Invoke(c =>
                                                {
                                                    topicEntry.Placeholder = "Nome do tópico";
                                                    topicEntry.Bind(CustomEntry.TextProperty, $"{nameof(vm.SelectedTopic)}.{nameof(vm.SelectedTopic.Text)}");
                                                    topicEntry.Bind(CustomEntry.SaveCommandProperty, nameof(vm.SaveTopicTitle));
                                                    topicEntry.Bind(CustomEntry.IsSavingProperty, nameof(vm.IsSavingTopic), BindingMode.OneWayToSource);
                                                    topicEntry.Bind(CustomEntry.IsSavingEnabledProperty, nameof(vm.IsSavingEnabled));
                                                }),

                                                new Button     {
                                                    ImageSource = Images.Delete
                                                }.Standard().Danger().Round(40).Center()
                                                .Bind(nameof(vm.DeleteTopic)),
                                            },
                                        }
                                    }.Padding(5).SetTranslationY(-100),
                                },

                                // FOOTER - Actions
                                Footer = new ContentView
                                {
                                    Padding = 5,

                                    Content = new Button
                                    {
                                        ImageSource = Images.Add,

                                        Behaviors =
                                        {
                                            new FadingBehavior {
                                            }
                                            .BindBehavior(FadingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool()),
                                            new MovingBehavior {
                                                MoveTo = EMoveTo.End
                                            }
                                            .BindBehavior(MovingBehavior.IsActiveProperty, nameof(vm.SelectedTopic), converter: new NullToBool()),
                                        },
                                    }.Standard().Round(40).SetTranslationX(50).Right()
                                    .Bind(nameof(vm.CreateInformation)),
                                }
                            }.VerticalListStyle().SingleSelection().FillExpandV()
                            .Row(Row.Minute).Col(Col.Information)
                            .Bind(CollectionView.ItemsSourceProperty, nameof(vm.Information)),

                            new AdMobView                      {
                                AdUnitId = Constants.AdMinute
                            }
                            .Row(Row.Banner).ColSpan(2),
                        }
                    }.Standard(),