Skip to content
Draft
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
5 changes: 5 additions & 0 deletions Flow.Launcher.Core/Plugin/JsonRPCV2Models/JsonRPCPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public void ShowMsg(string title, string subTitle, string iconPath, bool useMain
_api.ShowMsg(title, subTitle, iconPath, useMainWindowAsOwner);
}

public void ShowNotification(string title, string subTitle = "", NotificationSeverity severity = NotificationSeverity.Informational)
{
_api.ShowNotification(title, subTitle, severity);
}

public void OpenSettingDialog()
{
_api.OpenSettingDialog();
Expand Down
11 changes: 11 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ public interface IPublicAPI
/// <param name="subTitle">Optional message subtitle</param>
void ShowMsgErrorWithButton(string title, string buttonText, Action buttonAction, string subTitle = "");

/// <summary>
/// Show an inline notification bar in the Flow Launcher main window.
/// Unlike <see cref="ShowMsg"/>, this displays directly inside the application window and
/// cannot be blocked by OS notification settings.
/// The notification bar remains visible until the user closes it.
/// </summary>
/// <param name="title">Notification title</param>
/// <param name="subTitle">Optional notification subtitle</param>
/// <param name="severity">Severity level that controls the icon and accent color</param>
void ShowNotification(string title, string subTitle = "", NotificationSeverity severity = NotificationSeverity.Informational);

/// <summary>
/// Show the MainWindow when hiding
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions Flow.Launcher.Plugin/NotificationSeverity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Flow.Launcher.Plugin
{
/// <summary>
/// Specifies the severity level of an inline notification shown in the Flow Launcher window.
/// </summary>
public enum NotificationSeverity
{
/// <summary>Informational notification (blue icon).</summary>
Informational = 0,

/// <summary>Success notification (green icon).</summary>
Success = 1,

/// <summary>Warning notification (yellow icon).</summary>
Warning = 2,

/// <summary>Error notification (red icon).</summary>
Error = 3
}
}
10 changes: 10 additions & 0 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,16 @@
Y2="0" />
</Grid>

<ui:InfoBar
Title="{Binding InlineNotificationTitle}"
Margin="4 0 4 0"
IsClosable="True"
IsIconVisible="True"
IsOpen="{Binding InlineNotificationIsOpen, Mode=TwoWay}"
Message="{Binding InlineNotificationMessage}"
Severity="{Binding InlineNotificationSeverity}"
WindowChrome.IsHitTestVisibleInChrome="True" />

<Grid x:Name="MiddleSeparatorArea" ClipToBounds="True">
<ContentControl>
<ContentControl.Style>
Expand Down
18 changes: 18 additions & 0 deletions Flow.Launcher/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
using System.Collections.Concurrent;
using System.IO;
using System.Windows;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Plugin;
using Flow.Launcher.ViewModel;
using iNKORE.UI.WPF.Modern.Controls;
using Microsoft.Toolkit.Uwp.Notifications;

namespace Flow.Launcher
Expand Down Expand Up @@ -141,5 +145,19 @@ private static void LegacyShowWithButton(string title, string buttonText, Action
var msg = new MsgWithButton();
msg.Show(title, buttonText, buttonAction, subTitle, iconPath);
}

public static void ShowInline(string title, string subTitle, NotificationSeverity severity)
{
var infoBarSeverity = severity switch
{
NotificationSeverity.Success => InfoBarSeverity.Success,
NotificationSeverity.Warning => InfoBarSeverity.Warning,
NotificationSeverity.Error => InfoBarSeverity.Error,
_ => InfoBarSeverity.Informational
};

var mainVM = Ioc.Default.GetRequiredService<MainViewModel>();
mainVM.ShowInlineNotification(title, subTitle, infoBarSeverity);
}
}
}
5 changes: 5 additions & 0 deletions Flow.Launcher/PublicAPIInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ public void ShowMsg(string title, string subTitle, string iconPath, bool useMain
Notification.Show(title, subTitle, iconPath);
}

public void ShowNotification(string title, string subTitle = "", NotificationSeverity severity = NotificationSeverity.Informational)
{
Notification.ShowInline(title, subTitle, severity);
}

public void ShowMsgWithButton(string title, string buttonText, Action buttonAction, string subTitle = "", string iconPath = "") =>
ShowMsgWithButton(title, buttonText, buttonAction, subTitle, iconPath, true);

Expand Down
20 changes: 20 additions & 0 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Storage;
using iNKORE.UI.WPF.Modern;
using iNKORE.UI.WPF.Modern.Controls;
using Microsoft.VisualStudio.Threading;

namespace Flow.Launcher.ViewModel
Expand Down Expand Up @@ -935,6 +936,25 @@ public UserControl CustomizedPreviewControl
public double ClockPanelOpacity { get; set; } = 1;
public double SearchIconOpacity { get; set; } = 1;

public bool InlineNotificationIsOpen { get; set; }
public string InlineNotificationTitle { get; set; } = string.Empty;
public string InlineNotificationMessage { get; set; } = string.Empty;
public InfoBarSeverity InlineNotificationSeverity { get; set; } = InfoBarSeverity.Informational;

internal void ShowInlineNotification(string title, string message, InfoBarSeverity severity)
{
if (!Application.Current.Dispatcher.CheckAccess())
{
Application.Current.Dispatcher.Invoke(() => ShowInlineNotification(title, message, severity));
return;
}

InlineNotificationTitle = title;
InlineNotificationMessage = message;
InlineNotificationSeverity = severity;
InlineNotificationIsOpen = true;
}

private string _placeholderText;
public string PlaceholderText
{
Expand Down