Skip to content

Commit

Permalink
Merge pull request #240 from OdetteP/lottie_animation
Browse files Browse the repository at this point in the history
Adding lottie animation
  • Loading branch information
martijn00 committed Nov 27, 2019
2 parents ee28073 + 3a2f09e commit 034621c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions Samples/MaterialMvvmSample.iOS/LottieLogo1.json

Large diffs are not rendered by default.

Expand Up @@ -109,6 +109,7 @@
<BundleResource Include="Resources\Fonts\Roboto-Regular.ttf" />
<BundleResource Include="Resources\Fonts\Roboto-Bold.ttf" />
<BundleResource Include="Resources\Fonts\Roboto-Medium.ttf" />
<BundleResource Include="LottieLogo1.json" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
Expand Down
Expand Up @@ -18,7 +18,7 @@ public MaterialCircularView()

public async Task RunLoadingDialog()
{
var loadingDialog = await MaterialDialog.Instance.LoadingDialogAsync(message: "Something is running");
var loadingDialog = await MaterialDialog.Instance.LoadingDialogAsync(message: "Something is running", lottieAnimation: "LottieLogo1.json");
await Task.Delay(5000); // Represents a task that is running.
await loadingDialog.DismissAsync();
}
Expand Down
3 changes: 2 additions & 1 deletion Samples/MaterialMvvmSample/Views/MaterialTextFieldView.xaml
Expand Up @@ -6,7 +6,8 @@
xmlns:material="clr-namespace:XF.Material.Forms.UI;assembly=XF.Material"
x:Class="MaterialMvvmSample.Views.MaterialTextFieldView">
<ContentPage.Content>
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Vertical"
Padding="20">
<material:MaterialTextField Placeholder="Auto Capitalization"
IsAutoCapitalizationEnabled="True" />

Expand Down
Expand Up @@ -24,7 +24,7 @@ protected override void OnElementChanged(ElementChangedEventArgs<AnimationView>
}

_materialElement = e?.NewElement as MaterialCircularLoadingView;
if (_materialElement != null)
if (_materialElement != null && string.IsNullOrEmpty(_materialElement.Animation))
{
_materialElement.Animation = "loading_animation.json";
}
Expand Down
7 changes: 7 additions & 0 deletions XF.Material/UI/Dialogs/IMaterialDialog.cs
Expand Up @@ -64,6 +64,13 @@ public interface IMaterialDialog
/// <param name="configuration">The style of the loading dialog.</param>
Task<IMaterialModalPage> LoadingDialogAsync(string message, MaterialLoadingDialogConfiguration configuration = null);

/// <summary>
/// Shows a dialog indicating a running task.
/// </summary>
/// <param name="message">The message of the dialog.</param>
/// <param name="configuration">The style of the loading dialog.</param>
Task<IMaterialModalPage> LoadingDialogAsync(string message, string lottieAnimation, MaterialLoadingDialogConfiguration configuration = null);

/// <summary>
/// Shows a snackbar indicating a running task.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions XF.Material/UI/Dialogs/MaterialDialog.cs
Expand Up @@ -72,6 +72,11 @@ internal MaterialDialog()
return MaterialLoadingDialog.Loading(message, configuration);
}

public Task<IMaterialModalPage> LoadingDialogAsync(string message, string lottieAnimation, MaterialLoadingDialogConfiguration configuration = null)
{
return MaterialLoadingDialog.Loading(message, lottieAnimation, configuration);
}

public Task<IMaterialModalPage> LoadingSnackbarAsync(
string message,
MaterialSnackbarConfiguration configuration = null)
Expand Down
16 changes: 16 additions & 0 deletions XF.Material/UI/Dialogs/MaterialLoadingDialog.xaml.cs
Expand Up @@ -16,6 +16,14 @@ internal MaterialLoadingDialog(string message, MaterialLoadingDialogConfiguratio
Message.Text = message;
}

internal MaterialLoadingDialog(string message, string lottieAnimation, MaterialLoadingDialogConfiguration configuration)
{
InitializeComponent();
Configure(configuration);
Message.Text = message;
LoadingImage.Animation = lottieAnimation;
}

public override bool Dismissable => false;

public override string MessageText
Expand All @@ -34,6 +42,14 @@ internal static async Task<IMaterialModalPage> Loading(string message, MaterialL
return dialog;
}

internal static async Task<IMaterialModalPage> Loading(string message, string lottieAnimation, MaterialLoadingDialogConfiguration configuration = null)
{
var dialog = new MaterialLoadingDialog(message, lottieAnimation, configuration);
await dialog.ShowAsync();

return dialog;
}

protected override void OnAppearing()
{
base.OnAppearing();
Expand Down

0 comments on commit 034621c

Please sign in to comment.