diff --git a/MobileApp1/Classes/ServiceResult.cs b/MobileApp1/Classes/ServiceResult.cs deleted file mode 100644 index f822a5e..0000000 --- a/MobileApp1/Classes/ServiceResult.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace MobileApp1 -{ - public class ServiceResult - { - public bool IsSuccess { get; set; } - public string Message { get; set; } - - } -} diff --git a/MobileApp1/DTO/ServiceResult.cs b/MobileApp1/DTO/ServiceResult.cs new file mode 100644 index 0000000..97d97fb --- /dev/null +++ b/MobileApp1/DTO/ServiceResult.cs @@ -0,0 +1,16 @@ +namespace MobileApp1 +{ + public class ServiceResult + { + public static ServiceResult Create(bool isSuccess, string message) => new ServiceResult() + { + IsSuccess = isSuccess, + Message = message + }; + + + public bool IsSuccess { get; set; } + public string Message { get; set; } + + } +} diff --git a/MobileApp1/DTO/WelcomePackResult.cs b/MobileApp1/DTO/WelcomePackResult.cs new file mode 100644 index 0000000..8d7a0b7 --- /dev/null +++ b/MobileApp1/DTO/WelcomePackResult.cs @@ -0,0 +1,10 @@ +namespace MobileApp1 +{ + public class WelcomePackResult : ServiceResult + { + public int NoticesCount { get; set; } = 0; + + public int MessagesCount { get; set; } = 0; + + } +} diff --git a/MobileApp1/MobileApp1.csproj b/MobileApp1/MobileApp1.csproj index ca1c69e..4c14b2b 100644 --- a/MobileApp1/MobileApp1.csproj +++ b/MobileApp1/MobileApp1.csproj @@ -47,9 +47,6 @@ LogoutPage.xaml - - MyStuffPage.xaml - PasswordResetPage.xaml @@ -65,8 +62,11 @@ LoginView.xaml - - HomePage.xaml + + WelcomePage.xaml + + + MyFoldersPage.xaml @@ -86,11 +86,14 @@ MSBuild:UpdateDesignTimeXaml - + MSBuild:UpdateDesignTimeXaml MSBuild:UpdateDesignTimeXaml + + MSBuild:UpdateDesignTimeXaml + \ No newline at end of file diff --git a/MobileApp1/Services/CorporationMockService.cs b/MobileApp1/Services/CorporationMockService.cs index d82ea8f..c0bf640 100644 --- a/MobileApp1/Services/CorporationMockService.cs +++ b/MobileApp1/Services/CorporationMockService.cs @@ -1,10 +1,15 @@ -namespace MobileApp1.Services +using System; + +namespace MobileApp1.Services { public class CorporationMockService : ICorporationService { + private Random randy = null; + + public CorporationMockService() { - + randy = new Random(); } @@ -19,14 +24,11 @@ { System.Threading.Thread.Sleep(6000); - this.DisplayName = username; + //this.DisplayName = username; + this.DisplayName = "John"; this.IsLoggedIn = true; - return new ServiceResult() - { - IsSuccess = true, - Message = "Logged In" - }; + return ServiceResult.Create(true, "Logged In"); } public ServiceResult Logout() @@ -36,11 +38,7 @@ this.DisplayName = string.Empty; this.IsLoggedIn = false; - return new ServiceResult() - { - IsSuccess = true, - Message = "Logged Out" - }; + return ServiceResult.Create(true, "Logged Out"); } public ServiceResult RequestPasswordReset(string username) @@ -50,10 +48,19 @@ this.DisplayName = string.Empty; this.IsLoggedIn = false; - return new ServiceResult() + return ServiceResult.Create(true, "Password Reset Requested"); + } + + public WelcomePackResult RetrieveWelcomePack() + { + System.Threading.Thread.Sleep(1000); + + return new WelcomePackResult() { IsSuccess = true, - Message = "Password Reset Requested" + Message = "", + MessagesCount = randy.Next(0, 25), + NoticesCount = randy.Next(0, 10) }; } diff --git a/MobileApp1/Services/CorporationService.cs b/MobileApp1/Services/CorporationService.cs index ed2fc0e..c8381c2 100644 --- a/MobileApp1/Services/CorporationService.cs +++ b/MobileApp1/Services/CorporationService.cs @@ -20,11 +20,7 @@ this.DisplayName = username; this.IsLoggedIn = true; - return new ServiceResult() - { - IsSuccess = true, - Message = "Logged In" - }; + return ServiceResult.Create(true, "Logged In"); } public ServiceResult Logout() @@ -32,11 +28,7 @@ this.DisplayName = string.Empty; this.IsLoggedIn = false; - return new ServiceResult() - { - IsSuccess = true, - Message = "Logged Out" - }; + return ServiceResult.Create(true, "Logged Out"); } public ServiceResult RequestPasswordReset(string username) @@ -44,10 +36,19 @@ this.DisplayName = string.Empty; this.IsLoggedIn = false; - return new ServiceResult() + return ServiceResult.Create(true, "Password Reset Requested"); + } + + public WelcomePackResult RetrieveWelcomePack() + { + System.Threading.Thread.Sleep(1000); + + return new WelcomePackResult() { IsSuccess = true, - Message = "Password Reset Requested" + Message = "", + MessagesCount = 0, + NoticesCount = 0 }; } diff --git a/MobileApp1/Services/ICorporationService.cs b/MobileApp1/Services/ICorporationService.cs index 172e23d..c4871ab 100644 --- a/MobileApp1/Services/ICorporationService.cs +++ b/MobileApp1/Services/ICorporationService.cs @@ -15,5 +15,7 @@ ServiceResult RequestPasswordReset(string username); + WelcomePackResult RetrieveWelcomePack(); + } } diff --git a/MobileApp1/Views/FlyoutMenuPage.xaml b/MobileApp1/Views/FlyoutMenuPage.xaml index 9d0b32c..16e2ca0 100644 --- a/MobileApp1/Views/FlyoutMenuPage.xaml +++ b/MobileApp1/Views/FlyoutMenuPage.xaml @@ -25,7 +25,7 @@ --> - + diff --git a/MobileApp1/Views/HomePage.xaml b/MobileApp1/Views/HomePage.xaml deleted file mode 100644 index afd6775..0000000 --- a/MobileApp1/Views/HomePage.xaml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/MobileApp1/Views/HomePage.xaml.cs b/MobileApp1/Views/HomePage.xaml.cs deleted file mode 100644 index ed0e09f..0000000 --- a/MobileApp1/Views/HomePage.xaml.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Threading.Tasks; -using Xamarin.Forms; -using Xamarin.Forms.Xaml; - -namespace MobileApp1.Views -{ - [XamlCompilation(XamlCompilationOptions.Compile)] - public partial class HomePage : ContentPage - { - public HomePage() - { - InitializeComponent(); - } - - private async void button1_Clicked(object sender, EventArgs e) - { - await Task.Run(() => - { - ContentPageHelper.SetDetailPage(this, typeof(MyFoldersPage)); - }); - } - - } -} \ No newline at end of file diff --git a/MobileApp1/Views/MainPage.xaml b/MobileApp1/Views/MainPage.xaml index 6ab3d64..6e9e729 100644 --- a/MobileApp1/Views/MainPage.xaml +++ b/MobileApp1/Views/MainPage.xaml @@ -8,7 +8,7 @@ - + diff --git a/MobileApp1/Views/MyFoldersPage.xaml b/MobileApp1/Views/MyFoldersPage.xaml index e60f591..a10220c 100644 --- a/MobileApp1/Views/MyFoldersPage.xaml +++ b/MobileApp1/Views/MyFoldersPage.xaml @@ -1,22 +1,16 @@  - - - - - - - - - - - - - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/MobileApp1/Views/MyFoldersPage.xaml.cs b/MobileApp1/Views/MyFoldersPage.xaml.cs index 12497b2..dfd615a 100644 --- a/MobileApp1/Views/MyFoldersPage.xaml.cs +++ b/MobileApp1/Views/MyFoldersPage.xaml.cs @@ -1,16 +1,20 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + using Xamarin.Forms; +using Xamarin.Forms.Xaml; namespace MobileApp1.Views { - public partial class MyFoldersPage : ContentPage + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class MyFoldersPage : TabbedPage { public MyFoldersPage() { InitializeComponent(); - - label1.Text = Guid.NewGuid().ToString(); } - } } \ No newline at end of file diff --git a/MobileApp1/Views/WelcomePage.xaml b/MobileApp1/Views/WelcomePage.xaml new file mode 100644 index 0000000..c27de8e --- /dev/null +++ b/MobileApp1/Views/WelcomePage.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MobileApp1/Views/WelcomePage.xaml.cs b/MobileApp1/Views/WelcomePage.xaml.cs new file mode 100644 index 0000000..7bdbd71 --- /dev/null +++ b/MobileApp1/Views/WelcomePage.xaml.cs @@ -0,0 +1,101 @@ +using System; +using System.Threading.Tasks; +using Xamarin.Forms; +using Xamarin.Forms.Xaml; + +namespace MobileApp1.Views +{ + [XamlCompilation(XamlCompilationOptions.Compile)] + public partial class WelcomePage : ContentPage + { + protected bool isBusy = false; + + + public WelcomePage() + { + InitializeComponent(); + } + + protected override void OnAppearing() + { + base.OnAppearing(); + + LoadPage(); + } + + private bool IsBusy + { + get => isBusy; + set + { + isBusy = value; + + //LoginPage cp = (LoginPage)ContentViewHelper.GetParentElement(this); + //if (cp != null) + //{ + // cp.IsBusy = value; + //} + + Device.BeginInvokeOnMainThread(() => + { + loadingIndicatorView1.IsRunning = value; + panel1.IsVisible = !value; + }); + + } + } + + + private async void button1_Clicked(object sender, EventArgs e) + { + await Task.Run(() => + { + ContentPageHelper.SetDetailPage(this, typeof(MyFoldersPage)); + }); + } + + + private async void LoadPage() + { + await Task.Run(() => + { + if (this.Parent == null) + { + return; + } + + App ap = ContentPageHelper.GetApp(this); + if (ap == null) + { + return; + } + + IsBusy = true; + + WelcomePackResult result = ap.CorporationService.RetrieveWelcomePack(); + + loadingIndicatorView1.Message = result.Message; + + IsBusy = false; + + //ContentViewHelper.SetMainPage(this, new AppShell()); + + //await cp.DisplayAlert("Clicked", "Login", "OK"); + + + if (result.IsSuccess) + { + + Device.BeginInvokeOnMainThread(() => + { + label1.Text = string.Format("Hi, {0}.", ap.CorporationService.DisplayName); + label2.Text = string.Format("You have {0} notice{1}", ((result.NoticesCount <= 0) ? "no": result.NoticesCount.ToString()), ((result.NoticesCount == 1) ? "" : "s")); + label3.Text = string.Format("You have {0} message{1}", ((result.MessagesCount <= 0) ? "no": result.MessagesCount.ToString()), ((result.MessagesCount == 1) ? "" : "s")); + }); + } + + }); + } + + } +} \ No newline at end of file