-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppShell.xaml.cs
84 lines (70 loc) · 2.41 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using SmartCAN.Pages;
using System.Diagnostics;
namespace SmartCAN;
public partial class AppShell : Shell
{
public AppShell(int role, User user)
{
InitializeComponent();
if (role == 0)
{
AddTab("Maps", "Maps", "localisation.png", user, role, typeof(Maps));
AddTab("Poubelles", "FourthPage", "email.png", user, role, typeof(FourthPage));
AddTab("Notifications", "ThirdPage", "notification.png", user, role, typeof(ThirdPage));
AddTab("Profil", "ProfilePage", "profile.png", user, role, typeof(ProfilePage));
}
else
{
AddTab("Maps", "Maps", "localisation.png", user, role, typeof(Maps));
AddTab("Employés", "SecondPage", "groupe.png", user, role, typeof(SecondPage));
AddTab("Poubelles", "FourthPage", "email.png", user, role, typeof(FourthPage));
AddTab("Notifications", "notification.png", "ThirdPage", user, role, typeof(ThirdPage));
AddTab("Profil", "ProfilePage", "profile.png", user, role, typeof(ProfilePage));
}
}
private async void OnDisconnectButtonClicked(object sender, EventArgs e)
{
var navigationStack = Navigation.NavigationStack;
if (navigationStack != null)
{
foreach (var page in navigationStack)
{
if (page != null)
{
Debug.WriteLine($"Page Type: {page.GetType().Name}");
}
}
}
if (Navigation != null)
{
await Navigation.PopModalAsync();
}
}
void AddTab(string title, string pageName, string image, User user, int role, Type pageType)
{
var tab = new Tab
{
Title = title,
Route = title,
Icon = image
};
Page page;
if (pageType == typeof(ProfilePage))
{
var profilePage = new ProfilePage(user, role);
profilePage.DisconnectButtonClicked += OnDisconnectButtonClicked;
page = profilePage;
}
else
{
page = Activator.CreateInstance(pageType, user, role) as Page;
}
var shellContent = new ShellContent
{
Content = page,
Route = title
};
tab.Items.Add(shellContent);
AppTabs.Items.Add(tab);
}
}