1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 15:06:06 +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' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>Latest</LangVersion> <LangVersion>Latest</LangVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="Views\Library\MainTabbedPage.xaml.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Remove="Resources\AdJTheme.xaml" /> <EmbeddedResource Remove="Resources\AdJTheme.xaml" />
<EmbeddedResource Remove="Views\Library\MainTabbedPage.xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -114,9 +119,6 @@
<Compile Update="Views\Pickers\ItemView.xaml.cs"> <Compile Update="Views\Pickers\ItemView.xaml.cs">
<DependentUpon>ItemView.xaml</DependentUpon> <DependentUpon>ItemView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Update="Views\Library\MainTabbedPage.xaml.cs">
<DependentUpon>MainTabbedPage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\Pickers\ItemPicker.xaml.cs"> <Compile Update="Views\Pickers\ItemPicker.xaml.cs">
<DependentUpon>ItemPicker.xaml</DependentUpon> <DependentUpon>ItemPicker.xaml</DependentUpon>
</Compile> </Compile>
@ -150,6 +152,12 @@
<EmbeddedResource Include="..\..\Data\index.md" Link="Data\index.md" /> <EmbeddedResource Include="..\..\Data\index.md" Link="Data\index.md" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Views\Library\MainTabbedPage.xaml.cs">
<DependentUpon>MainTabbedPage.xaml</DependentUpon>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Update="Properties\Resource.resx"> <EmbeddedResource Update="Properties\Resource.resx">
<Generator>PublicResXFileCodeGenerator</Generator> <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); await Shell.Current.GoToAsync("//deepsearch", true);
} }
private Command _AddToFavoritesCommand = null; private Command<ItemViewModel> _AddToFavoritesCommand = null;
public Command AddToFavoritesCommand public Command<ItemViewModel> AddToFavoritesCommand
{ {
get 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 page = Shell.Current;
var navigationPage = tabbedPage; //.MainNavigationPage; //var tabbedPage = App.Current.MainPage as MainTabbedPage;
var lastPage = navigationPage.Navigation.NavigationStack.LastOrDefault(); //var navigationPage = tabbedPage; //.MainNavigationPage;
var context = lastPage.BindingContext; //var lastPage = navigationPage.Navigation.NavigationStack.LastOrDefault();
Item item = (context as ItemViewModel)?.Item; //var context = lastPage.BindingContext;
//if (context is ItemDetailViewModel) //Item item = (context as ItemViewModel)?.Item;
//{ ////if (context is ItemDetailViewModel)
// item = (context as ItemDetailViewModel).Item; ////{
//} //// item = (context as ItemDetailViewModel).Item;
//else if (context is ItemsViewModel) ////}
//{ ////else if (context is ItemsViewModel)
// item = (context as ItemsViewModel).AllItems; ////{
//} //// item = (context as ItemsViewModel).AllItems;
////}
//await Application.Current.MainPage.DisplayAlert("Id", item.Id, "OK"); //await Application.Current.MainPage.DisplayAlert("Id", item.Id, "OK");
var item = itemVM.Item;
var vm = Main.Bookmarks; var vm = Main.Bookmarks;
var result = await Application.Current.MainPage.DisplayActionSheet("Ajouter à", "Annuler", "Nouvelle liste", vm.BookmarkCollectionNames.ToArray<string>()); var result = await Application.Current.MainPage.DisplayActionSheet("Ajouter à", "Annuler", "Nouvelle liste", vm.BookmarkCollectionNames.ToArray<string>());
if (result != "Annuler") if (result != "Annuler")
@ -207,7 +210,7 @@ namespace AideDeJeu.ViewModels
var itemsViewModel = new ItemViewModel() { Item = item, AllItems = items, Filter = filterViewModel }; var itemsViewModel = new ItemViewModel() { Item = item, AllItems = items, Filter = filterViewModel };
itemsViewModel.LoadItemsCommand.Execute(null); itemsViewModel.LoadItemsCommand.Execute(null);
SwitchToMainTab(); await SwitchToMainTabAsync();
if (filterViewModel == null) if (filterViewModel == null)
{ {
@ -219,14 +222,15 @@ namespace AideDeJeu.ViewModels
} }
} }
public void SwitchToMainTab() public async Task SwitchToMainTabAsync()
{ {
var tabbedPage = App.Current.MainPage as MainTabbedPage; await Shell.Current.GoToAsync("//library");
if (tabbedPage != null) //var tabbedPage = App.Current.MainPage as MainTabbedPage;
{ //if (tabbedPage != null)
tabbedPage.SelectedItem = null; //{
tabbedPage.SelectedItem = tabbedPage; //.MainNavigationPage; // tabbedPage.SelectedItem = null;
} // tabbedPage.SelectedItem = tabbedPage; //.MainNavigationPage;
//}
} }
public async Task GotoItemsPageAsync(ItemViewModel itemsVM) public async Task GotoItemsPageAsync(ItemViewModel itemsVM)
@ -256,6 +260,7 @@ namespace AideDeJeu.ViewModels
public async Task NavigateToLinkAsync(string s) public async Task NavigateToLinkAsync(string s)
{ {
await SwitchToMainTabAsync();
await Navigation.PushAsync(new ItemPage(s), true);//.GoToAsync($"item?path={Uri.EscapeDataString(s)}"); await Navigation.PushAsync(new ItemPage(s), true);//.GoToAsync($"item?path={Uri.EscapeDataString(s)}");
return; return;
if (s != null) if (s != null)
@ -293,7 +298,7 @@ namespace AideDeJeu.ViewModels
filterViewModel.FilterWith(key, val); filterViewModel.FilterWith(key, val);
} }
} }
SwitchToMainTab(); await SwitchToMainTabAsync();
if (filterViewModel == null) if (filterViewModel == null)
{ {
await GotoItemsPageAsync(itemsViewModel); await GotoItemsPageAsync(itemsViewModel);

View file

@ -3,10 +3,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"
xmlns:tools="clr-namespace:AideDeJeu.Tools" 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:Class="AideDeJeu.Views.Library.BookmarksPage"
x:Name="This" x:Name="This"
x:DataType="libvm:BookmarksViewModel"
Title="Favoris" Title="Favoris"
Icon="stars_stack.png"> Icon="stars_stack.png">
<ContentPage.BindingContext>
<libvm:BookmarksViewModel />
</ContentPage.BindingContext>
<ContentPage.Resources> <ContentPage.Resources>
<ResourceDictionary> <ResourceDictionary>
<tools:IntToBooleanConverter x:Key="IntToBooleanConverter" NonZeroValue="False" NullOrZeroValue="True" /> <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}}" /> <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> <ListView.ItemTemplate>
<DataTemplate> <DataTemplate x:DataType="lib:Item">
<ViewCell> <ViewCell>
<Grid Padding="10"> <Grid Padding="10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>

View file

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

View file

@ -22,7 +22,7 @@
</ContentPage.Resources> </ContentPage.Resources>
<ContentPage.ToolbarItems> <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}" /> <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="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}" /> <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> </ContentPage.ToolbarItems>