mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Séparation ItemsPage / FilteredItemsPage
This commit is contained in:
		
							parent
							
								
									73a3cc5982
								
							
						
					
					
						commit
						f8e5423d8f
					
				
					 7 changed files with 184 additions and 94 deletions
				
			
		|  | @ -39,6 +39,9 @@ | |||
|     <Compile Update="Views\ItemDetailPage.xaml.cs"> | ||||
|       <DependentUpon>ItemDetailPage.xaml</DependentUpon> | ||||
|     </Compile> | ||||
|     <Compile Update="Views\FilteredItemsPage.xaml.cs"> | ||||
|       <DependentUpon>FilteredItemsPage.xaml</DependentUpon> | ||||
|     </Compile> | ||||
|     <Compile Update="Views\ItemsPage.xaml.cs"> | ||||
|       <DependentUpon>ItemsPage.xaml</DependentUpon> | ||||
|     </Compile> | ||||
|  |  | |||
|  | @ -81,8 +81,15 @@ namespace AideDeJeu.ViewModels | |||
|                         { | ||||
|                             var itemsViewModel = new ItemsViewModel() { AllItems = items }; | ||||
|                             itemsViewModel.LoadItemsCommand.Execute(null); | ||||
|                             if (items.GetNewFilterViewModel() == null) | ||||
|                             { | ||||
|                                 await Navigator.GotoItemsPageAsync(itemsViewModel); | ||||
|                             } | ||||
|                             else | ||||
|                             { | ||||
|                                 await Navigator.GotoFilteredItemsPageAsync(itemsViewModel); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|  |  | |||
|  | @ -42,5 +42,13 @@ namespace AideDeJeu.ViewModels | |||
|             await Navigation.PushAsync(new ItemsPage(itemsVM)); | ||||
|         } | ||||
| 
 | ||||
|         public async Task GotoFilteredItemsPageAsync(ItemsViewModel itemsVM) | ||||
|         { | ||||
|             if (itemsVM == null) | ||||
|                 return; | ||||
| 
 | ||||
|             await Navigation.PushAsync(new FilteredItemsPage(itemsVM)); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| } | ||||
|  |  | |||
							
								
								
									
										70
									
								
								AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,70 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <MasterDetailPage  | ||||
|     xmlns="http://xamarin.com/schemas/2014/forms"  | ||||
|     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  | ||||
|     xmlns:local="clr-namespace:AideDeJeu.Views"  | ||||
|     xmlns:tools="clr-namespace:AideDeJeu.Tools"  | ||||
|     x:Class="AideDeJeu.Views.FilteredItemsPage"  | ||||
|     x:Name="This"  | ||||
|     IsPresented="False"  | ||||
|     Title="{Binding Title}"> | ||||
|     <MasterDetailPage.ToolbarItems> | ||||
|         <ToolbarItem Name="About" Text="À propos de..." Order="Secondary" Icon="wooden_sign.png" Command="{Binding Main.AboutCommand}" /> | ||||
|     </MasterDetailPage.ToolbarItems> | ||||
|     <MasterDetailPage.Resources> | ||||
|         <ResourceDictionary> | ||||
|         </ResourceDictionary> | ||||
|     </MasterDetailPage.Resources> | ||||
|     <MasterDetailPage.Master> | ||||
|         <ContentPage Title=" "> | ||||
|             <StackLayout Orientation="Vertical"> | ||||
|                 <ListView SelectionMode="None" ItemsSource="{Binding Filter.Filters}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" > | ||||
|                     <ListView.ItemTemplate> | ||||
|                         <DataTemplate> | ||||
|                             <ViewCell> | ||||
|                                 <ViewCell.View> | ||||
|                                     <StackLayout Margin="10,5,10,0" Padding="0" Spacing="0"> | ||||
|                                         <Label BindingContext="{Binding}" Text="{Binding Name}" Style="{StaticResource Key=subsubsection}" /> | ||||
|                                         <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding KeyValues, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Index}" /> | ||||
|                                     </StackLayout> | ||||
|                                 </ViewCell.View> | ||||
|                             </ViewCell> | ||||
|                         </DataTemplate> | ||||
|                     </ListView.ItemTemplate> | ||||
|                 </ListView> | ||||
|             </StackLayout> | ||||
|         </ContentPage> | ||||
|     </MasterDetailPage.Master> | ||||
|     <MasterDetailPage.Detail> | ||||
|         <ContentPage Title=""> | ||||
|             <Grid VerticalOptions="Fill" HorizontalOptions="Fill"> | ||||
|                 <Grid.ColumnDefinitions> | ||||
|                     <ColumnDefinition Width="auto" /> | ||||
|                     <ColumnDefinition Width="*" /> | ||||
|                 </Grid.ColumnDefinitions> | ||||
|                 <Grid.RowDefinitions> | ||||
|                     <RowDefinition Height="auto" /> | ||||
|                     <RowDefinition Height="*" /> | ||||
|                 </Grid.RowDefinitions> | ||||
|                 <Button Grid.Column="0" Grid.Row="0" Text="=" Clicked="Button_Clicked"/> | ||||
|                 <SearchBar Grid.Column="1" Grid.Row="0" x:Name="SearchBar" HeightRequest="42" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}"> | ||||
|                     <SearchBar.Behaviors> | ||||
|                         <tools:TextChangedBehavior /> | ||||
|                     </SearchBar.Behaviors> | ||||
|                 </SearchBar> | ||||
|                 <ListView Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped"> | ||||
|                     <ListView.ItemTemplate> | ||||
|                         <DataTemplate> | ||||
|                             <ViewCell AutomationProperties.IsInAccessibleTree="True" AutomationId="machin" AutomationProperties.Name="hop"> | ||||
|                                 <StackLayout Padding="10" Orientation="Vertical"> | ||||
|                                     <Label Text="{Binding Name}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="16" /> | ||||
|                                     <Label Text="{Binding AltNameText}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="12" /> | ||||
|                                 </StackLayout> | ||||
|                             </ViewCell> | ||||
|                         </DataTemplate> | ||||
|                     </ListView.ItemTemplate> | ||||
|                 </ListView> | ||||
|             </Grid> | ||||
|         </ContentPage> | ||||
|     </MasterDetailPage.Detail> | ||||
| </MasterDetailPage> | ||||
							
								
								
									
										77
									
								
								AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								AideDeJeu/AideDeJeu/Views/FilteredItemsPage.xaml.cs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,77 @@ | |||
