mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Navigation
This commit is contained in:
parent
d8f6d3a8bd
commit
11f2031b20
5 changed files with 56 additions and 36 deletions
|
|
@ -113,9 +113,9 @@ namespace AideDeJeu.Tools
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
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;
|
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)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ namespace AideDeJeu.ViewModels
|
||||||
public ItemsViewModel(ItemSourceType itemSourceType)
|
public ItemsViewModel(ItemSourceType itemSourceType)
|
||||||
{
|
{
|
||||||
this.ItemSourceType = itemSourceType;
|
this.ItemSourceType = itemSourceType;
|
||||||
|
Filter = Main.GetFilterViewModel(ItemSourceType);
|
||||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false));
|
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync().ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
public ICommand LoadItemsCommand { get; protected set; }
|
public ICommand LoadItemsCommand { get; protected set; }
|
||||||
|
|
@ -24,7 +25,7 @@ namespace AideDeJeu.ViewModels
|
||||||
{
|
{
|
||||||
await Main.Navigator.GotoItemDetailPageAsync(item);
|
await Main.Navigator.GotoItemDetailPageAsync(item);
|
||||||
}
|
}
|
||||||
protected ItemSourceType ItemSourceType;
|
//protected ItemSourceType ItemSourceType;
|
||||||
|
|
||||||
|
|
||||||
private IEnumerable<Item> _AllItems = null;
|
private IEnumerable<Item> _AllItems = null;
|
||||||
|
|
@ -91,6 +92,34 @@ namespace AideDeJeu.ViewModels
|
||||||
return _AllItems;
|
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 = new List<Item>();
|
||||||
public IEnumerable<Item> Items
|
public IEnumerable<Item> Items
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +156,7 @@ namespace AideDeJeu.ViewModels
|
||||||
IsBusy = true;
|
IsBusy = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var filterViewModel = Main.GetFilterViewModel(ItemSourceType);
|
var filterViewModel = Filter;// Main.GetFilterViewModel(ItemSourceType);
|
||||||
var items = await filterViewModel.FilterItems(await GetAllItemsAsync(), cancellationToken: cancellationToken);
|
var items = await filterViewModel.FilterItems(await GetAllItemsAsync(), cancellationToken: cancellationToken);
|
||||||
Items = items.ToList();
|
Items = items.ToList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,21 +22,6 @@ namespace AideDeJeu.ViewModels
|
||||||
|
|
||||||
public class MainViewModel : BaseViewModel
|
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;
|
private bool _isLoading;
|
||||||
public bool IsLoading
|
public bool IsLoading
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +49,7 @@ namespace AideDeJeu.ViewModels
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
SetProperty(ref _ItemsSourcesIndex, value);
|
SetProperty(ref _ItemsSourcesIndex, value);
|
||||||
ItemSourceType = ItemsSources[value].Key;
|
//ItemSourceType = ItemsSources[value].Key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -126,23 +111,24 @@ namespace AideDeJeu.ViewModels
|
||||||
|
|
||||||
public MainViewModel()
|
public MainViewModel()
|
||||||
{
|
{
|
||||||
LoadItemsCommand = new Command(async () =>
|
//LoadItemsCommand = new Command(async () =>
|
||||||
{
|
// {
|
||||||
await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
|
// await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
|
||||||
});
|
// });
|
||||||
GotoItemCommand = new Command<Item>(async (item) =>
|
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);
|
//SwitchToSpellsHD = new Command(() => ItemSourceType = ItemSourceType.SpellHD);
|
||||||
SwitchToMonstersHD = new Command(() => ItemSourceType = ItemSourceType.MonsterHD);
|
//SwitchToMonstersHD = new Command(() => ItemSourceType = ItemSourceType.MonsterHD);
|
||||||
SwitchToSpellsVO = new Command(() => ItemSourceType = ItemSourceType.SpellVO);
|
//SwitchToSpellsVO = new Command(() => ItemSourceType = ItemSourceType.SpellVO);
|
||||||
SwitchToMonstersVO = new Command(() => ItemSourceType = ItemSourceType.MonsterVO);
|
//SwitchToMonstersVO = new Command(() => ItemSourceType = ItemSourceType.MonsterVO);
|
||||||
AboutCommand = new Command(async () => await Main.Navigator.GotoAboutPageAsync());
|
AboutCommand = new Command(async () => await Main.Navigator.GotoAboutPageAsync());
|
||||||
SearchCommand = new Command<string>(async (text) =>
|
SearchCommand = new Command<string>(async (text) =>
|
||||||
{
|
{
|
||||||
GetFilterViewModel(ItemSourceType).SearchText = text;
|
//GetFilterViewModel(ItemSourceType).SearchText = text;
|
||||||
await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
|
//await GetItemsViewModel(ItemSourceType).ExecuteLoadItemsCommandAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,6 +161,10 @@ namespace AideDeJeu.ViewModels
|
||||||
return ItemSourceType.SpellHD;
|
return ItemSourceType.SpellHD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task NavigateToItem(Item item)
|
||||||
|
{
|
||||||
|
await Navigator.GotoItemDetailPageAsync(item);
|
||||||
|
}
|
||||||
public async Task NavigateToLink(string s)
|
public async Task NavigateToLink(string s)
|
||||||
{
|
{
|
||||||
if (s != null)
|
if (s != null)
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,12 @@
|
||||||
<MasterDetailPage.Master>
|
<MasterDetailPage.Master>
|
||||||
<ContentPage Title=" ">
|
<ContentPage Title=" ">
|
||||||
<StackLayout Orientation="Vertical">
|
<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"/>
|
<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}" />
|
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding ItemsSources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding ItemsSourcesIndex}" />
|
||||||
</StackLayout>
|
</StackLayout>-->
|
||||||
<ListView SelectionMode="None" ItemsSource="{Binding ItemSourceType, Converter={StaticResource ItemSourceTypeToFilterConverter}}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" >
|
<!--, Converter={StaticResource ItemSourceTypeToFilterConverter}-->
|
||||||
|
<ListView SelectionMode="None" ItemsSource="{Binding Filter.Filters}" HasUnevenRows="True" RowHeight="-1" SeparatorVisibility="None" IsPullToRefreshEnabled="False" HorizontalOptions="FillAndExpand" >
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,8 @@ namespace AideDeJeu.Views
|
||||||
|
|
||||||
this.MasterBehavior = MasterBehavior.Popover;
|
this.MasterBehavior = MasterBehavior.Popover;
|
||||||
|
|
||||||
if (Main.Items.Count() == 0)
|
//if (Main.Items.Count() == 0)
|
||||||
Main.LoadItemsCommand.Execute(null);
|
//Main.LoadItemsCommand.Execute(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e)
|
private void ItemsListView_ItemTapped(object sender, ItemTappedEventArgs e)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue