mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2026-03-23 07:16:17 +00:00
Refonte navigation avec une seule MasterDetailPage et plein de binding ^^
This commit is contained in:
parent
8b3fdf0522
commit
07718efe91
22 changed files with 1487 additions and 40 deletions
|
|
@ -33,6 +33,9 @@
|
|||
<Compile Update="Views\SpellDetailPage.xaml.cs">
|
||||
<DependentUpon>SpellDetailPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Views\ItemsPage.xaml.cs">
|
||||
<DependentUpon>ItemsPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Views\SpellsPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>SpellsPage.xaml</DependentUpon>
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ namespace AideDeJeu
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
MainPage = new NavigationPage(new MainPage());
|
||||
//MainPage = new ItemsPage();
|
||||
MainPage = new NavigationPage(new ItemsPage());
|
||||
}
|
||||
|
||||
protected override void OnStart ()
|
||||
protected override void OnStart ()
|
||||
{
|
||||
// Handle when your app starts
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,31 @@ namespace AideDeJeu.Tools
|
|||
}
|
||||
}
|
||||
|
||||
public class ItemsTypeTemplateConverter : IValueConverter
|
||||
{
|
||||
public ControlTemplate SpellsTemplate { get; set; }
|
||||
public ControlTemplate MonstersTemplate { get; set; }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var itemType = value as ViewModels.ItemsViewModel.ItemType?;
|
||||
if (itemType == ViewModels.ItemsViewModel.ItemType.Spell)
|
||||
{
|
||||
return SpellsTemplate;
|
||||
}
|
||||
if (itemType == ViewModels.ItemsViewModel.ItemType.Monster)
|
||||
{
|
||||
return MonstersTemplate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ namespace AideDeJeu.ViewModels
|
|||
{
|
||||
public class BaseViewModel : INotifyPropertyChanged
|
||||
{
|
||||
//public IDataStore<Item> DataStore => DependencyService.Get<IDataStore<Item>>() ?? new MockDataStore();
|
||||
//public IDataStore<Spell> SpellDataStore => DependencyService.Get<IDataStore<Spell>>() ?? new SpellDataStore();
|
||||
public SpellsScrappers SpellsScrappers => DependencyService.Get<SpellsScrappers>() ?? new SpellsScrappers();
|
||||
public MonstersScrappers MonsterScrappers => DependencyService.Get<MonstersScrappers>() ?? new MonstersScrappers();
|
||||
|
||||
|
|
|
|||
81
AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs
Normal file
81
AideDeJeu/AideDeJeu/ViewModels/ItemsViewModel.cs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
|
||||
using AideDeJeuLib.Spells;
|
||||
using System.Collections.Generic;
|
||||
using AideDeJeuLib;
|
||||
|
||||
namespace AideDeJeu.ViewModels
|
||||
{
|
||||
public class ItemsViewModel : BaseViewModel
|
||||
{
|
||||
public enum ItemType
|
||||
{
|
||||
Spell,
|
||||
Monster,
|
||||
}
|
||||
public SpellsViewModel Spells { get; set; } = new SpellsViewModel();
|
||||
public MonstersViewModel Monsters { get; set; } = new MonstersViewModel();
|
||||
|
||||
private ItemType _ItemsType = ItemType.Spell;
|
||||
public ItemType ItemsType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ItemsType;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _ItemsType, value);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<Item> Items
|
||||
{
|
||||
get
|
||||
{
|
||||
if(ItemsType == ItemType.Spell)
|
||||
{
|
||||
return Spells.Items;
|
||||
}
|
||||
if (ItemsType == ItemType.Monster)
|
||||
{
|
||||
return Monsters.Items;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Command LoadItemsCommand { get; set; }
|
||||
|
||||
public Command SwitchToSpells { get; set; }
|
||||
public Command SwitchToMonsters { get; set; }
|
||||
|
||||
public ItemsViewModel()
|
||||
{
|
||||
//Title = "Browse";
|
||||
//Items = new ObservableCollection<Item>();
|
||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
|
||||
SwitchToSpells = new Command(() => ItemsType = ItemType.Spell);
|
||||
SwitchToMonsters = new Command(() => ItemsType = ItemType.Monster);
|
||||
}
|
||||
|
||||
async Task ExecuteLoadItemsCommand()
|
||||
{
|
||||
if(ItemsType == ItemType.Spell)
|
||||
{
|
||||
await Spells.ExecuteLoadItemsCommand();
|
||||
}
|
||||
if (ItemsType == ItemType.Monster)
|
||||
{
|
||||
await Monsters.ExecuteLoadItemsCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,12 +7,13 @@ using Xamarin.Forms;
|
|||
|
||||
using System.Collections.Generic;
|
||||
using AideDeJeuLib.Monsters;
|
||||
using AideDeJeuLib;
|
||||
|
||||
namespace AideDeJeu.ViewModels
|
||||
{
|
||||
public class MonstersViewModel : BaseViewModel
|
||||
{
|
||||
public ObservableCollection<Monster> Items { get; set; }
|
||||
public ObservableCollection<Item> Items { get; set; }
|
||||
|
||||
public List<KeyValuePair<string, string>> Categories { get; set; } = new List<KeyValuePair<string, string>>()
|
||||
{
|
||||
|
|
@ -189,11 +190,11 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
public MonstersViewModel()
|
||||
{
|
||||
Items = new ObservableCollection<Monster>();
|
||||
Items = new ObservableCollection<Item>();
|
||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
|
||||
}
|
||||
|
||||
async Task ExecuteLoadItemsCommand()
|
||||
public async Task ExecuteLoadItemsCommand()
|
||||
{
|
||||
if (IsBusy)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
public SpellDetailViewModel(Spell item = null)
|
||||
{
|
||||
Title = item?.Title;
|
||||
Title = item?.Name;
|
||||
Item = item;
|
||||
LoadItemCommand = new Command(async () => await ExecuteLoadItemCommand());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ using Xamarin.Forms;
|
|||
|
||||
using AideDeJeuLib.Spells;
|
||||
using System.Collections.Generic;
|
||||
using AideDeJeuLib;
|
||||
|
||||
namespace AideDeJeu.ViewModels
|
||||
{
|
||||
public class SpellsViewModel : BaseViewModel
|
||||
{
|
||||
public ObservableCollection<Spell> Items { get; set; }
|
||||
public ObservableCollection<Item> Items { get; set; }
|
||||
|
||||
public List<KeyValuePair<string, string>> Classes { get; set; } = new List<KeyValuePair<string, string>>()
|
||||
{
|
||||
|
|
@ -161,7 +162,7 @@ namespace AideDeJeu.ViewModels
|
|||
public SpellsViewModel()
|
||||
{
|
||||
//Title = "Browse";
|
||||
Items = new ObservableCollection<Spell>();
|
||||
Items = new ObservableCollection<Item>();
|
||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
|
||||
|
||||
//MessagingCenter.Subscribe<NewItemPage, Spell>(this, "AddItem", async (obj, item) =>
|
||||
|
|
@ -172,7 +173,7 @@ namespace AideDeJeu.ViewModels
|
|||
//});
|
||||
}
|
||||
|
||||
async Task ExecuteLoadItemsCommand()
|
||||
public async Task ExecuteLoadItemsCommand()
|
||||
{
|
||||
if (IsBusy)
|
||||
return;
|
||||
|
|
|
|||
163
AideDeJeu/AideDeJeu/Views/ItemsPage.xaml
Normal file
163
AideDeJeu/AideDeJeu/Views/ItemsPage.xaml
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<?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.ItemsPage"
|
||||
x:Name="This"
|
||||
IsPresented="False"
|
||||
Title="Liste des sorts"
|
||||
>
|
||||
<MasterDetailPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<ControlTemplate x:Key="SpellsMasterDataTemplate">
|
||||
<ScrollView Orientation="Vertical">
|
||||
<StackLayout Orientation="Vertical" Padding="15">
|
||||
|
||||
<Label Text="Classe" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Classes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Classe}" />
|
||||
|
||||
<Label Text="Niveau minimum" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.NiveauMin}" />
|
||||
|
||||
<Label Text="Niveau maximum" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Niveaux, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.NiveauMax}" />
|
||||
|
||||
<Label Text="École" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Ecoles, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Ecole}" />
|
||||
|
||||
<Label Text="Rituel" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Rituels, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Rituel}" />
|
||||
|
||||
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Spells.Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Spells.Source}" IsEnabled="False" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="MonstersMasterDataTemplate">
|
||||
<ScrollView Orientation="Vertical">
|
||||
<StackLayout Orientation="Vertical" Padding="15">
|
||||
|
||||
<Label Text="Catégorie" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Categories, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Category}" />
|
||||
|
||||
<Label Text="Type" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Types, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Type}" />
|
||||
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<Label Text="FP minimum" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Powers, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.MinPower}" />
|
||||
</StackLayout>
|
||||
|
||||
<StackLayout Orientation="Vertical">
|
||||
<Label Text="FP maximum" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Powers, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.MaxPower}" />
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
|
||||
<Label Text="Taille" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sizes, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Size}" />
|
||||
|
||||
<Label Text="Légendaire" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Legendaries, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Legendary}" />
|
||||
|
||||
<Label Text="Source" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{TemplateBinding Parent.BindingContext.Monsters.Sources, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{TemplateBinding Parent.BindingContext.Monsters.Source}" IsEnabled="False"/>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ControlTemplate>
|
||||
<tools:ItemsTypeTemplateConverter
|
||||
x:Key="ItemsTypeTemplateConverter"
|
||||
SpellsTemplate="{StaticResource SpellsMasterDataTemplate}"
|
||||
MonstersTemplate="{StaticResource MonstersMasterDataTemplate}" />
|
||||
</ResourceDictionary>
|
||||
</MasterDetailPage.Resources>
|
||||
<MasterDetailPage.Master>
|
||||
<ContentPage Title="Liste des sorts">
|
||||
<ContentView ControlTemplate="{Binding ItemsType, Converter={StaticResource ItemsTypeTemplateConverter}}" BindingContext="{Binding}" />
|
||||
<!--<ContentView ControlTemplate="{StaticResource SpellsMasterDataTemplate}" BindingContext="{Binding}" />-->
|
||||
</ContentPage>
|
||||
</MasterDetailPage.Master>
|
||||
<MasterDetailPage.Detail>
|
||||
<ContentPage Title="Liste des sorts">
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="ic_home.png" Command="{Binding SwitchToSpells}" />
|
||||
<ToolbarItem Name="Monsters" Text="Monstres" Order="Primary" Icon="ic_home.png" Command="{Binding SwitchToMonsters}" />
|
||||
<!--<ToolbarItem Name="Home" Text="Accueil" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />
|
||||
<ToolbarItem Name="Spells" Text="Sorts" Order="Primary" Icon="ic_home.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/" />-->
|
||||
<!--<ToolbarItem Name="Blog" Text="Blog" Order="Primary" Icon="ic_blog.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Blog/" />
|
||||
<ToolbarItem Name="Wikis" Text="Wikis" Order="Primary" Icon="ic_wikis.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/" />
|
||||
<ToolbarItem Name="Forum" Text="Forum" Order="Primary" Icon="ic_forum.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Forum/" />
|
||||
|
||||
<ToolbarItem Name="Gallery2" Text="Galerie" Order="Secondary" Icon="ic_gallery.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Media/" />
|
||||
<ToolbarItem Name="Plays2" Text="Parties" Order="Secondary" Icon="ic_plays.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/Wiki/Parties.MainPage.ashx" />
|
||||
<ToolbarItem Name="Search2" Text="Rechercher" Order="Secondary" Icon="ic_search.png" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/search/default.aspx" />-->
|
||||
<!--<ToolbarItem Text="Profil" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/yaf_cp_profile.aspx" />
|
||||
<ToolbarItem Text="Messages privés" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/forum/default.aspx?g=cp_pm" />
|
||||
<ToolbarItem Text="Connexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/login.aspx" />
|
||||
<ToolbarItem Text="Déconnexion" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/logout.aspx" />
|
||||
<ToolbarItem Text="Inscription" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/register.aspx" />-->
|
||||
</ContentPage.ToolbarItems>
|
||||
<Grid>
|
||||
<ListView x:Name="ItemsListView"
|
||||
ItemsSource="{Binding Items}"
|
||||
VerticalOptions="FillAndExpand"
|
||||
HasUnevenRows="true"
|
||||
RefreshCommand="{Binding LoadItemsCommand}"
|
||||
IsPullToRefreshEnabled="true"
|
||||
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
|
||||
CachingStrategy="RecycleElement"
|
||||
ItemSelected="OnItemSelected">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<StackLayout Padding="10">
|
||||
<Label Text="{Binding Name}"
|
||||
LineBreakMode="NoWrap"
|
||||
Style="{DynamicResource subsubsection}"
|
||||
FontSize="16" />
|
||||
<!--<Label Text="{Binding Description}"
|
||||
LineBreakMode="NoWrap"
|
||||
Style="{DynamicResource ListItemDetailTextStyle}"
|
||||
FontSize="13" />-->
|
||||
</StackLayout>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
<!--<WebView x:Name="MainView" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Navigating="OnNavigating" Source="{Binding Source}" />-->
|
||||
<!--<ActivityIndicator x:Name="aiProgress" Color="Black" IsRunning="True" IsVisible="True" />-->
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
</MasterDetailPage.Detail>
|
||||
</MasterDetailPage>
|
||||
|
||||
<!--<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:views="clr-namespace:AideDeJeu.Views"
|
||||
x:Class="AideDeJeu.Views.MainPage">
|
||||
<TabbedPage.Children>
|
||||
<NavigationPage Title="Browse">
|
||||
<NavigationPage.Icon>
|
||||
<OnPlatform x:TypeArguments="FileImageSource">
|
||||
<On Platform="iOS" Value="tab_feed.png"/>
|
||||
</OnPlatform>
|
||||
</NavigationPage.Icon>
|
||||
<x:Arguments>
|
||||
<views:ItemsPage />
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
|
||||
<NavigationPage Title="About">
|
||||
<NavigationPage.Icon>
|
||||
<OnPlatform x:TypeArguments="FileImageSource">
|
||||
<On Platform="iOS" Value="tab_about.png"/>
|
||||
</OnPlatform>
|
||||
</NavigationPage.Icon>
|
||||
<x:Arguments>
|
||||
<views:AboutPage />
|
||||
</x:Arguments>
|
||||
</NavigationPage>
|
||||
</TabbedPage.Children>
|
||||
</TabbedPage>-->
|
||||
58
AideDeJeu/AideDeJeu/Views/ItemsPage.xaml.cs
Normal file
58
AideDeJeu/AideDeJeu/Views/ItemsPage.xaml.cs
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
using AideDeJeu.ViewModels;
|
||||
using AideDeJeuLib.Monsters;
|
||||
using AideDeJeuLib.Spells;
|
||||
using System;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace AideDeJeu.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class ItemsPage : MasterDetailPage //TabbedPage
|
||||
{
|
||||
ItemsViewModel viewModel;
|
||||
|
||||
public ItemsPage ()
|
||||
{
|
||||
InitializeComponent ();
|
||||
|
||||
BindingContext = viewModel = new ItemsViewModel();
|
||||
}
|
||||
|
||||
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
||||
{
|
||||
if (args.SelectedItem is Spell)
|
||||
{
|
||||
var item = args.SelectedItem as Spell;
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
var vm = new SpellDetailViewModel(item);
|
||||
vm.LoadItemCommand.Execute(null);
|
||||
await Navigation.PushAsync(new SpellDetailPage(vm));
|
||||
}
|
||||
else if (args.SelectedItem is Monster)
|
||||
{
|
||||
var item = args.SelectedItem as Monster;
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
var vm = new MonsterDetailViewModel(item);
|
||||
vm.LoadItemCommand.Execute(null);
|
||||
await Navigation.PushAsync(new MonsterDetailPage(vm));
|
||||
}
|
||||
|
||||
// Manually deselect item.
|
||||
ItemsListView.SelectedItem = null;
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
||||
if (viewModel.Items.Count == 0)
|
||||
viewModel.LoadItemsCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,23 +11,6 @@
|
|||
<ContentPage Title="Liste des monstres">
|
||||
<ScrollView Orientation="Vertical">
|
||||
<StackLayout Orientation="Vertical" Padding="15">
|
||||
<!--<StackLayout Orientation="Horizontal">
|
||||
<Button Clicked="OnPlay" Image="ic_play.png" />
|
||||
<Button Clicked="OnStop" Image="ic_stop.png" />
|
||||
</StackLayout>-->
|
||||
<!--<ListView x:Name="NavigationView" ItemsSource="{Binding MainMenu}">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextCell Text="{Binding Title}" TextColor="Black" Command="{Binding Path=BindingContext.OpenUrl, Source={x:Reference Name=This}}" CommandParameter="{Binding Url}" />
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>-->
|
||||
<!--<Label Text="Liste" />
|
||||
<Picker HorizontalOptions="FillAndExpand">
|
||||
<Picker.Items>
|
||||
<x:String>Sorts</x:String>
|
||||
</Picker.Items>
|
||||
</Picker>-->
|
||||
|
||||
<Label Text="Catégorie" Style="{StaticResource Key=subsubsection}" />
|
||||
<Picker HorizontalOptions="FillAndExpand" ItemsSource="{Binding Categories, Mode=OneWay}" ItemDisplayBinding="{Binding Value, Mode=OneWay}" SelectedIndex="{Binding Category}" />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
Title="{Binding Title}">
|
||||
<ScrollView>
|
||||
<StackLayout Orientation="Vertical" Padding="15">
|
||||
<Label Text="{Binding Item.Title}" Style="{StaticResource Key=subsubsection}" />
|
||||
<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsubsection}" />
|
||||
|
||||
<Label Text=" " />
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace AideDeJeu.Views
|
|||
|
||||
var item = new Spell
|
||||
{
|
||||
Title = "",
|
||||
Name = "",
|
||||
//Description = "This is an item description."
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace AideDeJeuLib.Cards
|
|||
var cardData = new CardData();
|
||||
cardData.Count = 1;
|
||||
cardData.Color = color;
|
||||
cardData.Title = spell.Title;
|
||||
cardData.Title = spell.Name;
|
||||
cardData.TitleSize = "10";
|
||||
cardData.Icon = "white-book-" + spell.Level;
|
||||
cardData.IconBack = "robe";
|
||||
|
|
|
|||
10
AideDeJeu/AideDeJeuLib/Item.cs
Normal file
10
AideDeJeu/AideDeJeuLib/Item.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace AideDeJeuLib
|
||||
{
|
||||
public class Item
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
|
|||
|
||||
namespace AideDeJeuLib.Monsters
|
||||
{
|
||||
public class Monster
|
||||
public class Monster : Item
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ using System.Text.RegularExpressions;
|
|||
|
||||
namespace AideDeJeuLib.Spells
|
||||
{
|
||||
public class Spell
|
||||
public class Spell : Item
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string TitleUS { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string NameUS { get; set; }
|
||||
public string LevelType { get; set; }
|
||||
public string Level { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
|
@ -50,8 +50,8 @@ namespace AideDeJeuLib.Spells
|
|||
public static Spell FromHtml(HtmlNode nodeSpell)
|
||||
{
|
||||
var spell = new Spell();
|
||||
spell.Title = nodeSpell.SelectSingleNode("h1").InnerText;
|
||||
spell.TitleUS = nodeSpell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
spell.Name = nodeSpell.SelectSingleNode("h1").InnerText;
|
||||
spell.NameUS = nodeSpell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
spell.LevelType = nodeSpell.SelectSingleNode("h2/em").InnerText;
|
||||
spell.Level = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[0].Split(' ')[1];
|
||||
spell.Type = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[1];
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace AideDeJeuLib.Spells
|
|||
if (thssort.Length > 0)
|
||||
{
|
||||
Spell spell = new Spell();
|
||||
spell.Title = thssort[0].InnerText;
|
||||
spell.Name = thssort[0].InnerText;
|
||||
var href = thssort[0].Element("a").GetAttributeValue("href", "");
|
||||
var regex = new Regex("vf=(?<id>.*)");
|
||||
spell.Id = regex.Match(href).Groups["id"].Value;
|
||||
|
|
@ -108,8 +108,8 @@ namespace AideDeJeuLib.Spells
|
|||
foreach (var spell in spells)
|
||||
{
|
||||
var newSpell = new Spell();
|
||||
newSpell.Title = spell.SelectSingleNode("h1").InnerText;
|
||||
newSpell.TitleUS = spell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
newSpell.Name = spell.SelectSingleNode("h1").InnerText;
|
||||
newSpell.NameUS = spell.SelectSingleNode("div[@class='trad']").InnerText;
|
||||
newSpell.LevelType = spell.SelectSingleNode("h2/em").InnerText;
|
||||
newSpell.Level = newSpell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[0].Split(' ')[1];
|
||||
newSpell.Type = newSpell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[1];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue