1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 14:35:45 +00:00

Début passage en repositories (! bookmarks cassés)

This commit is contained in:
Yan Maniez 2019-10-14 17:03:15 +02:00
parent 383e19d144
commit e34223173f
7 changed files with 73 additions and 33 deletions

View file

@ -14,8 +14,13 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>Latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Views\Library\MainTabbedPage.xaml.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="Resources\AdJTheme.xaml" />
<EmbeddedResource Remove="Views\Library\MainTabbedPage.xaml" />
</ItemGroup>
<ItemGroup>
@ -114,9 +119,6 @@
<Compile Update="Views\Pickers\ItemView.xaml.cs">
<DependentUpon>ItemView.xaml</DependentUpon>
</Compile>
<Compile Update="Views\Library\MainTabbedPage.xaml.cs">
<DependentUpon>MainTabbedPage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\Pickers\ItemPicker.xaml.cs">
<DependentUpon>ItemPicker.xaml</DependentUpon>
</Compile>
@ -150,6 +152,12 @@
<EmbeddedResource Include="..\..\Data\index.md" Link="Data\index.md" />
</ItemGroup>
<ItemGroup>
<None Include="Views\Library\MainTabbedPage.xaml.cs">
<DependentUpon>MainTabbedPage.xaml</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resource.resx">
<Generator>PublicResXFileCodeGenerator</Generator>

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace AideDeJeu.Repositories
{
public class BookmarksRepository
{
}
}

View file

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace AideDeJeu.Repositories
{
public class LibraryRepository
{
}
}

View file

@ -155,31 +155,34 @@ namespace AideDeJeu.ViewModels
await Shell.Current.GoToAsync("//deepsearch", true);
}
private Command _AddToFavoritesCommand = null;
public Command AddToFavoritesCommand
private Command<ItemViewModel> _AddToFavoritesCommand = null;
public Command<ItemViewModel> AddToFavoritesCommand
{
get
{
return _AddToFavoritesCommand ?? (_AddToFavoritesCommand = new Command(async () => await ExecuteAddToFavoritesCommandAsync()));
return _AddToFavoritesCommand ?? (_AddToFavoritesCommand = new Command<ItemViewModel>(async (item) => await ExecuteAddToFavoritesCommandAsync(item)));
}
}
public async Task ExecuteAddToFavoritesCommandAsync()
public async Task ExecuteAddToFavoritesCommandAsync(ItemViewModel itemVM)
{
var tabbedPage = App.Current.MainPage as MainTabbedPage;
var navigationPage = tabbedPage; //.MainNavigationPage;
var lastPage = navigationPage.Navigation.NavigationStack.LastOrDefault();
var context = lastPage.BindingContext;
Item item = (context as ItemViewModel)?.Item;
//if (context is ItemDetailViewModel)
//{
// item = (context as ItemDetailViewModel).Item;
//}
//else if (context is ItemsViewModel)
//{
// item = (context as ItemsViewModel).AllItems;
//}
//var page = Shell.Current;
//var tabbedPage = App.Current.MainPage as MainTabbedPage;
//var navigationPage = tabbedPage; //.MainNavigationPage;
//var lastPage = navigationPage.Navigation.NavigationStack.LastOrDefault();
//var context = lastPage.BindingContext;
//Item item = (context as ItemViewModel)?.Item;
////if (context is ItemDetailViewModel)
////{
//// item = (context as ItemDetailViewModel).Item;
////}
////else if (context is ItemsViewModel)
////{
//// item = (context as ItemsViewModel).AllItems;
////}
//await Application.Current.MainPage.DisplayAlert("Id", item.Id, "OK");
var item = itemVM.Item;
var vm = Main.Bookmarks;
var result = await Application.Current.MainPage.DisplayActionSheet("Ajouter à", "Annuler", "Nouvelle liste", vm.BookmarkCollectionNames.ToArray<string>());
if (result != "Annuler")
@ -207,7 +210,7 @@ namespace AideDeJeu.ViewModels
var itemsViewModel = new ItemViewModel() { Item = item, AllItems = items, Filter = filterViewModel };
itemsViewModel.LoadItemsCommand.Execute(null);
SwitchToMainTab();
await SwitchToMainTabAsync();
if (filterViewModel == null)
{
@ -219,14 +222,15 @@ namespace AideDeJeu.ViewModels
}
}
public void SwitchToMainTab()
public async Task SwitchToMainTabAsync()
{
var tabbedPage = App.Current.MainPage as MainTabbedPage;
if (tabbedPage != null)
{
tabbedPage.SelectedItem = null;
tabbedPage.SelectedItem = tabbedPage; //.MainNavigationPage;
}
await Shell.Current.GoToAsync("//library");
//var tabbedPage = App.Current.MainPage as MainTabbedPage;
//if (tabbedPage != null)
//{
// tabbedPage.SelectedItem = null;
// tabbedPage.SelectedItem = tabbedPage; //.MainNavigationPage;
//}
}
public async Task GotoItemsPageAsync(ItemViewModel itemsVM)
@ -256,6 +260,7 @@ namespace AideDeJeu.ViewModels
public async Task NavigateToLinkAsync(string s)
{
await SwitchToMainTabAsync();
await Navigation.PushAsync(new ItemPage(s), true);//.GoToAsync($"item?path={Uri.EscapeDataString(s)}");
return;
if (s != null)
@ -293,7 +298,7 @@ namespace AideDeJeu.ViewModels
filterViewModel.FilterWith(key, val);
}
}
SwitchToMainTab();
await SwitchToMainTabAsync();
if (filterViewModel == null)
{
await GotoItemsPageAsync(itemsViewModel);

View file

@ -3,10 +3,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
xmlns:tools="clr-namespace:AideDeJeu.Tools"
xmlns:libvm="clr-namespace:AideDeJeu.ViewModels.Library"
xmlns:lib="clr-namespace:AideDeJeuLib"
x:Class="AideDeJeu.Views.Library.BookmarksPage"
x:Name="This"
x:DataType="libvm:BookmarksViewModel"
Title="Favoris"
Icon="stars_stack.png">
<ContentPage.BindingContext>
<libvm:BookmarksViewModel />
</ContentPage.BindingContext>
<ContentPage.Resources>
<ResourceDictionary>
<tools:IntToBooleanConverter x:Key="IntToBooleanConverter" NonZeroValue="False" NullOrZeroValue="True" />
@ -37,9 +43,10 @@
<Label Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Margin="15,0,15,0" Style="{StaticResource heading3}" Text="Cette liste est vide, ajoutez des éléments à partir de la bibliothèque !" IsVisible="{Binding BookmarkCollection.Count, Converter={StaticResource IntToBooleanConverter}}" />
<ListView Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" x:Name="ItemsListView" SelectionMode="None" ItemsSource="{Binding BookmarkCollection}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}">
<!--SelectedItem="{Binding SelectedItem}"-->
<ListView Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" x:Name="ItemsListView" SelectionMode="None" ItemsSource="{Binding BookmarkCollection}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement">
<ListView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="lib:Item">
<ViewCell>
<Grid Padding="10">
<Grid.ColumnDefinitions>

