diff --git a/src/ViewModels/PopupHost.cs b/src/ViewModels/PopupHost.cs index b6351fcb..1a4c8bb2 100644 --- a/src/ViewModels/PopupHost.cs +++ b/src/ViewModels/PopupHost.cs @@ -52,17 +52,13 @@ namespace SourceGit.ViewModels if (task != null) { var finished = await task; + _popup.InProgress = false; if (finished) - { Popup = null; - } - else - { - _popup.InProgress = false; - } } else { + _popup.InProgress = false; Popup = null; } } diff --git a/src/Views/Launcher.axaml b/src/Views/Launcher.axaml index 05eca820..a9202d99 100644 --- a/src/Views/Launcher.axaml +++ b/src/Views/Launcher.axaml @@ -317,23 +317,9 @@ - - - - - - - - - + diff --git a/src/Views/LoadingIcon.axaml.cs b/src/Views/LoadingIcon.axaml.cs index c7c6fd14..5a7e0014 100644 --- a/src/Views/LoadingIcon.axaml.cs +++ b/src/Views/LoadingIcon.axaml.cs @@ -17,7 +17,9 @@ namespace SourceGit.Views protected override void OnLoaded(RoutedEventArgs e) { base.OnLoaded(e); - StartAnim(); + + if (IsVisible) + StartAnim(); } protected override void OnUnloaded(RoutedEventArgs e) diff --git a/src/Views/PopupRunningStatus.axaml b/src/Views/PopupRunningStatus.axaml new file mode 100644 index 00000000..c2759715 --- /dev/null +++ b/src/Views/PopupRunningStatus.axaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/src/Views/PopupRunningStatus.axaml.cs b/src/Views/PopupRunningStatus.axaml.cs new file mode 100644 index 00000000..e9a77a04 --- /dev/null +++ b/src/Views/PopupRunningStatus.axaml.cs @@ -0,0 +1,70 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Shapes; +using Avalonia.Interactivity; +using Avalonia.Media; + +namespace SourceGit.Views +{ + public partial class PopupRunningStatus : UserControl + { + public static readonly StyledProperty DescriptionProperty = + AvaloniaProperty.Register(nameof(Description)); + + public string Description + { + get => GetValue(DescriptionProperty); + set => SetValue(DescriptionProperty, value); + } + + public PopupRunningStatus() + { + InitializeComponent(); + } + + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + + if (IsVisible) + StartAnim(); + } + + protected override void OnUnloaded(RoutedEventArgs e) + { + StopAnim(); + base.OnUnloaded(e); + } + + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change) + { + base.OnPropertyChanged(change); + + if (change.Property == IsVisibleProperty) + { + if (IsVisible) + StartAnim(); + else + StopAnim(); + } + } + + private void StartAnim() + { + icon.Content = new Path() + { + Data = this.FindResource("Icons.Loading") as StreamGeometry, + Classes = { "rotating" }, + }; + progressBar.IsIndeterminate = true; + } + + private void StopAnim() + { + if (icon.Content is Path path) + path.Classes.Clear(); + icon.Content = null; + progressBar.IsIndeterminate = false; + } + } +}