mirror of
https://github.com/jwetzell/qController.git
synced 2026-08-05 23:43:49 +00:00
Double tap to edit number/name now working
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user