Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Mobile | Add pull-to-refresh to the Earn and Redeem pages #923

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/MobileUI/Pages/EarnDetailsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace SSW.Rewards.Mobile.Pages;
using CommunityToolkit.Mvvm.Messaging;
using SSW.Rewards.Mobile.Messages;

namespace SSW.Rewards.Mobile.Pages;

[QueryProperty(nameof(QuizId), nameof(QuizId))]
public partial class EarnDetailsPage
Expand All @@ -20,4 +23,14 @@ protected override async void OnAppearing()
int quizId = int.Parse(QuizId);
await _viewModel.Initialise(quizId);
}

protected override void OnDisappearing()
{
base.OnDisappearing();

if (_viewModel.TestPassed)
{
WeakReferenceMessenger.Default.Send(new QuizzesUpdatedMessage());
}
}
}
155 changes: 79 additions & 76 deletions src/MobileUI/Pages/EarnPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,84 +9,87 @@
ControlTemplate="{DynamicResource PageTemplate}"
x:DataType="viewModels:EarnViewModel"
x:Class="SSW.Rewards.Mobile.Pages.EarnPage">
<ScrollView>
<Grid>
<Grid RowDefinitions="Auto, *"
Margin="15"
RowSpacing="10">
<Grid Grid.Row="0"
RowDefinitions="Auto"
x:Name="CarouselSection">
<Grid.Triggers>
<DataTrigger TargetType="Grid" Binding="{Binding CarouselQuizzes.Count}" Value="0">
<Setter Property="IsVisible" Value="False" />
</DataTrigger>
</Grid.Triggers>
<CarouselView Grid.Row="0"
x:Name="Carousel"
HeightRequest="400"
Loop="True"
ItemsSource="{Binding CarouselQuizzes}"
HorizontalScrollBarVisibility="Never"
IndicatorView="QuizIndicator">
<CarouselView.ItemTemplate>
<RefreshView Command="{Binding RefreshQuizzesCommand}"
IsRefreshing="{Binding IsRefreshing}">
<ScrollView>
<Grid>
<Grid RowDefinitions="Auto, *"
Margin="15"
RowSpacing="10">
<Grid Grid.Row="0"
RowDefinitions="Auto"
x:Name="CarouselSection">
<Grid.Triggers>
<DataTrigger TargetType="Grid" Binding="{Binding CarouselQuizzes.Count}" Value="0">
<Setter Property="IsVisible" Value="False" />
</DataTrigger>
</Grid.Triggers>
<CarouselView Grid.Row="0"
x:Name="Carousel"
HeightRequest="400"
Loop="True"
ItemsSource="{Binding CarouselQuizzes}"
HorizontalScrollBarVisibility="Never"
IndicatorView="QuizIndicator">
<CarouselView.ItemTemplate>
<DataTemplate x:DataType="viewModels:QuizItemViewModel">
<controls:CarouselItem
CarouselImage="{Binding CarouselImage}"
Description="{Binding Description}"
Points="{Binding Points}"
ButtonText="GO"
ButtonCommand="{Binding Source={x:Reference QuizList}, Path=BindingContext.OpenQuizCommand}"
ItemId="{Binding Id}"
IsButtonDisabled="{Binding Passed}"/>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>

<IndicatorView Grid.Row="0"
SelectedIndicatorColor="{StaticResource SSWRed}"
IndicatorColor="{StaticResource IndicatorColor}"
IndicatorSize="4.5"
HorizontalOptions="Center"
VerticalOptions="End"
Margin="0,0,0,25"
x:Name="QuizIndicator" />
</Grid>
<CollectionView
Grid.Row="1"
x:Name="QuizListSection"
ItemsSource="{Binding Quizzes}"
ItemsUpdatingScrollMode="KeepItemsInView"
ItemSizingStrategy="{OnPlatform iOS='MeasureFirstItem', Android='MeasureAllItems'}">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModels:QuizItemViewModel">
<controls:CarouselItem
CarouselImage="{Binding CarouselImage}"
Description="{Binding Description}"
Points="{Binding Points}"
ButtonText="GO"
ButtonCommand="{Binding Source={x:Reference QuizList}, Path=BindingContext.OpenQuizCommand}"
ItemId="{Binding Id}"
IsButtonDisabled="{Binding Passed}"/>
<Grid Padding="0,0,0,6">
<controls:ListItem Title="{Binding Title}"
Description="{Binding Description}"
Points="{Binding Points}"
ButtonText="GO"
ButtonCommand="{Binding Source={x:Reference QuizList}, Path=BindingContext.OpenQuizCommand}"
ItemId="{Binding Id}"
ThumbnailImage="{Binding ThumbnailImage}"
PlaceholderGlyph="&#xf11b;"
ShowTick="{Binding Passed}"
IsDisabled="{Binding Passed}"
IsButtonDisabled="{Binding Passed}"/>
</Grid>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>

<IndicatorView Grid.Row="0"
SelectedIndicatorColor="{StaticResource SSWRed}"
IndicatorColor="{StaticResource IndicatorColor}"
IndicatorSize="4.5"
HorizontalOptions="Center"
VerticalOptions="End"
Margin="0,0,0,25"
x:Name="QuizIndicator" />
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
<CollectionView
Grid.Row="1"
x:Name="QuizListSection"
ItemsSource="{Binding Quizzes}"
ItemsUpdatingScrollMode="KeepItemsInView"
ItemSizingStrategy="{OnPlatform iOS='MeasureFirstItem', Android='MeasureAllItems'}">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="viewModels:QuizItemViewModel">
<Grid Padding="0,0,0,6">
<controls:ListItem Title="{Binding Title}"
Description="{Binding Description}"
Points="{Binding Points}"
ButtonText="GO"
ButtonCommand="{Binding Source={x:Reference QuizList}, Path=BindingContext.OpenQuizCommand}"
ItemId="{Binding Id}"
ThumbnailImage="{Binding ThumbnailImage}"
PlaceholderGlyph="&#xf11b;"
ShowTick="{Binding Passed}"
IsDisabled="{Binding Passed}"
IsButtonDisabled="{Binding Passed}"/>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
<ActivityIndicator
HorizontalOptions="Center"
VerticalOptions="Center"
Color="{StaticResource SSWRed}"
IsEnabled="{Binding IsBusy}"
IsRunning="{Binding IsBusy}"
IsVisible="{Binding IsBusy}" />
</Grid>
<ActivityIndicator
HorizontalOptions="Center"
VerticalOptions="Center"
Color="{StaticResource SSWRed}"
IsEnabled="{Binding IsBusy}"
IsRunning="{Binding IsBusy}"
IsVisible="{Binding IsBusy}" />
</Grid>
</ScrollView>
</ScrollView>
</RefreshView>
</ContentPage>
Loading
Loading