corp-app/CORP-MAUI/Controls/DesktopSidebar.xaml.cs

101 lines
3.8 KiB
C#

namespace CORP_MAUI.Controls;
public partial class DesktopSidebar : ContentView
{
public event EventHandler<string>? NavigationRequested;
private string _currentRoute = "News";
private readonly Color _activeBackground = Color.FromArgb("#E8F0FE");
private readonly Color _inactiveBackground = Colors.Transparent;
public DesktopSidebar()
{
InitializeComponent();
// По умолчанию выделяем "Новости"
UpdateActiveItem("News");
}
private void UpdateActiveItem(string route)
{
_currentRoute = route;
// Сбрасываем все фоны
ProfileItem.BackgroundColor = _inactiveBackground;
NewsItem.BackgroundColor = _inactiveBackground;
EmployeesItem.BackgroundColor = _inactiveBackground;
DepartmentsItem.BackgroundColor = _inactiveBackground;
RequestsItem.BackgroundColor = _inactiveBackground;
ChatsItem.BackgroundColor = _inactiveBackground;
DocumentsItem.BackgroundColor = _inactiveBackground;
FinanceItem.BackgroundColor = _inactiveBackground;
SettingsItem.BackgroundColor = _inactiveBackground;
// Выделяем активный пункт
switch (route)
{
case "Profile": ProfileItem.BackgroundColor = _activeBackground; break;
case "News": NewsItem.BackgroundColor = _activeBackground; break;
case "Employees": EmployeesItem.BackgroundColor = _activeBackground; break;
case "Departments": DepartmentsItem.BackgroundColor = _activeBackground; break;
case "Requests": RequestsItem.BackgroundColor = _activeBackground; break;
case "Chats": ChatsItem.BackgroundColor = _activeBackground; break;
case "Documents": DocumentsItem.BackgroundColor = _activeBackground; break;
case "Finance": FinanceItem.BackgroundColor = _activeBackground; break;
case "Settings": SettingsItem.BackgroundColor = _activeBackground; break;
}
}
private void OnProfileClicked(object? sender, EventArgs e)
{
UpdateActiveItem("Profile");
NavigationRequested?.Invoke(this, "Profile");
}
private void OnNewsClicked(object? sender, EventArgs e)
{
UpdateActiveItem("News");
NavigationRequested?.Invoke(this, "News");
}
private void OnEmployeesClicked(object? sender, EventArgs e)
{
UpdateActiveItem("Employees");
NavigationRequested?.Invoke(this, "Employees");
}
private void OnDepartmentsClicked(object? sender, EventArgs e)
{
UpdateActiveItem("Departments");
NavigationRequested?.Invoke(this, "Departments");
}
private void OnRequestsClicked(object? sender, EventArgs e)
{
UpdateActiveItem("Requests");
NavigationRequested?.Invoke(this, "Requests");
}
private void OnChatsClicked(object? sender, EventArgs e)
{
UpdateActiveItem("Chats");
NavigationRequested?.Invoke(this, "Chats");
}
private void OnDocumentsClicked(object? sender, EventArgs e)
{
UpdateActiveItem("Documents");
NavigationRequested?.Invoke(this, "Documents");
}
private async void OnFinanceClicked(object? sender, EventArgs e)
{
if (Application.Current?.Windows.Count > 0)
await Application.Current.Windows[0].Page!.DisplayAlert("Финансы", "Раздел финансов находится в разработке", "OK");
}
private async void OnSettingsClicked(object? sender, EventArgs e)
{
if (Application.Current?.Windows.Count > 0)
await Application.Current.Windows[0].Page!.DisplayAlert("Настройки", "Раздел настроек находится в разработке", "OK");
}
}