Ajout d'une interface pour empecher l'ouverture de pluseiurs page quand on spam un bouton + ajout de son dans l'app (marche qu'avec chemin absolu pour l'instant)

code
Vivien DUFOUR 2 years ago
parent 7d53cc8e20
commit bef54b51da

@ -9,20 +9,10 @@
<TabBar>
<ShellContent
Title="Accueil"
ContentTemplate="{DataTemplate views:Accueil}"
Route="Accueil" />
<ShellContent
Title="Favoris"
ContentTemplate="{DataTemplate views:Favoris}"
Route="Favoris" />
<ShellContent
Title="Partition"
ContentTemplate="{DataTemplate views:Partition}"
Route="Partition" />
<ShellContent
Title="Accueil"
ContentTemplate="{DataTemplate views:Accueil}"
Route="Accueil" />
</TabBar>

@ -67,14 +67,15 @@
Margin="0,5,0,0"
VerticalOptions="Start"
HorizontalOptions="End"
Clicked="GoToFavoris"
Clicked="GoToFavorisButton"
/>
<Rectangle Grid.Row="1" Grid.Column="0"
<Button Grid.Row="1" Grid.Column="0"
WidthRequest="75"
HeightRequest="75"
BackgroundColor="Blue" />
BackgroundColor="Blue"
Clicked="GoToPartitionButton"/>
</Grid>
</ScrollView>

@ -1,14 +1,29 @@
namespace ViewsApp.Views;
public partial class Accueil : ContentPage
public partial class Accueil : ContentPage, IAllowClick
{
public Accueil()
{
InitializeComponent();
}
private void GoToFavoris(object sender, EventArgs e)
private void GoToFavorisButton(object sender, EventArgs e)
{
if (!IAllowClick.AllowTap) return;
else IAllowClick.AllowTap = false;
Navigation.PushAsync(new Favoris());
IAllowClick.ResumeTap();
}
private void GoToPartitionButton(object sender, EventArgs e)
{
if (!IAllowClick.AllowTap) return;
else IAllowClick.AllowTap = false;
Navigation.PushAsync(new Partition());
IAllowClick.ResumeTap();
}
}

@ -35,7 +35,7 @@
HeightRequest="60"
VerticalOptions="Start"
HorizontalOptions="Start"
Clicked="GoToAccueilByLogo"
Clicked="GoToAccueilByLogoButton"
/>
<SearchBar Grid.Row="0" Grid.Column="1"
@ -72,10 +72,11 @@
<Rectangle Grid.Row="1" Grid.Column="0"
WidthRequest="75"
HeightRequest="75"
BackgroundColor="Blue"/>
<Button Grid.Row="1" Grid.Column="0"
WidthRequest="75"
HeightRequest="75"
BackgroundColor="Blue"
Clicked="GoToPartitionButton"/>
</Grid>
</ScrollView>

@ -1,14 +1,31 @@
namespace ViewsApp.Views;
public partial class Favoris : ContentPage
public partial class Favoris : ContentPage, IAllowClick
{
public Favoris()
{
InitializeComponent();
}
private void GoToAccueilByLogo(object sender, EventArgs e)
private void GoToAccueilByLogoButton(object sender, EventArgs e)
{
Navigation.PushAsync(new Accueil());
if (!IAllowClick.AllowTap) return;
else IAllowClick.AllowTap = false;
Navigation.PopAsync();
IAllowClick.ResumeTap();
}
private void GoToPartitionButton(object sender, EventArgs e)
{
if (!IAllowClick.AllowTap) return;
else IAllowClick.AllowTap = false;
Navigation.PushAsync(new Partition());
IAllowClick.ResumeTap();
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ViewsApp.Views
{
public interface IAllowClick
{
public static bool AllowTap = true;
public static async void ResumeTap()
{
await Task.Delay(500);
AllowTap = true;
}
}
}

@ -21,5 +21,7 @@
</ListView.ItemTemplate>
</ListView>
<Button Text="Musique" Clicked="Button_Clicked"/>
</VerticalStackLayout>
</ContentPage>

@ -1,5 +1,7 @@
using System.Diagnostics;
using ViewsApp.Model;
namespace ViewsApp.Views;
public partial class Partition : ContentPage
@ -12,7 +14,15 @@ public partial class Partition : ContentPage
InitializeComponent();
listUtil.BindingContext = MyManager;
}
}
private void Button_Clicked(object sender, EventArgs e)
{
var player = new Windows.Media.Playback.MediaPlayer();
var uri = new Uri($"C:/Users/Utilisateur/Documents/Cours/SAE/SAE_201/ViewsApp/ViewsApp/Resources/Raw/au_clair_de_la_lune.mp3");
player.SetUriSource(uri);
player.Volume = 0.5;
player.Play();
}
}
Loading…
Cancel
Save