WIP
This commit is contained in:
parent
22417409a2
commit
a72d457eef
52 changed files with 919 additions and 280 deletions
|
|
@ -11,7 +11,9 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using XLabs.Forms.Controls;
|
||||
using XLabs.Forms.Mvvm;
|
||||
using XLabs.Forms.Pages;
|
||||
using XLabs.Forms.Services;
|
||||
using XLabs.Ioc;
|
||||
using XLabs.Platform.Mvvm;
|
||||
|
|
@ -30,16 +32,30 @@ namespace BookAStar
|
|||
{
|
||||
public static IPlatform PlatformSpecificInstance { get; set; }
|
||||
public static string AppName { get; set; }
|
||||
|
||||
public void ShowQueries()
|
||||
{
|
||||
masterDetail.Detail = bQueriesPage;
|
||||
masterDetail.SendBackButtonPressed();
|
||||
}
|
||||
public void ShowAccounts()
|
||||
{
|
||||
masterDetail.Detail = accChooserPage;
|
||||
masterDetail.SendBackButtonPressed();
|
||||
}
|
||||
// Exists in order to dispose of a static instance strongly typed
|
||||
// TODO : replace all references to this field
|
||||
// by Views resolution, and then, drop it
|
||||
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
|
||||
|
||||
app.Closing += (o, e) => Debug.WriteLine("Application Closing");
|
||||
app.Error += (o, e) => Debug.WriteLine("Application Error");
|
||||
|
|
@ -48,42 +64,56 @@ namespace BookAStar
|
|||
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 void Configure(IXFormsApp app)
|
||||
{
|
||||
ViewFactory.EnableCache = true;
|
||||
ViewFactory.Register<DashboardPage, DashboardViewModel>(
|
||||
resolver => new DashboardViewModel());
|
||||
ViewFactory.Register<BookQueryPage, BookQueryViewModel>();
|
||||
ViewFactory.Register<EditBillingLinePage, BillingLineViewModel>();
|
||||
ViewFactory.Register<EditEstimatePage, EstimateViewModel>();
|
||||
}
|
||||
|
||||
|
||||
ExtendedMasterDetailPage masterDetail;
|
||||
|
||||
public App(IPlatform instance)
|
||||
{
|
||||
PlatformSpecificInstance = instance;
|
||||
InitializeComponent();
|
||||
Init();
|
||||
MainPage = GetMainPage();
|
||||
BuildMainPage();
|
||||
}
|
||||
BookQueriesPage bQueriesPage;
|
||||
AccountChooserPage accChooserPage;
|
||||
HomePage home;
|
||||
|
||||
public static Page GetMainPage()
|
||||
private void BuildMainPage()
|
||||
{
|
||||
ViewFactory.Register<SettingsPage,SettingsViewModel>();
|
||||
ViewFactory.Register<BookQueryPage, BookQueryViewModel>(
|
||||
resolver => new BookQueryViewModel ()
|
||||
);
|
||||
|
||||
var bQueriesPage = new BookQueriesPage
|
||||
accChooserPage = new AccountChooserPage();
|
||||
|
||||
bQueriesPage = new BookQueriesPage
|
||||
{
|
||||
BindingContext = DataManager.Current.BookQueries,
|
||||
Title = "Demandes"
|
||||
};
|
||||
|
||||
// var mainPage = new NavigationPage(bQueriesPage);
|
||||
home = new HomePage() { Title = "Accueil" };
|
||||
|
||||
var mainPage = new XLabs.Forms.Pages.ExtendedMasterDetailPage() {
|
||||
// var mainPage = new NavigationPage(bQueriesPage);
|
||||
/*
|
||||
masterDetail = new ExtendedMasterDetailPage() {
|
||||
Title="MainPAge"
|
||||
};
|
||||
|
||||
mainPage.Master = bQueriesPage;
|
||||
mainPage.Detail = new SettingsPage();
|
||||
|
||||
Resolver.Resolve<IDependencyContainer>()
|
||||
.Register<INavigationService>(t => new NavigationService(mainPage.Navigation));
|
||||
masterDetail.Master = new DashboardPage {
|
||||
Title = "Bookingstar",
|
||||
BindingContext = new DashboardViewModel() };
|
||||
masterDetail.Detail = new HomePage { Title = "Accueil" };
|
||||
|
||||
*/
|
||||
ToolbarItem tiSetts = new ToolbarItem()
|
||||
{
|
||||
Text = "Paramètres",
|
||||
|
|
@ -95,9 +125,11 @@ namespace BookAStar
|
|||
Text = "Accueil",
|
||||
Icon = "icon.png"
|
||||
};
|
||||
mainPage.ToolbarItems.Add(tiHome);
|
||||
mainPage.ToolbarItems.Add(tiSetts);
|
||||
return mainPage;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* searchPage = new SearchPage
|
||||
{
|
||||
|
|
@ -161,13 +193,33 @@ namespace BookAStar
|
|||
};
|
||||
MainPage = Navigation;
|
||||
*/
|
||||
var mainTab = new ExtendedTabbedPage()
|
||||
{
|
||||
Title = "XLabs",
|
||||
SwipeEnabled = true,
|
||||
TintColor = Color.White,
|
||||
BarTintColor = Color.Blue,
|
||||
Badges = { "1", "2", "3" },
|
||||
TabBarBackgroundImage = "visuel_sexion.png",
|
||||
TabBarSelectedImage = "icon.png",
|
||||
};
|
||||
|
||||
var navPage = new NavigationPage(bQueriesPage);
|
||||
//var navPage = new NavigationPage(mainTab);
|
||||
|
||||
navPage.ToolbarItems.Add(tiHome);
|
||||
navPage.ToolbarItems.Add(tiSetts);
|
||||
|
||||
this.MainPage = navPage;
|
||||
|
||||
Resolver.Resolve<IDependencyContainer>()
|
||||
.Register<INavigationService>(t => new NavigationService(navPage.Navigation))
|
||||
;
|
||||
}
|
||||
|
||||
internal void EditCommandLine(Page parentPage, CommandLine com)
|
||||
internal void EditCommandLine(Page parentPage, BillingLine com)
|
||||
{
|
||||
CommandLineEditorPage editCommandLine = new CommandLineEditorPage
|
||||
EditBillingLinePage editCommandLine = new EditBillingLinePage
|
||||
{
|
||||
Title = "Edition d'une ligne de facture",
|
||||
BindingContext = com
|
||||
|
|
@ -181,26 +233,12 @@ namespace BookAStar
|
|||
"gcm/register",
|
||||
PlatformSpecificInstance.GetDeviceInfo());
|
||||
}
|
||||
|
||||
public void ShowBookQuery(BookQueryData data)
|
||||
|
||||
public static void ShowBookQuery (BookQueryData query)
|
||||
{
|
||||
BookQueryPage bookQueryPage = new BookQueryPage
|
||||
{
|
||||
Title = "Demande de devis",
|
||||
BindingContext = data
|
||||
};
|
||||
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);
|
||||
var page = ViewFactory.CreatePage<BookQueryViewModel
|
||||
, BookQueryPage>(null, new BookQueryViewModel(query));
|
||||
App.Current.MainPage.Navigation.PushAsync(page as Page);
|
||||
}
|
||||
|
||||
// TODO système de persistance de l'état de l'appli
|
||||
|
|
@ -212,12 +250,12 @@ namespace BookAStar
|
|||
/// <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)
|
||||
public static async Task ShowPage(VisualElement parentPage, Type pageType)
|
||||
{
|
||||
// Get all the constructors of the page type.
|
||||
var constructors = pageType.GetTypeInfo().DeclaredConstructors;
|
||||
|
||||
foreach ( var page in
|
||||
foreach (var page in
|
||||
from constructor in constructors
|
||||
where constructor.GetParameters().Length == 0
|
||||
select (Page)constructor.Invoke(null))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue