Skip to content

Commit 9eac2b7

Browse files
committed
ux: add loading icon
1 parent de0d0c1 commit 9eac2b7

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

src/ViewModels/BranchCompare.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ namespace SourceGit.ViewModels
1212
{
1313
public class BranchCompare : ObservableObject
1414
{
15+
public bool IsLoading
16+
{
17+
get => _isLoading;
18+
private set => SetProperty(ref _isLoading, value);
19+
}
20+
1521
public Models.Branch Base
1622
{
1723
get => _based;
@@ -101,6 +107,8 @@ public void NavigateTo(string commitSHA)
101107
public void Swap()
102108
{
103109
(Base, To) = (_to, _based);
110+
111+
VisibleChanges = [];
104112
SelectedChanges = [];
105113

106114
if (_baseHead != null)
@@ -166,6 +174,7 @@ public ContextMenu CreateChangeContextMenu()
166174
await App.CopyTextAsync(change.Path);
167175
ev.Handled = true;
168176
};
177+
menu.Items.Add(new MenuItem() { Header = "-" });
169178
menu.Items.Add(copyPath);
170179

171180
var copyFullPath = new MenuItem();
@@ -184,6 +193,8 @@ public ContextMenu CreateChangeContextMenu()
184193

185194
private void Refresh()
186195
{
196+
IsLoading = true;
197+
187198
Task.Run(async () =>
188199
{
189200
if (_baseHead == null)
@@ -221,6 +232,7 @@ private void Refresh()
221232
Dispatcher.UIThread.Post(() =>
222233
{
223234
VisibleChanges = visible;
235+
IsLoading = false;
224236

225237
if (VisibleChanges.Count > 0)
226238
SelectedChanges = [VisibleChanges[0]];
@@ -253,6 +265,7 @@ private void RefreshVisible()
253265
}
254266

255267
private string _repo;
268+
private bool _isLoading = true;
256269
private Models.Branch _based = null;
257270
private Models.Branch _to = null;
258271
private Models.Commit _baseHead = null;

src/Views/Avatar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public override void Render(DrawingContext context)
9696

9797
public void OnAvatarResourceChanged(string email, Bitmap image)
9898
{
99-
if (User.Email.Equals(email, StringComparison.Ordinal))
99+
if (email.Equals(User?.Email, StringComparison.Ordinal))
100100
{
101101
_img = image;
102102
InvalidateVisual();

src/Views/BranchCompare.axaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<!-- Compare Targets -->
4040
<Border Grid.Row="1">
41-
<Grid Margin="48,8,48,8" ColumnDefinitions="*,48,*">
41+
<Grid Margin="8" ColumnDefinitions="*,48,*">
4242
<Border Grid.Column="0" BorderBrush="{DynamicResource Brush.Diff.DeletedHighlight}" BorderThickness="1" Background="{DynamicResource Brush.Contents}" CornerRadius="4" Padding="4">
4343
<Grid RowDefinitions="Auto,*">
4444
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto,Auto">
@@ -129,6 +129,12 @@
129129
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"
130130
ContextRequested="OnChangeContextRequested"/>
131131
</Border>
132+
133+
<!-- Loading Status Icon -->
134+
<v:LoadingIcon Grid.Row="1"
135+
Width="48" Height="48"
136+
HorizontalAlignment="Center" VerticalAlignment="Center"
137+
IsVisible="{Binding IsLoading}"/>
132138
</Grid>
133139

134140
<GridSplitter Grid.Column="1"

src/Views/DirHistories.axaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@
107107
</ListBox.ItemTemplate>
108108
</ListBox>
109109

110+
<!-- Loading Status Icon -->
111+
<v:LoadingIcon Grid.Column="0"
112+
Width="48" Height="48"
113+
HorizontalAlignment="Center" VerticalAlignment="Center"
114+
IsVisible="{Binding IsLoading}"/>
115+
110116
<GridSplitter Grid.Column="1"
111117
MinWidth="1"
112118
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
@@ -115,7 +121,7 @@
115121
BorderBrush="{DynamicResource Brush.Border0}"/>
116122

117123
<!-- Commit Detail -->
118-
<Border Grid.Column="2" Padding="0,4,4,8">
124+
<Border Grid.Column="2" Padding="0,4,4,8" IsVisible="{Binding !IsLoading}">
119125
<ContentControl Content="{Binding Detail, Mode=OneWay}">
120126
<ContentControl.DataTemplates>
121127
<DataTemplate DataType="vm:CommitDetail">

0 commit comments

Comments
 (0)