Skip to content

Commit

Permalink
Merge pull request #133 from edgiardina/compiled-bindings
Browse files Browse the repository at this point in the history
Compiled bindings to improve performance
  • Loading branch information
edgiardina authored Mar 26, 2024
2 parents 1786de8 + 68d53a5 commit 124266f
Show file tree
Hide file tree
Showing 30 changed files with 225 additions and 106 deletions.
3 changes: 3 additions & 0 deletions ViewModels/StatsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ public class StatsViewModel : BaseViewModel

public ObservableCollectionRange<BiggestMoversStat> BiggestMovers { get; set; }

public Command LoadItemsCommand { get; set; }

public StatsViewModel(PinballRankingApiV1 pinballRankingApiV1, PinballRankingApiV2 pinballRankingApiV2, ILogger<StatsViewModel> logger) : base(pinballRankingApiV1, pinballRankingApiV2, logger)
{
Title = "Stats";
MostPointsPlayers = new ObservableCollectionRange<PointsThisYearStat>();
MostEventsPlayers = new ObservableCollectionRange<MostEventsStat>();
BiggestMovers = new ObservableCollectionRange<BiggestMoversStat>();
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
}

public async Task ExecuteLoadItemsCommand()
Expand Down
6 changes: 4 additions & 2 deletions Views/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
xmlns:vm="clr-namespace:Ifpa.ViewModels"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="{x:Static local:Strings.AboutPage_About}"
xmlns:local="clr-namespace:Ifpa">
x:DataType="vm:AboutViewModel"
xmlns:local="clr-namespace:Ifpa"
xmlns:ifpaplayer="clr-namespace:PinballApi.Models.WPPR.v2.Players;assembly=PinballApi">
<ContentPage.Resources>
<ResourceDictionary>
<toolkit:IsListNotNullOrEmptyConverter x:Key="isListNotNullOrEmptyConverter" />
Expand Down Expand Up @@ -123,7 +125,7 @@
Margin="0,0,0,10" />
<CollectionView ItemsSource="{Binding Sponsors}">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifpaplayer:Player">
<Label TextColor="{StaticResource LinkTextColor}">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="PlayerLabel_Tapped"
Expand Down
2 changes: 2 additions & 0 deletions Views/ActivityFeedPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
x:Class="Ifpa.Views.ActivityFeedPage"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="{x:Static local:Strings.ActivityFeedPage_ActivityFeed}"
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:ActivityFeedViewModel"
xmlns:local="clr-namespace:Ifpa">
<ContentPage.Resources>
<datatemplates:ActivityFeedRankChangeDataTemplate x:Key="rankChangeTemplate" />
Expand Down
2 changes: 2 additions & 0 deletions Views/CalendarDetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:maps="http://schemas.microsoft.com/dotnet/2021/maui/maps"
xmlns:local="clr-namespace:Ifpa"
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:CalendarDetailViewModel"
ios:Page.LargeTitleDisplay="Never">
<ContentPage.Resources>
<ResourceDictionary>
Expand Down
9 changes: 6 additions & 3 deletions Views/ChampionshipSeriesDetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
ios:Page.LargeTitleDisplay="Never"
xmlns:local="clr-namespace:Ifpa"
Title="{Binding Title}">
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:ChampionshipSeriesDetailViewModel"
Title="{Binding Title}"
xmlns:ifpawppr="clr-namespace:PinballApi.Models.WPPR.v2.Series;assembly=PinballApi">
<ContentPage.Resources>
<ResourceDictionary>
<converters:IntToOrdinalStringConverter x:Key="intToOrdinalString" />
Expand All @@ -27,7 +30,7 @@
SelectionMode="Single"
SelectionChanged="StandingsCollectionView_SelectionChanged">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifpawppr:RegionStanding">
<!-- TODO: Revert Fixed Height Request and line break mode when this bug is fixed
https://github.com/dotnet/maui/issues/16877 -->
<Grid RowDefinitions="Auto, 1">
Expand Down Expand Up @@ -109,7 +112,7 @@
SelectionMode="Single"
ItemsSource="{Binding SeriesTournaments.SubmittedTournaments}">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifpawppr:SubmittedTournament">
<Grid RowDefinitions="Auto, 1">
<!-- TODO: Revert Fixed Height Request and line break mode when this bug is fixed
https://github.com/dotnet/maui/issues/16877 -->
Expand Down
4 changes: 3 additions & 1 deletion Views/ChampionshipSeriesListPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Ifpa.Views.ChampionshipSeriesListPage"
Title="{Binding Title}"
xmlns:local="clr-namespace:Ifpa">
xmlns:local="clr-namespace:Ifpa"
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:ChampionshipSeriesListViewModel">
<!-- RefreshView doesn't size correctly in iOS so it's been removed for now
https://github.com/dotnet/maui/issues/7315 -->
<CollectionView x:Name="ChampionshipSeriesCollectionView"
Expand Down
7 changes: 5 additions & 2 deletions Views/ChampionshipSeriesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
xmlns:mi="http://www.aathifmahir.com/dotnet/2022/maui/icons"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="{Binding Title}"
xmlns:local="clr-namespace:Ifpa">
xmlns:local="clr-namespace:Ifpa"
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:ChampionshipSeriesViewModel"
xmlns:ifpawppr="clr-namespace:PinballApi.Models.WPPR.v2.Series;assembly=PinballApi">
<ContentPage.Resources>
<toolkit:InvertedBoolConverter x:Key="invertedBoolConverter" />
</ContentPage.Resources>
Expand All @@ -23,7 +26,7 @@
SelectionChanged="MyListView_SelectionChanged"
SelectionMode="Single">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifpawppr:SeriesOverallResult">
<StackLayout>
<StackLayout Padding="5,0,5,0"
Orientation="Horizontal">
Expand Down
7 changes: 5 additions & 2 deletions Views/ChampionshipSeriesPlayerCardPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Ifpa.Views.ChampionshipSeriesPlayerCardPage"
Title="{Binding Title}"
xmlns:local="clr-namespace:Ifpa">
xmlns:local="clr-namespace:Ifpa"
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:ChampionshipSeriesPlayerCardViewModel"
xmlns:ifpawppr="clr-namespace:PinballApi.Models.WPPR.v2.Series;assembly=PinballApi">
<CollectionView x:Name="MyListView"
ItemsSource="{Binding TournamentCardRecords}"
SelectionMode="Single"
SelectionChanged="MyListView_SelectionChanged">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifpawppr:PlayerCard">
<!-- TODO: Revert Fixed Height Request and line break mode when this bug is fixed
https://github.com/dotnet/maui/issues/16877 -->
<StackLayout HeightRequest="56">
Expand Down
11 changes: 7 additions & 4 deletions Views/CustomRankingsDetailPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
xmlns:controls="clr-namespace:Ifpa.Controls"
Title="{Binding Title}"
xmlns:local="clr-namespace:Ifpa"
x:Name="SearchPlayersPage">
x:Name="SearchPlayersPage"
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:CustomRankingsDetailViewModel"
xmlns:ifparankings="clr-namespace:PinballApi.Models.WPPR.v2.Rankings;assembly=PinballApi">
<ContentPage.Resources>
<ResourceDictionary>
<converters:IntToOrdinalStringConverter x:Key="intToOrdinalString" />
Expand All @@ -32,7 +35,7 @@
SelectionMode="Single"
SelectionChanged="RankingsListView_SelectionChanged">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifparankings:CustomRankingViewResult">
<VerticalStackLayout>
<StackLayout Margin="15,10"
Orientation="Horizontal">
Expand Down Expand Up @@ -120,7 +123,7 @@
ItemsSource="{Binding ViewFilters}"
SelectionMode="None">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifparankings:CustomRankingViewFilter">
<VerticalStackLayout>
<StackLayout Margin="15"
Orientation="Horizontal">
Expand All @@ -146,7 +149,7 @@
SelectionMode="Single"
SelectionChanged="TournamentListView_SelectionChanged">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifparankings:Tournament">
<VerticalStackLayout>
<VerticalStackLayout Spacing="10"
Padding="10">
Expand Down
7 changes: 5 additions & 2 deletions Views/CustomRankingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
xmlns:local="clr-namespace:Ifpa.Converters"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="{Binding Title}"
x:Name="SearchPlayersPage">
x:Name="SearchPlayersPage"
xmlns:vm="clr-namespace:Ifpa.ViewModels"
x:DataType="vm:CustomRankingsViewModel"
xmlns:ifparankings="clr-namespace:PinballApi.Models.WPPR.v2.Rankings;assembly=PinballApi">
<ContentPage.Resources>
<ResourceDictionary>
<local:IntToOrdinalStringConverter x:Key="intToOrdinalString" />
Expand All @@ -21,7 +24,7 @@
SelectionMode="Single"
SelectionChanged="OnItemSelected">
<CollectionView.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="ifparankings:CustomRankingView">
<StackLayout>
<StackLayout Padding="10"
Orientation="Vertical">
Expand Down
4 changes: 3 additions & 1 deletion Views/DataTemplates/ActivityFeedRankChangeDataTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
xmlns:converters="clr-namespace:Ifpa.Converters"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="Ifpa.Views.DataTemplates.ActivityFeedRankChangeDataTemplate"
xmlns:local="clr-namespace:Ifpa">
xmlns:local="clr-namespace:Ifpa"
xmlns:models="clr-namespace:Ifpa.Models"
x:DataType="models:ActivityFeedItem">
<StackLayout>
<Grid Padding="10"
ColumnDefinitions="35, *">
Expand Down
90 changes: 58 additions & 32 deletions Views/DataTemplates/ActivityFeedTournamentResultDataTemplate.xaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<DataTemplate xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" x:Class="Ifpa.Views.DataTemplates.ActivityFeedTournamentResultDataTemplate" xmlns:local="clr-namespace:Ifpa">
<StackLayout>
<Grid Padding="10" ColumnDefinitions="35, *">
<Grid.Resources>
<ResourceDictionary>
<toolkit:InvertedBoolConverter x:Key="inverter" />
</ResourceDictionary>
</Grid.Resources>
<Image Grid.Column="0" Source="ribbon.png" HeightRequest="25" WidthRequest="25">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource IconAccentColor}" />
</Image.Behaviors>
</Image>
<StackLayout Grid.Column="1" HorizontalOptions="FillAndExpand" Padding="10,0,0,0">
<Label Text="{x:Static local:Strings.ActivityFeedTournamentResultDataTemplate_TournamentResultPosted}" FontAttributes="Bold" />
<Label FontSize="Small">
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="{x:Static local:Strings.ActivityFeedTournamentResultDataTemplate_TournamentResultsFor}" TextColor="{DynamicResource SecondaryTextColor}" />
<Span Text="{Binding Description, Mode=OneWay}" />
<Span Text="{x:Static local:Strings.ActivityFeedTournamentResultDataTemplate_WerePostedToYourProfile}" TextColor="{DynamicResource SecondaryTextColor}" />
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
<Label LineBreakMode="NoWrap" FontSize="Micro" Text="{Binding CreatedDateTime, StringFormat='{0:d}'}" TextColor="{DynamicResource SecondaryTextColor}" />
</StackLayout>
<BoxView Color="{StaticResource IconAccentColor}" Grid.ColumnSpan="2" Margin="10,0,0,0" IsVisible="{Binding HasBeenSeen, Mode=OneWay, Converter={StaticResource inverter}}" CornerRadius="6" WidthRequest="12" HeightRequest="12" VerticalOptions="Center" HorizontalOptions="End" />
</Grid>
<BoxView Style="{StaticResource BoxSeperator}" />
</StackLayout>
<DataTemplate xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="Ifpa.Views.DataTemplates.ActivityFeedTournamentResultDataTemplate"
xmlns:local="clr-namespace:Ifpa"
xmlns:models="clr-namespace:Ifpa.Models"
x:DataType="models:ActivityFeedItem">
<StackLayout>
<Grid Padding="10"
ColumnDefinitions="35, *">
<Grid.Resources>
<ResourceDictionary>
<toolkit:InvertedBoolConverter x:Key="inverter" />
</ResourceDictionary>
</Grid.Resources>
<Image Grid.Column="0"
Source="ribbon.png"
HeightRequest="25"
WidthRequest="25">
<Image.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{StaticResource IconAccentColor}" />
</Image.Behaviors>
</Image>
<StackLayout Grid.Column="1"
HorizontalOptions="FillAndExpand"
Padding="10,0,0,0">
<Label Text="{x:Static local:Strings.ActivityFeedTournamentResultDataTemplate_TournamentResultPosted}"
FontAttributes="Bold" />
<Label FontSize="Small">
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="{x:Static local:Strings.ActivityFeedTournamentResultDataTemplate_TournamentResultsFor}"
TextColor="{DynamicResource SecondaryTextColor}" />
<Span Text="{Binding Description, Mode=OneWay}" />
<Span Text="{x:Static local:Strings.ActivityFeedTournamentResultDataTemplate_WerePostedToYourProfile}"
TextColor="{DynamicResource SecondaryTextColor}" />
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
<Label LineBreakMode="NoWrap"
FontSize="Micro"
Text="{Binding CreatedDateTime, StringFormat='{0:d}'}"
TextColor="{DynamicResource SecondaryTextColor}" />
</StackLayout>
<BoxView Color="{StaticResource IconAccentColor}"
Grid.ColumnSpan="2"
Margin="10,0,0,0"
IsVisible="{Binding HasBeenSeen, Mode=OneWay, Converter={StaticResource inverter}}"
CornerRadius="6"
WidthRequest="12"
HeightRequest="12"
VerticalOptions="Center"
HorizontalOptions="End" />
</Grid>
<BoxView Style="{StaticResource BoxSeperator}" />
</StackLayout>
</DataTemplate>
Loading

0 comments on commit 124266f

Please sign in to comment.