Skip to content

Commit 91e34b1

Browse files
Change statusbar depending on light or dark mode
1 parent 1dd6f60 commit 91e34b1

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

JournalApp/Data/PreferenceService.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using MudBlazor.Utilities;
1+
using CommunityToolkit.Maui.Core;
2+
using CommunityToolkit.Maui.Core.Platform;
3+
using MudBlazor.Utilities;
24

35
namespace JournalApp;
46

@@ -22,6 +24,7 @@ public PreferenceService(ILogger<PreferenceService> logger, IPreferences prefere
2224
_application.RequestedThemeChanged += Application_RequestedThemeChanged;
2325
}
2426

27+
UpdateStatusBar();
2528
GenerateMoodColors();
2629
}
2730

@@ -122,9 +125,28 @@ private void Application_RequestedThemeChanged(object sender, AppThemeChangedEve
122125

123126
private void OnThemeChanged()
124127
{
128+
UpdateStatusBar();
125129
ThemeChanged?.Invoke(this, IsDarkMode);
126130
}
127131

132+
private void UpdateStatusBar()
133+
{
134+
if (OperatingSystem.IsAndroid())
135+
{
136+
logger.LogDebug("Updating status bar");
137+
if (IsDarkMode)
138+
{
139+
StatusBar.SetColor(Color.FromHex("#EAB8D6"));
140+
StatusBar.SetStyle(StatusBarStyle.DarkContent);
141+
}
142+
else
143+
{
144+
StatusBar.SetColor(Color.FromHex("#854C73"));
145+
StatusBar.SetStyle(StatusBarStyle.LightContent);
146+
}
147+
}
148+
}
149+
128150
private void GenerateMoodColors()
129151
{
130152
var emojis = DataPoint.Moods.Where(x => x != "🤔").ToList();
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<color name="colorPrimary">#854C73</color>
4-
<color name="colorPrimaryDark">#EAB8D6</color>
5-
<color name="colorAccent">#715867</color>
4+
<color name="colorPrimaryDark">#854C73</color>
65
</resources>

0 commit comments

Comments
 (0)