Connexion fonctionne (mais faut appuyer sur Entrée) + ET OMG C'EST TROP COOL LE BINDING 🎉 -> vue SearchMob qui affiche certaines infos :) (+quelques surprises)
continuous-integration/drone/push Build is passing Details

pull/32/head
Nicolas BLONDEAU 2 years ago
parent afa14c1b14
commit 7c9beff1c5

@ -73,8 +73,14 @@ namespace Model
public List<Conseil> ListConseils { get; set; }
public string ImageLink { get; init ; }
public string CardLink { get; init; }
public Monstre(int id, string name, string danger, string desc, List<string> characList, List<string> appearList, List<Conseil> conseilList)
{
if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(desc) || string.IsNullOrWhiteSpace(danger))
{
throw new ArgumentException("Un monstre doit avoir un nom, une description et une dangerosité!");
}
Id = id;
Name = name;
Dangerosite = danger;
@ -83,11 +89,7 @@ namespace Model
AppearanceList = appearList;
ListConseils = conseilList;
ImageLink = name.ToLower() + ".png";
if (string.IsNullOrWhiteSpace(Name) || string.IsNullOrWhiteSpace(Description) || string.IsNullOrWhiteSpace(danger))
{
throw new ArgumentException("Un monstre doit avoir un nom, une description et une dangerosité!");
}
CardLink = "collection" + name.ToLower() + ".png";
}
public override string ToString()
@ -105,6 +107,6 @@ namespace Model
}
public override int GetHashCode()
=> base.GetHashCode();
=> Name.GetHashCode();
}
}

@ -13,7 +13,7 @@ namespace Model
{
/// <summary>
/// La classe User représente un utilisateur ayant pour identifiant son pseudo (publique),
/// son nom et prénom en privé, pour une utilisation ultérieure et/ou pour identifier de manière
/// son nom et prénom, pour une utilisation ultérieure et/ou pour identifier de manière
/// plus simple l'utilisateur dans la base de donnée (car un pseudo n'est pas forcément explicite)
/// </summary>
[DataContract]

@ -7,6 +7,23 @@ namespace Vues
public partial class App : Application
{
public MonsterManager monsterManager { get; private set; } = new MonsterManager(new LoaderStub());
public UserManager userManager { get; private set; } = new UserManager(new LoaderXml());
private User user;
public User User
{
get
{
return user;
}
set
{
user = value;
OnPropertyChanged("User");
}
}
private Monstre monstreSelectionne;
public Monstre MonstreSelectionne {
get
{
@ -18,7 +35,6 @@ namespace Vues
OnPropertyChanged("MonstreSelectionne");
}
}
private Monstre monstreSelectionne;
public App()
{
InitializeComponent();

@ -19,9 +19,10 @@
<FlexLayout.Resources>
<Style TargetType="Entry">
<Setter Property="WidthRequest" Value="250" />
<Setter Property="BackgroundColor" Value="{StaticResource Gray300}" />
<Setter Property="BackgroundColor" Value="{StaticResource Gray200}" />
<Setter Property="PlaceholderColor" Value="{StaticResource Gray500}" />
<Setter Property="Margin" Value="3" />
<Setter Property="Margin" Value="3"/>
<Setter Property="ClearButtonVisibility" Value="WhileEditing" />
</Style>
<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="FontSize" Value="Small" />
@ -57,11 +58,11 @@
Source="connexion.png"
HeightRequest="70"
Margin="0, 0, 0, 30" />
<Entry Placeholder="Identifiant" />
<Entry Placeholder="Mot de passe"
IsPassword="True"/>
<Entry Placeholder="Identifiant" ReturnType="Next" Completed="Id_Entry_Completed" />
<Entry Placeholder="Mot de passe" IsPassword="True" ReturnType="Done" Completed="Mdp_Entry_Completed"/>
<Button Style="{StaticResource buttonStyle}"
Text="Valider" />
Text="Valider"
Clicked="ValiderClicked"/>
</FlexLayout>
</toolkit:DockLayout>
</ContentPage>

@ -1,9 +1,38 @@
using Model;
namespace Vues;
public partial class Connexion : ContentPage
{
public Connexion()
string id;
string mdp;
public Connexion()
{
InitializeComponent();
}
BindingContext = (Application.Current as App).userManager;
}
public async void ValiderClicked(object sender, EventArgs e)
{
foreach (User u in (Application.Current as App).userManager.ListUsers)
{
if ((Application.Current as App).userManager.checkIfExists(id, mdp) && u.verifyPssw(mdp))
{
(Application.Current as App).User = u;
await Navigation.PushAsync(new SearchMob());
}
}
return;
}
private void Id_Entry_Completed(object sender, EventArgs e)
{
id = ((Entry)sender).Text;
}
private void Mdp_Entry_Completed(object sender, EventArgs e)
{
mdp = ((Entry)sender).Text;
}
}

@ -19,5 +19,4 @@ public partial class Inscription : ContentPage
userMngr.saveUsers(users);
}
}

@ -13,7 +13,7 @@
PlaceholderColor="DimGray"
CancelButtonColor="DimGray"/>
</HorizontalStackLayout>
<ListView x:Name="ListV" ItemsSource="{Binding ListMonsters}" Grid.Row="1" ItemTapped="OnClick">
<ListView x:Name="ListViewMonsters" ItemsSource="{Binding ListMonsters}" Grid.Row="1" ItemTapped="OnClick">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
@ -25,20 +25,22 @@
</ListView.ItemTemplate>
</ListView>
</Grid>
<Grid Grid.Column="1" RowDefinitions="*,*,*,*" BindingContext="{Binding SelectedItem, Source={x:Reference ListV}}">
<Label Text="{Binding Name}"/>
<HorizontalStackLayout>
<!-- Image du mob -->
<Image Source="{Binding ImageLink}" MaximumHeightRequest="400"/>
<!-- Caractéristiques -->
<Frame Margin="40">
<ScrollView Grid.Column="1">
<Grid Grid.Column="1" RowDefinitions="Auto,*,*,*" BindingContext="{Binding SelectedItem, Source={x:Reference ListViewMonsters}}">
<Grid Grid.Row="0" ColumnDefinitions="*,Auto" Padding="25" BackgroundColor="LightBlue">
<!-- Caractéristiques -->
<Label
BackgroundColor="DarkSalmon"
HorizontalTextAlignment="Center" VerticalTextAlignment="Center"
Grid.Column="0"
Text="{Binding Description, StringFormat=Description : \{0\}}"
FontSize="Medium">
</Label>
</Frame>
</HorizontalStackLayout>
</Grid>
<!-- Image du mob -->
<Image Grid.Column="1" Source="{Binding CardLink}" HeightRequest="600"/>
</Grid>
</Grid>
</ScrollView>
</Grid>
</ContentPage>

@ -8,7 +8,6 @@ public partial class SearchMob : ContentPage
{
InitializeComponent();
BindingContext = (Application.Current as App).monsterManager;
}
public void OnClick(object sender, ItemTappedEventArgs e)

Loading…
Cancel
Save