Skip to content

Commit

Permalink
Fixed timed visibility when text is changing, adding ShowLastError to…
Browse files Browse the repository at this point in the history
… mix loaders and commands
  • Loading branch information
roubachof committed Jun 23, 2022
1 parent 7684782 commit c06368c
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 162 deletions.
291 changes: 148 additions & 143 deletions Retronado/Sample/Views/CommandsPage.xaml
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>

<ContentPage x:Class="Sample.Views.CommandsPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
Expand All @@ -16,7 +17,6 @@
x:DataType="viewModels:CommandsPageViewModel"
NavigationPage.HasNavigationBar="false">


<ContentPage.Content>
<Grid>
<Grid.RowDefinitions>
Expand All @@ -29,146 +29,151 @@
BackgroundColor="{StaticResource TopElementBackground}"
Theme="Standard" />

<RefreshView Grid.Row="1" IsRefreshing="{Binding Loader.ShowRefresher}"
<RefreshView Grid.Row="1"
IsRefreshing="{Binding Loader.ShowRefresher}"
RefreshColor="{StaticResource AccentColor}"
Command="{Binding Loader.RefreshCommand}">
<ScrollView>
<tlv:TemplatedTaskLoader TaskLoaderNotifier="{Binding Loader}">
<tlv:TemplatedTaskLoader.ResultControlTemplate>
<ControlTemplate>
<Grid RowDefinitions="300,*"
x:DataType="viewModels:CommandsPageViewModel"
BindingContext="{Binding Source={RelativeSource AncestorType={x:Type viewModels:CommandsPageViewModel}}}">
<Image Grid.Row="0"
skeleton:Skeleton.BackgroundColor="{StaticResource GreyBackground}"
skeleton:Skeleton.IsBusy="{Binding Loader.ShowLoader}"
Aspect="Fill"
Source="{Binding Loader.Result.ScreenshotUrl}" />

<sho:MaterialFrame Grid.Row="0"
Padding="15,5,15,30"
VerticalOptions="End"
CornerRadius="0"
MaterialBlurStyle="Dark"
MaterialTheme="AcrylicBlur">
<Grid Padding="0"
ColumnDefinitions="*,60"
RowDefinitions="40,20,20"
RowSpacing="0">
<Label Grid.Row="0"
Grid.Column="0"
Style="{StaticResource GameName}"
Margin="0,0,10,0"
skeleton:Skeleton.BackgroundColor="{StaticResource GreyBackground}"
skeleton:Skeleton.IsBusy="{Binding Loader.ShowLoader}"
Text="{Binding Loader.Result.Name}" />

<Label Grid.Row="1"
Style="{StaticResource GameCompany}"
skeleton:Skeleton.BackgroundColor="{StaticResource GreyBackground}"
skeleton:Skeleton.IsBusy="{Binding Loader.ShowLoader}"
Text="{Binding Loader.Result.MajorCompany}" />

<Label Grid.Row="2"
Style="{StaticResource GameGenre}"
Text="{Binding Loader.Result.MajorGenre}" />

<Image Grid.Row="0"
Grid.RowSpan="3"
Grid.Column="1"
Margin="0,10,0,0"
Source="{Binding Loader.Result.CoverUrl}" />

</Grid>
</sho:MaterialFrame>

<Button Grid.Row="1"
HeightRequest="40"
Margin="0,-20,100,0"
Padding="10"
HorizontalOptions="Center"
VerticalOptions="Start"
BackgroundColor="{StaticResource AccentColor}"
Command="{Binding BuyGameCommand}"
FontFamily="{StaticResource FontAtariSt}"
Text="BUY IT"
TextColor="{StaticResource TopElementBackground}" />

<Button Grid.Row="1"
HeightRequest="40"
Margin="100,-20,0,0"
Padding="10"
HorizontalOptions="Center"
VerticalOptions="Start"
BackgroundColor="{StaticResource AccentColor}"
Command="{Binding PlayTheGameCommand}"
FontFamily="{StaticResource FontAtariSt}"
Text="PLAY IT"
TextColor="{StaticResource TopElementBackground}" />


<Label Grid.Row="1"
Style="{StaticResource GameGenre}"
Margin="15,45,15,0"
Text="{Binding Loader.Result.Summary}"
TextColor="White" />
</Grid>
</ControlTemplate>
</tlv:TemplatedTaskLoader.ResultControlTemplate>
<tlv:TemplatedTaskLoader.LoadingControlTemplate>
<ControlTemplate>
<ActivityIndicator Color="{StaticResource AccentColor}"
IsRunning="True"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</ControlTemplate>
</tlv:TemplatedTaskLoader.LoadingControlTemplate>
<tlv:TemplatedTaskLoader.ErrorControlTemplate>
<ControlTemplate x:DataType="{x:Null}">
<StackLayout HorizontalOptions="Center"
VerticalOptions="Center"
BindingContext="{Binding Source={RelativeSource AncestorType={x:Type tlv:TemplatedTaskLoader}},
<tlv:TemplatedTaskLoader TaskLoaderNotifier="{Binding Loader}">
<tlv:TemplatedTaskLoader.ResultControlTemplate>
<ControlTemplate>
<Grid RowDefinitions="300,*"
x:DataType="viewModels:CommandsPageViewModel"
BindingContext="{Binding Source={RelativeSource
AncestorType={x:Type viewModels:CommandsPageViewModel}}}">
<Image Grid.Row="0"
skeleton:Skeleton.BackgroundColor="{StaticResource GreyBackground}"
skeleton:Skeleton.IsBusy="{Binding Loader.ShowLoader}"
Aspect="Fill"
Source="{Binding Loader.Result.ScreenshotUrl}" />

<sho:MaterialFrame Grid.Row="0"
Padding="15,5,15,30"
VerticalOptions="End"
CornerRadius="0"
MaterialBlurStyle="Dark"
MaterialTheme="AcrylicBlur">
<Grid Padding="0"
ColumnDefinitions="*,60"
RowDefinitions="40,20,20"
RowSpacing="0">
<Label Grid.Row="0"
Grid.Column="0"
Style="{StaticResource GameName}"
Margin="0,0,10,0"
skeleton:Skeleton.BackgroundColor="{StaticResource GreyBackground}"
skeleton:Skeleton.IsBusy="{Binding Loader.ShowLoader}"
Text="{Binding Loader.Result.Name}" />

<Label Grid.Row="1"
Style="{StaticResource GameCompany}"
skeleton:Skeleton.BackgroundColor="{StaticResource GreyBackground}"
skeleton:Skeleton.IsBusy="{Binding Loader.ShowLoader}"
Text="{Binding Loader.Result.MajorCompany}" />

<Label Grid.Row="2"
Style="{StaticResource GameGenre}"
Text="{Binding Loader.Result.MajorGenre}" />

<Image Grid.Row="0"
Grid.RowSpan="3"
Grid.Column="1"
Margin="0,10,0,0"
Source="{Binding Loader.Result.CoverUrl}" />

</Grid>
</sho:MaterialFrame>

<Button Grid.Row="1"
HeightRequest="40"
Margin="0,-20,100,0"
Padding="10"
HorizontalOptions="Center"
VerticalOptions="Start"
BackgroundColor="{StaticResource AccentColor}"
Command="{Binding BuyGameCommand}"
FontFamily="{StaticResource FontAtariSt}"
Text="BUY IT"
TextColor="{StaticResource TopElementBackground}" />

<Button Grid.Row="1"
HeightRequest="40"
Margin="100,-20,0,0"
Padding="10"
HorizontalOptions="Center"
VerticalOptions="Start"
BackgroundColor="{StaticResource AccentColor}"
Command="{Binding PlayTheGameCommand}"
FontFamily="{StaticResource FontAtariSt}"
Text="PLAY IT"
TextColor="{StaticResource TopElementBackground}" />


<Label Grid.Row="1"
Style="{StaticResource GameGenre}"
Margin="15,45,15,0"
Text="{Binding Loader.Result.Summary}"
TextColor="White" />
</Grid>
</ControlTemplate>
</tlv:TemplatedTaskLoader.ResultControlTemplate>

