-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
76 lines (55 loc) · 1.6 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
70
71
72
73
74
75
76
using System.ComponentModel;
namespace PracticaPalabrasMAUI;
public partial class App : Application
{
public static Page CurrentPage { get; set; }
public static App CurrentApp { get; set; }
private ResourceDictionary AntDic { get; set; }
public event EventHandler langChanged;
public App()
{
CurrentApp = this;
InitializeComponent();
UpdateLang();
MainPage = new AppShell();
RequestedThemeChanged += (s, e) => { Current.UserAppTheme = Theme; };
Current.UserAppTheme = Theme;
}
public AppTheme Theme
{
get =>Enum.Parse<AppTheme>( Preferences.Get(nameof(Theme), AppTheme.Unspecified.ToString()));
set
{
Preferences.Set(nameof(Theme), value.ToString());
Current.UserAppTheme = value;
}
}
public ResourceDictionary Colors=> Current.Resources.MergedDictionaries.First();
public void UpdateLang()
{
ResourceDictionary dic;
switch(Language.LangCode)
{
case "es-ES":
dic =new es_ES();
break;
case "es-CA":
dic = new es_CA();
break;
default:
dic = new en_UK();
break;
}
if(!Equals(AntDic,dic) && !Equals(AntDic, null))
{
Current.Resources.MergedDictionaries.Remove(AntDic);
}
Current.Resources.MergedDictionaries.Add(dic);
AntDic = dic;
if(langChanged != null)
{
langChanged(this, new EventArgs());
}
}
}