-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample updated to Preview 14 and Added themeing
- Loading branch information
1 parent
407a085
commit 1ab74a2
Showing
19 changed files
with
469 additions
and
216 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,12 +1,60 @@ | ||
namespace TestApp | ||
using TestApp.Models; | ||
using TestApp.Services; | ||
using VijayAnand.MauiToolkit.Services; | ||
|
||
namespace TestApp | ||
{ | ||
public partial class App : Application | ||
{ | ||
private static readonly object locker = new(); | ||
private readonly IThemeService? themeService; | ||
|
||
public App() | ||
{ | ||
InitializeComponent(); | ||
if (Instance == null) | ||
{ | ||
lock (locker) | ||
{ | ||
if (Instance == null) | ||
{ | ||
Instance = this; | ||
} | ||
} | ||
} | ||
|
||
InitializeComponent(); | ||
MainPage = new AppShell(); | ||
|
||
themeService = AppService.GetService<IThemeService>(); | ||
|
||
User = new UserModel(); | ||
// Add logic to check whether the user is authenticated or not and then update this flag | ||
User.Authenticated = false; | ||
} | ||
|
||
public static App? Instance { get; private set; } | ||
|
||
public UserModel User { get; internal set; } | ||
|
||
protected override void OnStart() | ||
{ | ||
OnResume(); | ||
} | ||
|
||
protected override void OnResume() | ||
{ | ||
themeService?.SetTheme(); | ||
RequestedThemeChanged += OnAppThemeChangeRequested; | ||
} | ||
|
||
protected override void OnSleep() | ||
{ | ||
RequestedThemeChanged -= OnAppThemeChangeRequested; | ||
} | ||
|
||
private void OnAppThemeChangeRequested(object? sender, AppThemeChangedEventArgs e) | ||
{ | ||
MainThread.BeginInvokeOnMainThread(() => themeService?.SetTheme()); | ||
} | ||
} | ||
} |
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,14 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ContentPage x:Class="TestApp.HomePage" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TestApp" | ||
Title="Home" | ||
BackgroundColor="{DynamicResource SecondaryColor}"> | ||
<ContentPage.Content> | ||
<StackLayout HorizontalOptions="Center" | ||
VerticalOptions="Center"> | ||
<ContentPage | ||
x:Class="TestApp.HomePage" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TestApp" | ||
Title="Home"> | ||
<Grid Style="{StaticResource ContentArea}"> | ||
<StackLayout HorizontalOptions="Center" VerticalOptions="Center"> | ||
<Label Text="Home Page" /> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</Grid> | ||
</ContentPage> |
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,15 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ContentPage x:Class="TestApp.LoginPage" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TestApp" | ||
Title="Login" | ||
BackgroundColor="{DynamicResource SecondaryColor}"> | ||
<ContentPage.Content> | ||
<StackLayout HorizontalOptions="Center" | ||
VerticalOptions="Center"> | ||
<Button Text="Login" | ||
Clicked="Login_Clicked" /> | ||
<ContentPage | ||
x:Class="TestApp.LoginPage" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TestApp" | ||
Title="Login" | ||
Shell.NavBarIsVisible="False"> | ||
<Grid Style="{StaticResource ContentArea}"> | ||
<StackLayout HorizontalOptions="Center" VerticalOptions="Center"> | ||
<Button Clicked="OnLoginClicked" Text="Login" /> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</Grid> | ||
</ContentPage> |
Oops, something went wrong.