From 471ea5e37a49e9ae75a7dc69ffe57d3ab5fffd0d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 21 Sep 2016 04:02:40 +0200 Subject: [PATCH 01/59] WIP --- BookAStar/BookAStar.Droid/Assets/test.html | 71 ++++++++++ .../BookAStar.Droid/BookAStar.Droid.csproj | 8 +- BookAStar/BookAStar.Droid/MainActivity.cs | 43 ++----- BookAStar/BookAStar.Droid/MarkdownEditor.cs | 66 +++------- .../BookAStar.Droid/MarkdownEditor.cshtml | 43 +++---- .../BookAStar.Droid/MarkdownViewRenderer.cs | 94 ++++++++++++++ .../BookAStar.Droid/MarkdownWebViewClient.cs | 6 +- .../Properties/AssemblyInfo.cs | 2 +- .../Resources/Resource.Designer.cs | 43 ++++--- .../Resources/drawable/Icon-anon-48px.png | Bin 0 -> 1700 bytes .../Resources/drawable/Icon-anon-64px.png | Bin 0 -> 2426 bytes .../Resources/drawable/Icon-anon-73px.png | Bin 0 -> 2516 bytes .../Resources/drawable/Icon-anon-org.png | Bin 0 -> 2719 bytes .../Resources/drawable/icon-anon.png | Bin 0 -> 1031 bytes .../Resources/layout/EditEstimate.axml | 5 + BookAStar/BookAStar/App.xaml | 20 ++- BookAStar/BookAStar/App.xaml.cs | 121 +++++++++--------- BookAStar/BookAStar/BookAStar.csproj | 26 ++-- BookAStar/BookAStar/Constants.cs | 34 ++++- .../BookAStar/Helpers/AvatarImageSource.cs | 28 ++++ .../BookAStar/{ => Helpers}/DataManager.cs | 11 +- BookAStar/BookAStar/Helpers/MainSettings.cs | 6 - BookAStar/BookAStar/Helpers/RemoteEntity.cs | 95 ++++++++------ BookAStar/BookAStar/Helpers/RemoteEntityRO.cs | 4 +- BookAStar/BookAStar/Interfaces/IMDEditor.cs | 13 ++ .../BookAStar/{ => Interfaces}/IPlatform.cs | 5 +- BookAStar/BookAStar/Model/BookQueryData.cs | 6 - .../BookAStar/Model/ClientProviderInfo.cs | 23 ++++ BookAStar/BookAStar/Model/Manager.cs | 9 +- BookAStar/BookAStar/Model/Social/Location.cs | 12 +- .../BookAStar/Model/Workflow/Estimate.cs | 32 ++++- BookAStar/BookAStar/Pages/BlogPage.cs | 2 +- .../BookAStar/Pages/BookQueriesPage.xaml | 66 ++++++---- .../BookAStar/Pages/BookQueriesPage.xaml.cs | 8 +- BookAStar/BookAStar/Pages/BookQueryPage.xaml | 40 ++++-- .../BookAStar/Pages/BookQueryPage.xaml.cs | 18 ++- .../BookAStar/Pages/EditEstimatePage.xaml | 42 ++++++ .../BookAStar/Pages/EditEstimatePage.xaml.cs | 44 +++++++ BookAStar/BookAStar/Pages/EventDetail.xaml.cs | 2 +- .../BookAStar/Pages/MakeAnEstimatePage.xaml | 10 -- .../Pages/MakeAnEstimatePage.xaml.cs | 28 ---- BookAStar/BookAStar/Pages/QueriesPage.xaml | 6 - BookAStar/BookAStar/Pages/QueriesPage.xaml.cs | 18 --- BookAStar/BookAStar/Pages/SearchPage.xaml | 6 +- BookAStar/BookAStar/Pages/SettingsPage.xaml | 16 ++- .../BookAStar/Pages/SettingsPage.xaml.cs | 12 +- .../BookAStar/Properties/AssemblyInfo.cs | 6 +- BookAStar/BookAStar/Views/MarkdownView.cs | 36 +++--- BookAStar/BookAStar/icon-anon.png | Bin 0 -> 1031 bytes 49 files changed, 742 insertions(+), 444 deletions(-) create mode 100644 BookAStar/BookAStar.Droid/Assets/test.html create mode 100644 BookAStar/BookAStar.Droid/MarkdownViewRenderer.cs create mode 100644 BookAStar/BookAStar.Droid/Resources/drawable/Icon-anon-48px.png create mode 100644 BookAStar/BookAStar.Droid/Resources/drawable/Icon-anon-64px.png create mode 100644 BookAStar/BookAStar.Droid/Resources/drawable/Icon-anon-73px.png create mode 100644 BookAStar/BookAStar.Droid/Resources/drawable/Icon-anon-org.png create mode 100644 BookAStar/BookAStar.Droid/Resources/drawable/icon-anon.png create mode 100644 BookAStar/BookAStar.Droid/Resources/layout/EditEstimate.axml create mode 100644 BookAStar/BookAStar/Helpers/AvatarImageSource.cs rename BookAStar/BookAStar/{ => Helpers}/DataManager.cs (74%) create mode 100644 BookAStar/BookAStar/Interfaces/IMDEditor.cs rename BookAStar/BookAStar/{ => Interfaces}/IPlatform.cs (85%) create mode 100644 BookAStar/BookAStar/Model/ClientProviderInfo.cs create mode 100644 BookAStar/BookAStar/Pages/EditEstimatePage.xaml create mode 100644 BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs delete mode 100644 BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml delete mode 100644 BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml.cs delete mode 100644 BookAStar/BookAStar/Pages/QueriesPage.xaml delete mode 100644 BookAStar/BookAStar/Pages/QueriesPage.xaml.cs create mode 100644 BookAStar/BookAStar/icon-anon.png diff --git a/BookAStar/BookAStar.Droid/Assets/test.html b/BookAStar/BookAStar.Droid/Assets/test.html new file mode 100644 index 00000000..1a5fbf10 --- /dev/null +++ b/BookAStar/BookAStar.Droid/Assets/test.html @@ -0,0 +1,71 @@ + + + + + + + + + +

Title

+
+

Hello Estimate!

