mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-31 23:45:39 +00:00
Début refonte navigation
This commit is contained in:
parent
615181650d
commit
77e2eff092
6 changed files with 96 additions and 45 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using AideDeJeu.ViewModels;
|
using AideDeJeu.ViewModels;
|
||||||
using AideDeJeu.Views;
|
using AideDeJeu.Views;
|
||||||
|
using AideDeJeuLib.Models;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Xamarin.Forms.Xaml;
|
using Xamarin.Forms.Xaml;
|
||||||
|
|
||||||
|
|
@ -16,9 +17,10 @@ namespace AideDeJeu
|
||||||
|
|
||||||
DependencyService.Register<MainViewModel>();
|
DependencyService.Register<MainViewModel>();
|
||||||
var vm = DependencyService.Get<MainViewModel>();
|
var vm = DependencyService.Get<MainViewModel>();
|
||||||
var mainPage = new MainPage();
|
var mainPage = new ItemDetailPage(new ItemDetailViewModel(new HomeItem()));// new MainPage();
|
||||||
vm.Navigator = new Navigator(mainPage.Detail.Navigation);
|
var navigationPage = new NavigationPage(mainPage);
|
||||||
MainPage = mainPage;
|
vm.Navigator = new Navigator(navigationPage.Navigation); //mainPage.Detail.Navigation);
|
||||||
|
MainPage = navigationPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnStart ()
|
protected override void OnStart ()
|
||||||
|
|
|
||||||
23
AideDeJeu/AideDeJeu/Models/HomeItem.cs
Normal file
23
AideDeJeu/AideDeJeu/Models/HomeItem.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace AideDeJeuLib.Models
|
||||||
|
{
|
||||||
|
public class HomeItem : Item
|
||||||
|
{
|
||||||
|
public override string Markdown
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return
|
||||||
|
"# [Sorts](spells_hd.md)\n\n" +
|
||||||
|
"# [Créatures](monsters_hd.md)\n\n" +
|
||||||
|
"# [Etats spéciaux](conditions_hd.md)\n\n" +
|
||||||
|
"# [Spells](spells_vo.md)\n\n" +
|
||||||
|
"# [Monsters](monsters_vo.md)\n\n" +
|
||||||
|
"# [Conditions](conditions_vo.md)\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -195,6 +195,8 @@ namespace AideDeJeu.ViewModels
|
||||||
public async Task NavigateToLink(string s)
|
public async Task NavigateToLink(string s)
|
||||||
{
|
{
|
||||||
if (s != null)
|
if (s != null)
|
||||||
|
{
|
||||||
|
if (s.Contains("#"))
|
||||||
{
|
{
|
||||||
var regex = new Regex("/(?<file>.*)\\.md#(?<anchor>.*)");
|
var regex = new Regex("/(?<file>.*)\\.md#(?<anchor>.*)");
|
||||||
var match = regex.Match(s);
|
var match = regex.Match(s);
|
||||||
|
|
@ -208,6 +210,11 @@ namespace AideDeJeu.ViewModels
|
||||||
await Navigator.GotoItemDetailPageAsync(spell);
|
await Navigator.GotoItemDetailPageAsync(spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Navigator.GotoItemsPageAsync(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,15 @@ namespace AideDeJeu.ViewModels
|
||||||
await Navigation.PushAsync(new ItemDetailPage(vm));
|
await Navigation.PushAsync(new ItemDetailPage(vm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task GotoItemsPageAsync(Item item)
|
||||||
|
{
|
||||||
|
//if (item == null)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
//var vm = new ItemDetailViewModel(item);
|
||||||
|
//vm.LoadItemCommand.Execute(null);
|
||||||
|
await Navigation.PushAsync(new MainPage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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.MainPage" x:Name="This" IsPresented="False" Title="">
|
<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.MainPage"
|
||||||
|
x:Name="This"
|
||||||
|
IsPresented="False"
|
||||||
|
Title="{Binding ItemSourceType,Converter={StaticResource ItemSourceTypeToTitleConverter}}">
|
||||||
<MasterDetailPage.Resources>
|
<MasterDetailPage.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<tools:ItemSourceTypeToStringConverter x:Key="ItemSourceTypeToTitleConverter" SpellVO="Spells" SpellHD="Sorts (H&D)" MonsterVO="Monsters" MonsterHD="Créatures (H&D)" />
|
<tools:ItemSourceTypeToStringConverter x:Key="ItemSourceTypeToTitleConverter" SpellVO="Spells" SpellHD="Sorts (H&D)" MonsterVO="Monsters" MonsterHD="Créatures (H&D)" />
|
||||||
|
|
@ -31,22 +39,19 @@
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
</MasterDetailPage.Master>
|
</MasterDetailPage.Master>
|
||||||
<MasterDetailPage.Detail>
|
<MasterDetailPage.Detail>
|
||||||
<NavigationPage>
|
<ContentPage Title="">
|
||||||
<x:Arguments>
|
<!--<ContentPage.ToolbarItems>
|
||||||
<ContentPage Title="{Binding ItemSourceType,Converter={StaticResource ItemSourceTypeToTitleConverter}}">
|
|
||||||
<ContentPage.ToolbarItems>
|
|
||||||
<!--<ToolbarItem Name="Sorts (H&D)" Text="Sorts (H&D)" Order="Secondary" Command="{Binding SwitchToSpellsHD}" />
|
|
||||||
<ToolbarItem Name="Creatures (H&D)" Text="Créatures (H&D)" Order="Secondary" Command="{Binding SwitchToMonstersHD}" />
|
|
||||||
<ToolbarItem Name="Spells (VO)" Text="Spells (VO)" Order="Secondary" Icon="spell_book.png" Command="{Binding SwitchToSpellsVO}" />
|
|
||||||
<ToolbarItem Name="Monsters (VO)" Text="Monsters (VO)" Order="Secondary" Icon="dragon_head.png" Command="{Binding SwitchToMonstersVO}" />-->
|
|
||||||
<ToolbarItem Name="About" Text="À propos de..." Order="Secondary" Icon="wooden_sign.png" Command="{Binding AboutCommand}" />
|
<ToolbarItem Name="About" Text="À propos de..." Order="Secondary" Icon="wooden_sign.png" Command="{Binding AboutCommand}" />
|
||||||
</ContentPage.ToolbarItems>
|
</ContentPage.ToolbarItems>-->
|
||||||
<StackLayout Orientation="Vertical" VerticalOptions="Fill" HorizontalOptions="Fill">
|
<StackLayout Orientation="Vertical" VerticalOptions="Fill" HorizontalOptions="Fill">
|
||||||
|
<StackLayout Orientation="Horizontal">
|
||||||
|
<Button Text="=" Clicked="Button_Clicked"/>
|
||||||
<SearchBar x:Name="SearchBar" HeightRequest="42" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}">
|
<SearchBar x:Name="SearchBar" HeightRequest="42" SearchCommand="{Binding SearchCommand}" SearchCommandParameter="{Binding Text, Source={x:Reference SearchBar}}">
|
||||||
<SearchBar.Behaviors>
|
<SearchBar.Behaviors>
|
||||||
<tools:TextChangedBehavior />
|
<tools:TextChangedBehavior />
|
||||||
</SearchBar.Behaviors>
|
</SearchBar.Behaviors>
|
||||||
</SearchBar>
|
</SearchBar>
|
||||||
|
</StackLayout>
|
||||||
<ListView x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped">
|
<ListView x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" CachingStrategy="RecycleElement" SelectedItem="{Binding SelectedItem}" ItemTapped="ItemsListView_ItemTapped">
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|
@ -61,7 +66,5 @@
|
||||||
</ListView>
|
</ListView>
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
</x:Arguments>
|
|
||||||
</NavigationPage>
|
|
||||||
</MasterDetailPage.Detail>
|
</MasterDetailPage.Detail>
|
||||||
</MasterDetailPage>
|
</MasterDetailPage>
|
||||||
|
|
@ -35,6 +35,8 @@ namespace AideDeJeu.Views
|
||||||
{
|
{
|
||||||
base.OnAppearing();
|
base.OnAppearing();
|
||||||
|
|
||||||
|
this.MasterBehavior = MasterBehavior.Default;
|
||||||
|
this.MasterBehavior = MasterBehavior.Popover;
|
||||||
if (Main.Items.Count() == 0)
|
if (Main.Items.Count() == 0)
|
||||||
Main.LoadItemsCommand.Execute(null);
|
Main.LoadItemsCommand.Execute(null);
|
||||||
}
|
}
|
||||||
|
|
@ -44,5 +46,10 @@ namespace AideDeJeu.Views
|
||||||
if (e.Item == null) return;
|
if (e.Item == null) return;
|
||||||
((ListView)sender).SelectedItem = null;
|
((ListView)sender).SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Button_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.IsPresented = !this.IsPresented;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue