intergartions XLabs.* WIP MVVM
This commit is contained in:
parent
24e13be888
commit
b6d3dc1a9b
49 changed files with 6236 additions and 2960 deletions
|
|
@ -3,9 +3,19 @@ using BookAStar.Interfaces;
|
|||
using BookAStar.Model;
|
||||
using BookAStar.Model.Workflow;
|
||||
using BookAStar.Pages;
|
||||
using BookAStar.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Forms.Mvvm;
|
||||
using XLabs.Forms.Services;
|
||||
using XLabs.Ioc;
|
||||
using XLabs.Platform.Mvvm;
|
||||
using XLabs.Platform.Services;
|
||||
/*
|
||||
Glyphish icons from
|
||||
http://www.glyphish.com/
|
||||
|
|
@ -18,97 +28,151 @@ namespace BookAStar
|
|||
{
|
||||
public partial class App : Application // superclass new in 1.3
|
||||
{
|
||||
SearchPage searchPage = new SearchPage
|
||||
{
|
||||
Title = "Trouvez votre artiste",
|
||||
Icon = "glyphish_07_map_marker.png"
|
||||
};
|
||||
NavigationPage mp;
|
||||
|
||||
SettingsPage settingsPage = new SettingsPage
|
||||
{
|
||||
Title = "Paramètres",
|
||||
Icon = "ic_corp_icon.png"
|
||||
};
|
||||
|
||||
PinPage pinPage = new PinPage
|
||||
{
|
||||
Title = "Carte",
|
||||
Icon = "glyphish_07_map_marker.png"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static IPlatform PlatformSpecificInstance { get; set; }
|
||||
public static string AppName { get; set; }
|
||||
public static App CurrentApp { get { return Current as App; } }
|
||||
|
||||
public DataManager DataManager { get; set; } = new DataManager();
|
||||
public static void Init()
|
||||
{
|
||||
var app = Resolver.Resolve<IXFormsApp>();
|
||||
if (app == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// navigation registration
|
||||
|
||||
internal void EditCommandLine(CommandLine com)
|
||||
app.Closing += (o, e) => Debug.WriteLine("Application Closing");
|
||||
app.Error += (o, e) => Debug.WriteLine("Application Error");
|
||||
app.Initialize += (o, e) => Debug.WriteLine("Application Initialized");
|
||||
app.Resumed += (o, e) => Debug.WriteLine("Application Resumed");
|
||||
app.Rotation += (o, e) => Debug.WriteLine("Application Rotated");
|
||||
app.Startup += (o, e) => Debug.WriteLine("Application Startup");
|
||||
app.Suspended += (o, e) => Debug.WriteLine("Application Suspended");
|
||||
|
||||
}
|
||||
|
||||
public App(IPlatform instance)
|
||||
{
|
||||
PlatformSpecificInstance = instance;
|
||||
InitializeComponent();
|
||||
Init();
|
||||
MainPage = GetMainPage();
|
||||
}
|
||||
|
||||
public static Page GetMainPage()
|
||||
{
|
||||
ViewFactory.Register<SettingsPage,SettingsViewModel>();
|
||||
ViewFactory.Register<BookQueryPage, BookQueryViewModel>(
|
||||
resolver => new BookQueryViewModel ()
|
||||
);
|
||||
|
||||
var bQueriesPage = new BookQueriesPage
|
||||
{
|
||||
BindingContext = DataManager.Current.BookQueries,
|
||||
Title = "Demandes"
|
||||
};
|
||||
|
||||
// var mainPage = new NavigationPage(bQueriesPage);
|
||||
|
||||
var mainPage = new XLabs.Forms.Pages.ExtendedMasterDetailPage() {
|
||||
Title="MainPAge"
|
||||
};
|
||||
|
||||
mainPage.Master = bQueriesPage;
|
||||
mainPage.Detail = new SettingsPage();
|
||||
|
||||
Resolver.Resolve<IDependencyContainer>()
|
||||
.Register<INavigationService>(t => new NavigationService(mainPage.Navigation));
|
||||
|
||||
ToolbarItem tiSetts = new ToolbarItem()
|
||||
{
|
||||
Text = "Paramètres",
|
||||
Icon = "ic_corp_icon.png"
|
||||
};
|
||||
|
||||
ToolbarItem tiHome = new ToolbarItem()
|
||||
{
|
||||
Text = "Accueil",
|
||||
Icon = "icon.png"
|
||||
};
|
||||
mainPage.ToolbarItems.Add(tiHome);
|
||||
mainPage.ToolbarItems.Add(tiSetts);
|
||||
return mainPage;
|
||||
|
||||
/* searchPage = new SearchPage
|
||||
{
|
||||
Title = "Trouvez votre artiste",
|
||||
Icon = "glyphish_07_map_marker.png"
|
||||
};
|
||||
|
||||
settingsPage = new SettingsPage
|
||||
{
|
||||
Title = "Paramètres",
|
||||
Icon = "ic_corp_icon.png"
|
||||
};
|
||||
|
||||
pinPage = new PinPage
|
||||
{
|
||||
Title = "Carte",
|
||||
Icon = "glyphish_07_map_marker.png"
|
||||
};
|
||||
PlatformSpecificInstance = instance;
|
||||
Navigation = new NavigationPage(searchPage);
|
||||
|
||||
//var hasLabelStyle = r.ContainsKey("labelStyle");
|
||||
// var stid = this.StyleId;
|
||||
// null var appsstyle = settingsPage.Style;
|
||||
// appsstyle.CanCascade = true;
|
||||
MainPage = Navigation;
|
||||
ToolbarItem tiSetts = new ToolbarItem()
|
||||
{
|
||||
Text = "Settings",
|
||||
Icon = "ic_corp_icon.png"
|
||||
};
|
||||
Navigation.ToolbarItems.Add(tiSetts);
|
||||
tiSetts.Clicked += (object sender, EventArgs e) =>
|
||||
{
|
||||
ShowPage (settingsPage);
|
||||
};
|
||||
ToolbarItem tiQueries = new ToolbarItem
|
||||
{
|
||||
Text = "Demandes"
|
||||
};
|
||||
|
||||
tiQueries.Clicked += (object sender, EventArgs e) =>
|
||||
{
|
||||
BookQueriesPage bookQueriesPage = new BookQueriesPage
|
||||
{
|
||||
Title = "Demandes de devis"
|
||||
};
|
||||
bookQueriesPage.BindingContext = DataManager.BookQueries;
|
||||
ShowPage(bookQueriesPage);
|
||||
};
|
||||
Navigation.ToolbarItems.Add(tiQueries);
|
||||
ToolbarItem tiMap = new ToolbarItem
|
||||
{
|
||||
Text = "Carte",
|
||||
Icon = "glyphish_07_map_marker.png"
|
||||
};
|
||||
Navigation.ToolbarItems.Add(tiMap);
|
||||
tiMap.Clicked += (object sender, EventArgs e) =>
|
||||
{
|
||||
ShowPage(pinPage);
|
||||
};
|
||||
MainPage = Navigation;
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
internal void EditCommandLine(Page parentPage, CommandLine com)
|
||||
{
|
||||
CommandLineEditorPage editCommandLine = new CommandLineEditorPage
|
||||
{
|
||||
Title = "Edition d'une ligne de facture",
|
||||
BindingContext = com
|
||||
};
|
||||
mp.Navigation.PushAsync(editCommandLine);
|
||||
}
|
||||
|
||||
public App(IPlatform instance)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
PlatformSpecificInstance = instance;
|
||||
mp = new NavigationPage(searchPage)
|
||||
{
|
||||
BackgroundColor = (Color)Application.Current.Resources["PageBackgroundColor"]
|
||||
};
|
||||
var color = Application.Current.Resources["PageBackgroundColor"];
|
||||
//var hasLabelStyle = r.ContainsKey("labelStyle");
|
||||
// var stid = this.StyleId;
|
||||
// null var appsstyle = settingsPage.Style;
|
||||
// appsstyle.CanCascade = true;
|
||||
MainPage = mp;
|
||||
ToolbarItem tiSetts = new ToolbarItem()
|
||||
{
|
||||
Text = "Settings",
|
||||
Icon = "ic_corp_icon.png"
|
||||
};
|
||||
mp.ToolbarItems.Add(tiSetts);
|
||||
tiSetts.Clicked += (object sender, EventArgs e) =>
|
||||
{
|
||||
ShowPage (settingsPage);
|
||||
};
|
||||
ToolbarItem tiQueries = new ToolbarItem
|
||||
{
|
||||
Text = "Demandes"
|
||||
};
|
||||
|
||||
tiQueries.Clicked += (object sender, EventArgs e) =>
|
||||
{
|
||||
BookQueriesPage bookQueriesPage = new BookQueriesPage
|
||||
{
|
||||
Title = "Demandes de devis"
|
||||
};
|
||||
bookQueriesPage.BindingContext = DataManager.BookQueries;
|
||||
ShowPage(bookQueriesPage);
|
||||
};
|
||||
mp.ToolbarItems.Add(tiQueries);
|
||||
ToolbarItem tiMap = new ToolbarItem
|
||||
{
|
||||
Text = "Carte",
|
||||
Icon = "glyphish_07_map_marker.png"
|
||||
};
|
||||
mp.ToolbarItems.Add(tiMap);
|
||||
tiMap.Clicked += (object sender, EventArgs e) =>
|
||||
{
|
||||
ShowPage(pinPage);
|
||||
};
|
||||
|
||||
parentPage.Navigation.PushAsync(editCommandLine);
|
||||
}
|
||||
|
||||
public void PostDeviceInfo()
|
||||
|
|
@ -122,31 +186,45 @@ namespace BookAStar
|
|||
{
|
||||
BookQueryPage bookQueryPage = new BookQueryPage
|
||||
{
|
||||
Title = "Demande de devis"
|
||||
Title = "Demande de devis",
|
||||
BindingContext = data
|
||||
};
|
||||
bookQueryPage.BindingContext = data;
|
||||
ShowPage(bookQueryPage);
|
||||
ShowPage(bookQueryPage);
|
||||
}
|
||||
|
||||
public void EditEstimate(Estimate data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
EditEstimatePage editEstimate = new EditEstimatePage
|
||||
{
|
||||
Title = "Création d'un devis"
|
||||
};
|
||||
editEstimate.Estimate = data;
|
||||
ShowPage(editEstimate);
|
||||
// ShowPage(editEstimate);
|
||||
}
|
||||
|
||||
// TODO système de persistance de l'état de l'appli
|
||||
private void ShowPage(Page p)
|
||||
|
||||
/// <summary>
|
||||
/// Shows a page asynchronously by locating the default constructor, creating the page,
|
||||
/// the pushing it onto the navigation stack.
|
||||
/// </summary>
|
||||
/// <param name="parentPage">Parent Page</param>
|
||||
/// <param name="pageType">Type of page to show</param>
|
||||
/// <returns></returns>
|
||||
private static async Task ShowPage(VisualElement parentPage, Type pageType)
|
||||
{
|
||||
if (p.Parent!=null)
|
||||
// Get all the constructors of the page type.
|
||||
var constructors = pageType.GetTypeInfo().DeclaredConstructors;
|
||||
|
||||
foreach ( var page in
|
||||
from constructor in constructors
|
||||
where constructor.GetParameters().Length == 0
|
||||
select (Page)constructor.Invoke(null))
|
||||
{
|
||||
mp.Navigation.RemovePage(p);
|
||||
p.Parent = null;
|
||||
await parentPage.Navigation.PushAsync(page);
|
||||
break;
|
||||
}
|
||||
mp.Navigation.PushAsync(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue