Skip to content

Commit 6d98b94

Browse files
committed
Add loading animation
1 parent a92f9fb commit 6d98b94

File tree

3 files changed

+85
-9
lines changed

3 files changed

+85
-9
lines changed

src/Bible.Alarm/App.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Bible.Alarm.Views.General;
88
using Bible.Alarm.ViewModels;
99
using Bible.Alarm.ViewModels.Shared;
10-
#nullable enable
1110

1211
namespace Bible.Alarm;
1312

src/Bible.Alarm/Views/General/LoadingPage.xaml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@
66
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
77
BackgroundColor="White"
88
Title="Bible Alarm">
9+
<ContentPage.Resources>
10+
<Style x:Key="DotStyle" TargetType="Label">
11+
<Setter Property="FontSize" Value="48" />
12+
<Setter Property="TextColor" Value="SlateBlue" />
13+
<Setter Property="HorizontalOptions" Value="Center" />
14+
<Setter Property="VerticalOptions" Value="Center" />
15+
</Style>
16+
</ContentPage.Resources>
917
<ContentPage.Content>
1018
<Grid>
1119
<StackLayout
1220
HorizontalOptions="Center"
1321
Orientation="Vertical"
14-
VerticalOptions="Center">
22+
VerticalOptions="Center"
23+
Spacing="20">
1524
<ActivityIndicator
1625
IsRunning="True"
1726
Color="SlateBlue"
18-
WidthRequest="100"
19-
HeightRequest="100">
27+
WidthRequest="80"
28+
HeightRequest="80">
2029
<ActivityIndicator.Scale>
2130
<OnPlatform x:TypeArguments="x:Double">
2231
<OnPlatform.Platforms>
@@ -27,12 +36,27 @@
2736
</OnPlatform>
2837
</ActivityIndicator.Scale>
2938
</ActivityIndicator>
30-
<Label
31-
Text="Loading..."
32-
FontSize="Large"
39+
40+
<!-- Animated loading dots -->
41+
<HorizontalStackLayout
3342
HorizontalOptions="Center"
34-
Margin="0,20,0,0"
35-
TextColor="SlateBlue" />
43+
Spacing="8">
44+
<Label
45+
x:Name="Dot1"
46+
Text=""
47+
Style="{StaticResource DotStyle}"
48+
Opacity="0.3" />
49+
<Label
50+
x:Name="Dot2"
51+
Text=""
52+
Style="{StaticResource DotStyle}"
53+
Opacity="0.3" />
54+
<Label
55+
x:Name="Dot3"
56+
Text=""
57+
Style="{StaticResource DotStyle}"
58+
Opacity="0.3" />
59+
</HorizontalStackLayout>
3660
</StackLayout>
3761
</Grid>
3862
</ContentPage.Content>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,64 @@
1+
using System.Timers;
2+
using Microsoft.Maui.ApplicationModel;
3+
14
namespace Bible.Alarm.Views.General;
25

36
[XamlCompilation(XamlCompilationOptions.Compile)]
47
public partial class LoadingPage : ContentPage
58
{
9+
private readonly System.Timers.Timer _animationTimer;
10+
private int _currentDot = 0;
11+
612
public LoadingPage()
713
{
814
InitializeComponent();
15+
16+
// Start animated dots
17+
_animationTimer = new System.Timers.Timer(500); // Change dot every 500ms
18+
_animationTimer.Elapsed += OnTimerElapsed;
19+
_animationTimer.AutoReset = true;
20+
_animationTimer.Start();
21+
22+
// Initialize first dot
23+
UpdateDots();
24+
}
25+
26+
private void OnTimerElapsed(object? sender, ElapsedEventArgs e)
27+
{
28+
MainThread.BeginInvokeOnMainThread(() =>
29+
{
30+
_currentDot = (_currentDot + 1) % 3;
31+
UpdateDots();
32+
});
33+
}
34+
35+
private void UpdateDots()
36+
{
37+
// Reset all dots to low opacity
38+
Dot1.Opacity = 0.3;
39+
Dot2.Opacity = 0.3;
40+
Dot3.Opacity = 0.3;
41+
42+
// Highlight current dot
43+
switch (_currentDot)
44+
{
45+
case 0:
46+
Dot1.Opacity = 1.0;
47+
break;
48+
case 1:
49+
Dot2.Opacity = 1.0;
50+
break;
51+
case 2:
52+
Dot3.Opacity = 1.0;
53+
break;
54+
}
55+
}
56+
57+
protected override void OnDisappearing()
58+
{
59+
base.OnDisappearing();
60+
_animationTimer?.Stop();
61+
_animationTimer?.Dispose();
962
}
1063
}
1164

0 commit comments

Comments
 (0)