-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAppShell.xaml.cs
61 lines (48 loc) · 1.47 KB
/
AppShell.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
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
using RuokalistaApp.Pages;
namespace RuokalistaApp;
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute("SeuraavaViikko", typeof(NextWeekPage));
Routing.RegisterRoute("Main", typeof(MainPage));
Routing.RegisterRoute("Welcome", typeof(WelcomePage));
if(Preferences.Get("kasvisruokalistaEnabled", false))
{
if (!Preferences.Get("NaytaKasvis", false))
{
tabbar.Items.Remove(KasvisruokaTab);
}
}
else
{
tabbar.Items.Remove(KasvisruokaTab);
}
CheckForConfigUpdatesAsync();
}
private async void CheckForConfigUpdatesAsync()
{
try
{
var ServerConfig = await Task.Run(() => Config.GetServerConfig(Preferences.Default.Get("School", "")));
var primaryColor = ServerConfig["primaryColor"] ?? Config.PrimaryFallbackColor;
if(Preferences.Default.Get("PrimaryColor", Config.PrimaryFallbackColor) != primaryColor)
{
App.SetCurrentAppColor(primaryColor);
Preferences.Default.Set("PrimaryColor", primaryColor);
}
Preferences.Default.Set("kasvisruokalistaEnabled", bool.Parse(ServerConfig["kasvisruokalistaEnabled"] ?? "false"));
}
catch (Exception)
{
string text = "Virhe hakiessa päivityksiä palvelimelta!";
ToastDuration duration = ToastDuration.Short;
double fontSize = 15;
var toast = Toast.Make(text, duration, fontSize);
await toast.Show();
}
}
}