| using AideDeJeu.ViewModels; | ||||
| using System; | ||||
| using System.Linq; | ||||
| using Xamarin.Forms; | ||||
| using Xamarin.Forms.Xaml; | ||||
| 
 | ||||
| namespace AideDeJeu.Views | ||||
| { | ||||
|     [XamlCompilation(XamlCompilationOptions.Compile)] | ||||
| 	public partial class FilteredItemsPage : MasterDetailPage | ||||
|     { | ||||
|         MainViewModel Main | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return DependencyService.Get<MainViewModel>(); | ||||
|             } | ||||
|         } | ||||
|         //INavig//ator Navigator; | ||||
| 
 | ||||
|         public ItemsViewModel _ItemsViewModel; | ||||
|         public ItemsViewModel ItemsViewModel | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 return _ItemsViewModel; | ||||
|             } | ||||
|         } | ||||
|         public FilteredItemsPage (ItemsViewModel itemsViewModel) | ||||
| 		{ | ||||
| 			InitializeComponent (); | ||||
| 
 | ||||
|             BindingContext = _ItemsViewModel = itemsViewModel; // Main; | ||||
| 
 | ||||
|             //this.SizeChanged += (o, e) => { | ||||
|             //    if(this.Width > 0 && this.Height > 0) | ||||
|             //    { | ||||
|             //        this.IsPresented = this.Width > this.Height; | ||||
|             //    } | ||||
|             //}; | ||||
|         } | ||||
|         public FilteredItemsPage() | ||||
|         { | ||||
|             InitializeComponent(); | ||||
| 
 | ||||
|             BindingContext = Main; | ||||
| 
 | ||||
|             //this.SizeChanged += (o, e) => { | ||||
|             //    if (this.Width > 0 && this.Height > 0) | ||||
|             //    { | ||||
|             //        this.IsPresented = this.Width > this.Height; | ||||
|             //    } | ||||
|             //}; | ||||
|         } | ||||
| 
 | ||||
