-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #358 from brunck/implement-shell-navigation
Implement Shell Navigation
- Loading branch information
Showing
19 changed files
with
310 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,56 @@ | ||
using MobileKidsIdApp.Services; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xamarin.Forms; | ||
using Xamarin.Forms.Xaml; | ||
|
||
[assembly: XamlCompilation (XamlCompilationOptions.Compile)] | ||
[assembly: XamlCompilation(XamlCompilationOptions.Compile)] | ||
namespace MobileKidsIdApp | ||
{ | ||
public partial class App : Application | ||
{ | ||
public static NavigationPage RootPage { private set; get; } | ||
public partial class App : Application | ||
{ | ||
public static Page RootPage { private set; get; } | ||
public static ViewModels.ChildProfileList CurrentFamily { get; set; } | ||
|
||
|
||
public App () | ||
{ | ||
InitializeComponent(); | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
Csla.ApplicationContext.ContextManager = new Models.ApplicationContextManager(); | ||
|
||
if (Csla.ApplicationContext.User == null) | ||
Csla.ApplicationContext.User = new Csla.Security.UnauthenticatedPrincipal(); | ||
|
||
SetRootPage(); | ||
} | ||
|
||
private void SetRootPage() | ||
{ | ||
if (RootPage is Views.Login page && page.BindingContext is ViewModels.Login vm) | ||
{ | ||
vm.SetRootPage = null; | ||
} | ||
|
||
if (!Csla.ApplicationContext.User.Identity.IsAuthenticated) | ||
{ | ||
RootPage = new NavigationPage(new Views.Login { BindingContext = new ViewModels.Login() }); | ||
ViewModels.Login loginViewModel = new ViewModels.Login | ||
{ | ||
SetRootPage = () => SetRootPage() | ||
}; | ||
RootPage = new Views.Login { BindingContext = loginViewModel }; | ||
} | ||
else | ||
{ | ||
RootPage = new NavigationPage(new Views.Landing { BindingContext = new ViewModels.Landing() }); | ||
RootPage = new AppShell { BindingContext = new ViewModels.Landing() }; | ||
} | ||
|
||
MainPage = RootPage; | ||
} | ||
|
||
|
||
internal static async Task Logout() | ||
public void Logout() | ||
{ | ||
RootPage.Navigation.InsertPageBefore(new NavigationPage(new Views.Login { BindingContext = new ViewModels.Login() }), | ||
RootPage.Navigation.NavigationStack.First()); | ||
await RootPage.Navigation.PopAsync(); | ||
ViewModels.Login loginViewModel = new ViewModels.Login | ||
{ | ||
SetRootPage = () => SetRootPage() | ||
}; | ||
MainPage = RootPage = new Views.Login { BindingContext = loginViewModel }; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Shell | ||
x:Class="MobileKidsIdApp.AppShell" | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:views="clr-namespace:MobileKidsIdApp.Views"> | ||
|
||
<Shell.Resources> | ||
<ResourceDictionary> | ||
<Style x:Key="BaseStyle" TargetType="Element"> | ||
<Setter Property="Shell.BackgroundColor" Value="{StaticResource MCM-DarkTeal-2}" /> | ||
<Setter Property="Shell.ForegroundColor" Value="{StaticResource MCM-White-1}" /> | ||
<Setter Property="Shell.TitleColor" Value="{StaticResource MCM-White-1}" /> | ||
</Style> | ||
<Style BasedOn="{StaticResource BaseStyle}" TargetType="ShellContent" /> | ||
</ResourceDictionary> | ||
</Shell.Resources> | ||
|
||
<!-- This must be a FlyoutItem because there has to be at least one FlyoutItem on a flyout nav shell page. --> | ||
<FlyoutItem Title="My Kids"> | ||
<ShellContent ContentTemplate="{DataTemplate views:ChildProfileList}" /> | ||
</FlyoutItem> | ||
|
||
<MenuItem Command="{Binding DisplayContentMenuCommand}" Text="Content" /> | ||
<MenuItem Command="{Binding OptionsCommand}" Text="Options" /> | ||
<MenuItem Command="{Binding LogoutCommand}" Text="Logout" /> | ||
</Shell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Xamarin.Forms; | ||
|
||
namespace MobileKidsIdApp | ||
{ | ||
public partial class AppShell : Shell | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
Oops, something went wrong.