Add (Vu_homePage): Ajout d'une collection

pull/2/head
Louis DUFOUR 2 years ago
parent 69eed3e9cb
commit 49f6ebecb7

@ -13,21 +13,35 @@
</ToolbarItem>
</ContentPage.ToolbarItems>
<Grid>
<StackLayout>
<Label>Mes livres</Label>
<StackLayout>
<Button Text="Click to Rotate Text!"
VerticalOptions="Center"
HorizontalOptions="Center"
Clicked="OnButtonClicked" />
<Label x:Name="label"
Text="Click the Button above"
FontSize="18"
VerticalOptions="Center"
HorizontalOptions="Center" />
</StackLayout>
</Grid>
<CollectionView ItemsSource="{Binding MyCollections}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="0" RowDefinitions="Auto">
<Image Source="{Binding Icone}"
HeightRequest="60"
WidthRequest="60" />
<Label Text="{Binding Name}"
FontAttributes="Bold" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<Button Text="Click to Rotate Text!"
VerticalOptions="Center"
HorizontalOptions="Center"
Clicked="OnButtonClicked" />
</StackLayout>
<!--Pour l'opti on peut préciser le type du bind en aller tout en haut du fichier et faisent x:class ...-->
</ContentPage>

@ -1,30 +1,35 @@
namespace BookApp
using System.Collections.ObjectModel;
namespace BookApp
{
public partial class MainPage : ContentPage
{
//int count = 0;
public class ObjetTemp
{
public string Name { get; set; }
public string Icone { get; set; }
public ObjetTemp(string name, string icone) { Name = name; Icone = icone; }
}
public ObservableCollection<ObjetTemp> MyCollections { get; set; }
public MainPage()
{
InitializeComponent();
MyCollections = new ObservableCollection<ObjetTemp>()
{
new ObjetTemp("Item1", "./Reources/Images/books_vertical_fill.svg"),
new ObjetTemp("Item1", "./Reources/Images/books_vertical_fill.svg"),
new ObjetTemp("Item1", "./Reources/Images/books_vertical_fill.svg"),
new ObjetTemp("Item1", "./Reources/Images/books_vertical_fill.svg"),
};
BindingContext = this;
}
async void OnButtonClicked(object sender, EventArgs args)
{
await Shell.Current.GoToAsync(nameof(Tous));
}
/*
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
if (count == 1)
CounterBtn.Text = $"Clicked {count} time";
else
CounterBtn.Text = $"Clicked {count} times";
SemanticScreenReader.Announce(CounterBtn.Text);
}*/
}
}

@ -0,0 +1,3 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 9.66797C0 10.2422 0.480469 10.7109 1.04297 10.7109H8.625V18.293C8.625 18.8555 9.09375 19.3359 9.66797 19.3359C10.2422 19.3359 10.7227 18.8555 10.7227 18.293V10.7109H18.293C18.8555 10.7109 19.3359 10.2422 19.3359 9.66797C19.3359 9.09375 18.8555 8.61328 18.293 8.61328H10.7227V1.04297C10.7227 0.480469 10.2422 0 9.66797 0C9.09375 0 8.625 0.480469 8.625 1.04297V8.61328H1.04297C0.480469 8.61328 0 9.09375 0 9.66797Z" fill="black" fill-opacity="0.85"/>
</svg>

After

Width:  |  Height:  |  Size: 564 B

@ -4,7 +4,7 @@
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<Color x:Key="Primary">#512BD4</Color>
<Color x:Key="Primary">red</Color>
<Color x:Key="Secondary">#DFD8F7</Color>
<Color x:Key="Tertiary">#2B0B98</Color>
<Color x:Key="White">White</Color>

@ -377,7 +377,7 @@
</Style>
<Style TargetType="Shell" ApplyToDerivedTypes="True">
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource Gray950}}" />
<Setter Property="Shell.BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Gray950}}" />
<Setter Property="Shell.ForegroundColor" Value="{OnPlatform WinUI={StaticResource Primary}, Default={StaticResource White}}" />
<Setter Property="Shell.TitleColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource White}}" />
<Setter Property="Shell.DisabledColor" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray950}}" />

Loading…
Cancel
Save