Skip to content

Commit 24d3998

Browse files
committed
ux: add loading icon
1 parent de0d0c1 commit 24d3998

File tree

7 files changed

+52
-3
lines changed

7 files changed

+52
-3
lines changed

src/Resources/Styles.axaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@
250250
<Setter Property="RotateTransform.Angle" Value="360.0"/>
251251
</KeyFrame>
252252
</Animation>
253+
<Animation Duration="0:0:0.5" IterationCount="1">
254+
<KeyFrame Cue="0%">
255+
<Setter Property="Opacity" Value="0.2"/>
256+
</KeyFrame>
257+
<KeyFrame Cue="100%">
258+
<Setter Property="Opacity" Value="1"/>
259+
</KeyFrame>
260+
</Animation>
253261
</Style.Animations>
254262
</Style>
255263
<Style Selector="Path[IsVisible=True].waiting">

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/ViewModels/RevisionCompare.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ namespace SourceGit.ViewModels
1212
{
1313
public class RevisionCompare : ObservableObject, IDisposable
1414
{
15+
public bool IsLoading
16+
{
17+
get => _isLoading;
18+
private set => SetProperty(ref _isLoading, value);
19+
}
20+
1521
public object StartPoint
1622
{
1723
get => _startPoint;
@@ -109,7 +115,9 @@ public void NavigateTo(string commitSHA)
109115
public void Swap()
110116
{
111117
(StartPoint, EndPoint) = (_endPoint, _startPoint);
118+
VisibleChanges = [];
112119
SelectedChanges = [];
120+
IsLoading = true;
113121
Task.Run(Refresh);
114122
}
115123

@@ -230,6 +238,7 @@ private void Refresh()
230238
Dispatcher.UIThread.Post(() =>
231239
{
232240
VisibleChanges = visible;
241+
IsLoading = false;
233242

234243
if (VisibleChanges.Count > 0)
235244
SelectedChanges = [VisibleChanges[0]];
@@ -244,6 +253,7 @@ private string GetSHA(object obj)
244253
}
245254

246255
private string _repo;
256+
private bool _isLoading = true;
247257
private object _startPoint = null;
248258
private object _endPoint = null;
249259
private List<Models.Change> _changes = 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">

src/Views/RevisionCompare.axaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@
101101
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"
102102
ContextRequested="OnChangeContextRequested"/>
103103
</Border>
104+
105+
<!-- Loading Status Icon -->
106+
<v:LoadingIcon Grid.Row="1"
107+
Width="48" Height="48"
108+
HorizontalAlignment="Center" VerticalAlignment="Center"
109+
IsVisible="{Binding IsLoading}"/>
104110
</Grid>
105111

106112
<GridSplitter Grid.Column="1"

0 commit comments

Comments
 (0)