mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-11-01 16:05:42 +00:00
Popup 3 boutons
This commit is contained in:
parent
e8852bb569
commit
1ad8da9fd3
5 changed files with 56 additions and 13 deletions
|
|
@ -31,7 +31,7 @@ namespace AideDeJeu.Droid
|
||||||
if (Rg.Plugins.Popup.Popup.SendBackPressed(base.OnBackPressed))
|
if (Rg.Plugins.Popup.Popup.SendBackPressed(base.OnBackPressed))
|
||||||
{
|
{
|
||||||
// Do something if there are some pages in the `PopupStack`
|
// Do something if there are some pages in the `PopupStack`
|
||||||
Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAsync();
|
//Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopAsync();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ namespace AideDeJeu.ViewModels
|
||||||
}
|
}
|
||||||
else if(BookmarkCollectionIndex == BookmarkCollectionNames.Count - 1)
|
else if(BookmarkCollectionIndex == BookmarkCollectionNames.Count - 1)
|
||||||
{
|
{
|
||||||
await Main.Navigator.OpenCancellableTextInputAlertDialog("");
|
var result = await Main.Navigator.OpenCancellableTextInputAlertDialog("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,7 +159,11 @@ namespace AideDeJeu.ViewModels
|
||||||
|
|
||||||
private async Task ExecuteConfigureCommand()
|
private async Task ExecuteConfigureCommand()
|
||||||
{
|
{
|
||||||
await Main.Navigator.OpenCancellableTextInputAlertDialog(BookmarkCollectionNames[BookmarkCollectionIndex]);
|
var result = await Main.Navigator.OpenCancellableTextInputAlertDialog(BookmarkCollectionNames[BookmarkCollectionIndex]);
|
||||||
|
if (result.Item2 == Navigator.PopupResultEnum.Delete)
|
||||||
|
{
|
||||||
|
var confirm = await App.Current.MainPage.DisplayAlert("Supprimer ?", "Etes vous sûr de vouloir supprimer la liste ?", "Supprimer", "Annuler");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using AideDeJeu.Views;
|
using AideDeJeu.Views;
|
||||||
using AideDeJeuLib;
|
using AideDeJeuLib;
|
||||||
using Rg.Plugins.Popup.Services;
|
using Rg.Plugins.Popup.Services;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
@ -207,16 +208,21 @@ namespace AideDeJeu.ViewModels
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public enum PopupResultEnum
|
||||||
public async Task<string> OpenCancellableTextInputAlertDialog(string inputText)
|
{
|
||||||
|
Save,
|
||||||
|
Cancel,
|
||||||
|
Delete
|
||||||
|
}
|
||||||
|
public async Task<Tuple<string, PopupResultEnum>> OpenCancellableTextInputAlertDialog(string inputText)
|
||||||
{
|
{
|
||||||
// create the TextInputView
|
// create the TextInputView
|
||||||
var inputView = new TextInputCancellableView(
|
var inputView = new TextInputCancellableView(
|
||||||
"Nom de la liste ?", "Nouveau nom...", inputText, "Enregistrer", "Annuler", "Le nom ne peut pas être vide.");
|
"Nom de la liste ?", "Nouveau nom...", inputText, "Enregistrer", "Annuler", "Supprimer", "Le nom ne peut pas être vide.");
|
||||||
|
|
||||||
// create the Transparent Popup Page
|
// create the Transparent Popup Page
|
||||||
// of type string since we need a string return
|
// of type string since we need a string return
|
||||||
var popup = new InputAlertDialogBase<string>(inputView);
|
var popup = new InputAlertDialogBase<Tuple<string, PopupResultEnum>>(inputView);
|
||||||
|
|
||||||
|
|
||||||
// subscribe to the TextInputView's Button click event
|
// subscribe to the TextInputView's Button click event
|
||||||
|
|
@ -226,7 +232,7 @@ namespace AideDeJeu.ViewModels
|
||||||
if (!string.IsNullOrEmpty(((TextInputCancellableView)sender).TextInputResult))
|
if (!string.IsNullOrEmpty(((TextInputCancellableView)sender).TextInputResult))
|
||||||
{
|
{
|
||||||
((TextInputCancellableView)sender).IsValidationLabelVisible = false;
|
((TextInputCancellableView)sender).IsValidationLabelVisible = false;
|
||||||
popup.PageClosedTaskCompletionSource.SetResult(((TextInputCancellableView)sender).TextInputResult);
|
popup.PageClosedTaskCompletionSource.SetResult(new Tuple<string, PopupResultEnum>(((TextInputCancellableView)sender).TextInputResult, PopupResultEnum.Save));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -238,7 +244,13 @@ namespace AideDeJeu.ViewModels
|
||||||
inputView.CancelButtonEventHandler +=
|
inputView.CancelButtonEventHandler +=
|
||||||
(sender, obj) =>
|
(sender, obj) =>
|
||||||
{
|
{
|
||||||
popup.PageClosedTaskCompletionSource.SetResult(null);
|
popup.PageClosedTaskCompletionSource.SetResult(new Tuple<string, PopupResultEnum>(null, PopupResultEnum.Cancel));
|
||||||
|
};
|
||||||
|
|
||||||
|
inputView.DeleteButtonEventHandler +=
|
||||||
|
(sender, obj) =>
|
||||||
|
{
|
||||||
|
popup.PageClosedTaskCompletionSource.SetResult(new Tuple<string, PopupResultEnum>(null, PopupResultEnum.Delete));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Push the page to Navigation Stack
|
// Push the page to Navigation Stack
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,22 @@
|
||||||
<Entry x:Name="InputEntry" Placeholder="Enter Here..." />
|
<Entry x:Name="InputEntry" Placeholder="Enter Here..." />
|
||||||
<Grid>
|
<Grid>
|
||||||
<Button
|
<Button
|
||||||
x:Name="SaveButton"
|
x:Name="DeleteButton"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
|
BackgroundColor="Red"
|
||||||
|
Text="Supprimer"
|
||||||
|
TextColor="White">
|
||||||
|
<Button.HeightRequest>
|
||||||
|
<OnPlatform x:TypeArguments="x:Double">
|
||||||
|
<On Platform="Android" Value="40" />
|
||||||
|
<On Platform="iOS" Value="30" />
|
||||||
|
<On Platform="UWP, Windows" Value="35" />
|
||||||
|
</OnPlatform>
|
||||||
|
</Button.HeightRequest>
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
x:Name="SaveButton"
|
||||||
|
Grid.Column="1"
|
||||||
BackgroundColor="DodgerBlue"
|
BackgroundColor="DodgerBlue"
|
||||||
Text="Save"
|
Text="Save"
|
||||||
TextColor="White">
|
TextColor="White">
|
||||||
|
|
@ -38,7 +52,9 @@
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
x:Name="CancelButton"
|
x:Name="CancelButton"
|
||||||
Grid.Column="1"
|
Grid.Column="0"
|
||||||
|
Grid.ColumnSpan="2"
|
||||||
|
Grid.Row="1"
|
||||||
BackgroundColor="Gray"
|
BackgroundColor="Gray"
|
||||||
Text="Cancel"
|
Text="Cancel"
|
||||||
TextColor="White">
|
TextColor="White">
|
||||||
|
|
@ -52,6 +68,7 @@
|
||||||
</Button>
|
</Button>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ namespace AideDeJeu.Views
|
||||||
// the Cancel button's click event
|
// the Cancel button's click event
|
||||||
public EventHandler CancelButtonEventHandler { get; set; }
|
public EventHandler CancelButtonEventHandler { get; set; }
|
||||||
|
|
||||||
|
public EventHandler DeleteButtonEventHandler { get; set; }
|
||||||
|
|
||||||
// public string to expose the
|
// public string to expose the
|
||||||
// text Entry input's value
|
// text Entry input's value
|
||||||
public string TextInputResult { get; set; }
|
public string TextInputResult { get; set; }
|
||||||
|
|
@ -60,21 +62,23 @@ namespace AideDeJeu.Views
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextInputCancellableView(string titleText, string placeHolderText, string inputText,
|
public TextInputCancellableView(string titleText, string placeHolderText, string inputText,
|
||||||
string saveButtonText, string cancelButtonText, string validationText)
|
string saveButtonText, string cancelButtonText, string deleteButtonText, string validationText)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
// update the Element's textual values
|
// update the Element's textual values
|
||||||
TitleLabel.Text = titleText;
|
TitleLabel.Text = titleText;
|
||||||
InputEntry.Text = inputText;
|
TextInputResult = InputEntry.Text = inputText;
|
||||||
InputEntry.Placeholder = placeHolderText;
|
InputEntry.Placeholder = placeHolderText;
|
||||||
SaveButton.Text = saveButtonText;
|
SaveButton.Text = saveButtonText;
|
||||||
CancelButton.Text = cancelButtonText;
|
CancelButton.Text = cancelButtonText;
|
||||||
|
DeleteButton.Text = deleteButtonText;
|
||||||
ValidationLabel.Text = validationText;
|
ValidationLabel.Text = validationText;
|
||||||
|
|
||||||
// handling events to expose to public
|
// handling events to expose to public
|
||||||
SaveButton.Clicked += SaveButton_Clicked;
|
SaveButton.Clicked += SaveButton_Clicked;
|
||||||
CancelButton.Clicked += CancelButton_Clicked;
|
CancelButton.Clicked += CancelButton_Clicked;
|
||||||
|
DeleteButton.Clicked += DeleteButton_Clicked;
|
||||||
InputEntry.TextChanged += InputEntry_TextChanged;
|
InputEntry.TextChanged += InputEntry_TextChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,6 +94,12 @@ namespace AideDeJeu.Views
|
||||||
CancelButtonEventHandler?.Invoke(this, e);
|
CancelButtonEventHandler?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeleteButton_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// invoke the event handler if its being subscribed
|
||||||
|
DeleteButtonEventHandler?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
private void InputEntry_TextChanged(object sender,
|
private void InputEntry_TextChanged(object sender,
|
||||||
TextChangedEventArgs e)
|
TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue