mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Ajout de la recherche de titre et préparation v1.02
This commit is contained in:
parent
a89e7a9cd1
commit
ddf693fc9c
12 changed files with 125 additions and 60 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="2" android:versionName="1.01" package="com.nioux.aidedejeu" android:installLocation="auto">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="3" android:versionName="1.02" package="com.nioux.aidedejeu" android:installLocation="auto">
|
||||
<uses-sdk android:minSdkVersion="15" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application android:label="Aide de Jeu"></application>
|
||||
|
|
|
|||
27
AideDeJeu/AideDeJeu/Tools/Behaviors.cs
Normal file
27
AideDeJeu/AideDeJeu/Tools/Behaviors.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace AideDeJeu.Tools
|
||||
{
|
||||
public class TextChangedBehavior : Behavior<SearchBar>
|
||||
{
|
||||
protected override void OnAttachedTo(SearchBar bindable)
|
||||
{
|
||||
base.OnAttachedTo(bindable);
|
||||
bindable.TextChanged += Bindable_TextChanged;
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(SearchBar bindable)
|
||||
{
|
||||
base.OnDetachingFrom(bindable);
|
||||
bindable.TextChanged -= Bindable_TextChanged;
|
||||
}
|
||||
|
||||
private void Bindable_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
((SearchBar)sender).SearchCommand?.Execute(e.NewTextValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,13 +8,45 @@ namespace AideDeJeu.ViewModels
|
|||
{
|
||||
public abstract class ItemsViewModel : BaseViewModel
|
||||
{
|
||||
public ItemsViewModel(ObservableCollection<Item> items)
|
||||
public ItemsViewModel(INavigator navigator, ObservableCollection<Item> items)
|
||||
{
|
||||
Navigator = navigator;
|
||||
Items = items;
|
||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommandAsync());
|
||||
}
|
||||
protected ObservableCollection<Item> AllItems { get; set; } = new ObservableCollection<Item>();
|
||||
public ObservableCollection<Item> Items { get; protected set; }
|
||||
public ICommand LoadItemsCommand { get; protected set; }
|
||||
public abstract Task ExecuteLoadItemsCommandAsync();
|
||||
public abstract Task ExecuteGotoItemCommandAsync(Item item);
|
||||
protected INavigator Navigator { get; set; }
|
||||
|
||||
private string _SearchText = "";
|
||||
public string SearchText
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchText;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetProperty(ref _SearchText, value);
|
||||
FilterItems();
|
||||
}
|
||||
}
|
||||
|
||||
public void FilterItems()
|
||||
{
|
||||
Items.Clear();
|
||||
foreach (var item in AllItems)
|
||||
{
|
||||
if (item.Name.ToLower().Contains(SearchText.ToLower()))
|
||||
{
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
set
|
||||
{
|
||||
CurrentViewModel.SearchText = "";
|
||||
SetProperty(ref _ItemsType, value);
|
||||
CurrentViewModel.SearchText = "";
|
||||
OnPropertyChanged(nameof(CurrentViewModel));
|
||||
LoadItemsCommand.Execute(null);
|
||||
}
|
||||
|
|
@ -47,19 +49,23 @@ namespace AideDeJeu.ViewModels
|
|||
public ObservableCollection<Item> Items { get; private set; } = new ObservableCollection<Item>();
|
||||
|
||||
public Command LoadItemsCommand { get; private set; }
|
||||
public Command<Item> GotoItemCommand { get; private set; }
|
||||
|
||||
public Command SwitchToSpells { get; private set; }
|
||||
public Command SwitchToMonsters { get; private set; }
|
||||
public Command AboutCommand { get; private set; }
|
||||
public Command<string> SearchCommand { get; private set; }
|
||||
|
||||
public MainViewModel(INavigator navigator)
|
||||
{
|
||||
Spells = new SpellsViewModel(Items);
|
||||
Monsters = new MonstersViewModel(Items);
|
||||
Spells = new SpellsViewModel(navigator, Items);
|
||||
Monsters = new MonstersViewModel(navigator, Items);
|
||||
LoadItemsCommand = new Command(async () => await CurrentViewModel.ExecuteLoadItemsCommandAsync());
|
||||
GotoItemCommand = new Command<Item>(async (item) => await CurrentViewModel.ExecuteGotoItemCommandAsync(item));
|
||||
SwitchToSpells = new Command(() => ItemsType = ItemType.Spell);
|
||||
SwitchToMonsters = new Command(() => ItemsType = ItemType.Monster);
|
||||
AboutCommand = new Command(async() => await navigator.GotoAboutPageAsync());
|
||||
SearchCommand = new Command<string>((text) => CurrentViewModel.SearchText = text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -181,8 +181,8 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
|
||||
|
||||
public MonstersViewModel(ObservableCollection<Item> items)
|
||||
: base(items)
|
||||
public MonstersViewModel(INavigator navigator, ObservableCollection<Item> items)
|
||||
: base(navigator, items)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -195,12 +195,13 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
try
|
||||
{
|
||||
Items.Clear();
|
||||
AllItems.Clear();
|
||||
var monsters = await new MonstersScrappers().GetMonsters(category: Categories[Category].Key, type: Types[Type].Key, minPower: Powers[MinPower].Key, maxPower: Powers[MaxPower].Key, size: Sizes[Size].Key, legendary:Legendaries[Legendary].Key, source: Sources[Source].Key);
|
||||
foreach (var monster in monsters)
|
||||
{
|
||||
Items.Add(monster);
|
||||
AllItems.Add(monster);
|
||||
}
|
||||
FilterItems();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -211,5 +212,11 @@ namespace AideDeJeu.ViewModels
|
|||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task ExecuteGotoItemCommandAsync(Item item)
|
||||
{
|
||||
await Navigator.GotoMonsterDetailPageAsync(item as Monster);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -152,8 +152,8 @@ namespace AideDeJeu.ViewModels
|
|||
}
|
||||
|
||||
|
||||
public SpellsViewModel(ObservableCollection<Item> items)
|
||||
: base(items)
|
||||
public SpellsViewModel(INavigator navigator, ObservableCollection<Item> items)
|
||||
: base(navigator, items)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -166,12 +166,13 @@ namespace AideDeJeu.ViewModels
|
|||
|
||||
try
|
||||
{
|
||||
Items.Clear();
|
||||
AllItems.Clear();
|
||||
var items = await SpellsScrappers.GetSpells(classe: Classes[Classe].Key, niveauMin: NiveauMin, niveauMax: NiveauMax, ecole: Ecoles[Ecole].Key, rituel: Rituels[Rituel].Key, source: Sources[Source].Key);
|
||||
foreach (var item in items)
|
||||
{
|
||||
Items.Add(item);
|
||||
AllItems.Add(item);
|
||||
}
|
||||
FilterItems();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -182,5 +183,11 @@ namespace AideDeJeu.ViewModels
|
|||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task ExecuteGotoItemCommandAsync(Item item)
|
||||
{
|
||||
await Navigator.GotoSpellDetailPageAsync(item as Spell);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -27,30 +27,15 @@
|
|||
<FormattedString.Spans>
|
||||
<Span Text="Aide de Jeu" FontAttributes="Bold" FontSize="22" />
|
||||
<Span Text=" " />
|
||||
<Span Text="1.01" ForegroundColor="{StaticResource LightTextColor}" />
|
||||
</FormattedString.Spans>
|
||||
</FormattedString>
|
||||
</Label.FormattedText>
|
||||
</Label>
|
||||
<Label>
|
||||
<Label.FormattedText>
|
||||
<FormattedString>
|
||||
<FormattedString.Spans>
|
||||
<Span Text="Cette application est une aide de jeu pour le plus célèbre des jeux de rôle" />
|
||||
<Span Text="Son contenu provient du site AideDD, et est traduit du SRD" />
|
||||
</FormattedString.Spans>
|
||||
</FormattedString>
|
||||
</Label.FormattedText>
|
||||
</Label>
|
||||
<Label>
|
||||
<Label.FormattedText>
|
||||
<FormattedString>
|
||||
<FormattedString.Spans>
|
||||
<Span Text="Les icones proviennent du site Game-icons.net" />
|
||||
<Span Text="1.02" ForegroundColor="{StaticResource LightTextColor}" />
|
||||
</FormattedString.Spans>
|
||||
</FormattedString>
|
||||
</Label.FormattedText>
|
||||
</Label>
|
||||
<Label Text="Cette application est une aide de jeu pour le plus célèbre des jeux de rôle" />
|
||||
<Label Text="Son contenu provient du site AideDD, et est traduit du SRD" />
|
||||
<Label Text="Les icones proviennent du site Game-icons.net" />
|
||||
|
||||
<Button Margin="0,10,0,0" Text="Site web" Command="{Binding OpenWebCommand}" BackgroundColor="{StaticResource titlered}" TextColor="{StaticResource bgtan}" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
|
|
|||
|
|
@ -105,8 +105,12 @@
|
|||
<ToolbarItem Text="Inscription" Order="Secondary" Command="{Binding OpenUrl}" CommandParameter="http://www.pathfinder-fr.org/members/register.aspx" />-->
|
||||
</ContentPage.ToolbarItems>
|
||||
<StackLayout Orientation="Vertical">
|
||||
<SearchBar />
|
||||
|
||||
<SearchBar x:Name="SearchBar" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}">
|
||||
<SearchBar.Behaviors>
|
||||
<tools:TextChangedBehavior />
|
||||
</SearchBar.Behaviors>
|
||||
</SearchBar>
|
||||
|
||||
<ListView x:Name="ItemsListView"
|
||||
ItemsSource="{Binding Items}"
|
||||
VerticalOptions="FillAndExpand"
|
||||
|
|
|
|||
|
|
@ -30,26 +30,27 @@ namespace AideDeJeu.Views
|
|||
|
||||
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
||||
{
|
||||
if (args.SelectedItem is Spell)
|
||||
{
|
||||
var item = args.SelectedItem as Spell;
|
||||
if (item == null)
|
||||
return;
|
||||
viewModel.GotoItemCommand.Execute(args.SelectedItem);
|
||||
//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 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));
|
||||
}
|
||||
// var vm = new MonsterDetailViewModel(item);
|
||||
// vm.LoadItemCommand.Execute(null);
|
||||
// await Navigation.PushAsync(new MonsterDetailPage(vm));
|
||||
//}
|
||||
|
||||
// Manually deselect item.
|
||||
ItemsListView.SelectedItem = null;
|
||||
|
|
|
|||
|
|
@ -6,5 +6,9 @@ namespace AideDeJeuLib
|
|||
{
|
||||
public class Item
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string NameVO { get; set; }
|
||||
public string NamePHB { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,6 @@ namespace AideDeJeuLib.Monsters
|
|||
{
|
||||
public class Monster : Item
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string NameVO { get; set; }
|
||||
public string NamePHB { get; set; }
|
||||
public string Power { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Size { get; set; }
|
||||
|
|
|
|||
|
|
@ -9,10 +9,6 @@ namespace AideDeJeuLib.Spells
|
|||
{
|
||||
public class Spell : Item
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string NameVO { get; set; }
|
||||
public string NamePHB { get; set; }
|
||||
public string LevelType { get; set; }
|
||||
public string Level { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue