1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 15:06:06 +00:00

Navigation

This commit is contained in:
Yan Maniez 2018-07-13 19:24:59 +02:00
parent d8f6d3a8bd
commit 11f2031b20
5 changed files with 56 additions and 36 deletions

View file

@ -113,9 +113,9 @@ namespace AideDeJeu.Tools
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var vm = DependencyService.Get<MainViewModel>();
var vm = DependencyService.Get<ItemsViewModel>();
var itemSourceType = vm.ItemSourceType;
return vm.GetFilterViewModel(itemSourceType).Filters;
return vm.Main.GetFilterViewModel(itemSourceType).Filters;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

View file

@ -17,6 +17,7 @@ namespace AideDeJeu.ViewModels
public ItemsViewModel(ItemSourceType itemSourceType)
{
this.ItemSourceType = itemSourceType;
Filter = Main.GetFilterViewModel(ItemSourceType);
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false));
}
public ICommand LoadItemsCommand { get; protected set; }
@ -24,7 +25,7 @@ namespace AideDeJeu.ViewModels
{
await Main.Navigator.GotoItemDetailPageAsync(item);
}
protected ItemSourceType ItemSourceType;
//protected ItemSourceType ItemSourceType;
private IEnumerable<Item> _AllItems = null;
@ -91,6 +92,34 @@ namespace AideDeJeu.ViewModels
return _AllItems;
}
private ItemSourceType _ItemSourceType = ItemSourceType.SpellHD;
public ItemSourceType ItemSourceType
{
get
{
return _ItemSourceType;
}
set
{
SetProperty(ref _ItemSourceType, value);
//LoadItemsCommand.Execute(null);
OnPropertyChanged(nameof(Items));
}
}
private FilterViewModel _Filter;
public FilterViewModel Filter
{
get
{
return _Filter;
}
set
{
SetProperty(ref _Filter, value);
}
}
public IEnumerable<Item> _Items = new List<Item>();
public IEnumerable<Item> Items
{
@ -127,7 +156,7 @@ namespace AideDeJeu.ViewModels
IsBusy = true;
try
{
var filterViewModel = Main.GetFilterViewModel(ItemSourceType);
var filterViewModel = Filter;// Main.GetFilterViewModel(ItemSourceType);
var items = await filterViewModel.FilterItems(await GetAllItemsAsync(), cancellationToken: cancellationToken);
Items = items.ToList();
}

View file

@ -22,21 +22,6 @@ namespace AideDeJeu.ViewModels
public class MainViewModel : BaseViewModel
{
private ItemSourceType _ItemSourceType = ItemSourceType.SpellHD;
public ItemSourceType ItemSourceType
{
get
{
return _ItemSourceType;
}
set
{
SetProperty(ref _ItemSourceType, value);
LoadItemsCommand.Execute(null);
OnPropertyChanged(nameof(Items));
}
}
private bool _isLoading;
public bool IsLoading
{
@ -64,7 +49,7 @@ namespace AideDeJeu.ViewModels
set
{
SetProperty(ref _ItemsSourcesIndex, value);
ItemSourceType = ItemsSources[value].Key;
//ItemSourceType = ItemsSources[value].Key;
}
}
@ -126,23 +111,24 @@ namespace AideDeJeu.ViewModels
public MainViewModel()
{
LoadItemsCommand = new Command(async () =>
{
await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
});
//LoadItemsCommand = new Command(async () =>
// {
// await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
// });
GotoItemCommand = new Command<Item>(async (item) =>
{
await GetItemsViewModel(ItemSourceType).ExecuteGotoItemCommandAsync(item);
await NavigateToItem(item);
//await GetItemsViewModel(ItemSourceType).ExecuteGotoItemCommandAsync(item);
});
SwitchToSpellsHD = new Command(() => ItemSourceType = ItemSourceType.SpellHD);
SwitchToMonstersHD = new Command(() => ItemSourceType = ItemSourceType.MonsterHD);
SwitchToSpellsVO = new Command(() => ItemSourceType = ItemSourceType.SpellVO);
SwitchToMonstersVO = new Command(() => ItemSourceType = ItemSourceType.MonsterVO);
//SwitchToSpellsHD = new Command(() => ItemSourceType = ItemSourceType.SpellHD);
//SwitchToMonstersHD = new Command(() => ItemSourceType = ItemSourceType.MonsterHD);
//SwitchToSpellsVO = new Command(() => ItemSourceType = ItemSourceType.SpellVO);
//SwitchToMonstersVO = new Command(() => ItemSourceType = ItemSourceType.MonsterVO);
AboutCommand = new Command(async () => await Main.Navigator.GotoAboutPageAsync());
SearchCommand = new Command<string>(async (text) =>
{
GetFilterViewModel(ItemSourceType).SearchText = text;
await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
//GetFilterViewModel(ItemSourceType).SearchText = text;
//await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
});
}
@ -175,6 +161,10 @@ namespace AideDeJeu.ViewModels
return ItemSourceType.SpellHD;
}
public async Task NavigateToItem(Item item)
{
await Navigator.GotoItemDetailPageAsync(item);
}
public async Task NavigateToLink(string s)
{
if (s != null)

View file

@ -20,11 +20,12 @@
<MasterDetailPage.Master>
<ContentPage Title=" ">
<StackLayout Orientation="Vertical">
<StackLayout Margin="10,5,10,0" Padding="0" Spacing="0">
<!--<StackLayout Margin="10,5,10,0" Padding="0" Spacing="0">
<Label Text="Listes" Style="{StaticResource Key=subsubsection}" AutomationProperties.IsInAccessibleTree="True" AutomationProperties.Name="test"/>
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding ItemsSources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding ItemsSourcesIndex}" />
</StackLayout>
<ListView SelectionMode="None" ItemsSource="{Binding ItemSourceType, Converter={StaticResource ItemSourceTypeToFilterConverter}}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" >
</StackLayout>-->
<!--, Converter={StaticResource ItemSourceTypeToFilterConverter}-->
<ListView SelectionMode="None" ItemsSource="{Binding Filter.Filters}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>

View file

@ -59,8 +59,8 @@ namespace AideDeJeu.Views
this.MasterBehavior = MasterBehavior.Popover;
if (Main.Items.Count() == 0)
Main.LoadItemsCommand.Execute(null);
//if (Main.Items.Count() == 0)
//Main.LoadItemsCommand.Execute(null);
}
private void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e)