-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.xaml.cs
69 lines (57 loc) · 1.69 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using RuokalistaApp.Pages;
namespace RuokalistaApp;
public partial class App : Application
{
public App()
{
if (Preferences.Default.ContainsKey("Teema"))
{
var key = Preferences.Default.Get("Teema", 0);
if (key == 0)
{
Application.Current.UserAppTheme = AppTheme.Unspecified;
}
else if (key == 1)
{
Application.Current.UserAppTheme = AppTheme.Dark;
}
else if (key == 2)
{
Application.Current.UserAppTheme = AppTheme.Light;
}
}
InitializeComponent();
if(Preferences.Get("SetupDone", false))
{
Application.Current.MainPage = new AppShell();
var color = Preferences.Get("PrimaryColor", Config.PrimaryFallbackColor);
Application.Current.Resources["Primary"] = Color.FromArgb(color);
MainPage.Appearing += (s, e) => UpdateAndroidSystemBars(color);
}
else
{
Application.Current.MainPage = new WelcomePage();
var color = Config.PrimaryFallbackColor;
Application.Current.Resources["Primary"] = Color.FromArgb(color);
MainPage.Appearing += (s, e) => UpdateAndroidSystemBars(color);
}
}
public static void SetCurrentAppColor(string color)
{
Application.Current.Resources["Primary"] = Color.FromArgb(color);
UpdateAndroidSystemBars(color);
}
private static void UpdateAndroidSystemBars(string color)
{
#if ANDROID
if (Platform.CurrentActivity?.Window != null && Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
var androidColor = Android.Graphics.Color.ParseColor(color);
// Set the status bar color
Platform.CurrentActivity.Window.SetStatusBarColor(androidColor);
// Set the navigation bar color
Platform.CurrentActivity.Window.SetNavigationBarColor(androidColor);
}
#endif
}
}