View file

@ -19,7 +19,7 @@ namespace AideDeJeu.Views.Library
{
InitializeComponent ();
BindingContext = DependencyService.Get<BookmarksViewModel>();
//BindingContext = DependencyService.Get<BookmarksViewModel>();
}
}
}

View file

@ -22,7 +22,7 @@
</ContentPage.Resources>
<ContentPage.ToolbarItems>
<tools:BindableToolbarItem Name="Filter" Text="Filtrer" Order="Primary" Icon="funnel.png" IsVisible="{Binding Filter, Converter={StaticResource NullToFalseConverter}, Mode=OneWay}" Command="{Binding Main.ChangeFilterIsPresentedCommand, Mode=OneTime}" />
<ToolbarItem Name="AddToFavorites" Text="Ajouter aux favoris" Order="Primary" Icon="round_star.png" Command="{Binding Main.Navigator.AddToFavoritesCommand, Mode=OneTime}" />
<ToolbarItem Name="AddToFavorites" Text="Ajouter aux favoris" Order="Primary" Icon="round_star.png" Command="{Binding Main.Navigator.AddToFavoritesCommand, Mode=OneTime}" CommandParameter="{Binding}" />
<ToolbarItem Name="Print" Text="Générer un PDF" Order="Secondary" Icon="scroll_unfurled.png" Command="{Binding Main.Navigator.GeneratePDFCommand, Mode=OneTime}" CommandParameter="{Binding Item.Markdown}" />
<ToolbarItem Name="Speak" Text="Écouter / Arrêter" Order="Secondary" Icon="scroll_unfurled.png" Command="{Binding Main.Speech.SpeakItemCommand, Mode=OneTime}" CommandParameter="{Binding Item}" />
</ContentPage.ToolbarItems>