refactor: rewrite Launcher

* move main tabbar to a standalone control
* simpfy notification
This commit is contained in:
leo 2024-06-26 20:56:29 +08:00
parent 1ce0d0f7bf
commit e330862ec9
No known key found for this signature in database
8 changed files with 406 additions and 349 deletions

View file

@ -112,20 +112,14 @@ namespace SourceGit
public static void RaiseException(string context, string message)
{
if (Current is App app && app._notificationReceiver != null)
{
var notice = new Models.Notification() { IsError = true, Message = message };
app._notificationReceiver.OnReceiveNotification(context, notice);
}
if (Current is App app && app._launcher != null)
app._launcher.DispatchNotification(context, message, true);
}
public static void SendNotification(string context, string message)
{
if (Current is App app && app._notificationReceiver != null)
{
var notice = new Models.Notification() { IsError = false, Message = message };
app._notificationReceiver.OnReceiveNotification(context, notice);
}
if (Current is App app && app._launcher != null)
app._launcher.DispatchNotification(context, message, false);
}
public static void SetLocale(string localeKey)
@ -285,9 +279,8 @@ namespace SourceGit
BindingPlugins.DataValidators.RemoveAt(0);
Native.OS.SetupEnternalTools();
var launcher = new Views.Launcher();
_notificationReceiver = launcher;
desktop.MainWindow = launcher;
_launcher = new ViewModels.Launcher();
desktop.MainWindow = new Views.Launcher() { DataContext = _launcher };
if (ViewModels.Preference.Instance.ShouldCheck4UpdateOnStartup)
{
@ -330,8 +323,8 @@ namespace SourceGit
return default;
}
private ViewModels.Launcher _launcher = null;
private ResourceDictionary _activeLocale = null;
private ResourceDictionary _colorOverrides = null;
private Models.INotificationReceiver _notificationReceiver = null;
}
}