Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/MauiSherpa.LinuxGtk/LinuxToolbarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,24 @@ public void AttachToWindow(Gtk.Window window)
_copilotButton.OnClicked += (s, _) => _copilotContext.ToggleOverlay();
_headerBar.PackStart(_copilotButton);

// Settings gear button on the right side
// Settings gear button beside copilot
var settingsButton = Gtk.Button.New();
settingsButton.SetIconName("emblem-system-symbolic");
settingsButton.SetTooltipText("Settings");
settingsButton.OnClicked += (s, _) => OpenSettingsDialog();
_headerBar.PackEnd(settingsButton);
_headerBar.PackStart(settingsButton);

// Doctor button beside settings
var doctorButton = Gtk.Button.New();
var doctorIconName = _themeService.IsDarkMode ? "fa-stethoscope-white-24.png" : "fa-stethoscope-24.png";
var doctorIconPath = System.IO.Path.Combine(AppContext.BaseDirectory, "Resources", doctorIconName);
if (System.IO.File.Exists(doctorIconPath))
doctorButton.SetChild(Gtk.Image.NewFromFile(doctorIconPath));
else
doctorButton.SetIconName("dialog-information-symbolic");
Comment thread
Redth marked this conversation as resolved.
doctorButton.SetTooltipText("Doctor");
doctorButton.OnClicked += (s, _) => _toolbarService.RequestNavigation("/doctor");
_headerBar.PackStart(doctorButton);

_window.SetTitlebar(_headerBar);
}
Expand Down
25 changes: 18 additions & 7 deletions src/MauiSherpa/Components/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@
protected override void OnInitialized()
{
ThemeService.ThemeChanged += OnThemeChanged;
if (PlatformInfo.IsWindows)
ToolbarService.NavigationRequested += OnNavigationRequested;
ToolbarService.NavigationRequested += OnNavigationRequested;
}

protected override void OnAfterRender(bool firstRender)
Expand Down Expand Up @@ -265,8 +264,7 @@
{
ThemeService.ThemeChanged -= OnThemeChanged;
NavManager.LocationChanged -= OnLocationChanged;
if (PlatformInfo.IsWindows)
ToolbarService.NavigationRequested -= OnNavigationRequested;
ToolbarService.NavigationRequested -= OnNavigationRequested;
}

private void OnLocationChanged(object? sender, Microsoft.AspNetCore.Components.Routing.LocationChangedEventArgs e)
Expand All @@ -277,12 +275,25 @@
ToolbarService.NotifyRouteChanged(route);
}

private void OpenCopilot() => CopilotContext.OpenOverlay();

private void OnNavigationRequested(string route)
{
Comment thread
Redth marked this conversation as resolved.
InvokeAsync(() => NavManager.NavigateTo(route));
}
// Defensively validate/normalize the route coming from native UI
if (string.IsNullOrWhiteSpace(route))
{
return;
}

private void OpenCopilot() => CopilotContext.OpenOverlay();
route = route.Trim();

// Reject absolute URIs/schemes to avoid accidental external navigation
if (Uri.TryCreate(route, UriKind.Absolute, out _))
{
return;
}
_ = InvokeAsync(() => NavManager.NavigateTo(route));
}
}

<style>
Expand Down
Loading