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

@ -7,22 +7,12 @@
xmlns:views="clr-namespace:ViewsApp.Views" xmlns:views="clr-namespace:ViewsApp.Views"
Shell.FlyoutBehavior="Disabled"> Shell.FlyoutBehavior="Disabled">
<TabBar> <TabBar>
<ShellContent
Title="Accueil"
ContentTemplate="{DataTemplate views:Accueil}"
Route="Accueil" />
<ShellContent
Title="Favoris" <ShellContent
ContentTemplate="{DataTemplate views:Favoris}" Title="Accueil"
Route="Favoris" /> ContentTemplate="{DataTemplate views:Accueil}"
Route="Accueil" />
<ShellContent
Title="Partition"
ContentTemplate="{DataTemplate views:Partition}"
Route="Partition" />
</TabBar> </TabBar>

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

@ -1,14 +1,29 @@
namespace ViewsApp.Views; namespace ViewsApp.Views;
public partial class Accueil : ContentPage public partial class Accueil : ContentPage, IAllowClick
{ {
public Accueil() public Accueil()
{ {
InitializeComponent(); 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()); 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" HeightRequest="60"
VerticalOptions="Start" VerticalOptions="Start"
HorizontalOptions="Start" HorizontalOptions="Start"
Clicked="GoToAccueilByLogo" Clicked="GoToAccueilByLogoButton"
/> />
<SearchBar Grid.Row="0" Grid.Column="1" <SearchBar Grid.Row="0" Grid.Column="1"
@ -72,10 +72,11 @@
<Rectangle Grid.Row="1" Grid.Column="0" <Button Grid.Row="1" Grid.Column="0"
WidthRequest="75" WidthRequest="75"
HeightRequest="75" HeightRequest="75"
BackgroundColor="Blue"/> BackgroundColor="Blue"
Clicked="GoToPartitionButton"/>
</Grid> </Grid>
</ScrollView> </ScrollView>

@ -1,14 +1,31 @@
namespace ViewsApp.Views; namespace ViewsApp.Views;
public partial class Favoris : ContentPage public partial class Favoris : ContentPage, IAllowClick
{ {
public Favoris() public Favoris()
{ {
InitializeComponent(); 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;
}
}
}

@ -20,6 +20,8 @@
</DataTemplate> </DataTemplate>
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView> </ListView>
<Button Text="Musique" Clicked="Button_Clicked"/>
</VerticalStackLayout> </VerticalStackLayout>
</ContentPage> </ContentPage>

@ -1,5 +1,7 @@
using System.Diagnostics;
using ViewsApp.Model; using ViewsApp.Model;
namespace ViewsApp.Views; namespace ViewsApp.Views;
public partial class Partition : ContentPage public partial class Partition : ContentPage
@ -12,7 +14,15 @@ public partial class Partition : ContentPage
InitializeComponent(); InitializeComponent();
listUtil.BindingContext = MyManager; 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