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

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

@ -12,11 +12,12 @@ public partial class EntryPopup : Popup
public void CloseButton(object sender, EventArgs e) public void CloseButton(object sender, EventArgs e)
{ {
if (!string.IsNullOrWhiteSpace(Entrytxt.Text)) Close(Entrytxt.Text); Close();
} }
private void Valider(object sender, EventArgs e) 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" ?> <?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:UserInfo="clr-namespace:Stim" xmlns:local="clr-namespace:Stim"
x:Class="Stim.ProfilPage" x:Class="Stim.ProfilPage"
Title="Profil"> Title="Profil">
<ScrollView> <ScrollView>
@ -24,14 +24,14 @@
<VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/> <VerticalStackLayout BackgroundColor="Black" Grid.Column="0" Grid.Row="1"/>
<VerticalStackLayout BackgroundColor="Black" Grid.Column="2" 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> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<VerticalStackLayout Grid.Column="0" Margin="10,0,0,0"> <VerticalStackLayout Grid.Column="0" Margin="10,0,0,0">
<Image Source="{Binding CurrentUser.UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/> <Image Source="{Binding UserImage}" HeightRequest="200" WidthRequest="200" Margin="0,0,10,0"/>
<UserInfo:UserInfo Bind="{Binding CurrentUser.Username}"/> <local:UserInfo Name="{Binding Username}" Button="0"/>
<Grid Margin="0,20,0,0"> <Grid Margin="0,20,0,0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -39,29 +39,19 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border> <Border>
<Label Text="{Binding CurrentUser.Biographie}" HeightRequest="200" HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/> <Label Text="{Binding Biographie}" HeightRequest="200" HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/>
</Border> </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 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>
<Grid Margin="0,20,0,0"> <local:UserInfo Name="{Binding Password}" Button="2" />
<Grid.ColumnDefinitions> <local:UserInfo Name="{Binding Email}" Button="3" />
<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}"/>
</VerticalStackLayout> </VerticalStackLayout>
<VerticalStackLayout Grid.Column="1" Margin="100,0,0,0"> <VerticalStackLayout Grid.Column="1" Margin="100,0,0,0">
<Label HorizontalOptions="Center" Text="Mes suivis"/> <Label HorizontalOptions="Center" Text="Mes suivis"/>
<ScrollView> <ScrollView>
<Border> <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> </Border>
</ScrollView> </ScrollView>
</VerticalStackLayout> </VerticalStackLayout>

@ -10,9 +10,12 @@
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border Margin="0,10,0,0" Padding="0"> <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> </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> </Grid>
</ContentView> </ContentView>

@ -1,28 +1,65 @@
using Microsoft.VisualBasic;
using CommunityToolkit.Maui.Views;
namespace Stim; namespace Stim;
public partial class UserInfo : ContentView 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); } get => (string)GetValue(NameProperty);
set { SetValue(BindProperty, value); } 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() public UserInfo()
{ {
InitializeComponent(); 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