diff --git a/Converters/NotEqualMultiValueConverter.cs b/Converters/NotEqualMultiValueConverter.cs new file mode 100644 index 0000000..504e8f9 --- /dev/null +++ b/Converters/NotEqualMultiValueConverter.cs @@ -0,0 +1,21 @@ +using System.Globalization; + +namespace Ifpa.Converters +{ + public class NotEqualMultiValueConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length == 2 && values[0] != null && values[1] != null) + { + return !values[0].Equals(values[1]); + } + return false; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/IfpaMaui.csproj b/IfpaMaui.csproj index b9d499f..b9f65ab 100644 --- a/IfpaMaui.csproj +++ b/IfpaMaui.csproj @@ -56,9 +56,9 @@ - + - + @@ -73,7 +73,7 @@ - + diff --git a/Models/Settings.cs b/Models/Settings.cs index eecf19b..bc06c64 100644 --- a/Models/Settings.cs +++ b/Models/Settings.cs @@ -75,6 +75,12 @@ public static string CalendarRankingSystem set => Preferences.Set("CalendarRankingSystem", value); } + public static bool CalendarShowLeagues + { + get => Preferences.Get("CalendarShowLeagues", false); + set => Preferences.Set("CalendarShowLeagues", value); + } + public static long LastCalendarIdSeen { get => Preferences.Get("LastCalendarIdSeen", 0L); diff --git a/Platforms/Android/Resources/values/colors.xml b/Platforms/Android/Resources/values/colors.xml index 4e1b197..20403df 100644 --- a/Platforms/Android/Resources/values/colors.xml +++ b/Platforms/Android/Resources/values/colors.xml @@ -2,7 +2,7 @@ #4579FB #2B0B98 - #2B0B98 + #4579FB #062C53 #d3d3d3 \ No newline at end of file diff --git a/Strings.Designer.cs b/Strings.Designer.cs index af42846..1a94505 100644 --- a/Strings.Designer.cs +++ b/Strings.Designer.cs @@ -447,6 +447,15 @@ internal static string CalendarFilterModalPage_SetCalendarLocation { } } + /// + /// Looks up a localized string similar to Show Leagues?. + /// + internal static string CalendarFilterModalPage_ShowLeagues { + get { + return ResourceManager.GetString("CalendarFilterModalPage_ShowLeagues", resourceCulture); + } + } + /// /// Looks up a localized string similar to Calendar. /// @@ -600,6 +609,15 @@ internal static string FavoritesPage_Delete { } } + /// + /// Looks up a localized string similar to - . + /// + internal static string Hyphen { + get { + return ResourceManager.GetString("Hyphen", resourceCulture); + } + } + /// /// Looks up a localized string similar to Mi. /// diff --git a/Strings.resx b/Strings.resx index 17d1984..38e44ee 100644 --- a/Strings.resx +++ b/Strings.resx @@ -654,4 +654,10 @@ Ranking Type + + Show Leagues? + + + - + \ No newline at end of file diff --git a/ViewModels/CalendarViewModel.cs b/ViewModels/CalendarViewModel.cs index 776384f..7862ddb 100644 --- a/ViewModels/CalendarViewModel.cs +++ b/ViewModels/CalendarViewModel.cs @@ -9,6 +9,7 @@ using TournamentSearch = PinballApi.Models.WPPR.Universal.Tournaments.Search.Tournament; using System.Windows.Input; using PinballApi.Models.WPPR.Universal; +using PinballApi.Models.WPPR.Universal.Tournaments.Search; namespace Ifpa.ViewModels { @@ -78,13 +79,15 @@ public async Task ExecuteLoadItemsCommand(Location geoLocation, int distance) } var tournamentType = (TournamentType?)(Settings.CalendarRankingSystem == "All" ? null : Enum.Parse(typeof(TournamentType), Settings.CalendarRankingSystem)); + TournamentEventType? eventType = Settings.CalendarShowLeagues ? null : TournamentEventType.Tournament; var items = await pinballRankingApi.TournamentSearch(latitude, longitude, distance, DistanceType.Miles, startDate: DateTime.Now, endDate: DateTime.Now.AddYears(1), - tournamentType: tournamentType, + tournamentType: tournamentType, + tournamentEventType: eventType, totalReturn: 500); logger.LogDebug("Api call completed at {0}", sw.ElapsedMilliseconds); @@ -102,7 +105,6 @@ public async Task ExecuteLoadItemsCommand(Location geoLocation, int distance) TournamentCalendarItems = new EventCollection(); items.Tournaments - .Where(item => item.EventEndDate - item.EventStartDate <= 5.Days()) .Select(n => new TournamentWithDistance(n, (long)Location.CalculateDistance(latitude.Value, longitude.Value, n.Latitude, n.Longitude, DistanceUnits.Miles))) .GroupBy(item => item.EventStartDate.Date) .ToList() diff --git a/ViewModels/PlayerSearchViewModel.cs b/ViewModels/PlayerSearchViewModel.cs index 83e2412..56c2954 100644 --- a/ViewModels/PlayerSearchViewModel.cs +++ b/ViewModels/PlayerSearchViewModel.cs @@ -40,7 +40,7 @@ public Command SearchCommand { var items = await PinballRankingApiV2.GetPlayersBySearch(new PlayerSearchFilter() { Name = text.Trim() }); - Players = items.Results.ToObservableCollection(); + Players = items.Results?.ToObservableCollection(); OnPropertyChanged("Players"); } IsLoaded = true; diff --git a/Views/CalendarDetailPage.xaml b/Views/CalendarDetailPage.xaml index b44db50..7c395a7 100644 --- a/Views/CalendarDetailPage.xaml +++ b/Views/CalendarDetailPage.xaml @@ -20,6 +20,7 @@ +