+
+
+ + + + + + + + + + + + diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index e2410b5b..c7b024ce 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -88,7 +88,8 @@ ..\..\packages\Xam.Plugin.Media.1.0.1\lib\MonoAndroid10\Media.Plugin.Abstractions.dll True - + + @@ -203,6 +204,7 @@ True MarkdownEditor.cshtml + @@ -224,6 +226,9 @@ + + Designer + @@ -301,6 +306,7 @@ + diff --git a/BookAStar/BookAStar.Droid/MainActivity.cs b/BookAStar/BookAStar.Droid/MainActivity.cs index 11e58483..d1dd5105 100644 --- a/BookAStar/BookAStar.Droid/MainActivity.cs +++ b/BookAStar/BookAStar.Droid/MainActivity.cs @@ -27,7 +27,8 @@ using Android.Webkit; using Xamarin.Forms; using Xamarin.Forms.Platform.Android; using Android.Views; - +using BookAStar.Helpers; +using BookAStar.Interfaces; namespace BookAStar.Droid { @@ -87,11 +88,11 @@ namespace BookAStar.Droid { var accStore = AccountStore.Create(this); - var accounts = accStore.FindAccountsForService(MainSettings.ApplicationName); + var accounts = accStore.FindAccountsForService(Constants.ApplicationName); accStore.Delete( accounts.Where(a => a.Username == userName).FirstOrDefault() - , MainSettings.ApplicationName); + , Constants.ApplicationName); Toast.MakeText(this, Resource.String.yavscIdentRemoved , ToastLength.Short); @@ -160,7 +161,7 @@ namespace BookAStar.Droid using (var reader = new StreamReader(response.GetResponseStream())) { responseText = reader.ReadToEnd(); - Log.Debug(MainSettings.ApplicationName, responseText); + Log.Debug(Constants.ApplicationName, responseText); } } } @@ -180,7 +181,7 @@ namespace BookAStar.Droid { return await Task.Run(() => { var manager = AccountStore.Create(this); - return manager.FindAccountsForService(MainSettings.ApplicationName); + return manager.FindAccountsForService(Constants.ApplicationName); }); } YaOAuth2Authenticator auth = new YaOAuth2Authenticator( @@ -215,7 +216,7 @@ namespace BookAStar.Droid // get me // var request = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, eventArgs.Account); - var request = new HttpRequestMessage(HttpMethod.Get, MainSettings.UserInfoUrl); + var request = new HttpRequestMessage(HttpMethod.Get, Constants.UserInfoUrl); request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokens.AccessToken); @@ -244,7 +245,7 @@ namespace BookAStar.Droid }; MainSettings.SaveUser(newuser); - accStore.Save(acc, MainSettings.ApplicationName); + accStore.Save(acc, Constants.ApplicationName); } } @@ -331,34 +332,6 @@ namespace BookAStar.Droid return m.InvokeJson(arg); } } - - public Xamarin.Forms.View CreateMarkdownView(string markdown, Action update) - { - var view = new Android.Webkit.WebView(Forms.Context); - var viewclient = new MarkdownWebViewClient(update); - view.SetWebViewClient(viewclient); - var mde = new MarkdownEditor(); - if (markdown!=null) - { - var md = new MarkdownDeep.Markdown(); - mde.Model = md.Transform(markdown); - } - var html = mde.GenerateString(); - view.Settings.BuiltInZoomControls = true; - view.Settings.JavaScriptEnabled = true; - view.Settings.LoadsImagesAutomatically = true; - view.Settings.SetAppCacheEnabled(true); - view.Settings.AllowContentAccess = true; - view.Settings.AllowFileAccess = true; - view.Settings.AllowFileAccessFromFileURLs = true; - view.Settings.AllowUniversalAccessFromFileURLs = true; - view.Settings.BlockNetworkImage = false; - view.Settings.BlockNetworkLoads = false; - view.LoadDataWithBaseURL("file:///android_asset/", - html, "text/html", "utf-8",null); - - return view.ToView(); - } } } diff --git a/BookAStar/BookAStar.Droid/MarkdownEditor.cs b/BookAStar/BookAStar.Droid/MarkdownEditor.cs index 24f34298..854ebed9 100644 --- a/BookAStar/BookAStar.Droid/MarkdownEditor.cs +++ b/BookAStar/BookAStar.Droid/MarkdownEditor.cs @@ -17,7 +17,7 @@ using System.Linq; using System.Text; -[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorTemplatePreprocessor", "4.1.2.18")] +[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorTemplatePreprocessor", "4.2.0.680")] public partial class MarkdownEditor : MarkdownEditorBase { @@ -32,32 +32,30 @@ public string Model { get; set; } public override void Execute() { -WriteLiteral("\r\n\r\n\r\n \r\n \r\n\r\n\r\n \r\n\r\n \r\n - + + + + + + + + + - - - diff --git a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs index c278d4e5..977886bc 100644 --- a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs @@ -15,10 +15,11 @@ namespace BookAStar.Pages public BookQueriesPage() { InitializeComponent(); - BindingContext = App.CurrentApp.DataManager.BookQueries; + } + protected override void OnBindingContextChanged() + { list.ItemsSource = BindingContext as ObservableCollection; - list.RefreshCommand = BindingContext as ICommand; - list.IsPullToRefreshEnabled = true; + base.OnBindingContextChanged(); } public RemoteEntity Queries @@ -40,7 +41,6 @@ namespace BookAStar.Pages { BookQueryData data = e.Item as BookQueryData; App.CurrentApp.ShowBookQuery(data); - throw new NotImplementedException(); } } } diff --git a/BookAStar/BookAStar/Pages/BookQueryPage.xaml b/BookAStar/BookAStar/Pages/BookQueryPage.xaml index 9067855d..0925bce4 100644 --- a/BookAStar/BookAStar/Pages/BookQueryPage.xaml +++ b/BookAStar/BookAStar/Pages/BookQueryPage.xaml @@ -1,19 +1,35 @@  + x:Class="BookAStar.Pages.BookQueryPage" + BackgroundColor="{x:Static local:Constants.BackgroundColor}" + Padding="{x:Static local:Constants.PagePadding}" + > + + + + + + + + - - - + \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs new file mode 100644 index 00000000..5d4ecb15 --- /dev/null +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs @@ -0,0 +1,44 @@ +using BookAStar.Model; +using BookAStar.Model.Workflow; +using BookAStar.Views; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using Xamarin.Forms; + +namespace BookAStar.Pages +{ + public partial class EditEstimatePage : ContentPage + { + public Estimate Estimate { get { return BindingContext as Estimate; } set { + BindingContext = value; + } } + public static readonly BindableProperty MarkdownProperty = + BindableProperty.Create("Description", typeof(string), typeof(Estimate), + null, BindingMode.TwoWay); + public static readonly BindableProperty ClientProperty = + BindableProperty.Create("Client", typeof(ClientProviderInfo), typeof(Estimate), + null, BindingMode.OneWay); + public static readonly BindableProperty QueryProperty = + BindableProperty.Create("Query", typeof(BookQueryData), typeof(Estimate), + null, BindingMode.OneWay); + + public EditEstimatePage() + { + InitializeComponent(); + } + protected override void OnBindingContextChanged() + { + base.OnBindingContextChanged(); + mdview.Markdown = Estimate?.Description; + } + + protected void OnDescriptionChanged (object sender, EventArgs e) + { + Estimate.Description = mdview.Markdown; + } + } +} diff --git a/BookAStar/BookAStar/Pages/EventDetail.xaml.cs b/BookAStar/BookAStar/Pages/EventDetail.xaml.cs index 9099b96e..70c2d88d 100644 --- a/BookAStar/BookAStar/Pages/EventDetail.xaml.cs +++ b/BookAStar/BookAStar/Pages/EventDetail.xaml.cs @@ -15,7 +15,7 @@ namespace BookAStar BindingContext = ev; btn_webpage.Clicked += (object sender, EventArgs e) => { - App.PlateformSpecificInstance.OpenWeb(ev.EventWebPage); + App.PlatformSpecificInstance.OpenWeb(ev.EventWebPage); }; } diff --git a/BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml b/BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml deleted file mode 100644 index 0b3b4b8f..00000000 --- a/BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml.cs deleted file mode 100644 index 9d124474..00000000 --- a/BookAStar/BookAStar/Pages/MakeAnEstimatePage.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookAStar.Model.Workflow; -using BookAStar.Views; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Xamarin.Forms; - -namespace BookAStar.Pages -{ - public partial class MakeAnEstimatePage : ContentPage - { - public Estimate Estimate { get { return BindingContext as Estimate; } set { - BindingContext = value; - } } - - public static readonly BindableProperty MarkdownProperty = - BindableProperty.Create("Description", typeof(string), typeof(Estimate), - null, BindingMode.TwoWay); - - public MakeAnEstimatePage(string clientId,long bookQueryId) - { - InitializeComponent(); - } - } -} diff --git a/BookAStar/BookAStar/Pages/QueriesPage.xaml b/BookAStar/BookAStar/Pages/QueriesPage.xaml deleted file mode 100644 index 19125c42..00000000 --- a/BookAStar/BookAStar/Pages/QueriesPage.xaml +++ /dev/null @@ -1,6 +0,0 @@ - - - \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/QueriesPage.xaml.cs b/BookAStar/BookAStar/Pages/QueriesPage.xaml.cs deleted file mode 100644 index a3bbc670..00000000 --- a/BookAStar/BookAStar/Pages/QueriesPage.xaml.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using Xamarin.Forms; - -namespace BookAStar -{ - public partial class QueriesPage : ContentPage - { - public QueriesPage() - { - InitializeComponent(); - } - } -} diff --git a/BookAStar/BookAStar/Pages/SearchPage.xaml b/BookAStar/BookAStar/Pages/SearchPage.xaml index c47a8d5d..7a9cfccb 100644 --- a/BookAStar/BookAStar/Pages/SearchPage.xaml +++ b/BookAStar/BookAStar/Pages/SearchPage.xaml @@ -6,10 +6,7 @@ Padding="10,40,10,10" > - - + @@ -19,7 +16,6 @@ - s diff --git a/BookAStar/BookAStar/Pages/SettingsPage.xaml b/BookAStar/BookAStar/Pages/SettingsPage.xaml index e0984276..9301f215 100644 --- a/BookAStar/BookAStar/Pages/SettingsPage.xaml +++ b/BookAStar/BookAStar/Pages/SettingsPage.xaml @@ -30,9 +30,10 @@ BindingContext="." > - + RowSpacing="2"> + @@ -42,10 +43,18 @@ BindingContext="." > + + - + + + + - diff --git a/BookAStar/BookAStar/Pages/SettingsPage.xaml.cs b/BookAStar/BookAStar/Pages/SettingsPage.xaml.cs index d1ad3c51..1a47a79b 100644 --- a/BookAStar/BookAStar/Pages/SettingsPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/SettingsPage.xaml.cs @@ -33,13 +33,7 @@ namespace BookAStar AccountListView.ItemSelected += Accounts_ItemSelected; pushstatus.Toggled += Pushstatus_Toggled; - - BtnViewDeviceInfo.Clicked += BtnDeviceInfo_Clicked; - } - - private void BtnDeviceInfo_Clicked(object sender, EventArgs e) - { - ((BookAStar.App) App.Current).ShowDeviceInfo(); + } protected void Pushstatus_Toggled(object sender, ToggledEventArgs e) @@ -64,7 +58,7 @@ namespace BookAStar var doIt = await Confirm("Suppression de l'identification", $"Vous êtes sur le point de supprimer votre identification pour ce compte : {user.UserName}\nContinuer ?"); if (doIt) - App.PlateformSpecificInstance.RevokeAccount(user.UserName); + App.PlatformSpecificInstance.RevokeAccount(user.UserName); } async Task Confirm(string title, string procedure) @@ -84,7 +78,7 @@ namespace BookAStar private void AddAccountBtn_Clicked(object sender, EventArgs e) { - App.PlateformSpecificInstance.AddAccount(); + App.PlatformSpecificInstance.AddAccount(); } diff --git a/BookAStar/BookAStar/Properties/AssemblyInfo.cs b/BookAStar/BookAStar/Properties/AssemblyInfo.cs index 076d24fe..dcb0c729 100644 --- a/BookAStar/BookAStar/Properties/AssemblyInfo.cs +++ b/BookAStar/BookAStar/Properties/AssemblyInfo.cs @@ -9,11 +9,11 @@ using System.Runtime.InteropServices; [assembly: AssemblyTitle("BookAStar")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("Paul Schneider")] [assembly: AssemblyProduct("BookAStar")] [assembly: AssemblyCopyright("Copyright © Paul Albert Schneider 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyTrademark("Yavsc")] +[assembly: AssemblyCulture("fr")] [assembly: NeutralResourcesLanguage("fr")] // Version information for an assembly consists of the following four values: diff --git a/BookAStar/BookAStar/Views/MarkdownView.cs b/BookAStar/BookAStar/Views/MarkdownView.cs index 0ede50ea..b00195ac 100644 --- a/BookAStar/BookAStar/Views/MarkdownView.cs +++ b/BookAStar/BookAStar/Views/MarkdownView.cs @@ -1,14 +1,15 @@ -using System; +using BookAStar.Interfaces; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; using Xamarin.Forms; - + namespace BookAStar.Views { - public partial class MarkdownView : ContentView + public class MarkdownView : View { public static readonly BindableProperty MarkdownProperty = BindableProperty.Create( "Markdown", typeof(string), typeof(MarkdownView), null, BindingMode.TwoWay @@ -23,25 +24,20 @@ namespace BookAStar.Views return markdown; } set { - markdown = value; - Content = App.PlateformSpecificInstance.CreateMarkdownView( - markdown, - e => { - Markdown = e; - if (Validated != null) - Validated.Invoke(this, new EventArgs()); + if (markdown != value) + if (Edited != null) + { + markdown = value; + Edited.Invoke(this, new EventArgs()); + return; } - ); - + + markdown = value; } } - - public MarkdownView() : base() - { - - } - - public event EventHandler Validated; - + + public event EventHandler Edited; + } + } diff --git a/BookAStar/BookAStar/icon-anon.png b/BookAStar/BookAStar/icon-anon.png new file mode 100644 index 0000000000000000000000000000000000000000..38d6db946724a8c9a2bac8cd7d2a08d7e1bacaac GIT binary patch literal 1031 zcmV+i1o-=jP)*YZ{1Bi=>U_!P|?qRLwLcD)yli#Gs-tQVEEt2#O%0 zNCd$f7Fw(LWWh8=TT+Bl+otJD2-Gw}bFqJZ@@RIl_LLs3nHW6UL~eiT!-d)?&C;{H@^yV!Vz0 z2f5=d(tOFx>h4y0sk>>0b@bA@nxlnJg1?Ufu*W?XS_RufOKIhYg5`7okMHO>6h9Nc z5I-J&6`(y>_+jn}_MnQ-*casMDEHn~x8>ai><;b3lOUr-<&ca}9q+6tW0LhW`xzYOCDK8H z_GfiaHZQT=$~DcfRbxnV75(!8*e!g@GhrGyzcL(Lml5G9dq8PH1(P~R%8clJ{2YMY zV1R}&)toLKiQNg6YUB%k!(%5q=(Nuj!y1c#r>SwQAyG1Ci6kE|L>A)+Gi*@>2E{w^ zH&u>GG9~e&Mh-_52b8g%zbpgTl_KCGw>oZPp`?WG0Aygm0a6@O$V6_i2)MuoN98J4 zbQolkvA{lB_>mF9@)9RfML3U2N0QQQAK_2K%;O2}<{SFWVW_7B7b5AnN~Gl0Ub8VI zMXi}>hN(av8Gb4uh;Y@BChD(m!Fn_L9x$gEQNKcQxo@C=*zJF!q{AesVd81huD#5K zZ7tii%UZMy7*d2+MIcF;h>@S9;&F zGuzIOI|=jq=(lP)6GNCVL!LA+G1KCQuY6cSWrGiGi}`_m29kk)t{Em!nlnR-ZH2+O z06{Ku&$+Il*|aNPYJef~Nnz#Oa6_qcU5l-OxuVscjmAAq_2G(;90ClFoMq>(OppJ- zf&YISm#iv$d-djUgSA-$(v$|Xe%E{{_x7U>*AxW0e2^002ovPDHLkV1oC> B*){+G literal 0 HcmV?d00001 From e217ecfcc314adcd5db9ba4ffcf8b623c258ddb5 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 25 Sep 2016 00:37:29 +0200 Subject: [PATCH 02/59] @VS update --- Yavsc.Client/Yavsc.Client.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Yavsc.Client/Yavsc.Client.csproj b/Yavsc.Client/Yavsc.Client.csproj index 85cf1cb1..e2655832 100644 --- a/Yavsc.Client/Yavsc.Client.csproj +++ b/Yavsc.Client/Yavsc.Client.csproj @@ -25,6 +25,7 @@ DEBUG;TRACE prompt 4 + pdbonly @@ -33,6 +34,7 @@ TRACE prompt 4 + From d17b73eb771a7a26fa365f1cdf3966acede3efca Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 25 Sep 2016 00:39:33 +0200 Subject: [PATCH 03/59] @Vs update --- BookAStar/BookAStar.Droid/BookAStar.Droid.csproj | 2 ++ BookAStar/BookAStar.iOS/BookAStar.iOS.csproj | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index c7b024ce..20085de3 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -42,6 +42,7 @@ 1100m Xamarin False + pdbonly @@ -62,6 +63,7 @@ False False False + diff --git a/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj b/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj index 1c69864b..ca76670d 100644 --- a/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj +++ b/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj @@ -26,6 +26,7 @@ i386, x86_64 None true + none @@ -36,6 +37,7 @@ None i386, x86_64 false + true @@ -50,6 +52,7 @@ iPhone Developer true Entitlements.plist + none @@ -61,6 +64,7 @@ false iPhone Developer Entitlements.plist + none @@ -74,6 +78,7 @@ Automatic:AdHoc iPhone Distribution Entitlements.plist + none @@ -86,6 +91,13 @@ Automatic:AppStore iPhone Distribution Entitlements.plist + + + + + + + From a24b9c4a655b701dc44e56bd1569965a62441c62 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 25 Sep 2016 00:40:21 +0200 Subject: [PATCH 04/59] cleans unused references --- BookAStar/BookAStar.Droid/MainActivity.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/BookAStar/BookAStar.Droid/MainActivity.cs b/BookAStar/BookAStar.Droid/MainActivity.cs index d1dd5105..9a7601e3 100644 --- a/BookAStar/BookAStar.Droid/MainActivity.cs +++ b/BookAStar/BookAStar.Droid/MainActivity.cs @@ -9,7 +9,6 @@ using Android.Gms.Common; using Android.Util; using Xamarin.Auth; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Net; using System.IO; @@ -17,16 +16,10 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Net.Http; -using System.Text; using BookAStar.Model.Auth.Account; using BookAStar.Droid.OAuth; using Yavsc.Helpers; using Yavsc.Models.Identity; -using static Android.Content.Res.Resources; -using Android.Webkit; -using Xamarin.Forms; -using Xamarin.Forms.Platform.Android; -using Android.Views; using BookAStar.Helpers; using BookAStar.Interfaces; From 906f3a217828b5f9073a0e94f1a9bbbe384e7d64 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 25 Sep 2016 00:40:49 +0200 Subject: [PATCH 05/59] adds the Video button --- BookAStar/BookAStar.Droid/MarkdownEditor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BookAStar/BookAStar.Droid/MarkdownEditor.cs b/BookAStar/BookAStar.Droid/MarkdownEditor.cs index 854ebed9..2dbf1da5 100644 --- a/BookAStar/BookAStar.Droid/MarkdownEditor.cs +++ b/BookAStar/BookAStar.Droid/MarkdownEditor.cs @@ -122,7 +122,7 @@ WriteLiteral(@"> [{ 'header': 1 }, { 'header': 2 }], // custom button values [{ 'list': 'ordered' }, { 'list': 'bullet' }], [{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent - ['link', 'image'], + ['link', 'image', 'video'], ['clean'] // remove formatting button ]; From db675279bb9d7d9cf763f6eab2aceb7f50ed4174 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 25 Sep 2016 00:41:30 +0200 Subject: [PATCH 06/59] Adds the video button --- BookAStar/BookAStar.Droid/MarkdownEditor.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BookAStar/BookAStar.Droid/MarkdownEditor.cshtml b/BookAStar/BookAStar.Droid/MarkdownEditor.cshtml index 1b9ccc99..86e90cf4 100644 --- a/BookAStar/BookAStar.Droid/MarkdownEditor.cshtml +++ b/BookAStar/BookAStar.Droid/MarkdownEditor.cshtml @@ -42,7 +42,7 @@ [{ 'header': 1 }, { 'header': 2 }], // custom button values [{ 'list': 'ordered' }, { 'list': 'bullet' }], [{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent - ['link', 'image'], + ['link', 'image', 'video'], ['clean'] // remove formatting button ]; From 87c4a7f282147b28766789221a72c0740be0dba7 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 25 Sep 2016 00:44:30 +0200 Subject: [PATCH 07/59] Wip theme+estimate --- BookAStar/BookAStar/App.xaml | 72 +++++++++++------ BookAStar/BookAStar/App.xaml.cs | 79 +++++++++++-------- BookAStar/BookAStar/BookAStar.csproj | 37 +++++---- .../BookAStar/Model/Workflow/CommandLine.cs | 8 +- .../BookAStar/Model/Workflow/Estimate.cs | 28 +++++++ BookAStar/BookAStar/Pages/BookQueryPage.xaml | 26 +++--- .../Pages/CommandLineEditorPage.xaml | 32 ++++++++ ....xaml.cs => CommandLineEditorPage.xaml.cs} | 10 +-- .../BookAStar/Pages/EditEstimatePage.xaml | 41 ++++------ .../BookAStar/Pages/EditEstimatePage.xaml.cs | 19 ++++- .../BookAStar/Views/CommandLineEditor.xaml | 25 ++++++ .../CommandLineEditor.xaml.cs} | 7 +- 12 files changed, 256 insertions(+), 128 deletions(-) create mode 100644 BookAStar/BookAStar/Pages/CommandLineEditorPage.xaml rename BookAStar/BookAStar/Pages/{MarkdownEditorPage.xaml.cs => CommandLineEditorPage.xaml.cs} (62%) create mode 100644 BookAStar/BookAStar/Views/CommandLineEditor.xaml rename BookAStar/BookAStar/{Pages/MainPage.xaml.cs => Views/CommandLineEditor.xaml.cs} (63%) diff --git a/BookAStar/BookAStar/App.xaml b/BookAStar/BookAStar/App.xaml index 92a8dfbe..a3f0bde3 100644 --- a/BookAStar/BookAStar/App.xaml +++ b/BookAStar/BookAStar/App.xaml @@ -4,36 +4,63 @@ x:Class="BookAStar.App" > - - - - - - #30FAFAFA - #207AFAFA - #FF103010 - #FF303010 - - + + - - - + + + + - \ No newline at end of file diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index 4d0b8edd..fa13a098 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -18,46 +18,56 @@ namespace BookAStar { public partial class App : Application // superclass new in 1.3 { - ContentPage deviceInfoPage; 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" }; - BookQueryPage bookQueryPage = new BookQueryPage { - Title = "Demande de devis" - }; - BookQueriesPage bookQueriesPage = new BookQueriesPage - { - Title = "Demandes de devis" - }; + + + + + - EditEstimatePage editEstimate = new EditEstimatePage - { - Title = "Création d'un devis" - }; 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(); - + + internal void EditCommandLine(CommandLine com) + { + CommandLineEditorPage editCommandLine = new CommandLineEditorPage + { + Title = "Edition d'une ligne de facture", + BindingContext = com + }; + mp.Navigation.PushAsync(editCommandLine); + } + public App(IPlatform instance) { - deviceInfoPage = new DeviceInfoPage(instance.GetDeviceInfo()); + InitializeComponent(); + PlatformSpecificInstance = instance; - mp = new NavigationPage(searchPage); + 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; @@ -80,7 +90,12 @@ namespace BookAStar tiQueries.Clicked += (object sender, EventArgs e) => { - ShowPage (bookQueriesPage); + BookQueriesPage bookQueriesPage = new BookQueriesPage + { + Title = "Demandes de devis" + }; + bookQueriesPage.BindingContext = DataManager.BookQueries; + ShowPage(bookQueriesPage); }; mp.ToolbarItems.Add(tiQueries); ToolbarItem tiMap = new ToolbarItem @@ -93,17 +108,9 @@ namespace BookAStar { ShowPage(pinPage); }; - - bookQueriesPage.BindingContext = DataManager.BookQueries; - } - public void ShowDeviceInfo() - { - ShowPage(deviceInfoPage); - } - public void PostDeviceInfo() { var res = PlatformSpecificInstance.InvokeApi( @@ -113,25 +120,33 @@ namespace BookAStar public void ShowBookQuery(BookQueryData data) { + BookQueryPage bookQueryPage = new BookQueryPage + { + Title = "Demande de devis" + }; bookQueryPage.BindingContext = data; ShowPage(bookQueryPage); } public void EditEstimate(Estimate data) { + EditEstimatePage editEstimate = new EditEstimatePage + { + Title = "Création d'un devis" + }; editEstimate.Estimate = data; ShowPage(editEstimate); } - private void ShowPage(Page p) + // TODO système de persistance de l'état de l'appli + private void ShowPage(Page p) { - if (p.Parent == null) - mp.Navigation.PushAsync(p); - else p.Focus(); - } - public void CloseWindow() - { - mp.Navigation.PopAsync(); + if (p.Parent!=null) + { + mp.Navigation.RemovePage(p); + p.Parent = null; + } + mp.Navigation.PushAsync(p); } } } diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj index 95e58428..e7744bb4 100644 --- a/BookAStar/BookAStar/BookAStar.csproj +++ b/BookAStar/BookAStar/BookAStar.csproj @@ -25,6 +25,7 @@ DEBUG;TRACE prompt 4 + pdbonly @@ -33,6 +34,7 @@ TRACE prompt 4 + @@ -51,16 +53,15 @@ BookQueryPage.xaml - + + CommandLineEditorPage.xaml + EventDetail.xaml - - MainPage.xaml - @@ -103,10 +104,10 @@ EditEstimatePage.xaml - - MarkdownEditorPage.xaml - + + CommandLineEditor.xaml + @@ -118,10 +119,6 @@ - - Designer - MSBuild:UpdateDesignTimeXaml - Designer MSBuild:UpdateDesignTimeXaml @@ -199,12 +196,6 @@ Yavsc.Client - - - MSBuild:UpdateDesignTimeXaml - Designer - - MSBuild:UpdateDesignTimeXaml @@ -220,6 +211,18 @@ + + + Designer + MSBuild:UpdateDesignTimeXaml + + + + + MSBuild:UpdateDesignTimeXaml + Designer + + diff --git a/BookAStar/BookAStar/Model/Workflow/CommandLine.cs b/BookAStar/BookAStar/Model/Workflow/CommandLine.cs index 89f72c57..65ef4cdd 100644 --- a/BookAStar/BookAStar/Model/Workflow/CommandLine.cs +++ b/BookAStar/BookAStar/Model/Workflow/CommandLine.cs @@ -1,12 +1,12 @@  +using System; + namespace BookAStar.Model.Workflow { - public class CommandLine { - public long Id { get; set; } - public string Comment { get; set; } - public BaseProduct Article { get; set; } + public string Description { get; set; } + public TimeSpan Duration { get; set; } public int Count { get; set; } public decimal UnitaryCost { get; set; } } diff --git a/BookAStar/BookAStar/Model/Workflow/Estimate.cs b/BookAStar/BookAStar/Model/Workflow/Estimate.cs index 02d03b97..7e06a982 100644 --- a/BookAStar/BookAStar/Model/Workflow/Estimate.cs +++ b/BookAStar/BookAStar/Model/Workflow/Estimate.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Xamarin.Forms; namespace BookAStar.Model.Workflow { @@ -67,5 +68,32 @@ namespace BookAStar.Model.Workflow return DataManager.Current.Contacts.LocalGet(ClientId); } } + + public FormattedString FormattedTotal + { + get + { + OnPlatform lfs = (OnPlatform < Font >) App.Current.Resources["LargeFontSize"]; + OnPlatform etc = (OnPlatform)App.Current.Resources["EmphasisTextColor"]; + + return new FormattedString + { + + Spans = { + new Span { Text = "Total TTC: " }, + new Span { Text = Total.ToString(), + ForegroundColor = etc.Android , + FontSize = (double) lfs.Android.FontSize }, + new Span { Text = "€", FontSize = (double) lfs.Android.FontSize } + } + }; + } + set { } + } + public decimal Total { get + { + return Bill?.Aggregate((decimal)0, (t, l) => t + l.Count * l.UnitaryCost) ?? (decimal)0; + } + } } } diff --git a/BookAStar/BookAStar/Pages/BookQueryPage.xaml b/BookAStar/BookAStar/Pages/BookQueryPage.xaml index 0925bce4..e9fc0ed2 100644 --- a/BookAStar/BookAStar/Pages/BookQueryPage.xaml +++ b/BookAStar/BookAStar/Pages/BookQueryPage.xaml @@ -9,27 +9,21 @@ > - - + - - + \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/MarkdownEditorPage.xaml.cs b/BookAStar/BookAStar/Pages/CommandLineEditorPage.xaml.cs similarity index 62% rename from BookAStar/BookAStar/Pages/MarkdownEditorPage.xaml.cs rename to BookAStar/BookAStar/Pages/CommandLineEditorPage.xaml.cs index 082c66ad..53ce3842 100644 --- a/BookAStar/BookAStar/Pages/MarkdownEditorPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/CommandLineEditorPage.xaml.cs @@ -8,16 +8,12 @@ using Xamarin.Forms; namespace BookAStar.Pages { - public partial class MarkdownEditorPage : ContentPage + public partial class CommandLineEditorPage : ContentPage { - public MarkdownEditorPage() + public CommandLineEditorPage() { InitializeComponent(); - } - - public void GetText() - { - + } } } diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml index 7b489cd4..1dedba98 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml @@ -2,41 +2,32 @@ - - + xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar" + xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"> + - - - + + + - - - - - - + + + \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs index 5d4ecb15..b48bd88c 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs @@ -16,7 +16,10 @@ namespace BookAStar.Pages public Estimate Estimate { get { return BindingContext as Estimate; } set { BindingContext = value; } } - public static readonly BindableProperty MarkdownProperty = + public static readonly BindableProperty TotalProperty = + BindableProperty.Create("Total", typeof(decimal), typeof(EditEstimatePage), + (decimal) 0, BindingMode.OneWay); + public static readonly BindableProperty DescriptionProperty = BindableProperty.Create("Description", typeof(string), typeof(Estimate), null, BindingMode.TwoWay); public static readonly BindableProperty ClientProperty = @@ -26,19 +29,31 @@ namespace BookAStar.Pages BindableProperty.Create("Query", typeof(BookQueryData), typeof(Estimate), null, BindingMode.OneWay); + + public EditEstimatePage() { InitializeComponent(); } + protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); - mdview.Markdown = Estimate?.Description; + // FIXME Why the Binding don't work? + mdview.Markdown = Estimate.Description; + } protected void OnDescriptionChanged (object sender, EventArgs e) { + // FIXME Why the Binding don't work? Estimate.Description = mdview.Markdown; } + protected void OnNewCommanLine(object sender, EventArgs e) + { + var com = new CommandLine(); + App.CurrentApp.EditCommandLine(com); + } + } } diff --git a/BookAStar/BookAStar/Views/CommandLineEditor.xaml b/BookAStar/BookAStar/Views/CommandLineEditor.xaml new file mode 100644 index 00000000..17a79010 --- /dev/null +++ b/BookAStar/BookAStar/Views/CommandLineEditor.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + Heures + Jours + Minutes + + + + + + + + \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/MainPage.xaml.cs b/BookAStar/BookAStar/Views/CommandLineEditor.xaml.cs similarity index 63% rename from BookAStar/BookAStar/Pages/MainPage.xaml.cs rename to BookAStar/BookAStar/Views/CommandLineEditor.xaml.cs index 318924ab..08443e3a 100644 --- a/BookAStar/BookAStar/Pages/MainPage.xaml.cs +++ b/BookAStar/BookAStar/Views/CommandLineEditor.xaml.cs @@ -5,13 +5,14 @@ using System.Text; using System.Threading.Tasks; using Xamarin.Forms; -namespace App2 +namespace BookAStar.Views { - public partial class MainPage : ContentPage + public partial class CommandLineEditor : ContentView { - public MainPage() + public CommandLineEditor() { InitializeComponent(); + } } } From 3c175f3969048a5135aaf698a685eaf9b86981cd Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 25 Sep 2016 00:44:42 +0200 Subject: [PATCH 08/59] cleaning --- BookAStar/BookAStar/Pages/DeviceInfoPage.cs | 30 ------------------- BookAStar/BookAStar/Pages/MainPage.xaml | 11 ------- .../BookAStar/Pages/MarkdownEditorPage.xaml | 9 ------ 3 files changed, 50 deletions(-) delete mode 100644 BookAStar/BookAStar/Pages/DeviceInfoPage.cs delete mode 100644 BookAStar/BookAStar/Pages/MainPage.xaml delete mode 100644 BookAStar/BookAStar/Pages/MarkdownEditorPage.xaml diff --git a/BookAStar/BookAStar/Pages/DeviceInfoPage.cs b/BookAStar/BookAStar/Pages/DeviceInfoPage.cs deleted file mode 100644 index 18789cb8..00000000 --- a/BookAStar/BookAStar/Pages/DeviceInfoPage.cs +++ /dev/null @@ -1,30 +0,0 @@ -using BookAStar.Model.Auth.Account; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using Xamarin.Forms; -using Yavsc.Models.Identity; - -namespace BookAStar.Pages -{ - public class DeviceInfoPage : ContentPage - { - public DeviceInfoPage(IGCMDeclaration infos) - { - Content = new StackLayout - { - Padding = 50, - VerticalOptions = LayoutOptions.Center, - Children = { - new Label{ Text = "Id: " + infos.DeviceId}, - new Label{ Text = "Model: " + infos.Model}, - new Label{ Text = "Platform: " + infos.Platform}, - new Label{ Text = "Version: " + infos.Version}, - } - }; - - } - } -} diff --git a/BookAStar/BookAStar/Pages/MainPage.xaml b/BookAStar/BookAStar/Pages/MainPage.xaml deleted file mode 100644 index 13d5c566..00000000 --- a/BookAStar/BookAStar/Pages/MainPage.xaml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/MarkdownEditorPage.xaml b/BookAStar/BookAStar/Pages/MarkdownEditorPage.xaml deleted file mode 100644 index 755adfc0..00000000 --- a/BookAStar/BookAStar/Pages/MarkdownEditorPage.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file From 1ee8e83013bd907a65940c07c919b5f05b679de2 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 27 Sep 2016 02:35:45 +0200 Subject: [PATCH 09/59] intergartions XLabs.* WIP MVVM --- .../BookAStar.Droid/BookAStar.Droid.csproj | 210 +- BookAStar/BookAStar.Droid/Helpers/Settings.cs | 4 +- .../Helpers/SimpleJsonPostMethod.cs | 26 +- BookAStar/BookAStar.Droid/MainActivity.cs | 111 +- BookAStar/BookAStar.Droid/MainApplication.cs | 63 + .../BookAStar.Droid/MarkdownWebViewClient.cs | 12 - .../PluginsHelp/ConnectivityReadme.txt | 17 - .../PluginsHelp/GeolocatorReadme.txt | 24 - .../Resources/Resource.Designer.cs | 7791 +++++++++++------ .../drawable/{icon-anon.png => icon_anon.png} | Bin .../Resources/values/strings.xml | 1 + .../Resources/values/styles.xml | 18 +- .../Services/GcmListenerService.cs | 2 +- BookAStar/BookAStar.Droid/app.config | 8 + .../BookAStar.Droid/google-services.json | 78 + BookAStar/BookAStar.Droid/packages.config | 43 +- BookAStar/BookAStar.iOS/AppDelegate.cs | 51 +- BookAStar/BookAStar.iOS/BookAStar.iOS.csproj | 16 +- BookAStar/BookAStar.iOS/app.config | 4 + BookAStar/BookAStar.iOS/packages.config | 2 +- BookAStar/BookAStar/App.xaml | 23 +- BookAStar/BookAStar/App.xaml.cs | 258 +- BookAStar/BookAStar/BookAStar.csproj | 58 +- BookAStar/BookAStar/Constants.cs | 7 +- BookAStar/BookAStar/Factories/ViewFactory.cs | 58 + .../BookAStar/Helpers/AvatarImageSource.cs | 4 +- BookAStar/BookAStar/Helpers/DataManager.cs | 2 +- .../BookAStar/Helpers/PropertySupport.cs | 27 + BookAStar/BookAStar/Helpers/RemoteEntity.cs | 56 +- BookAStar/BookAStar/Helpers/Settings.cs | 43 + .../BookAStar/Interfaces/IComponentContext.cs | 11 + .../BookAStar/Interfaces/IModelViewModel.cs | 16 + .../BookAStar/Interfaces/IViewFactory.cs | 25 + .../BookAStar/Model/ClientProviderInfo.cs | 8 + .../BookAStar/Model/Workflow/Estimate.cs | 1 + .../BookAStar/Pages/BookQueriesPage.xaml.cs | 8 +- BookAStar/BookAStar/Pages/BookQueryPage.xaml | 6 +- .../BookAStar/Pages/BookQueryPage.xaml.cs | 1 + .../BookAStar/Pages/EditEstimatePage.xaml | 20 +- .../BookAStar/Pages/EditEstimatePage.xaml.cs | 2 +- BookAStar/BookAStar/Pages/SettingsPage.xaml | 107 +- .../ViewModels/BookQueriesViewModel.cs | 22 + .../ViewModels/BookQueryViewModel.cs | 32 + .../BookAStar/ViewModels/SettingsViewModel.cs | 11 + .../BookAStar/ViewModels/ViewModelBase.cs | 45 + BookAStar/BookAStar/app.config | 4 + BookAStar/BookAStar/packages.config | 14 +- Yavsc.Client/project.json | 4 +- Yavsc.Client/project.lock.json | 248 +- 49 files changed, 6439 insertions(+), 3163 deletions(-) create mode 100644 BookAStar/BookAStar.Droid/MainApplication.cs delete mode 100644 BookAStar/BookAStar.Droid/PluginsHelp/ConnectivityReadme.txt delete mode 100644 BookAStar/BookAStar.Droid/PluginsHelp/GeolocatorReadme.txt rename BookAStar/BookAStar.Droid/Resources/drawable/{icon-anon.png => icon_anon.png} (100%) create mode 100644 BookAStar/BookAStar.Droid/google-services.json create mode 100644 BookAStar/BookAStar/Factories/ViewFactory.cs create mode 100644 BookAStar/BookAStar/Helpers/PropertySupport.cs create mode 100644 BookAStar/BookAStar/Helpers/Settings.cs create mode 100644 BookAStar/BookAStar/Interfaces/IComponentContext.cs create mode 100644 BookAStar/BookAStar/Interfaces/IModelViewModel.cs create mode 100644 BookAStar/BookAStar/Interfaces/IViewFactory.cs create mode 100644 BookAStar/BookAStar/ViewModels/BookQueriesViewModel.cs create mode 100644 BookAStar/BookAStar/ViewModels/BookQueryViewModel.cs create mode 100644 BookAStar/BookAStar/ViewModels/SettingsViewModel.cs create mode 100644 BookAStar/BookAStar/ViewModels/ViewModelBase.cs diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index 20085de3..52765a5e 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -66,30 +66,21 @@ - - False - ..\..\packages\Xam.Plugin.DeviceInfo.1.0.0.2\lib\MonoAndroid10\DeviceInfo.Plugin.dll - - - False - ..\..\packages\Xam.Plugin.DeviceInfo.1.0.0.2\lib\MonoAndroid10\DeviceInfo.Plugin.Abstractions.dll + + ..\..\packages\ExifLib.PCL.1.0.1\lib\portable-net45+sl50+win+WindowsPhoneApp81+wp80+Xamarin.iOS10+MonoAndroid10+MonoTouch10\ExifLib.dll + True - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\MonoAndroid10\FormsViewGroup.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\FormsViewGroup.dll True + + ..\..\Components\GoogleMediaFramework-1.0\lib\android\GoogleMediaFramework.dll + ..\..\packages\MarkdownDeep-av.NET.1.5.2\lib\MonoAndroid10\MarkdownDeep.dll True - - ..\..\packages\Xam.Plugin.Media.1.0.1\lib\MonoAndroid10\Media.Plugin.dll - True - - - ..\..\packages\Xam.Plugin.Media.1.0.1\lib\MonoAndroid10\Media.Plugin.Abstractions.dll - True - @@ -98,12 +89,71 @@ ..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True - - ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\MonoAndroid10\Plugin.Settings.dll + + ..\..\packages\Xam.Plugin.Connectivity.2.2.12\lib\MonoAndroid10\Plugin.Connectivity.dll True - - ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\MonoAndroid10\Plugin.Settings.Abstractions.dll + + ..\..\packages\Xam.Plugin.Connectivity.2.2.12\lib\MonoAndroid10\Plugin.Connectivity.Abstractions.dll + True + + + ..\..\packages\Plugin.CurrentActivity.1.0.1\lib\MonoAndroid10\Plugin.CurrentActivity.dll + True + + + ..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\MonoAndroid10\Plugin.DeviceInfo.dll + True + + + ..\..\packages\Xam.Plugin.DeviceInfo.2.0.2\lib\MonoAndroid10\Plugin.DeviceInfo.Abstractions.dll + True + + + ..\..\packages\Xam.Plugin.Geolocator.3.0.4\lib\MonoAndroid10\Plugin.Geolocator.dll + True + + + ..\..\packages\Xam.Plugin.Geolocator.3.0.4\lib\MonoAndroid10\Plugin.Geolocator.Abstractions.dll + True + + + ..\..\packages\Xam.Plugin.Media.2.3.0\lib\MonoAndroid10\Plugin.Media.dll + True + + + ..\..\packages\Xam.Plugin.Media.2.3.0\lib\MonoAndroid10\Plugin.Media.Abstractions.dll + True + + + ..\..\packages\Plugin.Permissions.1.1.7\lib\MonoAndroid10\Plugin.Permissions.dll + True + + + ..\..\packages\Plugin.Permissions.1.1.7\lib\MonoAndroid10\Plugin.Permissions.Abstractions.dll + True + + + ..\..\packages\Xam.Plugins.Settings.2.5.1.0\lib\MonoAndroid10\Plugin.Settings.dll + True + + + ..\..\packages\Xam.Plugins.Settings.2.5.1.0\lib\MonoAndroid10\Plugin.Settings.Abstractions.dll + True + + + ..\..\packages\Xamarin.Controls.SignaturePad.1.4.0\lib\MonoAndroid\SignaturePad.dll + True + + + ..\..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll + + + ..\..\packages\SQLite.Net.Async-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll + True + + + ..\..\packages\SQLite.Net-PCL.3.1.1\lib\MonoAndroid\SQLite.Net.Platform.XamarinAndroid.dll True @@ -152,46 +202,90 @@ ..\..\Components\xamarin.auth-1.2.3.1\lib\android\Xamarin.Auth.Android.dll - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Core.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Core.dll True - - False - ..\..\packages\Xamarin.Forms.Maps.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Maps.dll + + ..\..\packages\Xamarin.Forms.Labs.1.0.1.0\lib\portable-net45+win+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.Labs.dll + True - - ..\..\packages\Xamarin.Forms.Maps.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Maps.Android.dll + + False + ..\..\..\..\Visual Studio 2015\Projects\App2\packages\Xamarin.Forms.Maps.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Maps.dll + + + False + ..\..\..\..\Visual Studio 2015\Projects\App2\packages\Xamarin.Forms.Maps.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Maps.Android.dll - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.dll True - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll True - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll True + + ..\..\packages\Xamarin.GooglePlayServices.Ads.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Ads.dll + True + + + ..\..\packages\Xamarin.GooglePlayServices.Analytics.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Analytics.dll + + False ..\..\packages\Xamarin.GooglePlayServices.Base.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Base.dll - True - + ..\..\packages\Xamarin.GooglePlayServices.Basement.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Basement.dll - True - + ..\..\packages\Xamarin.GooglePlayServices.Gcm.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Gcm.dll - True - + ..\..\packages\Xamarin.GooglePlayServices.Maps.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Maps.dll + + + ..\..\packages\Xamarin.GooglePlayServices.Measurement.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Measurement.dll + + + ..\..\packages\XLabs.Caching.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Caching.dll True - - ..\..\packages\Xamarin.GooglePlayServices.Measurement.29.0.0.2\lib\MonoAndroid41\Xamarin.GooglePlayServices.Measurement.dll + + ..\..\packages\XLabs.Caching.SQLite.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Caching.Sqlite.dll + True + + + ..\..\packages\XLabs.Core.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Core.dll + True + + + ..\..\packages\XLabs.Forms.2.2.0-pre05\lib\monoandroid\XLabs.Forms.dll + True + + + ..\..\packages\XLabs.Forms.2.2.0-pre05\lib\monoandroid\XLabs.Forms.Droid.dll + True + + + ..\..\packages\XLabs.IoC.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.IOC.dll + True + + + ..\..\packages\XLabs.Platform.2.2.0-pre05\lib\MonoAndroid\XLabs.Platform.dll + True + + + ..\..\packages\XLabs.Platform.2.2.0-pre05\lib\MonoAndroid\XLabs.Platform.Droid.dll + True + + + ..\..\packages\XLabs.Serialization.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Serialization.dll True @@ -201,6 +295,7 @@ + True True @@ -220,12 +315,15 @@ Designer + RazorTemplatePreprocessor MarkdownEditor.cs None - + + Designer + @@ -254,6 +352,10 @@ + + False + 1.0.3 + False 1.0.0.2 @@ -262,6 +364,14 @@ False 1.0.3 + + False + 1.0 + + + False + 22.0.0.0 + False 7.0.1 @@ -274,6 +384,18 @@ False 1.5.2 + + False + 1.4.0.0 + + + False + 21.0.3.0 + + + False + 23.1.1.1 + False 1.2.3.1 @@ -295,9 +417,9 @@ - - - + + Designer + @@ -308,7 +430,7 @@ - + @@ -322,11 +444,11 @@ - + - + + + diff --git a/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs b/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs index 9dc7f15a..148fbdd5 100644 --- a/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs +++ b/BookAStar/BookAStar.Droid/Services/GcmListenerService.cs @@ -43,7 +43,7 @@ namespace BookAStar.Droid.Services var topic = data.GetString("Topic"); if (topic == "BookQuery") { - DateTime eventdate,enddate; + DateTime eventdate; var sdatestr = data.GetString("EventDate"); DateTime.TryParse(sdatestr, out eventdate); diff --git a/BookAStar/BookAStar.Droid/app.config b/BookAStar/BookAStar.Droid/app.config index 5ff34869..c8df8462 100644 --- a/BookAStar/BookAStar.Droid/app.config +++ b/BookAStar/BookAStar.Droid/app.config @@ -2,6 +2,10 @@ + + + + @@ -30,6 +34,10 @@ + + + + diff --git a/BookAStar/BookAStar.Droid/google-services.json b/BookAStar/BookAStar.Droid/google-services.json new file mode 100644 index 00000000..a6bd9aad --- /dev/null +++ b/BookAStar/BookAStar.Droid/google-services.json @@ -0,0 +1,78 @@ +{ + "project_info": { + "project_number": "325408689282", + "project_id": "yavsc-001" + }, + "client": [ + { + "client_info": { + "android_client_info": { + "package_name": "fr.pschneider.android.wearable.speedtracker" + } + }, + "oauth_client": [ + { + "client_id": "325408689282-6bekh7p3guj4k0f3301a6frf025cnrk1.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBCAE_pc6lrxLf8_Vyho0KSxLsqjxecPFk" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 1 + } + } + }, + { + "client_info": { + "mobilesdk_app_id": "1:325408689282:android:50a2328516f10af3", + "android_client_info": { + "package_name": "fr.pschneider.bas" + } + }, + "oauth_client": [ + { + "client_id": "325408689282-emdeucmt5pr9jg7170t0q9gnndacsqqf.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "fr.pschneider.bas", + "certificate_hash": "E97A345457861B8E2E7BA79BB814BB1ACC0471A6" + } + }, + { + "client_id": "325408689282-6bekh7p3guj4k0f3301a6frf025cnrk1.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyBCAE_pc6lrxLf8_Vyho0KSxLsqjxecPFk" + } + ], + "services": { + "analytics_service": { + "status": 1 + }, + "appinvite_service": { + "status": 1, + "other_platform_oauth_client": [] + }, + "ads_service": { + "status": 1 + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/BookAStar/BookAStar.Droid/packages.config b/BookAStar/BookAStar.Droid/packages.config index 3c8a0a89..b25e9b63 100644 --- a/BookAStar/BookAStar.Droid/packages.config +++ b/BookAStar/BookAStar.Droid/packages.config @@ -1,12 +1,19 @@  + - - - - - + + + + + + + + + + + @@ -15,11 +22,23 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BookAStar/BookAStar.iOS/AppDelegate.cs b/BookAStar/BookAStar.iOS/AppDelegate.cs index 78b47126..dbcd76b8 100644 --- a/BookAStar/BookAStar.iOS/AppDelegate.cs +++ b/BookAStar/BookAStar.iOS/AppDelegate.cs @@ -4,6 +4,9 @@ using System.Linq; using Foundation; using UIKit; +using BookAStar; +using BookAStar.Interfaces; +using Yavsc.Models.Identity; namespace App2.iOS { @@ -11,8 +14,27 @@ namespace App2.iOS // User Interface of the application, as well as listening (and optionally responding) to // application events from iOS. [Register("AppDelegate")] - public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate + public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate, + IPlatform { + public string GCMStatusMessage + { + get + { + throw new NotImplementedException(); + } + } + + public void AddAccount() + { + throw new NotImplementedException(); + } + + public bool EnablePushNotifications(bool enable) + { + throw new NotImplementedException(); + } + // // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window @@ -23,9 +45,34 @@ namespace App2.iOS public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); - LoadApplication(new App()); + LoadApplication(new App(this)); return base.FinishedLaunching(app, options); } + + public IGCMDeclaration GetDeviceInfo() + { + throw new NotImplementedException(); + } + + public object InvokeApi(string method, object arg) + { + throw new NotImplementedException(); + } + + public TAnswer InvokeApi(string method, object arg) + { + throw new NotImplementedException(); + } + + public void OpenWeb(string Uri) + { + throw new NotImplementedException(); + } + + public void RevokeAccount(string userName) + { + throw new NotImplementedException(); + } } } diff --git a/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj b/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj index ca76670d..0cce83b0 100644 --- a/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj +++ b/BookAStar/BookAStar.iOS/BookAStar.iOS.csproj @@ -133,35 +133,39 @@ - ..\..\packages\Xamarin.Forms.2.0.0.6482\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll True - ..\..\packages\Xamarin.Forms.2.0.0.6482\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll True - ..\..\packages\Xamarin.Forms.2.0.0.6482\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll True - ..\..\packages\Xamarin.Forms.2.0.0.6482\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll True + + {67F9D3A8-F71E-4428-913F-C37AE82CDB24} + Yavsc.Client + {A0815650-0A0A-47B0-8826-771F0E1AD137} BookAStar - + Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}. - + \ No newline at end of file diff --git a/BookAStar/BookAStar.iOS/app.config b/BookAStar/BookAStar.iOS/app.config index 8460dd43..bb76392c 100644 --- a/BookAStar/BookAStar.iOS/app.config +++ b/BookAStar/BookAStar.iOS/app.config @@ -6,6 +6,10 @@ + + + + \ No newline at end of file diff --git a/BookAStar/BookAStar.iOS/packages.config b/BookAStar/BookAStar.iOS/packages.config index c044abf8..b78e7945 100644 --- a/BookAStar/BookAStar.iOS/packages.config +++ b/BookAStar/BookAStar.iOS/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/BookAStar/BookAStar/App.xaml b/BookAStar/BookAStar/App.xaml index a3f0bde3..9b6d74a0 100644 --- a/BookAStar/BookAStar/App.xaml +++ b/BookAStar/BookAStar/App.xaml @@ -1,11 +1,16 @@  + x:Class="BookAStar.App" + xmlns:sys="clr-namespace:System;assembly=mscorlib"> + + - #f0f0ff + #30FAFAFA + #ffffff + #000000 Black Blue #5050ff @@ -15,9 +20,10 @@ + + - - #30FAFAFA + #30AAAAFA #207AFAFA #FF103010 #FF303010 @@ -47,6 +53,10 @@ + - diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index fa13a098..40882687 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -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(); + 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(); + ViewFactory.Register( + 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() + .Register(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) + + /// + /// Shows a page asynchronously by locating the default constructor, creating the page, + /// the pushing it onto the navigation stack. + /// + /// Parent Page + /// Type of page to show + /// + 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); } } } diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj index e7744bb4..b2216ffc 100644 --- a/BookAStar/BookAStar/BookAStar.csproj +++ b/BookAStar/BookAStar/BookAStar.csproj @@ -41,10 +41,16 @@ App.xaml + + + + + + @@ -105,6 +111,10 @@ EditEstimatePage.xaml + + + + CommandLineEditor.xaml @@ -147,6 +157,10 @@ + + ..\..\packages\ExifLib.PCL.1.0.1\lib\portable-net45+sl50+win+WindowsPhoneApp81+wp80+Xamarin.iOS10+MonoAndroid10+MonoTouch10\ExifLib.dll + True + ..\..\packages\Json.NET.Web.1.0.49\lib\portable45-net45+win8+wpa81\Json.NET.Web.dll @@ -159,28 +173,52 @@ ..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll - - ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Settings.dll + + ..\..\packages\Xam.Plugins.Settings.2.5.1.0\lib\portable-net45+wp80+win8+wpa81\Plugin.Settings.dll True - - ..\..\packages\Xam.Plugins.Settings.2.1.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Settings.Abstractions.dll + + ..\..\packages\Xam.Plugins.Settings.2.5.1.0\lib\portable-net45+wp80+win8+wpa81\Plugin.Settings.Abstractions.dll + True + + + ..\..\packages\SQLite.Net-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll True - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll True - ..\..\packages\Xamarin.Forms.Maps.2.3.0.107\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Maps.dll + ..\..\packages\Xamarin.Forms.Maps.2.3.2.127\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Maps.dll True - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll True - ..\..\packages\Xamarin.Forms.2.3.0.107\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.2.127\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll + True + + + ..\..\packages\XLabs.Core.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Core.dll + True + + + ..\..\packages\XLabs.Forms.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+monoandroid+MonoTouch+Xamarin.iOS10\XLabs.Forms.dll + True + + + ..\..\packages\XLabs.IoC.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.IOC.dll + True + + + ..\..\packages\XLabs.Platform.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+monoandroid+MonoTouch+Xamarin.iOS10\XLabs.Platform.dll + True + + + ..\..\packages\XLabs.Serialization.2.2.0-pre05\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Serialization.dll True @@ -224,12 +262,12 @@ - + Ce projet fait référence à des packages NuGet qui sont manquants sur cet ordinateur. Utilisez l'option de restauration des packages NuGet pour les télécharger. Pour plus d'informations, consultez http://go.microsoft.com/fwlink/?LinkID=322105. Le fichier manquant est : {0}. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Openclipart + + + Users Icon Set + 2012-09-06T18:37:31 + Check others icons on my "Minimal Icon Set" collection.\nSet of six simple icons for user management, useful for applications and user interface design + https://openclipart.org/detail/172195/users-icon-set-by-mi_brami-172195 + + + mi_brami + + + + + User + b&w + black + grey + icon + icons + round + set + simple + transparent + users + white + + + + + + + + + + + \ No newline at end of file From 0e281a35790e5c0e19555d9a99928bd4a189b75a Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Thu, 29 Sep 2016 04:54:14 +0200 Subject: [PATCH 12/59] WIP --- .../BookAStar.Droid/BookAStar.Droid.csproj | 14 +- BookAStar/BookAStar.Droid/MainActivity.cs | 28 ++-- BookAStar/BookAStar.Droid/packages.config | 3 +- BookAStar/BookAStar/App.xaml | 3 +- BookAStar/BookAStar/App.xaml.cs | 126 ++++++++++------ BookAStar/BookAStar/BookAStar.csproj | 78 +++++++--- BookAStar/BookAStar/Constants.cs | 26 ---- .../BookAStar/Helpers/AvatarImageSource.cs | 30 ---- BookAStar/BookAStar/Helpers/DataManager.cs | 6 +- BookAStar/BookAStar/Helpers/MainSettings.cs | 39 ++++- BookAStar/BookAStar/Helpers/PageHelpers.cs | 20 +++ BookAStar/BookAStar/Helpers/UserHelpers.cs | 28 ++++ BookAStar/BookAStar/Images/icon_add_user.png | Bin 0 -> 4702 bytes BookAStar/BookAStar/Images/icon_anon_user.png | Bin 0 -> 5372 bytes .../BookAStar/Images/icon_block_user.png | Bin 0 -> 7195 bytes .../BookAStar/Images/icon_remove_user.png | Bin 0 -> 4628 bytes BookAStar/BookAStar/Images/icon_user.png | Bin 0 -> 4535 bytes .../BookAStar/Images/icon_user_settings.png | Bin 0 -> 8437 bytes .../BookAStar/Interfaces/IBillingLine.cs | 12 ++ .../BookAStar/Interfaces/IBookQueryData.cs | 15 ++ BookAStar/BookAStar/Interfaces/IEstimate.cs | 20 +++ BookAStar/BookAStar/Model/Auth/User.cs | 12 +- BookAStar/BookAStar/Model/BookQueryData.cs | 5 +- .../BookAStar/Model/ClientProviderInfo.cs | 9 +- .../{CommandLine.cs => BillingLine.cs} | 5 +- .../BookAStar/Model/Workflow/Estimate.cs | 5 +- .../BookAStar/Pages/AccountChooserPage.xaml | 53 +++++++ ...age.xaml.cs => AccountChooserPage.xaml.cs} | 45 +++--- .../BookAStar/Pages/BookQueriesPage.xaml | 12 +- .../BookAStar/Pages/BookQueriesPage.xaml.cs | 4 +- BookAStar/BookAStar/Pages/BookQueryPage.xaml | 3 +- .../BookAStar/Pages/BookQueryPage.xaml.cs | 5 +- BookAStar/BookAStar/Pages/DashboardPage.xaml | 53 +++++++ .../BookAStar/Pages/DashboardPage.xaml.cs | 45 ++++++ ...itorPage.xaml => EditBillingLinePage.xaml} | 12 +- ...ge.xaml.cs => EditBillingLinePage.xaml.cs} | 5 +- .../BookAStar/Pages/EditEstimatePage.xaml | 13 +- .../BookAStar/Pages/EditEstimatePage.xaml.cs | 2 +- BookAStar/BookAStar/Pages/EventDetail.xaml | 12 +- BookAStar/BookAStar/Pages/HomePage.xaml | 17 +++ BookAStar/BookAStar/Pages/HomePage.xaml.cs | 18 +++ BookAStar/BookAStar/Pages/SearchPage.xaml | 12 +- BookAStar/BookAStar/Pages/SettingsPage.xaml | 63 -------- .../ViewModels/BillingLineViewModel.cs | 78 ++++++++++ .../ViewModels/BookQueryViewModel.cs | 5 +- .../ViewModels/DashboardViewModel.cs | 137 ++++++++++++++++++ .../BookAStar/ViewModels/EstimateViewModel.cs | 91 ++++++++++++ .../BookAStar/ViewModels/SettingsViewModel.cs | 11 -- .../ViewModels/UserLoginViewModel.cs | 14 ++ .../BookAStar/ViewModels/ViewModelBase.cs | 1 + BookAStar/BookAStar/icon-anon.png | Bin 1031 -> 0 bytes BookAStar/BookAStar/packages.config | 6 +- 52 files changed, 920 insertions(+), 281 deletions(-) delete mode 100644 BookAStar/BookAStar/Helpers/AvatarImageSource.cs create mode 100644 BookAStar/BookAStar/Helpers/PageHelpers.cs create mode 100644 BookAStar/BookAStar/Helpers/UserHelpers.cs create mode 100644 BookAStar/BookAStar/Images/icon_add_user.png create mode 100644 BookAStar/BookAStar/Images/icon_anon_user.png create mode 100644 BookAStar/BookAStar/Images/icon_block_user.png create mode 100644 BookAStar/BookAStar/Images/icon_remove_user.png create mode 100644 BookAStar/BookAStar/Images/icon_user.png create mode 100644 BookAStar/BookAStar/Images/icon_user_settings.png create mode 100644 BookAStar/BookAStar/Interfaces/IBillingLine.cs create mode 100644 BookAStar/BookAStar/Interfaces/IBookQueryData.cs create mode 100644 BookAStar/BookAStar/Interfaces/IEstimate.cs rename BookAStar/BookAStar/Model/Workflow/{CommandLine.cs => BillingLine.cs} (64%) create mode 100644 BookAStar/BookAStar/Pages/AccountChooserPage.xaml rename BookAStar/BookAStar/Pages/{SettingsPage.xaml.cs => AccountChooserPage.xaml.cs} (67%) create mode 100644 BookAStar/BookAStar/Pages/DashboardPage.xaml create mode 100644 BookAStar/BookAStar/Pages/DashboardPage.xaml.cs rename BookAStar/BookAStar/Pages/{CommandLineEditorPage.xaml => EditBillingLinePage.xaml} (80%) rename BookAStar/BookAStar/Pages/{CommandLineEditorPage.xaml.cs => EditBillingLinePage.xaml.cs} (67%) create mode 100644 BookAStar/BookAStar/Pages/HomePage.xaml create mode 100644 BookAStar/BookAStar/Pages/HomePage.xaml.cs delete mode 100644 BookAStar/BookAStar/Pages/SettingsPage.xaml create mode 100644 BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs create mode 100644 BookAStar/BookAStar/ViewModels/DashboardViewModel.cs create mode 100644 BookAStar/BookAStar/ViewModels/EstimateViewModel.cs delete mode 100644 BookAStar/BookAStar/ViewModels/SettingsViewModel.cs create mode 100644 BookAStar/BookAStar/ViewModels/UserLoginViewModel.cs delete mode 100644 BookAStar/BookAStar/icon-anon.png diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index 52765a5e..cf995dc5 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -71,7 +71,7 @@ True - ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\FormsViewGroup.dll + ..\..\packages\Xamarin.Forms.2.3.0.34-pre1\lib\MonoAndroid10\FormsViewGroup.dll True @@ -202,7 +202,7 @@ ..\..\Components\xamarin.auth-1.2.3.1\lib\android\Xamarin.Auth.Android.dll - ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Core.dll + ..\..\packages\Xamarin.Forms.2.3.0.34-pre1\lib\MonoAndroid10\Xamarin.Forms.Core.dll True @@ -218,15 +218,15 @@ ..\..\..\..\Visual Studio 2015\Projects\App2\packages\Xamarin.Forms.Maps.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Maps.Android.dll - ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.0.34-pre1\lib\MonoAndroid10\Xamarin.Forms.Platform.dll True - ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll + ..\..\packages\Xamarin.Forms.2.3.0.34-pre1\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll True - ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.0.34-pre1\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll True @@ -444,11 +444,11 @@ - + - + diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index 0232ef16..c6f4676e 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -5,19 +5,18 @@ using BookAStar.Model.Workflow; using BookAStar.Pages; using BookAStar.ViewModels; using System; -using System.Collections.ObjectModel; using System.Diagnostics; 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; using XLabs.Platform.Services; + /* Glyphish icons from http://www.glyphish.com/ @@ -33,21 +32,19 @@ 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 static bool MasterPresented { + get + { return CurrentApp.masterDetail.IsPresented; } + internal set + { CurrentApp.masterDetail.IsPresented = value; } + } + public void Init() { var app = Resolver.Resolve(); @@ -72,11 +69,11 @@ namespace BookAStar ViewFactory.Register( resolver => new DashboardViewModel()); ViewFactory.Register(); + ViewFactory.Register(); ViewFactory.Register(); ViewFactory.Register(); } - ExtendedMasterDetailPage masterDetail; public App(IPlatform instance) @@ -86,8 +83,8 @@ namespace BookAStar Init(); BuildMainPage(); - NavigationPage.SetHasNavigationBar(MainPage, true); - NavigationPage.SetHasBackButton(MainPage, true); + NavigationPage.SetHasNavigationBar(MainPage, false); + NavigationPage.SetHasBackButton(MainPage, false); } BookQueriesPage bQueriesPage; AccountChooserPage accChooserPage; @@ -99,9 +96,9 @@ namespace BookAStar bQueriesPage = new BookQueriesPage { - BindingContext = DataManager.Current.BookQueries, Title = "Demandes", - Icon = "icon.png" + Icon = "icon.png", + BindingContext = new BookQueriesViewModel() }; home = new HomePage() { Title = "Accueil", Icon = "icon.png" }; @@ -109,16 +106,16 @@ namespace BookAStar // var mainPage = new NavigationPage(bQueriesPage); masterDetail = new ExtendedMasterDetailPage() { - Title="MainPAge" + Title="MainPage" }; masterDetail.Master = new DashboardPage { Title = "Bookingstar", BindingContext = new DashboardViewModel() }; - masterDetail.Detail = home; + // masterDetail.Detail = home; - + masterDetail.Detail = new NavigationPage(home); ToolbarItem tiSetts = new ToolbarItem() { Text = "Paramètres", @@ -131,17 +128,7 @@ namespace BookAStar Icon = "icon.png" }; - // FIXME "Tabs not supported in this configuration" - 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(masterDetail) { Title = "Navigation", Icon = "icon.png" @@ -150,23 +137,14 @@ namespace BookAStar navPage.ToolbarItems.Add(tiHome); navPage.ToolbarItems.Add(tiSetts); - - this.MainPage = navPage; - + */ + this.MainPage = masterDetail; + Resolver.Resolve() - .Register(t => new NavigationService(navPage.Navigation)) - ; + .Register(t => new NavigationService(masterDetail.Detail.Navigation)) + ; } - internal void EditCommandLine(Page parentPage, BillingLine com) - { - EditBillingLinePage editCommandLine = new EditBillingLinePage - { - Title = "Edition d'une ligne de facture", - BindingContext = com - }; - parentPage.Navigation.PushAsync(editCommandLine); - } public void PostDeviceInfo() { From 26110e7a998fdc8e4432f38273414c56dcef7aa0 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 19:28:33 +0200 Subject: [PATCH 20/59] Publishes the bill setter --- BookAStar/BookAStar/Model/Workflow/Estimate.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BookAStar/BookAStar/Model/Workflow/Estimate.cs b/BookAStar/BookAStar/Model/Workflow/Estimate.cs index 58b8cffc..a9dd6f41 100644 --- a/BookAStar/BookAStar/Model/Workflow/Estimate.cs +++ b/BookAStar/BookAStar/Model/Workflow/Estimate.cs @@ -25,7 +25,7 @@ namespace BookAStar.Model.Workflow /// In db, they are separated by : /// /// - public List AttachedGraphicList { get; private set; } + public List AttachedGraphicList { get; set; } public string AttachedGraphicsString { From 1cc5a3c710372c76d0ee468b4f61f18c21f17d84 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 19:32:28 +0200 Subject: [PATCH 21/59] Binds the refresh command, and titles the page --- BookAStar/BookAStar/Pages/BookQueriesPage.xaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml index 30388796..497b5c2a 100644 --- a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml +++ b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml @@ -4,6 +4,7 @@ xmlns:local="clr-namespace:BookAStar;assembly=BookAStar" x:Class="BookAStar.Pages.BookQueriesPage" Style="{StaticResource PageStyle}" + Page.Title="Les Demandes" > @@ -27,7 +28,8 @@ - + From 5d030bf51f7a3d69a6a9e931e327cf24bfdd5412 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 19:33:31 +0200 Subject: [PATCH 22/59] cleaning thanks to Xaml code --- .../BookAStar/Pages/BookQueriesPage.xaml.cs | 34 +++---------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs index 55c6868c..9e953465 100644 --- a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs @@ -1,44 +1,18 @@ -using BookAStar.Helpers; -using BookAStar.Model; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; +using BookAStar.Model; +using BookAStar.ViewModels; using Xamarin.Forms; using XLabs.Ioc; using XLabs.Platform.Services; namespace BookAStar.Pages { + public partial class BookQueriesPage : ContentPage { public BookQueriesPage() { InitializeComponent(); - - BindingContext = DataManager.Current.BookQueries; - } - protected override void OnBindingContextChanged() - { - list.ItemsSource = BindingContext as ObservableCollection; - base.OnBindingContextChanged(); - } - - public RemoteEntity Queries - { - get - { - return BindingContext!=null? BindingContext as RemoteEntity:null; - } - } - - protected override void OnAppearing() - { - base.OnAppearing(); - if (Queries.CanExecute(null)) Queries.Execute(null); + BindingContext = new BookQueriesViewModel(); } private void OnViewDetail(object sender, ItemTappedEventArgs e) From ec546348d9f97dfb0a7e306a2f7db6d89503c27c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 19:33:54 +0200 Subject: [PATCH 23/59] cleanning --- BookAStar/BookAStar/Pages/DashboardPage.xaml.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs b/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs index 658e2384..0d6bac9c 100644 --- a/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs @@ -1,4 +1,5 @@ -using System; +using BookAStar.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -31,15 +32,19 @@ namespace BookAStar.Pages public void OnViewPerformerStatus(object sender, EventArgs e) { - App.CurrentApp.ShowAccounts(); + ShowPage(null, true); } public void OnViewUserQueries(object sender, EventArgs e) { - App.CurrentApp.ShowQueries(); - + ShowPage(null, true); } + private void ShowPage(object [] args, bool animate=false) where T:Page + { + Resolver.Resolve().NavigateTo(animate, args); + App.MasterPresented = false; + } } } From 828772cd6f04680fb6786c66cbf725af008c028c Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 19:35:53 +0200 Subject: [PATCH 24/59] makes the ctor dependent of its viewmodel --- .../Pages/EditBillingLinePage.xaml.cs | 6 ++-- .../BookAStar/Pages/EditEstimatePage.xaml.cs | 34 ++++++++----------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs index 5c9e8915..b5cb5d2d 100644 --- a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs @@ -1,4 +1,5 @@ -using System; +using BookAStar.ViewModels; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,9 +11,10 @@ namespace BookAStar.Pages { public partial class EditBillingLinePage : ContentPage { - public EditBillingLinePage() + public EditBillingLinePage(BillingLineViewModel model) { InitializeComponent(); + BindingContext = model; } } } diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs index 00ea16bc..aa4f3238 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs @@ -1,5 +1,6 @@ using BookAStar.Model; using BookAStar.Model.Workflow; +using BookAStar.ViewModels; using BookAStar.Views; using System; using System.Collections.Generic; @@ -8,6 +9,9 @@ using System.Text; using System.Threading.Tasks; using Xamarin.Forms; +using XLabs.Forms.Services; +using XLabs.Ioc; +using XLabs.Platform.Services; namespace BookAStar.Pages { @@ -16,43 +20,33 @@ namespace BookAStar.Pages public Estimate Estimate { get { return BindingContext as Estimate; } set { BindingContext = value; } } - public static readonly BindableProperty TotalProperty = - BindableProperty.Create("Total", typeof(decimal), typeof(EditEstimatePage), - (decimal) 0, BindingMode.OneWay); - public static readonly BindableProperty DescriptionProperty = - BindableProperty.Create("Description", typeof(string), typeof(Estimate), - null, BindingMode.TwoWay); - public static readonly BindableProperty ClientProperty = - BindableProperty.Create("Client", typeof(ClientProviderInfo), typeof(Estimate), - null, BindingMode.OneWay); - public static readonly BindableProperty QueryProperty = - BindableProperty.Create("Query", typeof(BookQueryData), typeof(Estimate), - null, BindingMode.OneWay); - - - public EditEstimatePage() + public EditEstimatePage(EstimateViewModel model) { InitializeComponent(); + BindingContext = model; } protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); - // FIXME Why the Binding don't work? - mdview.Markdown = Estimate.Description; - + // FIXME WAZA + if (BindingContext != null) + mdview.Markdown = ((EstimateViewModel)BindingContext).Description; } protected void OnDescriptionChanged (object sender, EventArgs e) { // FIXME Why the Binding don't work? - Estimate.Description = mdview.Markdown; + ((EstimateViewModel)BindingContext).Description = mdview.Markdown; } + protected void OnNewCommanLine(object sender, EventArgs e) { var com = new BillingLine(); - App.CurrentApp.EditCommandLine(this,com); + Resolver.Resolve().NavigateTo( + true, + new object[] { new BillingLineViewModel(com) } ); } } From cb56d5e5235250151c3d108268e3e67087dcd856 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 19:39:22 +0200 Subject: [PATCH 25/59] makes public the ViewModel's --- .../BookAStar/ViewModels/BillingLineViewModel.cs | 7 +------ .../BookAStar/ViewModels/BookQueriesViewModel.cs | 13 ++++++++++++- BookAStar/BookAStar/ViewModels/EstimateViewModel.cs | 13 ++++++------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs b/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs index 1512b559..da39a0a0 100644 --- a/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs +++ b/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs @@ -1,16 +1,11 @@ using BookAStar.Interfaces; using BookAStar.Model.Workflow; using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using XLabs.Forms.Mvvm; namespace BookAStar.ViewModels { - class BillingLineViewModel : ViewModel, IBillingLine + public class BillingLineViewModel : ViewModel, IBillingLine { public BillingLineViewModel(BillingLine data) { diff --git a/BookAStar/BookAStar/ViewModels/BookQueriesViewModel.cs b/BookAStar/BookAStar/ViewModels/BookQueriesViewModel.cs index 744a4c25..5c22076f 100644 --- a/BookAStar/BookAStar/ViewModels/BookQueriesViewModel.cs +++ b/BookAStar/BookAStar/ViewModels/BookQueriesViewModel.cs @@ -6,11 +6,17 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; namespace BookAStar.ViewModels { - class BookQueriesViewModel : XLabs.Forms.Mvvm.ViewModel + public class BookQueriesViewModel : XLabs.Forms.Mvvm.ViewModel { + public BookQueriesViewModel() + { + + } + public ObservableCollection Queries { get @@ -18,5 +24,10 @@ namespace BookAStar.ViewModels return DataManager.Current.BookQueries; } } + + public ICommand RefreshQueries + { + get { return DataManager.Current.BookQueries; } + } } } diff --git a/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs b/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs index ef2a5162..51e42836 100644 --- a/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs +++ b/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs @@ -1,9 +1,4 @@ -using BookAStar.Model.Interfaces; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using XLabs.Forms.Mvvm; using BookAStar.Model.Workflow; using System.Collections.ObjectModel; @@ -11,11 +6,15 @@ using BookAStar.Model; namespace BookAStar.ViewModels { - class EstimateViewModel : ViewModel + public class EstimateViewModel : ViewModel { public EstimateViewModel(Estimate data) { estimate = data; + + if (data.AttachedFiles == null) data.AttachedFiles = new List(); + if (data.AttachedGraphicList == null) data.AttachedGraphicList = new List(); + if (data.Bill == null) data.Bill = new List(); AttachedFiles = new ObservableCollection(data.AttachedFiles); AttachedGraphicList = new ObservableCollection(data.AttachedGraphicList); Bill = new ObservableCollection(data.Bill); From 144412f64b1f90b3a99734ccda749f00abaf738e Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 20:20:01 +0200 Subject: [PATCH 26/59] re-activates the cache provider --- BookAStar/BookAStar.Droid/BookAStar.Droid.csproj | 4 ++-- BookAStar/BookAStar.Droid/MainActivity.cs | 7 ++----- BookAStar/BookAStar.Droid/packages.config | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index 879a8c8a..f8606fc6 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -266,8 +266,8 @@ ..\..\packages\XLabs.Caching.2.3.0-pre02\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Caching.dll True - - ..\..\packages\XLabs.Caching.SQLite.2.0.5653-pre2\lib\portable-net45+netcore45+wp8+MonoAndroid1+MonoTouch1\XLabs.Caching.SQLite.dll + + ..\..\packages\XLabs.Caching.SQLite.2.3.0-pre02\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Caching.Sqlite.dll True diff --git a/BookAStar/BookAStar.Droid/MainActivity.cs b/BookAStar/BookAStar.Droid/MainActivity.cs index 647671dc..b4c9380c 100644 --- a/BookAStar/BookAStar.Droid/MainActivity.cs +++ b/BookAStar/BookAStar.Droid/MainActivity.cs @@ -131,13 +131,10 @@ namespace BookAStar.Droid .Register(app) .Register(t => new KeyVaultStorage(t.Resolve().Id.ToCharArray())) - /* + .Register( t => new SQLiteSimpleCache(new SQLitePlatformAndroid(), - new SQLiteConnectionString(pathToDatabase, true), t.Resolve())) - - */ - ; + new SQLiteConnectionString(pathToDatabase, true), t.Resolve())); Resolver.SetResolver(resolverContainer.GetResolver()); } diff --git a/BookAStar/BookAStar.Droid/packages.config b/BookAStar/BookAStar.Droid/packages.config index 22387ca9..b25003a3 100644 --- a/BookAStar/BookAStar.Droid/packages.config +++ b/BookAStar/BookAStar.Droid/packages.config @@ -33,7 +33,7 @@ - + From b149fa56f2289a291ff10628c29a7435422d5ab5 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sun, 2 Oct 2016 20:20:38 +0200 Subject: [PATCH 27/59] Fixes the layout --- .../BookAStar/Pages/EditEstimatePage.xaml | 19 +++++++------------ BookAStar/BookAStar/Views/MarkdownView.cs | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml index 8de41415..3f407899 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml @@ -15,7 +15,7 @@ - + @@ -23,9 +23,10 @@ - + diff --git a/BookAStar/BookAStar/Views/MarkdownView.cs b/BookAStar/BookAStar/Views/MarkdownView.cs index b00195ac..3875e68f 100644 --- a/BookAStar/BookAStar/Views/MarkdownView.cs +++ b/BookAStar/BookAStar/Views/MarkdownView.cs @@ -38,6 +38,20 @@ namespace BookAStar.Views public event EventHandler Edited; + protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint) + { + double width = widthConstraint; + double height = heightConstraint; + + if (MinimumWidthRequest>0) + width = widthConstraint > 80 ? widthConstraint < double.MaxValue ? widthConstraint : MinimumWidthRequest : MinimumWidthRequest; + + if (MinimumHeightRequest > 0) + height = heightConstraint > 160 ? heightConstraint < double.MaxValue ? heightConstraint : MinimumHeightRequest : MinimumHeightRequest; + + return base.OnMeasure(width, height); + } + } } From 541f61688d3142de50827ad3ed94eca1277c2d95 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:06:52 +0200 Subject: [PATCH 28/59] implements some internal web exception --- BookAStar/BookAStar/Helpers/NotIdentifiedException.cs | 10 ++++++++++ BookAStar/BookAStar/Helpers/ServiceNotAvailable1.cs | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 BookAStar/BookAStar/Helpers/NotIdentifiedException.cs create mode 100644 BookAStar/BookAStar/Helpers/ServiceNotAvailable1.cs diff --git a/BookAStar/BookAStar/Helpers/NotIdentifiedException.cs b/BookAStar/BookAStar/Helpers/NotIdentifiedException.cs new file mode 100644 index 00000000..537143ce --- /dev/null +++ b/BookAStar/BookAStar/Helpers/NotIdentifiedException.cs @@ -0,0 +1,10 @@ +using System; + +namespace BookAStar +{ + public class NotIdentifiedException : Exception + { + public NotIdentifiedException(string message) : base(message) { } + } +} + diff --git a/BookAStar/BookAStar/Helpers/ServiceNotAvailable1.cs b/BookAStar/BookAStar/Helpers/ServiceNotAvailable1.cs new file mode 100644 index 00000000..a723cf32 --- /dev/null +++ b/BookAStar/BookAStar/Helpers/ServiceNotAvailable1.cs @@ -0,0 +1,10 @@ +using System; + +namespace BookAStar +{ + public class ServiceNotAvailable : Exception + { + public ServiceNotAvailable(string message, Exception innerException) : base(message, innerException) { } + + } +} \ No newline at end of file From 312d953da640e2345897933de1e7dd5a8198f368 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:07:51 +0200 Subject: [PATCH 29/59] fixes the XLabs.Serialization.Json.NET reference --- BookAStar/BookAStar.Droid/BookAStar.Droid.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj index f8606fc6..063681b9 100644 --- a/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj +++ b/BookAStar/BookAStar.Droid/BookAStar.Droid.csproj @@ -298,6 +298,10 @@ ..\..\packages\XLabs.Serialization.2.3.0-pre02\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Serialization.dll True + + ..\..\packages\XLabs.Serialization.JSON.2.3.0-pre02\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Serialization.Json.NET.dll + True + ..\..\packages\XLabs.Settings.2.3.0-pre02\lib\portable-net45+netcore45+wpa81+wp8+monoandroid+monotouch+xamarinios10+xamarinmac\XLabs.Settings.dll True From e28f858c51540cde99fe7329f112a361c421fc40 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:08:53 +0200 Subject: [PATCH 30/59] refactoring --- BookAStar/BookAStar/Helpers/LocaLEntity.cs | 34 ++++++++++++++ BookAStar/BookAStar/Helpers/RemoteEntity.cs | 50 +-------------------- 2 files changed, 36 insertions(+), 48 deletions(-) create mode 100644 BookAStar/BookAStar/Helpers/LocaLEntity.cs diff --git a/BookAStar/BookAStar/Helpers/LocaLEntity.cs b/BookAStar/BookAStar/Helpers/LocaLEntity.cs new file mode 100644 index 00000000..2f86ecdb --- /dev/null +++ b/BookAStar/BookAStar/Helpers/LocaLEntity.cs @@ -0,0 +1,34 @@ + +using System; +using System.Collections.ObjectModel; +using System.Linq; + +namespace BookAStar +{ + public class LocalEntity : ObservableCollection where K : IEquatable + { + public V CurrentItem { get; protected set; } + protected Func GetKey { get; set; } + public LocalEntity(Func getKey) : base() + { + if (getKey == null) throw new InvalidOperationException(); + GetKey = getKey; + } + public virtual void Merge(V item) + { + var key = GetKey(item); + if (this.Any(x => GetKey(x).Equals(key))) + { + Remove(LocalGet(key)); + } + Add(item); + CurrentItem = item; + } + public V LocalGet(K key) + { + CurrentItem = this.Single(x => GetKey(x).Equals(key)); + return CurrentItem; + } + } + +} \ No newline at end of file diff --git a/BookAStar/BookAStar/Helpers/RemoteEntity.cs b/BookAStar/BookAStar/Helpers/RemoteEntity.cs index 16c48352..0245dcc9 100644 --- a/BookAStar/BookAStar/Helpers/RemoteEntity.cs +++ b/BookAStar/BookAStar/Helpers/RemoteEntity.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Windows.Input; -using System.Linq; using System.Net.Http; using Newtonsoft.Json; using System.Threading.Tasks; @@ -11,42 +9,6 @@ using System.Net; namespace BookAStar { - public class NotIdentifiedException : Exception { - public NotIdentifiedException(string message) : base(message) { } - } - - public class ServiceNotAvailable : Exception - { - public ServiceNotAvailable(string message, Exception innerException) : base(message, innerException) { } - - } - - public class LocalEntity : ObservableCollection where K : IEquatable - { - public V CurrentItem { get; protected set; } - protected Func GetKey { get; set; } - public LocalEntity(Func getKey) : base() - { - if (getKey == null) throw new InvalidOperationException(); - GetKey = getKey; - } - public virtual void Merge(V item) - { - var key = GetKey(item); - if (this.Any(x => GetKey(x).Equals(key))) - { - Remove(LocalGet(key)); - } - Add(item); - CurrentItem = item; - } - public V LocalGet(K key) - { - CurrentItem = this.Single(x => GetKey(x).Equals(key)); - return CurrentItem; - } - } - public class RemoteEntity : LocalEntity, ICommand where K : IEquatable { private string _controller; @@ -75,8 +37,6 @@ namespace BookAStar if (CanExecuteChanged != null) CanExecuteChanged.Invoke(this, new EventArgs()); } - - /// /// Refresh the collection @@ -85,12 +45,8 @@ namespace BookAStar public async void Execute(object parameter) { BeforeExecute(); - using (HttpClient client = new HttpClient()) + using (HttpClient client = CreateClient()) { - - // Update credentials - client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue( - "Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken); // Get the whole data try { @@ -116,14 +72,13 @@ namespace BookAStar AfterExecuting(); } - - private void AfterExecuting() { IsExecuting = false; if (CanExecuteChanged != null) CanExecuteChanged.Invoke(this, new EventArgs()); } + public async Task Get(K key) { var item = LocalGet(key); @@ -147,7 +102,6 @@ namespace BookAStar { var content = await response.Content.ReadAsStringAsync(); item = JsonConvert.DeserializeObject(content); - // LocalData.Clear(); Merge(item); } } From a3a1c4ec917e84967babee823547dbe8366f7282 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:09:16 +0200 Subject: [PATCH 31/59] inits the Json service --- BookAStar/BookAStar.Droid/MainActivity.cs | 63 +++++++++++------------ 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/BookAStar/BookAStar.Droid/MainActivity.cs b/BookAStar/BookAStar.Droid/MainActivity.cs index b4c9380c..b410b27f 100644 --- a/BookAStar/BookAStar.Droid/MainActivity.cs +++ b/BookAStar/BookAStar.Droid/MainActivity.cs @@ -1,45 +1,43 @@ -using System; - -using Android.App; -using Android.Content.PM; -using Android.Widget; -using Android.OS; +using Android.App; using Android.Content; +using Android.Content.PM; using Android.Gms.Common; +using Android.OS; +using Android.Speech.Tts; using Android.Util; - +using Android.Widget; +using BookAStar.Droid.OAuth; +using BookAStar.Helpers; +using BookAStar.Interfaces; +using BookAStar.Model.Auth.Account; +using Newtonsoft.Json.Linq; +using Plugin.DeviceInfo; +using SQLite.Net; +using SQLite.Net.Platform.XamarinAndroid; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; using Xamarin.Auth; +using XLabs; +using XLabs.Caching; +using XLabs.Caching.SQLite; +using XLabs.Enums; using XLabs.Forms; -using XLabs.Platform.Device; using XLabs.Forms.Services; +using XLabs.Ioc; +using XLabs.Platform.Device; +using XLabs.Platform.Mvvm; +using XLabs.Platform.Services; using XLabs.Platform.Services.Email; using XLabs.Platform.Services.Media; using XLabs.Serialization; - -using Newtonsoft.Json.Linq; -using System.Net; -using System.IO; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Net.Http; -using BookAStar.Model.Auth.Account; -using BookAStar.Droid.OAuth; +using XLabs.Serialization.JsonNET; using Yavsc.Helpers; using Yavsc.Models.Identity; -using BookAStar.Helpers; -using BookAStar.Interfaces; -using Plugin.DeviceInfo; -using Android.Speech.Tts; -using XLabs.Platform.Services; -using XLabs.Caching.SQLite; -using SQLite.Net.Platform.XamarinAndroid; -using SQLite.Net; -using XLabs.Ioc; -using XLabs.Platform.Mvvm; -using XLabs.Caching; -using XLabs; -using XLabs.Enums; namespace BookAStar.Droid { @@ -130,8 +128,7 @@ namespace BookAStar.Droid .Register(resolverContainer) .Register(app) .Register(t => new KeyVaultStorage(t.Resolve().Id.ToCharArray())) - - + .Register() .Register( t => new SQLiteSimpleCache(new SQLitePlatformAndroid(), new SQLiteConnectionString(pathToDatabase, true), t.Resolve())); From ffad59c513d8d7a048ad843f05dbc8fb30870b73 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:10:06 +0200 Subject: [PATCH 32/59] adds the XLabs Json reference --- BookAStar/BookAStar.Droid/packages.config | 1 + 1 file changed, 1 insertion(+) diff --git a/BookAStar/BookAStar.Droid/packages.config b/BookAStar/BookAStar.Droid/packages.config index b25003a3..a196ada6 100644 --- a/BookAStar/BookAStar.Droid/packages.config +++ b/BookAStar/BookAStar.Droid/packages.config @@ -39,6 +39,7 @@ + \ No newline at end of file From 9f6105de2376b7c6101f63989c594864e7b65aa6 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:10:39 +0200 Subject: [PATCH 33/59] refactoring --- .../BookAStar/ViewModels/EstimateViewModel.cs | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs b/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs index 51e42836..1ad3dffb 100644 --- a/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs +++ b/BookAStar/BookAStar/ViewModels/EstimateViewModel.cs @@ -3,6 +3,7 @@ using XLabs.Forms.Mvvm; using BookAStar.Model.Workflow; using System.Collections.ObjectModel; using BookAStar.Model; +using Xamarin.Forms; namespace BookAStar.ViewModels { @@ -10,21 +11,17 @@ namespace BookAStar.ViewModels { public EstimateViewModel(Estimate data) { - estimate = data; - + Data = data; if (data.AttachedFiles == null) data.AttachedFiles = new List(); if (data.AttachedGraphicList == null) data.AttachedGraphicList = new List(); if (data.Bill == null) data.Bill = new List(); AttachedFiles = new ObservableCollection(data.AttachedFiles); AttachedGraphicList = new ObservableCollection(data.AttachedGraphicList); Bill = new ObservableCollection(data.Bill); - description = data.Description; - title = data.Title; - status = data.Status; } - Estimate estimate; - + public Estimate Data { get; protected set; } + public ObservableCollection AttachedFiles { get; protected set; @@ -41,17 +38,18 @@ namespace BookAStar.ViewModels } - private string description; + string newDesc; public string Description { get { - return description; + return Data.Description; } set { - SetProperty(ref description, value, "Description"); + SetProperty(ref newDesc, value, "Description"); + Data.Description = newDesc; } } @@ -60,12 +58,13 @@ namespace BookAStar.ViewModels { get { - return status; + return Data.Status; } set { SetProperty(ref status, value, "Status"); + Data.Status = status; } } private string title; @@ -73,18 +72,40 @@ namespace BookAStar.ViewModels { get { - return title; + return Data.Title; } set { SetProperty(ref title, value, "Title"); + Data.Title = title; } } - public ClientProviderInfo Client { get { return estimate.Client; } } + public ClientProviderInfo Client { get { return Data.Client; } } - public BookQueryData Query { get { return estimate.Query; } } + public BookQueryData Query { get { return Data.Query; } } + public FormattedString FormattedTotal + { + get + { + OnPlatform lfs = (OnPlatform)App.Current.Resources["LargeFontSize"]; + OnPlatform etc = (OnPlatform)App.Current.Resources["EmphasisTextColor"]; + + return new FormattedString + { + + Spans = { + new Span { Text = "Total TTC: " }, + new Span { Text = Data.Total.ToString(), + ForegroundColor = etc.Android , + FontSize = (double) lfs.Android.FontSize }, + new Span { Text = "€", FontSize = (double) lfs.Android.FontSize } + } + }; + } + set { } + } } } From 49a04fb6d23af44a3c1a8ad6c635a19bf1d64481 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:31:57 +0200 Subject: [PATCH 34/59] PickerStyle --- BookAStar/BookAStar/App.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BookAStar/BookAStar/App.xaml b/BookAStar/BookAStar/App.xaml index 23898b58..737b90fa 100644 --- a/BookAStar/BookAStar/App.xaml +++ b/BookAStar/BookAStar/App.xaml @@ -56,13 +56,14 @@ - + - - + + Heures Jours @@ -37,6 +37,6 @@ - + \ No newline at end of file From df32a4cb455fe75213cd74cf81148158197e0b2d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:35:59 +0200 Subject: [PATCH 40/59] Invalidates mesure at modification --- BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs index b5cb5d2d..47d11877 100644 --- a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; - +using System.Windows.Input; using Xamarin.Forms; namespace BookAStar.Pages @@ -15,6 +15,7 @@ namespace BookAStar.Pages { InitializeComponent(); BindingContext = model; + InvalidateMeasure(); } } } From 829e33563e99474eea15d36753572fff69de3f82 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:36:24 +0200 Subject: [PATCH 41/59] yalayout --- BookAStar/BookAStar/Pages/EditEstimatePage.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml index 3f407899..d3027868 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml @@ -29,7 +29,7 @@ Markdown="{Binding Description, Mode=TwoWay}" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, - Factor=.4}" + Factor=.6}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}" From 5ab7eab780fcac31d33ae1daa924fc4d88e6db61 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:37:42 +0200 Subject: [PATCH 42/59] fixes the line edtion action --- BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs index aa4f3238..57fe8aaa 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs @@ -17,9 +17,6 @@ namespace BookAStar.Pages { public partial class EditEstimatePage : ContentPage { - public Estimate Estimate { get { return BindingContext as Estimate; } set { - BindingContext = value; - } } public EditEstimatePage(EstimateViewModel model) { @@ -46,7 +43,7 @@ namespace BookAStar.Pages var com = new BillingLine(); Resolver.Resolve().NavigateTo( true, - new object[] { new BillingLineViewModel(com) } ); + new object[] { new BillingLineViewModel((Estimate)this.BindingContext,com) } ); } } From 50e10e89ad67f0dbc2abfc15b203f2d9ae15fd88 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:39:14 +0200 Subject: [PATCH 43/59] fixes the FormattedString location --- .../BookAStar/Model/Workflow/Estimate.cs | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/BookAStar/BookAStar/Model/Workflow/Estimate.cs b/BookAStar/BookAStar/Model/Workflow/Estimate.cs index a9dd6f41..3b1e4174 100644 --- a/BookAStar/BookAStar/Model/Workflow/Estimate.cs +++ b/BookAStar/BookAStar/Model/Workflow/Estimate.cs @@ -1,10 +1,7 @@ using BookAStar.Helpers; using BookAStar.Model.Interfaces; -using System; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; -using Xamarin.Forms; namespace BookAStar.Model.Workflow { @@ -70,27 +67,7 @@ namespace BookAStar.Model.Workflow } } - public FormattedString FormattedTotal - { - get - { - OnPlatform lfs = (OnPlatform < Font >) App.Current.Resources["LargeFontSize"]; - OnPlatform etc = (OnPlatform)App.Current.Resources["EmphasisTextColor"]; - - return new FormattedString - { - - Spans = { - new Span { Text = "Total TTC: " }, - new Span { Text = Total.ToString(), - ForegroundColor = etc.Android , - FontSize = (double) lfs.Android.FontSize }, - new Span { Text = "€", FontSize = (double) lfs.Android.FontSize } - } - }; - } - set { } - } + public decimal Total { get { return Bill?.Aggregate((decimal)0, (t, l) => t + l.Count * l.UnitaryCost) ?? (decimal)0; From 0a8b4adb76e4a9bf14c6db439f946a86d0cdc50a Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:39:58 +0200 Subject: [PATCH 44/59] publishes access on settings manager --- BookAStar/BookAStar/Helpers/Settings.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/BookAStar/BookAStar/Helpers/Settings.cs b/BookAStar/BookAStar/Helpers/Settings.cs index 0025c2a4..5d03245f 100644 --- a/BookAStar/BookAStar/Helpers/Settings.cs +++ b/BookAStar/BookAStar/Helpers/Settings.cs @@ -11,7 +11,7 @@ namespace BookAStar.Helpers /// public static class Settings { - private static ISettings AppSettings + public static ISettings AppSettings { get { @@ -22,12 +22,13 @@ namespace BookAStar.Helpers #region Setting Constants private const string SettingsKey = "settings_key"; - private static readonly string SettingsDefault = string.Empty; + public static readonly string SettingsDefault = string.Empty; + public static readonly string XLabsSettingsPrefix = "_XLABS_"; - #endregion + #endregion - public static string GeneralSettings + public static string GeneralSettings { get { From b36c67f870db0079843e6008eb31d114ea7d8a96 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:40:22 +0200 Subject: [PATCH 45/59] implements an upload --- BookAStar/BookAStar/Helpers/UserHelpers.cs | 46 +++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/BookAStar/BookAStar/Helpers/UserHelpers.cs b/BookAStar/BookAStar/Helpers/UserHelpers.cs index f1d43366..d57b4f65 100644 --- a/BookAStar/BookAStar/Helpers/UserHelpers.cs +++ b/BookAStar/BookAStar/Helpers/UserHelpers.cs @@ -1,8 +1,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; +using System.IO; using System.Linq; +using System.Net.Http; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Xamarin.Forms; @@ -12,17 +16,49 @@ namespace BookAStar.Helpers { public static ImageSource Avatar(string avatarPath) { - /*foreach (var r in App.Current.Resources) - { - Debug.WriteLine($"#R# {r.Key} : {r.GetType().Name}"); - }*/ var result = avatarPath == null ? - ImageSource.FromResource(/* "BookAStar.icon_user.png" */ "BookAStar.Images.icon_user.png") : + ImageSource.FromResource( "BookAStar.Images.icon_user.png") : avatarPath.StartsWith("res://") ? ImageSource.FromResource(avatarPath.Substring(6)) : ImageSource.FromUri(new Uri(avatarPath)); var test = ImageSource.FromResource("none.resource.png"); return result; } + + public static HttpClient CreateClient() + { + var client = new HttpClient(); + client.DefaultRequestHeaders.Authorization = + new System.Net.Http.Headers.AuthenticationHeaderValue( + "Bearer", MainSettings.CurrentUser.YavscTokens.AccessToken); + return client; + } + + /// + /// Uploads the given stream to + /// /api/fs, in order to be saved under the given file name + /// + /// + /// + /// + public static async Task Upload(Stream inputStream, string fileName) + { + using (var client = CreateClient()) + { + using (var content = + new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture))) + { + content.Add(new StreamContent(inputStream), "Files", fileName); + + using ( + var message = + await client.PostAsync(Constants.FsUrl, content)) + { + return (message.IsSuccessStatusCode); + } + } + } + } + } } From 3da9d7834d4a872cdcd2e8c0490215314527f948 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 20:15:04 +0200 Subject: [PATCH 46/59] cleanning --- BookAStar/BookAStar/Helpers/UserHelpers.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/BookAStar/BookAStar/Helpers/UserHelpers.cs b/BookAStar/BookAStar/Helpers/UserHelpers.cs index d57b4f65..db43c9b4 100644 --- a/BookAStar/BookAStar/Helpers/UserHelpers.cs +++ b/BookAStar/BookAStar/Helpers/UserHelpers.cs @@ -1,12 +1,7 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.Globalization; using System.IO; -using System.Linq; using System.Net.Http; -using System.Text; -using System.Text.RegularExpressions; using System.Threading.Tasks; using Xamarin.Forms; From d785e5e8267ed46769e9efe82c00ef5e5d4e377d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 02:42:23 +0200 Subject: [PATCH 47/59] Fixes Json Serialization --- BookAStar/BookAStar/Model/ClientProviderInfo.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/BookAStar/BookAStar/Model/ClientProviderInfo.cs b/BookAStar/BookAStar/Model/ClientProviderInfo.cs index 604beaae..21991bfa 100644 --- a/BookAStar/BookAStar/Model/ClientProviderInfo.cs +++ b/BookAStar/BookAStar/Model/ClientProviderInfo.cs @@ -1,10 +1,6 @@ using BookAStar.Helpers; using BookAStar.Model.Social; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Newtonsoft.Json; using Xamarin.Forms; namespace BookAStar.Model @@ -21,6 +17,7 @@ namespace BookAStar.Model public Location BillingAddress { get; set; } // TODO Get User Professional status existence as a boolean // And hack the avatar with + [JsonIgnore] public ImageSource AvatarOrNot { get From f42b66383aec40cc987ee6902b628889fbc4f160 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 02:44:44 +0200 Subject: [PATCH 48/59] refactoring --- BookAStar/BookAStar/BookAStar.csproj | 2 ++ BookAStar/BookAStar/Helpers/LocaLEntity.cs | 13 ++++++++++-- .../BookAStar/Interfaces/ILocalEntity.cs | 21 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 BookAStar/BookAStar/Interfaces/ILocalEntity.cs diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj index 9bd62926..908d00f0 100644 --- a/BookAStar/BookAStar/BookAStar.csproj +++ b/BookAStar/BookAStar/BookAStar.csproj @@ -43,6 +43,8 @@ + + diff --git a/BookAStar/BookAStar/Helpers/LocaLEntity.cs b/BookAStar/BookAStar/Helpers/LocaLEntity.cs index 2f86ecdb..6ec0f775 100644 --- a/BookAStar/BookAStar/Helpers/LocaLEntity.cs +++ b/BookAStar/BookAStar/Helpers/LocaLEntity.cs @@ -1,19 +1,23 @@  +using BookAStar.Interfaces; using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; namespace BookAStar { - public class LocalEntity : ObservableCollection where K : IEquatable + public class LocalEntity : ObservableCollection, ILocalEntity where K : IEquatable { public V CurrentItem { get; protected set; } - protected Func GetKey { get; set; } + public Func GetKey { get; set; } public LocalEntity(Func getKey) : base() { if (getKey == null) throw new InvalidOperationException(); GetKey = getKey; + IList l = this; } + public virtual void Merge(V item) { var key = GetKey(item); @@ -29,6 +33,11 @@ namespace BookAStar CurrentItem = this.Single(x => GetKey(x).Equals(key)); return CurrentItem; } + + public void Load() + { + this.Populate(); + } } } \ No newline at end of file diff --git a/BookAStar/BookAStar/Interfaces/ILocalEntity.cs b/BookAStar/BookAStar/Interfaces/ILocalEntity.cs new file mode 100644 index 00000000..38988e9f --- /dev/null +++ b/BookAStar/BookAStar/Interfaces/ILocalEntity.cs @@ -0,0 +1,21 @@ +using System; + +namespace BookAStar +{ + public interface ILoadable + { + void Load(); + } + + public interface ILocalEntity : ILoadable where K : IEquatable + { + V CurrentItem { get; } + + Func GetKey { get; set; } + + V LocalGet(K key); + + void Merge(V item); + + } +} \ No newline at end of file From 10f8e9a7f5f87ec3028c82abefadeae69d91e14e Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 02:46:24 +0200 Subject: [PATCH 49/59] settings as XLabs config manager --- BookAStar/BookAStar/App.xaml.cs | 40 ++-- BookAStar/BookAStar/Helpers/MainSettings.cs | 205 ++++++++++++-------- BookAStar/BookAStar/Helpers/Settings.cs | 9 +- 3 files changed, 151 insertions(+), 103 deletions(-) diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index add3d1df..b0bbba9d 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -33,13 +33,14 @@ namespace BookAStar public static IPlatform PlatformSpecificInstance { get; set; } public static string AppName { get; set; } - + // 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 static bool MasterPresented { + public static bool MasterPresented + { get { return CurrentApp.masterDetail.IsPresented; } internal set @@ -49,7 +50,7 @@ namespace BookAStar public void Init() { var app = Resolver.Resolve(); - + if (app == null) { return; @@ -74,11 +75,11 @@ namespace BookAStar ViewFactory.Register(); ViewFactory.Register(); ViewFactory.Register(); - ConfigManager = new XLabs.Settings.GenericConfigSettingsMgr(s => - Settings.AppSettings.GetValueOrDefault(s, Settings.SettingsDefault), null); + MainSettings.AppSettings.GetValueOrDefault(s, MainSettings.SettingsDefault), null); + } - + ExtendedMasterDetailPage masterDetail; public App(IPlatform instance) @@ -110,14 +111,17 @@ namespace BookAStar home = new HomePage() { Title = "Accueil", Icon = "icon.png" }; // var mainPage = new NavigationPage(bQueriesPage); - - masterDetail = new ExtendedMasterDetailPage() { - Title="MainPage" + + masterDetail = new ExtendedMasterDetailPage() + { + Title = "MainPage" }; - masterDetail.Master = new DashboardPage { + masterDetail.Master = new DashboardPage + { Title = "Bookingstar", - BindingContext = new DashboardViewModel() }; + BindingContext = new DashboardViewModel() + }; // masterDetail.Detail = home; @@ -133,7 +137,7 @@ namespace BookAStar Text = "Accueil", Icon = "icon.png" }; - + /* var navPage = new NavigationPage(masterDetail) { Title = "Navigation", @@ -145,10 +149,10 @@ namespace BookAStar navPage.ToolbarItems.Add(tiSetts); */ this.MainPage = masterDetail; - + Resolver.Resolve() .Register(t => new NavigationService(masterDetail.Detail.Navigation)) - ; + ; } @@ -158,12 +162,12 @@ namespace BookAStar "gcm/register", PlatformSpecificInstance.GetDeviceInfo()); } - + public static void ShowBookQuery (BookQueryData query) { - var page = ViewFactory.CreatePage((b,p)=> p.BindingContext = new BookQueryViewModel(query)); - App.Current.MainPage.Navigation.PushAsync(page as Page); + var page = ViewFactory.CreatePage((b, p) => p.BindingContext = new BookQueryViewModel(query)); + App.Current.MainPage.Navigation.PushAsync(page as Page); } // TODO système de persistance de l'état de l'appli diff --git a/BookAStar/BookAStar/Helpers/MainSettings.cs b/BookAStar/BookAStar/Helpers/MainSettings.cs index 63151925..71e871d0 100644 --- a/BookAStar/BookAStar/Helpers/MainSettings.cs +++ b/BookAStar/BookAStar/Helpers/MainSettings.cs @@ -4,6 +4,7 @@ using BookAStar.Model.Auth.Account; using Newtonsoft.Json; using Plugin.Settings; using Plugin.Settings.Abstractions; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -12,63 +13,68 @@ using Xamarin.Forms; namespace BookAStar { - - /// - /// This is the Settings static class that can be used in your Core solution or in any - /// of your client applications. All settings are laid out the same exact way with getters - /// and setters. - /// - public static class MainSettings - { - - private static ISettings AppSettings { - get { - return CrossSettings.Current; - } - } - #region Setting Constants + /// + /// This is the Settings static class that can be used in your Core solution or in any + /// of your client applications. All settings are laid out the same exact way with getters + /// and setters. + /// + public static class MainSettings + { - private const string userNameKey = "user_id"; - private const string PushNotificationsKey = "pushNotifs"; + public static ISettings AppSettings + { + get + { + return CrossSettings.Current; + } + } + + #region Setting Constants + public static readonly string SettingsDefault = string.Empty; + public static readonly string EntityDataSettingsPrefix = "Ed"; + public static readonly string EntityCursorSettingsPrefix = "Ec"; + private const string userNameKey = "user_id"; + private const string PushNotificationsKey = "pushNotifs"; private const string AllowGPSUsageKey = "allowGPSUsage"; private const string UserListsKey = "userList"; private const string GoogleRegIdKey = "googleRedId"; private const string AllowProBookingOnlyKey = "allowProBookingOnly"; - - private static readonly string UserIdDefault = - string.Empty; - private static readonly bool PushNotificationsDefault = false; - public static readonly string GoogleSenderId = "325408689282"; + private static readonly string UserIdDefault = + string.Empty; + private static readonly bool PushNotificationsDefault = false; - private const string MusicalKey = "musical_prefs"; - private const string EnvironKey = "environ_prefs"; - private static readonly Dictionary MusicalDefault = - new Dictionary { - { "Pop", 0.5 }, { "Hip Hop" , 0.5 }, { "Rock" , 0.5 }, { "Funk", 0.5 }, - { "R&B", 0.5 }, { "Jazz", 0.5 } - }; + public static readonly string GoogleSenderId = "325408689282"; + + private const string MusicalKey = "musical_prefs"; + private const string EnvironKey = "environ_prefs"; + private static readonly Dictionary MusicalDefault = + new Dictionary { + { "Pop", 0.5 }, { "Hip Hop" , 0.5 }, { "Rock" , 0.5 }, { "Funk", 0.5 }, + { "R&B", 0.5 }, { "Jazz", 0.5 } + }; private static readonly Dictionary musical = new Dictionary(); - private static readonly Dictionary EnvironDefault = - new Dictionary { - { "Discothèque", 0.5 }, { "Salles de concert", 0.5 }, - { "Piano bar", 0.5 }, { "Bar", 0.5 }, { "Cinema", 0.5 }, - { "Théatre", 0.5 }, { "Salles des fêtes", 0.5 }, - { "Espace publique", 0.5 } - }; + private static readonly Dictionary EnvironDefault = + new Dictionary { + { "Discothèque", 0.5 }, { "Salles de concert", 0.5 }, + { "Piano bar", 0.5 }, { "Bar", 0.5 }, { "Cinema", 0.5 }, + { "Théatre", 0.5 }, { "Salles des fêtes", 0.5 }, + { "Espace publique", 0.5 } + }; private static readonly Dictionary environ = new Dictionary(); - #endregion + #endregion - public static string UserName + public static string UserName { - get { - return AppSettings.GetValueOrDefault(userNameKey, null); - } - } + get + { + return AppSettings.GetValueOrDefault(userNameKey, null); + } + } public const string bookQueryNotificationsKey = "BookQueryNotifications"; public static BookQueryData[] GetBookQueryNotifications() { @@ -76,7 +82,7 @@ namespace BookAStar var json = AppSettings.GetValueOrDefault(bookQueryNotificationsKey); if (!string.IsNullOrWhiteSpace(json)) return JsonConvert.DeserializeObject(json); - return new BookQueryData[] {}; + return new BookQueryData[] { }; } public static BookQueryData[] AddBookQueryNotification(BookQueryData query) @@ -89,9 +95,10 @@ namespace BookAStar return result; } - public static string GoogleRegId + public static string GoogleRegId { - set { + set + { var oldregid = GoogleRegId; AppSettings.AddOrUpdateValue(GoogleRegIdKey, value); // TODO If it changed, and there's an identified user, @@ -101,10 +108,10 @@ namespace BookAStar App.CurrentApp.PostDeviceInfo(); } } - get { return AppSettings.GetValueOrDefault(GoogleRegIdKey); } + get { return AppSettings.GetValueOrDefault(GoogleRegIdKey); } } - private static ObservableCollection accountList=null; + private static ObservableCollection accountList = null; public static ObservableCollection AccountList { get @@ -118,17 +125,19 @@ namespace BookAStar { var users = JsonConvert.DeserializeObject(json); if (users != null) - foreach (User user in users) - { - accountList.Add(user); - } + foreach (User user in users) + { + accountList.Add(user); + } } } return accountList; } } - - public static User CurrentUser { get + + public static User CurrentUser + { + get { var uname = UserName; if (uname == null) return null; @@ -166,22 +175,25 @@ namespace BookAStar public static User GetUser(string username) { - return AccountList.FirstOrDefault(a=>a.UserName == username); + return AccountList.FirstOrDefault(a => a.UserName == username); } - public static bool PushNotifications { - get { - return AppSettings.GetValueOrDefault( - PushNotificationsKey, - PushNotificationsDefault); - } - set { - // TODO Stop Broadcast receiver - AppSettings.AddOrUpdateValue ( - PushNotificationsKey, - value); + public static bool PushNotifications + { + get + { + return AppSettings.GetValueOrDefault( + PushNotificationsKey, + PushNotificationsDefault); } - } + set + { + // TODO Stop Broadcast receiver + AppSettings.AddOrUpdateValue( + PushNotificationsKey, + value); + } + } public static bool AllowGPSUsage { @@ -214,28 +226,61 @@ namespace BookAStar value); } } - public static void SetMusical (string key, double value) - { - AppSettings.AddOrUpdateValue (MusicalKey + key, value); - } + public static void SetMusical(string key, double value) + { + AppSettings.AddOrUpdateValue(MusicalKey + key, value); + } - public static double GetMusical (string key) - { - return AppSettings.GetValueOrDefault (MusicalKey + key, MusicalDefault [key]); - } + public static double GetMusical(string key) + { + return AppSettings.GetValueOrDefault(MusicalKey + key, MusicalDefault[key]); + } - public static Dictionary Musical { - get { - return musical; - } - } + public static Dictionary Musical + { + get + { + return musical; + } + } - public static Dictionary Environ + public static Dictionary Environ { get { return environ; } } + /// + /// Use a sub-key to make persist different tables with the same definition. + /// + /// + /// + /// + public static void Populate(this IList collection, string subKey = null) + { + var key = $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}"; + var data = AppSettings.GetValueOrDefault(key, null); + if (data != null) + { + var items = JsonConvert.DeserializeObject>(data); + if (items != null) + foreach (var item in items) + collection.Add(item); + } + } + + /// + /// Saves a list + /// + /// + /// + /// + public static void SaveCollection(this IList collection, string subKey=null) + { + if (collection == null) return; + var key = $"{EntityDataSettingsPrefix}/{subKey}/{typeof(V).FullName}"; + AppSettings.AddOrUpdateValue(key, JsonConvert.SerializeObject(collection)); + } } } diff --git a/BookAStar/BookAStar/Helpers/Settings.cs b/BookAStar/BookAStar/Helpers/Settings.cs index 5d03245f..248312af 100644 --- a/BookAStar/BookAStar/Helpers/Settings.cs +++ b/BookAStar/BookAStar/Helpers/Settings.cs @@ -1,6 +1,5 @@ // Helpers/Settings.cs -using Plugin.Settings; -using Plugin.Settings.Abstractions; +#if USELESS_but_makes_the_component_removable // this file must exist ^^ namespace BookAStar.Helpers { @@ -23,7 +22,6 @@ namespace BookAStar.Helpers private const string SettingsKey = "settings_key"; public static readonly string SettingsDefault = string.Empty; - public static readonly string XLabsSettingsPrefix = "_XLABS_"; #endregion @@ -39,6 +37,7 @@ namespace BookAStar.Helpers AppSettings.AddOrUpdateValue(SettingsKey, value); } } - } -} \ No newline at end of file +} + +#endif \ No newline at end of file From 464e87284e39525c53a58777cf14fa6de890e58b Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 02:47:02 +0200 Subject: [PATCH 50/59] Loads persistent data at startup --- BookAStar/BookAStar/Helpers/DataManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BookAStar/BookAStar/Helpers/DataManager.cs b/BookAStar/BookAStar/Helpers/DataManager.cs index 14c7f9ca..0e1ac78d 100644 --- a/BookAStar/BookAStar/Helpers/DataManager.cs +++ b/BookAStar/BookAStar/Helpers/DataManager.cs @@ -35,6 +35,10 @@ namespace BookAStar.Helpers Blogspot = new RemoteEntity("blog", x=>x.Id); Contacts = new LocalEntity(c => c.UserId); + BookQueries.Load(); + Estimates.Load(); + Blogspot.Load(); + Contacts.Load(); } public async Task GetBookQuery(long bookQueryId) From 5066767efba77513eaaf24d1f45800b546191263 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 02:47:35 +0200 Subject: [PATCH 51/59] fixes recent commit --- BookAStar/BookAStar/Helpers/RemoteEntity.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/BookAStar/BookAStar/Helpers/RemoteEntity.cs b/BookAStar/BookAStar/Helpers/RemoteEntity.cs index 0245dcc9..06b20b38 100644 --- a/BookAStar/BookAStar/Helpers/RemoteEntity.cs +++ b/BookAStar/BookAStar/Helpers/RemoteEntity.cs @@ -6,7 +6,7 @@ using Newtonsoft.Json; using System.Threading.Tasks; using System.Net; -namespace BookAStar +namespace BookAStar.Helpers { public class RemoteEntity : LocalEntity, ICommand where K : IEquatable @@ -34,8 +34,7 @@ namespace BookAStar if (IsExecuting) throw new InvalidOperationException("Already executing"); IsExecuting = true; - if (CanExecuteChanged != null) - CanExecuteChanged.Invoke(this, new EventArgs()); + CanExecuteChanged.Invoke(this, new EventArgs()); } /// @@ -45,7 +44,7 @@ namespace BookAStar public async void Execute(object parameter) { BeforeExecute(); - using (HttpClient client = CreateClient()) + using (HttpClient client = UserHelpers.CreateClient()) { // Get the whole data try @@ -61,6 +60,7 @@ namespace BookAStar { Merge(item); } + this.SaveCollection(); } } } @@ -75,8 +75,7 @@ namespace BookAStar private void AfterExecuting() { IsExecuting = false; - if (CanExecuteChanged != null) - CanExecuteChanged.Invoke(this, new EventArgs()); + CanExecuteChanged.Invoke(this, new EventArgs()); } public async Task Get(K key) From 80f2530fe48a8716f3e4e7e9d3db7b6655043e90 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 02:47:54 +0200 Subject: [PATCH 52/59] to be tested --- .../BookAStar/Helpers/ObservableString.cs | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 BookAStar/BookAStar/Helpers/ObservableString.cs diff --git a/BookAStar/BookAStar/Helpers/ObservableString.cs b/BookAStar/BookAStar/Helpers/ObservableString.cs new file mode 100644 index 00000000..2049d950 --- /dev/null +++ b/BookAStar/BookAStar/Helpers/ObservableString.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; + +namespace BookAStar +{ + public class ObservableString : IObservable, IDisposable + { + public ObservableString(string data) + { + this.data = data; + } + private string data = null; + private List> observers = new List>(); + + public string Data + { + get + { + return data; + } + + set + { + if (data != value) + { + data = value; + foreach (var obs in observers) + obs.OnCompleted(); + } + } + } + + public override string ToString() + { + return data; + } + + public static explicit operator ObservableString (string data) + { + return new ObservableString(data); + } + + public static explicit operator string (ObservableString observable) + { + return observable.ToString(); + } + + public void Dispose() + { + observers = null; + } + + public IDisposable Subscribe(IObserver observer) + { + observers.Add(observer); + return this; + } + } +} \ No newline at end of file From 16999896f7e79fb6842cd0f485a2e36190b25302 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 03:17:27 +0200 Subject: [PATCH 53/59] trying to get a better rendering ... --- BookAStar/BookAStar.Droid/MarkdownViewRenderer.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BookAStar/BookAStar.Droid/MarkdownViewRenderer.cs b/BookAStar/BookAStar.Droid/MarkdownViewRenderer.cs index dd71776d..217afc8c 100644 --- a/BookAStar/BookAStar.Droid/MarkdownViewRenderer.cs +++ b/BookAStar/BookAStar.Droid/MarkdownViewRenderer.cs @@ -105,6 +105,9 @@ namespace BookAStar.Droid base.OnElementPropertyChanged(sender, e); } - + protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) + { + base.OnMeasure(widthMeasureSpec, editorView.ContentHeight); + } } } \ No newline at end of file From 33561902c6704905674eb56cc73f7b4da947b65e Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 4 Oct 2016 03:17:43 +0200 Subject: [PATCH 54/59] yastyle --- BookAStar/BookAStar/App.xaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/BookAStar/BookAStar/App.xaml b/BookAStar/BookAStar/App.xaml index 737b90fa..8b32a8c3 100644 --- a/BookAStar/BookAStar/App.xaml +++ b/BookAStar/BookAStar/App.xaml @@ -45,8 +45,6 @@ @@ -56,7 +54,6 @@ + - - - - + + + + - + @@ -50,4 +51,5 @@ + \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs index 57fe8aaa..8bba1227 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using Xamarin.Forms; +using Xamarin.Forms.Internals; using XLabs.Forms.Services; using XLabs.Ioc; using XLabs.Platform.Services; @@ -28,14 +29,16 @@ namespace BookAStar.Pages { base.OnBindingContextChanged(); // FIXME WAZA - if (BindingContext != null) - mdview.Markdown = ((EstimateViewModel)BindingContext).Description; + if (BindingContext != null) { + mdview.Markdown = ((EstimateViewModel)BindingContext).Description; + } } protected void OnDescriptionChanged (object sender, EventArgs e) { // FIXME Why the Binding don't work? ((EstimateViewModel)BindingContext).Description = mdview.Markdown; + InvalidateMeasure(); } protected void OnNewCommanLine(object sender, EventArgs e) @@ -43,7 +46,7 @@ namespace BookAStar.Pages var com = new BillingLine(); Resolver.Resolve().NavigateTo( true, - new object[] { new BillingLineViewModel((Estimate)this.BindingContext,com) } ); + new object[] { new BillingLineViewModel(((EstimateViewModel)this.BindingContext).Data,com) } ); } } diff --git a/BookAStar/BookAStar/Views/MarkdownView.cs b/BookAStar/BookAStar/Views/MarkdownView.cs index 3875e68f..50417671 100644 --- a/BookAStar/BookAStar/Views/MarkdownView.cs +++ b/BookAStar/BookAStar/Views/MarkdownView.cs @@ -23,20 +23,21 @@ namespace BookAStar.Views { return markdown; } - set { + set + { if (markdown != value) - if (Edited != null) + { + markdown = value; + if (Modified != null) { - markdown = value; - Edited.Invoke(this, new EventArgs()); + Modified.Invoke(this, new EventArgs()); return; } - - markdown = value; + } } } - public event EventHandler Edited; + public event EventHandler Modified; protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint) { From 7b96137d745ae94978b27b852598c312712352c5 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 5 Oct 2016 03:48:59 +0200 Subject: [PATCH 57/59] Fixes User's dashboard --- BookAStar/BookAStar/Helpers/MainSettings.cs | 9 +++++- .../BookAStar/Pages/DashboardPage.xaml.cs | 9 +----- .../ViewModels/DashboardViewModel.cs | 28 +++++++++++++++++-- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/BookAStar/BookAStar/Helpers/MainSettings.cs b/BookAStar/BookAStar/Helpers/MainSettings.cs index 71e871d0..8da30074 100644 --- a/BookAStar/BookAStar/Helpers/MainSettings.cs +++ b/BookAStar/BookAStar/Helpers/MainSettings.cs @@ -157,12 +157,19 @@ namespace BookAStar if (olduserid != value.Id) { App.CurrentApp.PostDeviceInfo(); + UserChanged.Invoke(App.CurrentApp, new EventArgs()); } } - // TODO else Unregister this device + else if (olduserid != null) + { + UserChanged.Invoke(App.CurrentApp, new EventArgs()); + // TODO else Unregister this device + } } } + public static event EventHandler UserChanged; + public static void SaveUser(User user) { var existent = AccountList.FirstOrDefault(u => u.UserName == user.UserName); diff --git a/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs b/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs index 0d6bac9c..85290eb1 100644 --- a/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs @@ -16,18 +16,11 @@ namespace BookAStar.Pages { public partial class DashboardPage : ContentPage { - public RelayGesture UserNameGesture { get; set; } + public DashboardPage() { InitializeComponent(); - UserNameGesture = new RelayGesture((g, x) => - { - if (g.GestureType == GestureType.LongPress) - { - Resolver.Resolve().NavigateTo(true); - } - }); } public void OnViewPerformerStatus(object sender, EventArgs e) diff --git a/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs b/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs index 03d1abf4..72549605 100644 --- a/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs +++ b/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs @@ -1,9 +1,14 @@ using BookAStar.Helpers; using BookAStar.Model.Auth.Account; +using BookAStar.Pages; using System.Collections.ObjectModel; using System.Linq; using Xamarin.Forms; +using XLabs.Forms.Behaviors; +using XLabs.Forms.Controls; using XLabs.Forms.Mvvm; +using XLabs.Ioc; +using XLabs.Platform.Services; namespace BookAStar.ViewModels { @@ -98,6 +103,22 @@ namespace BookAStar.ViewModels Accounts = MainSettings.AccountList; User = MainSettings.CurrentUser; UpdateUserMeta(); + + UserNameGesture = new RelayGesture((g, x) => + { + if (g.GestureType == GestureType.LongPress) + { + Resolver.Resolve().NavigateTo(true); + } + }); + MainSettings.UserChanged += MainSettings_UserChanged; + + } + + private void MainSettings_UserChanged(object sender, System.EventArgs e) + { + User = MainSettings.CurrentUser; + UpdateUserMeta(); } private void UpdateUserMeta () @@ -117,9 +138,9 @@ namespace BookAStar.ViewModels { newUserIsPro = User.Roles?.Contains("Performer") ?? false; - newQueryCount = userIsPro ? DataManager.Current.BookQueries.Count : 0; + newQueryCount = newUserIsPro ? DataManager.Current.BookQueries.Count : 0; - newStatusString = userIsPro ? + newStatusString = newUserIsPro ? $"Profile professionel renseigné,\n{newQueryCount} demandes valides en cours" : "Profile professionel non renseigné"; newAvatar = UserHelpers.Avatar(user.Avatar); @@ -133,5 +154,8 @@ namespace BookAStar.ViewModels { UpdateUserMeta(); } + + public RelayGesture UserNameGesture { get; set; } + } } \ No newline at end of file From 2d6047b2cf26b7bf8e9f67cbc0ef7e852e0f7485 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 5 Oct 2016 18:45:03 +0200 Subject: [PATCH 58/59] Fix the "allow notifs" setting --- BookAStar/BookAStar/ViewModels/DashboardViewModel.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs b/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs index 72549605..88e181e6 100644 --- a/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs +++ b/BookAStar/BookAStar/ViewModels/DashboardViewModel.cs @@ -46,6 +46,17 @@ namespace BookAStar.ViewModels } } + public bool ReceivePushNotifications + { + get + { + return MainSettings.PushNotifications; + } + set + { + MainSettings.PushNotifications = value; + } + } private long queryCount; private User user; From 0f0a20d462335d323aff9d4c16bb8b1220fbf47d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Wed, 5 Oct 2016 18:45:45 +0200 Subject: [PATCH 59/59] Fixes navigation after app resume --- BookAStar/BookAStar/App.xaml.cs | 8 ++++---- BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs | 2 +- BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs | 2 +- BookAStar/BookAStar/Pages/DashboardPage.xaml.cs | 2 +- BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index 8f13c2ee..e5e319b7 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -196,11 +196,11 @@ namespace BookAStar navPage.ToolbarItems.Add(tiSetts); */ this.MainPage = masterDetail; - Resolver.Resolve() - .Register(t => new NavigationService(masterDetail.Detail.Navigation)) - ; + masterDetail.ToolbarItems.Add(tiHome); + masterDetail.ToolbarItems.Add(tiSetts); + NavigationService = new NavigationService(masterDetail.Detail.Navigation); } - + public INavigationService NavigationService { protected set; get; } public void PostDeviceInfo() { var res = PlatformSpecificInstance.InvokeApi( diff --git a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs index 9e953465..439438c7 100644 --- a/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/BookQueriesPage.xaml.cs @@ -18,7 +18,7 @@ namespace BookAStar.Pages private void OnViewDetail(object sender, ItemTappedEventArgs e) { BookQueryData data = e.Item as BookQueryData; - Resolver.Resolve().NavigateTo(true,data); + App.CurrentApp.NavigationService.NavigateTo(true,data); } } } diff --git a/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs b/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs index 77eb613e..8acfe73e 100644 --- a/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs @@ -77,7 +77,7 @@ namespace BookAStar.Pages Id = 0, Description = "# **Hello Estimate!**" }; - Resolver.Resolve().NavigateTo(true, + App.CurrentApp.NavigationService.NavigateTo(true, new EstimateViewModel(e)); } diff --git a/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs b/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs index 85290eb1..86cd2ca4 100644 --- a/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/DashboardPage.xaml.cs @@ -35,7 +35,7 @@ namespace BookAStar.Pages private void ShowPage(object [] args, bool animate=false) where T:Page { - Resolver.Resolve().NavigateTo(animate, args); + App.CurrentApp.NavigationService.NavigateTo(animate, args); App.MasterPresented = false; } diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs index 8bba1227..63ffd087 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml.cs @@ -44,7 +44,7 @@ namespace BookAStar.Pages protected void OnNewCommanLine(object sender, EventArgs e) { var com = new BillingLine(); - Resolver.Resolve().NavigateTo( + App.CurrentApp.NavigationService.NavigateTo( true, new object[] { new BillingLineViewModel(((EstimateViewModel)this.BindingContext).Data,com) } ); }