@@ -227,6 +227,103 @@ You can see that the `TaskLoaderView` uses an `AbsoluteLayout` internally. So yo
227227
228228<img src =" Docs/user_loading.gif " width =" 300 " />
229229
230+ #### Support for DataTemplate (since 2.1.0)
231+
232+ You can now add your customs views as ` View ` or ` DataTemplate ` .
233+ If you choose the latest option, you can now specify your custom views in a ` ResourceDictionary ` and set them in your ` TaskLoaderView ` style.
234+
235+ ``` xml
236+ <ContentPage .Resources>
237+ <ResourceDictionary >
238+ <DataTemplate x : Key =" LoadingLottieDataTemplate" >
239+ <lottie : AnimationView x : Name =" LoadingLottie"
240+ AbsoluteLayout.LayoutFlags=" PositionProportional"
241+ AbsoluteLayout.LayoutBounds=" 0.5, 0.4, 120, 120"
242+ HorizontalOptions =" FillAndExpand"
243+ VerticalOptions =" FillAndExpand"
244+ Animation =" {Binding Loader.ShowLoader, Converter={StaticResource CyclicLoadingLottieConverter}}"
245+ IsPlaying =" True"
246+ Loop =" True" />
247+ </DataTemplate >
248+
249+ <DataTemplate x : Key =" EmptyLottieDataTemplate" >
250+ <StackLayout AbsoluteLayout.LayoutFlags=" PositionProportional"
251+ AbsoluteLayout.LayoutBounds=" 0.5, 0.4, 300, 180"
252+ BindingContext =" {Binding Source={RelativeSource AncestorType={x:Type customViews:TaskLoaderView}}, Path=TaskLoaderNotifier}" >
253+
254+ <lottie : AnimationView HorizontalOptions =" FillAndExpand"
255+ VerticalOptions =" FillAndExpand"
256+ Animation =" empty_state.json"
257+ IsPlaying =" True"
258+ Loop =" True" />
259+
260+ <Label Style =" {StaticResource TextBody}"
261+ HorizontalOptions =" Center"
262+ VerticalOptions =" Center"
263+ Text =" {loc:Translate Empty_Screen}"
264+ TextColor =" White" />
265+ <Button Style =" {StaticResource TextBody}"
266+ HeightRequest =" 40"
267+ Margin =" 0,20,0,0"
268+ Padding =" 25,0"
269+ HorizontalOptions =" Center"
270+ BackgroundColor =" {StaticResource TopElementBackground}"
271+ Command =" {Binding ReloadCommand}"
272+ Text =" {loc:Translate ErrorButton_Retry}"
273+ TextColor =" White" />
274+ </StackLayout >
275+ </DataTemplate >
276+
277+ <DataTemplate x : Key =" ErrorLottieDataTemplate" >
278+ <StackLayout AbsoluteLayout.LayoutFlags=" PositionProportional"
279+ AbsoluteLayout.LayoutBounds=" 0.5, 0.4, 300, 180"
280+ BindingContext =" {Binding Source={RelativeSource AncestorType={x:Type customViews:TaskLoaderView}}, Path=TaskLoaderNotifier}" >
281+
282+ <lottie : AnimationView HorizontalOptions =" FillAndExpand"
283+ VerticalOptions =" FillAndExpand"
284+ Animation =" {Binding Error, Converter={StaticResource ExceptionToLottieConverter}}"
285+ IsPlaying =" True"
286+ Loop =" True" />
287+
288+ <Label Style =" {StaticResource TextBody}"
289+ HorizontalOptions =" Center"
290+ VerticalOptions =" Center"
291+ Text =" {Binding Error, Converter={StaticResource ExceptionToErrorMessageConverter}}"
292+ TextColor =" White" />
293+ <Button Style =" {StaticResource TextBody}"
294+ HeightRequest =" 40"
295+ Margin =" 0,20,0,0"
296+ Padding =" 25,0"
297+ HorizontalOptions =" Center"
298+ BackgroundColor =" {StaticResource TopElementBackground}"
299+ Command =" {Binding ReloadCommand}"
300+ Text =" {loc:Translate ErrorButton_Retry}"
301+ TextColor =" White" />
302+ </StackLayout >
303+ </DataTemplate >
304+
305+ <Style x : Key =" TaskLoaderStyle" TargetType =" customViews:TaskLoaderView" >
306+ <Setter Property =" AccentColor" Value =" {StaticResource AccentColor}" />
307+ <Setter Property =" FontFamily" Value =" {StaticResource FontAtariSt}" />
308+ <Setter Property =" EmptyStateMessage" Value =" {loc:Translate Empty_Screen}" />
309+ <Setter Property =" EmptyStateImageSource" Value =" {inf:ImageResource Sample.Images.dougal.png}" />
310+ <Setter Property =" RetryButtonText" Value =" {loc:Translate ErrorButton_Retry}" />
311+ <Setter Property =" TextColor" Value =" {StaticResource OnDarkColor}" />
312+ <Setter Property =" ErrorImageConverter" Value =" {StaticResource ExceptionToImageSourceConverter}" />
313+ <Setter Property =" ErrorMessageConverter" Value =" {StaticResource ExceptionToErrorMessageConverter}" />
314+ <Setter Property =" BackgroundColor" Value =" {StaticResource LightGreyBackground}" />
315+ <Setter Property =" NotificationBackgroundColor" Value =" {StaticResource TosWindows}" />
316+ <Setter Property =" NotificationTextColor" Value =" {StaticResource TextPrimaryColor}" />
317+
318+ <Setter Property =" LoadingView" Value =" {StaticResource LoadingLottieDataTemplate}" />
319+ <Setter Property =" EmptyView" Value =" {StaticResource EmptyLottieDataTemplate}" />
320+ <Setter Property =" ErrorView" Value =" {StaticResource ErrorLottieDataTemplate}" />
321+ </Style >
322+
323+ </ResourceDictionary >
324+ </ContentPage .Resources>
325+ ```
326+
230327### Support for Lottie
231328
232329With custom views and [ Lottie] ( https://github.com/Baseflow/LottieXamarin ) , you can add all the amazing animations made by your best designer \o/
0 commit comments