|         protected override void OnAppearing() | ||||
|         { | ||||
|             base.OnAppearing(); | ||||
| 
 | ||||
|             this.MasterBehavior = MasterBehavior.Popover; | ||||
| 
 | ||||
|             //if (Main.Items.Count() == 0) | ||||
|                 //Main.LoadItemsCommand.Execute(null); | ||||
|         } | ||||
| 
 | ||||
|         private void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e) | ||||
|         { | ||||
|             if (e.Item == null) return; | ||||
|             ((ListView)sender).SelectedItem = null; | ||||
|         } | ||||
| 
 | ||||
|         private void Button_Clicked(object sender, EventArgs e) | ||||
|         { | ||||
|             this.IsPresented = !this.IsPresented; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -1,58 +1,16 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <MasterDetailPage  | ||||
| <ContentPage  | ||||
|     xmlns="http://xamarin.com/schemas/2014/forms"  | ||||
|     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  | ||||
|     xmlns:local="clr-namespace:AideDeJeu.Views"  | ||||
|     xmlns:tools="clr-namespace:AideDeJeu.Tools"  | ||||
|     x:Class="AideDeJeu.Views.ItemsPage"  | ||||
|     x:Name="This"  | ||||
|     IsPresented="False"  | ||||
|     Title="{Binding Title}"> | ||||
|     <MasterDetailPage.ToolbarItems> | ||||
|     <ContentPage.ToolbarItems> | ||||
|         <ToolbarItem Name="About" Text="À propos de..." Order="Secondary" Icon="wooden_sign.png" Command="{Binding Main.AboutCommand}" /> | ||||
|     </MasterDetailPage.ToolbarItems> | ||||
|     <MasterDetailPage.Resources> | ||||
|         <ResourceDictionary> | ||||
|         </ResourceDictionary> | ||||
|     </MasterDetailPage.Resources> | ||||
|     <MasterDetailPage.Master> | ||||
|         <ContentPage Title=" "> | ||||
|             <StackLayout Orientation="Vertical"> | ||||
|                 <ListView SelectionMode="None" ItemsSource="{Binding Filter.Filters}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" > | ||||
|                     <ListView.ItemTemplate> | ||||
|                         <DataTemplate> | ||||
|                             <ViewCell> | ||||
|                                 <ViewCell.View> | ||||
|                                     <StackLayout Margin="10,5,10,0" Padding="0" Spacing="0"> | ||||
|                                         <Label BindingContext="{Binding}" Text="{Binding Name}" Style="{StaticResource Key=subsubsection}" /> | ||||
|                                         <Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding KeyValues, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Index}" /> | ||||
|                                     </StackLayout> | ||||
|                                 </ViewCell.View> | ||||
|                             </ViewCell> | ||||
|                         </DataTemplate> | ||||
|                     </ListView.ItemTemplate> | ||||
|                 </ListView> | ||||
|             </StackLayout> | ||||
|         </ContentPage> | ||||
|     </MasterDetailPage.Master> | ||||
|     <MasterDetailPage.Detail> | ||||
|         <ContentPage Title=""> | ||||
|             <Grid VerticalOptions="Fill" HorizontalOptions="Fill"> | ||||
|                 <Grid.ColumnDefinitions> | ||||
|                     <ColumnDefinition Width="auto" /> | ||||
|                     <ColumnDefinition Width="*" /> | ||||
|                 </Grid.ColumnDefinitions> | ||||
|                 <Grid.RowDefinitions> | ||||
|                     <RowDefinition Height="auto" /> | ||||
|                     <RowDefinition Height="*" /> | ||||
|                 </Grid.RowDefinitions> | ||||
|                 <Button Grid.Column="0" Grid.Row="0" Text="=" Clicked="Button_Clicked"/> | ||||
|                 <SearchBar Grid.Column="1" Grid.Row="0" x:Name="SearchBar" HeightRequest="42" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}"> | ||||
|                     <SearchBar.Behaviors> | ||||
|                         <tools:TextChangedBehavior /> | ||||
|                     </SearchBar.Behaviors> | ||||
|                 </SearchBar> | ||||
|                 <ListView Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped"> | ||||
|     </ContentPage.ToolbarItems> | ||||
|     <ListView HorizontalOptions="Fill" x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped"> | ||||
|         <ListView.ItemTemplate> | ||||
|             <DataTemplate> | ||||
|                 <ViewCell AutomationProperties.IsInAccessibleTree="True" AutomationId="machin" AutomationProperties.Name="hop"> | ||||
|  | @ -64,7 +22,4 @@ | |||
|             </DataTemplate> | ||||
|         </ListView.ItemTemplate> | ||||
|     </ListView> | ||||
|             </Grid> | ||||
| </ContentPage> | ||||
|     </MasterDetailPage.Detail> | ||||
| </MasterDetailPage> | ||||
|  | @ -7,7 +7,7 @@ using Xamarin.Forms.Xaml; | |||
| namespace AideDeJeu.Views | ||||
| { | ||||
|     [XamlCompilation(XamlCompilationOptions.Compile)] | ||||
| 	public partial class ItemsPage : MasterDetailPage | ||||
| 	public partial class ItemsPage : ContentPage | ||||
|     { | ||||
|         MainViewModel Main | ||||
|         { | ||||
|  | @ -16,7 +16,6 @@ namespace AideDeJeu.Views | |||
|                 return DependencyService.Get<MainViewModel>(); | ||||
|             } | ||||
|         } | ||||
|         //INavig//ator Navigator; | ||||
| 
 | ||||
|         public ItemsViewModel _ItemsViewModel; | ||||
|         public ItemsViewModel ItemsViewModel | ||||
|  | @ -30,37 +29,13 @@ namespace AideDeJeu.Views | |||
| 		{ | ||||
| 			InitializeComponent (); | ||||
| 
 | ||||
|             BindingContext = _ItemsViewModel = itemsViewModel; // Main; | ||||
| 
 | ||||
|             //this.SizeChanged += (o, e) => { | ||||
|             //    if(this.Width > 0 && this.Height > 0) | ||||
|             //    { | ||||
|             //        this.IsPresented = this.Width > this.Height; | ||||
|             //    } | ||||
|             //}; | ||||
|             BindingContext = _ItemsViewModel = itemsViewModel; | ||||
|         } | ||||
|         public ItemsPage() | ||||
|         { | ||||
|             InitializeComponent(); | ||||
| 
 | ||||
|             BindingContext = Main; | ||||
| 
 | ||||
|             //this.SizeChanged += (o, e) => { | ||||
|             //    if (this.Width > 0 && this.Height > 0) | ||||
|             //    { | ||||
|             //        this.IsPresented = this.Width > this.Height; | ||||
|             //    } | ||||
|             //}; | ||||
|         } | ||||
| 
 | ||||
|         protected override void OnAppearing() | ||||
|         { | ||||
|             base.OnAppearing(); | ||||
| 
 | ||||
|             this.MasterBehavior = MasterBehavior.Popover; | ||||
| 
 | ||||
|             //if (Main.Items.Count() == 0) | ||||
|                 //Main.LoadItemsCommand.Execute(null); | ||||
|         } | ||||
| 
 | ||||
|         private void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e) | ||||
|  | @ -68,10 +43,5 @@ namespace AideDeJeu.Views | |||
|             if (e.Item == null) return; | ||||
|             ((ListView)sender).SelectedItem = null; | ||||
|         } | ||||
| 
 | ||||
|         private void Button_Clicked(object sender, EventArgs e) | ||||
|         { | ||||
|             this.IsPresented = !this.IsPresented; | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez