From cac7a613a7209b12f91ad8a8914eebf131ec1fd3 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Thu, 10 Sep 2020 16:14:54 -0500 Subject: [PATCH] Double tap to edit number/name now working --- .../Classes/UI/QSelectedCueGrid.cs | 63 +++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/qController.Standard/Classes/UI/QSelectedCueGrid.cs b/qController.Standard/Classes/UI/QSelectedCueGrid.cs index 819b165..afd02a6 100644 --- a/qController.Standard/Classes/UI/QSelectedCueGrid.cs +++ b/qController.Standard/Classes/UI/QSelectedCueGrid.cs @@ -1,4 +1,5 @@ using Acr.UserDialogs; +using qController.ViewModels; using Xamarin.Forms; namespace qController.UI @@ -34,9 +35,10 @@ namespace qController.UI Label number = new Label { - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.FillAndExpand, + HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, + VerticalTextAlignment = TextAlignment.Center, Margin = 0, Padding = 0, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)) @@ -61,11 +63,14 @@ namespace qController.UI Label name = new Label { - VerticalOptions = LayoutOptions.CenterAndExpand, - HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.FillAndExpand, + HorizontalOptions = LayoutOptions.FillAndExpand, + HorizontalTextAlignment = TextAlignment.Center, + VerticalTextAlignment = TextAlignment.Center, + BackgroundColor = Color.Transparent, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)) }; - name.SetBinding(Label.TextProperty, "name", BindingMode.OneWay); + name.SetBinding(Label.TextProperty, "name", BindingMode.TwoWay); Children.Add(name, 0, 1); SetColumnSpan(name, 5); @@ -82,6 +87,54 @@ namespace qController.UI Children.Add(notes, 0, 2); SetColumnSpan(notes, 5); + //Double tap to edit name/number + + var nameDoubleTap = new TapGestureRecognizer(); + nameDoubleTap.NumberOfTapsRequired = 2; + + nameDoubleTap.Tapped += (s, e) => + { + UserDialogs.Instance.Prompt(new PromptConfig + { + Title = "Update Name", + Message = "Change name to update", + OkText = "Update", + Text = name.Text, + OnAction = (qName) => + { + if (!qName.Ok) + return; + name.Text = qName.Text; + } + }); + }; + + name.GestureRecognizers.Add(nameDoubleTap); + + var numberDoubleTap = new TapGestureRecognizer(); + numberDoubleTap.NumberOfTapsRequired = 2; + + numberDoubleTap.Tapped += (s, e) => + { + UserDialogs.Instance.Prompt(new PromptConfig + { + Title = "Update Number", + Message = "Change number to update", + OkText = "Update", + Text = number.Text, + OnAction = (qNumber) => + { + if (!qNumber.Ok) + return; + //This bypasses the label .Text property because the number might not be valid (no duplicates) + ((QCueViewModel)BindingContext).number = qNumber.Text; + } + }); + }; + + number.GestureRecognizers.Add(numberDoubleTap); + + } } }