mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-29 14:35:45 +00:00
Design
This commit is contained in:
parent
bbf8acc06d
commit
87438c69c4
13 changed files with 294 additions and 21 deletions
|
|
@ -20,6 +20,9 @@
|
|||
<Compile Update="Views\AboutPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Views\SpellDetailPage.xaml.cs">
|
||||
<DependentUpon>SpellDetailPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Views\ItemDetailPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
<Color x:Key="titlered">#58180D</Color> <!--% titles-->
|
||||
<Color x:Key="titlegold">#C9AD6A</Color> <!--% titlerules-->
|
||||
<Color x:Key="rulered">#9C2B1B</Color> <!--% triangular rule in statsblock-->
|
||||
<Color x:Key="contentblack">#000000</Color> <!--% ajout -->
|
||||
|
||||
|
||||
<!--% Trim (affects tables and paperboxes)-->
|
||||
<Color x:Key="PhbLightGreen">#E0E5C1</Color> <!--% PHB Part 1-->
|
||||
|
|
@ -68,11 +70,17 @@
|
|||
<Style TargetType="ContentPage">
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource bgtan}" />
|
||||
</Style>
|
||||
<Style TargetType="StackLayout">
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource bgtan}" />
|
||||
</Style>
|
||||
<Style TargetType="ScrollView">
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource bgtan}" />
|
||||
</Style>
|
||||
|
||||
<OnPlatform x:Key="LinuxLibertineCapitals" x:TypeArguments="x:String">
|
||||
<On Platform="iOS" Value="Linux Libertine Capitals" />
|
||||
<On Platform="Android" Value="LinLibertine_aS.ttf#Linux Libertine Capitals" />
|
||||
<On Platform="UWP, WinRT, WinPhone" Value="Assets/Fonts/LinLibertine_aS.ttf#Linux Libertine Capitals" />
|
||||
<On Platform="UWP, WinRT, WinPhone" Value="Assets/Fonts/LinLibertine_R.ttf#Linux Libertine" />
|
||||
</OnPlatform>
|
||||
|
||||
<OnPlatform x:Key="LinuxLibertine" x:TypeArguments="x:String">
|
||||
|
|
@ -81,6 +89,18 @@
|
|||
<On Platform="UWP, WinRT, WinPhone" Value="Assets/Fonts/LinLibertine_R.ttf#Linux Libertine" />
|
||||
</OnPlatform>
|
||||
|
||||
<OnPlatform x:Key="LinuxLibertineBold" x:TypeArguments="x:String">
|
||||
<On Platform="iOS" Value="Linux Libertine" />
|
||||
<On Platform="Android" Value="LinLibertine_RB.ttf#Linux Libertine" />
|
||||
<On Platform="UWP, WinRT, WinPhone" Value="Assets/Fonts/LinLibertine_RB.ttf#Linux Libertine" />
|
||||
</OnPlatform>
|
||||
|
||||
<OnPlatform x:Key="LinuxLibertineItal" x:TypeArguments="x:String">
|
||||
<On Platform="iOS" Value="Linux Libertine" />
|
||||
<On Platform="Android" Value="LinLibertine_RI.ttf#Linux Libertine" />
|
||||
<On Platform="UWP, WinRT, WinPhone" Value="Assets/Fonts/LinLibertine_RI.ttf#Linux Libertine" />
|
||||
</OnPlatform>
|
||||
|
||||
<Style TargetType="Label">
|
||||
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertine}" />
|
||||
</Style>
|
||||
|
|
@ -88,23 +108,43 @@
|
|||
<Style TargetType="Label" x:Key="section">
|
||||
<Setter Property="FontSize" Value="Large" />
|
||||
<Setter Property="TextColor" Value="{StaticResource titlered}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertineCapitals}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Label" x:Key="subsection">
|
||||
<Setter Property="FontSize" Value="Medium" />
|
||||
<Setter Property="TextColor" Value="{StaticResource titlered}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Label" x:Key="subsubsection">
|
||||
<Setter Property="FontSize" Value="Small" />
|
||||
<Setter Property="FontSize" Value="Large" />
|
||||
<Setter Property="TextColor" Value="{StaticResource titlered}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertineCapitals}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Label" x:Key="subsubsection">
|
||||
<Setter Property="FontSize" Value="Large" />
|
||||
<Setter Property="TextColor" Value="{StaticResource titlered}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertineCapitals}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Label" x:Key="content">
|
||||
<Setter Property="FontSize" Value="Medium" />
|
||||
<Setter Property="TextColor" Value="{StaticResource contentblack}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertine}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Label" x:Key="contentbold">
|
||||
<Setter Property="FontSize" Value="Medium" />
|
||||
<Setter Property="TextColor" Value="{StaticResource contentblack}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertineBold}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Label" x:Key="contentital">
|
||||
<Setter Property="FontSize" Value="Medium" />
|
||||
<Setter Property="TextColor" Value="{StaticResource contentblack}" />
|
||||
<Setter Property="FontFamily" Value="{DynamicResource LinuxLibertineItal}" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="NavigationPage">
|
||||
<Setter Property="BarBackgroundColor" Value="{StaticResource Primary}" />
|
||||
<Setter Property="BarTextColor" Value="White" />
|
||||
<Setter Property="BarBackgroundColor" Value="{StaticResource titlered}" />
|
||||
<Setter Property="BarTextColor" Value="{StaticResource bgtan}" />
|
||||
<Setter Property="BackgroundColor" Value="{StaticResource bgtan}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace AideDeJeu.Services
|
|||
{
|
||||
var scrapper = new Scrappers();
|
||||
var spells = await scrapper.GetSpells(await scrapper.GetSpellIds("c"));
|
||||
items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.DescriptionText }).ToList();
|
||||
items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.Description }).ToList();
|
||||
return await Task.FromResult(items);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
67
AideDeJeu/AideDeJeu/Services/SpellDataStore.cs
Normal file
67
AideDeJeu/AideDeJeu/Services/SpellDataStore.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using AideDeJeu.Models;
|
||||
using AideDeJeuLib;
|
||||
|
||||
[assembly: Xamarin.Forms.Dependency(typeof(AideDeJeu.Services.SpellDataStore))]
|
||||
namespace AideDeJeu.Services
|
||||
{
|
||||
public class SpellDataStore : IDataStore<Spell>
|
||||
{
|
||||
List<Spell> items;
|
||||
|
||||
public SpellDataStore()
|
||||
{
|
||||
items = new List<Spell>();
|
||||
var mockItems = new List<Spell>
|
||||
{
|
||||
};
|
||||
|
||||
foreach (var item in mockItems)
|
||||
{
|
||||
items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> AddItemAsync(Spell item)
|
||||
{
|
||||
items.Add(item);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateItemAsync(Spell item)
|
||||
{
|
||||
var _item = items.Where((Spell arg) => arg.Id == item.Id).FirstOrDefault();
|
||||
items.Remove(_item);
|
||||
items.Add(item);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task<bool> DeleteItemAsync(Spell item)
|
||||
{
|
||||
var _item = items.Where((Spell arg) => arg.Id == item.Id).FirstOrDefault();
|
||||
items.Remove(_item);
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task<Spell> GetItemAsync(string id)
|
||||
{
|
||||
return await Task.FromResult(items.FirstOrDefault(s => s.Id == id));
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Spell>> GetItemsAsync(bool forceRefresh = false)
|
||||
{
|
||||
var scrapper = new Scrappers();
|
||||
items = (await scrapper.GetSpells(await scrapper.GetSpellIds(""))).ToList();
|
||||
|
||||
//items = spells.Select(spell => new Item() { Text = spell.Title, Description = spell.DescriptionText }).ToList();
|
||||
return await Task.FromResult(items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,12 +7,14 @@ using Xamarin.Forms;
|
|||
|
||||
using AideDeJeu.Models;
|
||||
using AideDeJeu.Services;
|
||||
using AideDeJeuLib;
|
||||
|
||||
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();
|
||||
|
||||
bool isBusy = false;
|
||||
public bool IsBusy
|
||||
|
|
|
|||
17
AideDeJeu/AideDeJeu/ViewModels/SpellDetailViewModel.cs
Normal file
17
AideDeJeu/AideDeJeu/ViewModels/SpellDetailViewModel.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
|
||||
using AideDeJeu.Models;
|
||||
using AideDeJeuLib;
|
||||
|
||||
namespace AideDeJeu.ViewModels
|
||||
{
|
||||
public class SpellDetailViewModel : BaseViewModel
|
||||
{
|
||||
public Spell Item { get; set; }
|
||||
public SpellDetailViewModel(Spell item = null)
|
||||
{
|
||||
Title = item?.Title;
|
||||
Item = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
59
AideDeJeu/AideDeJeu/ViewModels/SpellsViewModel.cs
Normal file
59
AideDeJeu/AideDeJeu/ViewModels/SpellsViewModel.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Xamarin.Forms;
|
||||
|
||||
using AideDeJeu.Models;
|
||||
using AideDeJeu.Views;
|
||||
using AideDeJeuLib;
|
||||
|
||||
namespace AideDeJeu.ViewModels
|
||||
{
|
||||
public class SpellsViewModel : BaseViewModel
|
||||
{
|
||||
public ObservableCollection<Spell> Items { get; set; }
|
||||
public Command LoadItemsCommand { get; set; }
|
||||
|
||||
public SpellsViewModel()
|
||||
{
|
||||
Title = "Browse";
|
||||
Items = new ObservableCollection<Spell>();
|
||||
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
|
||||
|
||||
//MessagingCenter.Subscribe<NewItemPage, Spell>(this, "AddItem", async (obj, item) =>
|
||||
//{
|
||||
// var _item = item as Item;
|
||||
// Items.Add(_item);
|
||||
// await DataStore.AddItemAsync(_item);
|
||||
//});
|
||||
}
|
||||
|
||||
async Task ExecuteLoadItemsCommand()
|
||||
{
|
||||
if (IsBusy)
|
||||
return;
|
||||
|
||||
IsBusy = true;
|
||||
|
||||
try
|
||||
{
|
||||
Items.Clear();
|
||||
var items = await SpellDataStore.GetItemsAsync(true);
|
||||
foreach (var item in items)
|
||||
{
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsBusy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -104,9 +104,9 @@
|
|||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<StackLayout Padding="10">
|
||||
<Label Text="{Binding Text}"
|
||||
<Label Text="{Binding Title}"
|
||||
LineBreakMode="NoWrap"
|
||||
Style="{DynamicResource ListItemTextStyle}"
|
||||
Style="{DynamicResource subsubsection}"
|
||||
FontSize="16" />
|
||||
<!--<Label Text="{Binding Description}"
|
||||
LineBreakMode="NoWrap"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using AideDeJeu.Models;
|
||||
using AideDeJeu.ViewModels;
|
||||
using AideDeJeuLib;
|
||||
using System;
|
||||
|
||||
using Xamarin.Forms;
|
||||
|
|
@ -10,22 +11,22 @@ namespace AideDeJeu.Views
|
|||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class MainPage : MasterDetailPage //TabbedPage
|
||||
{
|
||||
ItemsViewModel viewModel;
|
||||
SpellsViewModel viewModel;
|
||||
|
||||
public MainPage ()
|
||||
{
|
||||
InitializeComponent ();
|
||||
|
||||
BindingContext = viewModel = new ItemsViewModel();
|
||||
BindingContext = viewModel = new SpellsViewModel();
|
||||
}
|
||||
|
||||
async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
|
||||
{
|
||||
var item = args.SelectedItem as Item;
|
||||
var item = args.SelectedItem as Spell;
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));
|
||||
await Navigation.PushAsync(new SpellDetailPage(new SpellDetailViewModel(item)));
|
||||
|
||||
// Manually deselect item.
|
||||
ItemsListView.SelectedItem = null;
|
||||
|
|
|
|||
45
AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml
Normal file
45
AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="AideDeJeu.Views.SpellDetailPage"
|
||||
Title="{Binding Title}">
|
||||
<ScrollView>
|
||||
<StackLayout Orientation="Vertical" Padding="15">
|
||||
<Label Text="{Binding Item.Title}" Style="{StaticResource Key=subsubsection}" />
|
||||
|
||||
<Label Text=" " />
|
||||
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label Text="{Binding Item.Type}" Style="{StaticResource Key=contentital}" />
|
||||
<Label Text="{Binding Item.Level, StringFormat='de niveau {0}'}" Style="{StaticResource Key=contentital}" />
|
||||
</StackLayout>
|
||||
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label Text="Durée d'incantation :" Style="{StaticResource Key=contentbold}" />
|
||||
<Label Text="{Binding Item.CastingTime}" Style="{StaticResource Key=content}" />
|
||||
</StackLayout>
|
||||
|
||||
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label Text="Portée :" Style="{StaticResource Key=contentbold}" />
|
||||
<Label Text="{Binding Item.Range}" Style="{StaticResource Key=content}" />
|
||||
</StackLayout>
|
||||
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label Text="Composantes :" Style="{StaticResource Key=contentbold}" />
|
||||
<Label Text="{Binding Item.Components}" Style="{StaticResource Key=content}" />
|
||||
</StackLayout>
|
||||
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label Text="Durée :" Style="{StaticResource Key=contentbold}" />
|
||||
<Label Text="{Binding Item.Duration}" Style="{StaticResource Key=content}" />
|
||||
</StackLayout>
|
||||
|
||||
<Label Text=" " />
|
||||
|
||||
<Label Text="{Binding Item.Description}" Style="{StaticResource Key=content}" />
|
||||
|
||||
<Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</ContentPage>
|
||||
38
AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs
Normal file
38
AideDeJeu/AideDeJeu/Views/SpellDetailPage.xaml.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
using AideDeJeu.Models;
|
||||
using AideDeJeu.ViewModels;
|
||||
using AideDeJeuLib;
|
||||
|
||||
namespace AideDeJeu.Views
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class SpellDetailPage : ContentPage
|
||||
{
|
||||
SpellDetailViewModel viewModel;
|
||||
|
||||
public SpellDetailPage(SpellDetailViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
BindingContext = this.viewModel = viewModel;
|
||||
}
|
||||
|
||||
public SpellDetailPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
var item = new Spell
|
||||
{
|
||||
Title = "",
|
||||
//Description = "This is an item description."
|
||||
};
|
||||
|
||||
viewModel = new SpellDetailViewModel(item);
|
||||
BindingContext = viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -72,8 +72,8 @@ namespace AideDeJeuLib
|
|||
newSpell.Components = spell.SelectSingleNode("div[strong/text()='Composantes']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||
newSpell.Duration = spell.SelectSingleNode("div[strong/text()='Durée']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||
newSpell.DescriptionDiv = spell.SelectSingleNode("div[contains(@class,'description')]");
|
||||
newSpell.Description = newSpell.DescriptionDiv.InnerHtml;
|
||||
newSpell.DescriptionText = newSpell.DescriptionDiv.InnerText;
|
||||
//newSpell.DescriptionHtml = newSpell.DescriptionDiv.InnerHtml;
|
||||
//newSpell.Description = newSpell.DescriptionDiv.InnerText;
|
||||
newSpell.Overflow = spell.SelectSingleNode("div[@class='overflow']")?.InnerText;
|
||||
newSpell.NoOverflow = spell.SelectSingleNode("div[@class='nooverflow']")?.InnerText;
|
||||
newSpell.Source = spell.SelectSingleNode("div[@class='source']").InnerText;
|
||||
|
|
@ -143,7 +143,7 @@ namespace AideDeJeuLib
|
|||
newSpell.Components = spell.SelectSingleNode("div[strong/text()='Composantes']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||
newSpell.Duration = spell.SelectSingleNode("div[strong/text()='Durée']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
|
||||
newSpell.DescriptionDiv = spell.SelectSingleNode("div[contains(@class,'description')]");
|
||||
newSpell.Description = newSpell.DescriptionDiv.InnerHtml;
|
||||
//newSpell.Description = newSpell.DescriptionDiv.InnerHtml;
|
||||
newSpell.Overflow = spell.SelectSingleNode("div[@class='overflow']")?.InnerText;
|
||||
newSpell.NoOverflow = spell.SelectSingleNode("div[@class='nooverflow']")?.InnerText;
|
||||
newSpell.Source = spell.SelectSingleNode("div[@class='source']").InnerText;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace AideDeJeuLib
|
|||
{
|
||||
public class Spell
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string TitleUS { get; set; }
|
||||
public string LevelType { get; set; }
|
||||
|
|
@ -16,8 +17,8 @@ namespace AideDeJeuLib
|
|||
public string Range { get; set; }
|
||||
public string Components { get; set; }
|
||||
public string Duration { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string DescriptionText { get; set; }
|
||||
public string DescriptionHtml { get { return DescriptionDiv.InnerHtml; } }
|
||||
public string Description { get { return DescriptionDiv.InnerHtml.Replace("<br>", "\r\n").Replace("<strong>","").Replace("</strong>", "").Replace("<em>", "").Replace("</em>", ""); } }
|
||||
public HtmlNode DescriptionDiv { get; set; }
|
||||
public string Overflow { get; set; }
|
||||
public string NoOverflow { get; set; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue