Feat : BindingProperty popup =>Marche pas sur contentview ?
continuous-integration/drone/push Build was killed Details

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 313f69f1de
commit 5abc2e945a

@ -11,7 +11,7 @@ namespace Model
public sealed class User : INotifyPropertyChanged , IEquatable<User>
{
[DataMember]
public string? Username
public string Username
{
get => username;
set
@ -29,7 +29,7 @@ namespace Model
public string Biographie
{
get => biographie ?? "Pas de biographie";
private set
set
{
if (string.IsNullOrWhiteSpace(value)) biographie = "Pas de biographie";
else
@ -44,7 +44,7 @@ namespace Model
public string Email
{
get => email;
private set
set
{
Regex rg_email = new Regex("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$");
if (!(string.IsNullOrWhiteSpace(value)) && rg_email.IsMatch(value))
@ -60,7 +60,7 @@ namespace Model
public string Password
{
get => password;
private set
set
{
Regex rg = new Regex("^(?=.*[A-Za-z])(?=.*[0-9@$!%*#?&])[A-Za-z-0-9@$!%*#?&]{8,}$");
if (string.IsNullOrWhiteSpace(value) || !rg.IsMatch(value)) throw new ArgumentNullException(value);
@ -167,5 +167,6 @@ namespace Model
foreach (Game game in Followed_Games) builder.Append($"{game.Name}\n");
return builder.ToString();
}
}
}

@ -10,6 +10,7 @@
<Entry Grid.Row="1" x:Name="Entrytxt"/>
<Button Grid.Row="2" Text="Valider" HorizontalOptions="Center" VerticalOptions="End" Background="{StaticResource Transparent}" Clicked="Valider"/>
<Button Grid.Row="3" Text="Annuler" HorizontalOptions="Center" VerticalOptions="End" Background="{StaticResource Transparent}" Clicked="CloseButton"/>
<HorizontalStackLayout x:Name="Error"></HorizontalStackLayout>
</Grid>
</VerticalStackLayout>
</toolkit:Popup>

@ -12,11 +12,12 @@ public partial class EntryPopup : Popup
public void CloseButton(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Entrytxt.Text)) Close(Entrytxt.Text);
Close();
}
private void Valider(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(Entrytxt.Text)) Close(Entrytxt.Text);
else Error.Children.Add(new Label { Text="Champ vide", TextColor=Colors.Red });
}
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:UserInfo="clr-namespace:Stim"
xmlns:local="clr-namespace:Stim"
x:Class="Stim.ProfilPage"
Title="Profil">
<ScrollView>
@ -24,14 +24,14 @@
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" Grid.Row="1"/>
<Grid Grid.Column="1" Grid.Row="1" Margin="0,10,100,0">
<Grid Grid.Column="1" Grid.Row="1" Margin="0,10,100,0" BindingContext="{Binding CurrentUser}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Column="0" Margin="10,0,0,0">
<Image Source="{Binding CurrentUser.UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/>
<UserInfo:UserInfo Bind="{Binding CurrentUser.Username}"/>
<Image Source="{Binding UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/>
<local:UserInfo Name="{Binding Username}" Button="0"/>
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
@ -39,29 +39,19 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border>
<Label Text="{Binding CurrentUser.Biographie}" HeightRequest="200" HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/>
<Label Text="{Binding Biographie}" HeightRequest="200" HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/>
</Border>
<Button ImageSource="pen.png" Grid.Column="1" MaximumHeightRequest="32" MaximumWidthRequest="32" Padding="0,0,0,0" Margin="5,0,0,0" BackgroundColor="{StaticResource Gray500}"></Button>
</Grid>
<Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Margin="0,10,0,0" Padding="0">
<Label Text="**********"/>
</Border>
<Button ImageSource="pen.png" Grid.Column="1" MaximumHeightRequest="32" MaximumWidthRequest="32" Padding="0,0,0,0" Margin="5,0,0,0" BackgroundColor="{StaticResource Gray500}"></Button>
</Grid>
<UserInfo:UserInfo Bind="{Binding CurrentUser.Email}"/>
<local:UserInfo Name="{Binding Password}" Button="2" />
<local:UserInfo Name="{Binding Email}" Button="3" />
</VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" Margin="100,0,0,0">
<Label HorizontalOptions="Center" Text="Mes suivis"/>
<ScrollView>
<Border>
<CollectionView ItemsSource="{Binding CurrentUser.Followed_Games}" SelectionMode="Single" SelectionChanged="CollectionView_SelectionChanged" ItemTemplate="{StaticResource followLoginTemplate}"/>
<CollectionView ItemsSource="{Binding Followed_Games}" SelectionMode="Single" SelectionChanged="CollectionView_SelectionChanged" ItemTemplate="{StaticResource followLoginTemplate}"/>
</Border>
</ScrollView>
</VerticalStackLayout>

@ -10,9 +10,12 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Margin="0,10,0,0" Padding="0">
<Label Text="{Binding Path=Bind, Source={x:Reference userInfoView}}" />
<Label Text="{Binding Name, Source={x:Reference userInfoView}}" />
</Border>
<Button ImageSource="pen.png" Grid.Column="1" MaximumHeightRequest="32" MaximumWidthRequest="32" Padding="0,0,0,0" Margin="5,0,0,0" BackgroundColor="{StaticResource Gray500}"></Button>
<Button Clicked="Modif" ImageSource="pen.png" Grid.Column="1"
MaximumHeightRequest="32" MaximumWidthRequest="32"
Padding="0,0,0,0" Margin="5,0,0,0"
BackgroundColor="{StaticResource Gray500}" />
</Grid>
</ContentView>

@ -1,28 +1,65 @@
using Microsoft.VisualBasic;
using CommunityToolkit.Maui.Views;
namespace Stim;
public partial class UserInfo : ContentView
{
public static readonly BindableProperty BindProperty =
BindableProperty.Create(nameof(Bind), typeof(string), typeof(UserInfo), string.Empty, propertyChanged: OnBindChanged);
public string Bind
public string Name
{
get { return (string)GetValue(BindProperty); }
set { SetValue(BindProperty, value); }
get => (string)GetValue(NameProperty);
set => SetValue(NameProperty, value);
}
public static readonly BindableProperty NameProperty =
BindableProperty.Create(nameof(Name), typeof(string), typeof(UserInfo), "Erreur");
private static void OnBindChanged(BindableObject bindable, object oldValue, object newValue)
public int Button
{
var contentView = (UserInfo)bindable;
get => (int)GetValue(ButtonProperty);
set => SetValue(ButtonProperty, value);
}
public static readonly BindableProperty ButtonProperty =
BindableProperty.Create(nameof(Button), typeof(int), typeof(UserInfo), 4);
public UserInfo()
{
InitializeComponent();
BindingContext = ((App)App.Current).Manager;
}
private void Button_Clicked(object sender, EventArgs e)
private async void Modif(object sender, EventArgs e)
{
if (Button == 0)
{
var result = await this.ShowPopupAsync(new EntryPopup("Username"));
if (string.IsNullOrWhiteSpace(result))
{
((App)App.Current).Manager.CurrentUser.Username = result;
}
}
else if (Button == 1)
{
var result = await this.(new EntryPopup("Username"));
if (string.IsNullOrWhiteSpace(result))
{
((App)App.Current).Manager.CurrentUser.Username = result;
}
}
else if (Button == 2)
{
var result = await this.(new EntryPopup("Password"));
if (string.IsNullOrWhiteSpace(result))
{
((App)App.Current).Manager.CurrentUser.Password = result;
}
}
else if (Button == 3)
{
var result = await this.(new EntryPopup("Email"));
if (string.IsNullOrWhiteSpace(result))
{
((App)App.Current).Manager.CurrentUser.Email = result;
}
}
else throw new ArgumentOutOfRangeException();
}
}
}
Loading…
Cancel
Save