Skip to content

Commit

Permalink
add demo for the wait indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
softlion committed Apr 19, 2023
1 parent 989d447 commit 3230c5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions UserInteractionDemo/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<Button Text="Toast" Command="{Binding ToastCommand}" />
<Button Text="Confirm" Command="{Binding ConfirmCommand}" />
<Button Text="Confirm 3 buttons" Command="{Binding Confirm3Command}" />
<Button Text="Wait indicator" Command="{Binding WaitIndicatorCommand}" />
</StackLayout>
</ScrollView>
</Grid>
Expand Down
15 changes: 15 additions & 0 deletions UserInteractionDemo/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class MainViewModel
public ICommand ToastCommand { get; }
public ICommand ConfirmCommand { get; }
public ICommand Confirm3Command { get; }
public ICommand WaitIndicatorCommand { get; }

public MainViewModel()
{
Expand Down Expand Up @@ -57,5 +58,19 @@ public MainViewModel()
};
await UserInteraction.Toast(text, ToastStyle.Notice);
});

WaitIndicatorCommand = new Command(async () =>
{
var dismiss = new CancellationTokenSource();
var wi = UserInteraction.WaitIndicator(dismiss.Token, "Wait 3 seconds", displayAfterSeconds: 0, userCanDismiss: false);
await Task.Delay(1000);
wi.Body = "Wait 2 seconds";
await Task.Delay(1000);
wi.Body = "Wait 1 second";
await Task.Delay(1000);
dismiss.Cancel();
});
}
}

0 comments on commit 3230c5f

Please sign in to comment.