<tlv:TemplatedTaskLoader.LoadingControlTemplate>
<ControlTemplate>
<ActivityIndicator Color="{StaticResource AccentColor}"
IsRunning="True"
HorizontalOptions="Center"
VerticalOptions="Center" />
</ControlTemplate>
</tlv:TemplatedTaskLoader.LoadingControlTemplate>

<tlv:TemplatedTaskLoader.ErrorControlTemplate>
<ControlTemplate x:DataType="{x:Null}">
<StackLayout HorizontalOptions="Center"
VerticalOptions="Center"
BindingContext="{Binding Source={RelativeSource AncestorType={x:Type tlv:TemplatedTaskLoader}},
Path=TaskLoaderNotifier}"
Orientation="Vertical"
Spacing="10">
<Frame CornerRadius="50"
HorizontalOptions="Center"
VerticalOptions="Center"
BackgroundColor="Transparent"
HasShadow="False"
IsClippedToBounds="True"
WidthRequest="100"
Padding="0"
HeightRequest="100"
Margin="0,0,0,10">
<Image HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="100"
HeightRequest="100"
Source="{Binding Error,
Orientation="Vertical"
Spacing="10">
<Frame CornerRadius="50"
HorizontalOptions="Center"
VerticalOptions="Center"
BackgroundColor="Transparent"
HasShadow="False"
IsClippedToBounds="True"
WidthRequest="100"
Padding="0"
HeightRequest="100"
Margin="0,0,0,10">
<Image HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="100"
HeightRequest="100"
Source="{Binding Error,
Converter={converters:ExceptionToImageSourceConverter}}" />
</Frame>
<Label Style="{StaticResource TextBodySecondary}"
WidthRequest="300"
Margin="0,0,0,20"
HorizontalTextAlignment="Center"
LineBreakMode="WordWrap"
MaxLines="2"
Text="{Binding Error,
</Frame>
<Label Style="{StaticResource TextBodySecondary}"
WidthRequest="300"
Margin="0,0,0,20"
HorizontalTextAlignment="Center"
LineBreakMode="WordWrap"
MaxLines="2"
Text="{Binding Error,
Converter={converters:ExceptionToErrorMessageConverter}}" />

<Button BackgroundColor="{StaticResource AccentColor}"
CornerRadius="10"
Padding="10,0"
HorizontalOptions="Center"
VerticalOptions="End"
Command="{Binding ReloadCommand}"
TextColor="Black"
Text="{x:Static loc:SampleResources.ErrorButton_Retry}" />
</StackLayout>
</ControlTemplate>
</tlv:TemplatedTaskLoader.ErrorControlTemplate>
</tlv:TemplatedTaskLoader>
<Button BackgroundColor="{StaticResource AccentColor}"
CornerRadius="10"
Padding="10,0"
HorizontalOptions="Center"
VerticalOptions="End"
Command="{Binding ReloadCommand}"
TextColor="Black"
Text="{x:Static loc:SampleResources.ErrorButton_Retry}" />
</StackLayout>
</ControlTemplate>
</tlv:TemplatedTaskLoader.ErrorControlTemplate>

</tlv:TemplatedTaskLoader>
</ScrollView>
</RefreshView>

Expand Down Expand Up @@ -199,14 +204,14 @@
</AbsoluteLayout>

<tlv:Snackbar Grid.Row="1"
Margin="15"
VerticalOptions="End"
BackgroundColor="White"
FontFamily="{StaticResource FontAtariSt}"
IsVisible="{Binding CompositeNotifier.ShowAnyError, Mode=TwoWay}"
Text="{Binding CompositeNotifier.LastError, Converter={StaticResource ExceptionToErrorMessageConverter}}"
TextColor="{StaticResource TextPrimaryColor}"
TextHorizontalOptions="Start" />
Margin="15"
VerticalOptions="End"
BackgroundColor="White"
FontFamily="{StaticResource FontAtariSt}"
IsVisible="{Binding CompositeNotifier.ShowLastError, Mode=TwoWay}"
Text="{Binding CompositeNotifier.LastError, Converter={StaticResource ExceptionToErrorMessageConverter}}"
TextColor="{StaticResource TextPrimaryColor}"
TextHorizontalOptions="Start" />
</Grid>
</ContentPage.Content>

Expand Down

0 comments on commit c06368c

Please sign in to comment.