diff --git a/gehGassiApp/gehGassiApp/MauiProgram.cs b/gehGassiApp/gehGassiApp/MauiProgram.cs index d2c12bf..2b146bb 100644 --- a/gehGassiApp/gehGassiApp/MauiProgram.cs +++ b/gehGassiApp/gehGassiApp/MauiProgram.cs @@ -1,4 +1,5 @@ -using CommunityToolkit.Maui; +using Plugin.Maui.AppRating; +using CommunityToolkit.Maui; using gehGassi.LocalNotifications; using gehGassiApp.Constants; using gehGassiApp.Core.Data; @@ -484,7 +485,8 @@ public static class MauiProgram SetHandler(); - return builder.Build(); + builder.Services.AddSingleton(AppRating.Default); + return builder.Build(); } #region Handler diff --git a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs index 71fba6f..294fc4c 100644 --- a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs +++ b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs @@ -545,7 +545,12 @@ namespace gehGassiApp.ViewModels request.Distance = Location.CalculateDistance(CurrentLocation.Lat.Value, CurrentLocation.Lng.Value, request.Lat, request.Lng, DistanceUnits.Kilometers); } - Walkers = requests.Value.ToObservableCollection(); + // Sortierung: Entfernung, dann mit Foto, dann mit Rating + Walkers = requests.Value + .OrderBy(x => x.Distance) + .ThenByDescending(x => !string.IsNullOrWhiteSpace(x.Photo)) + .ThenByDescending(x => x.AverageRating > 0) + .ToObservableCollection(); // Set First10Walkers for the home screen display First10Walkers = requests.Value.Take(10).ToObservableCollection(); diff --git a/gehGassiApp/gehGassiApp/ViewModels/More/MoreViewModel.cs b/gehGassiApp/gehGassiApp/ViewModels/More/MoreViewModel.cs index c915dda..84cb71d 100644 --- a/gehGassiApp/gehGassiApp/ViewModels/More/MoreViewModel.cs +++ b/gehGassiApp/gehGassiApp/ViewModels/More/MoreViewModel.cs @@ -1,4 +1,5 @@ -using System.Text.Json; +using Plugin.Maui.AppRating; +using System.Text.Json; using CommunityToolkit.Maui.Core; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -30,7 +31,8 @@ namespace gehGassiApp.ViewModels.More private readonly IDialogService _dialogService; private readonly ISystemMessageService _systemMessageService; private readonly IDispatcher _dispatcher; - private readonly IPushnotificationService _pushnotificationService; + private readonly IPushnotificationService _pushnotificationService; + private readonly IAppRating _appRating; /// /// Erstellt eine Instanz @@ -40,8 +42,8 @@ namespace gehGassiApp.ViewModels.More /// Instanz eines ISystemMessageService /// Instanz eines IDispatcher /// Instanz eines IPushnotificationService - public MoreViewModel(IAccountService accountService, IDialogService dialogService, ISystemMessageService systemMessageService, IDispatcher dispatcher, - IPushnotificationService pushnotificationService) + public MoreViewModel(IAccountService accountService, IDialogService dialogService, ISystemMessageService systemMessageService, IDispatcher dispatcher, + IPushnotificationService pushnotificationService, IAppRating appRating) { _accountService = accountService; _dialogService = dialogService; @@ -50,6 +52,43 @@ namespace gehGassiApp.ViewModels.More _pushnotificationService = pushnotificationService; Title = Text.View_Title_More; SelectedMenu = MenuSelected.More; + _appRating = appRating; + } + + /// + /// Command für die Store-Bewertung + /// + [RelayCommand] + public async Task RateApp() + { + try + { + await _appRating.PerformRatingOnStoreAsync( + packageName: "com.gehgassi.gehgassi", + applicationId: "id1662116305" + ); + } + catch (Exception ex) + { + await TrackErrorAsync(ex, true); + } + } + + /// + /// Command für das Teilen der App + /// + [RelayCommand] + public async Task ShareApp() + { + string url = DeviceInfo.Platform == DevicePlatform.iOS + ? "https://apps.apple.com/us/app/gehgassi/id1662116305" + : "https://play.google.com/store/apps/details?id=com.gehgassi.gehgassi"; + string text = $"Schau dir die gehgassi App an! {url}"; + await Share.Default.RequestAsync(new ShareTextRequest + { + Text = text, + Title = "App teilen" + }); } /// diff --git a/gehGassiApp/gehGassiApp/ViewModels/More/MoreWalkerViewModel.cs b/gehGassiApp/gehGassiApp/ViewModels/More/MoreWalkerViewModel.cs index f9374a2..dac3623 100644 --- a/gehGassiApp/gehGassiApp/ViewModels/More/MoreWalkerViewModel.cs +++ b/gehGassiApp/gehGassiApp/ViewModels/More/MoreWalkerViewModel.cs @@ -1,4 +1,5 @@ -using System.Text.Json; +using Plugin.Maui.AppRating; +using System.Text.Json; using CommunityToolkit.Maui.Core; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -30,7 +31,8 @@ namespace gehGassiApp.ViewModels.More private readonly IUserService _userService; private readonly ISystemMessageService _systemMessageService; private readonly IDispatcher _dispatcher; - private readonly IPushnotificationService _pushnotificationService; + private readonly IPushnotificationService _pushnotificationService; + private readonly IAppRating _appRating; /// /// Erstellt eine Instanz @@ -41,8 +43,8 @@ namespace gehGassiApp.ViewModels.More /// Instanz eines ISystemMessageService /// Instanz eines IDispatcher /// Instanz eines IPushnotificationService - public MoreWalkerViewModel(IAccountService accountService, IDialogService dialogService, IUserService userService, ISystemMessageService systemMessageService, IDispatcher dispatcher, - IPushnotificationService pushnotificationService) + public MoreWalkerViewModel(IAccountService accountService, IDialogService dialogService, IUserService userService, ISystemMessageService systemMessageService, IDispatcher dispatcher, + IPushnotificationService pushnotificationService, IAppRating appRating) { _accountService = accountService; _dialogService = dialogService; @@ -52,8 +54,43 @@ namespace gehGassiApp.ViewModels.More _pushnotificationService = pushnotificationService; Title = Text.View_Title_More; SelectedMenu = MenuSelected.More; + _appRating = appRating; } + /// + /// Command für die Store-Bewertung + /// + [RelayCommand] + public async Task RateApp() + { + try + { + await _appRating.PerformRatingOnStoreAsync( + packageName: "com.gehgassi.gehgassi", + applicationId: "id1662116305" + ); + } + catch (Exception ex) + { + await TrackErrorAsync(ex, true); + } + } + /// + /// Command für das Teilen der App + /// + [RelayCommand] + public async Task ShareApp() + { + string url = DeviceInfo.Platform == DevicePlatform.iOS + ? "https://apps.apple.com/us/app/gehgassi/id1662116305" + : "https://play.google.com/store/apps/details?id=com.gehgassi.gehgassi"; + string text = $"Schau dir die gehgassi App an! {url}"; + await Share.Default.RequestAsync(new ShareTextRequest + { + Text = text, + Title = "App teilen" + }); + } /// /// Gibt an ob Switch verfügbar ist /// diff --git a/gehGassiApp/gehGassiApp/ViewModels/Walks/PublicWalkRequestCreateViewModel.cs b/gehGassiApp/gehGassiApp/ViewModels/Walks/PublicWalkRequestCreateViewModel.cs index e414b18..d56b17a 100644 --- a/gehGassiApp/gehGassiApp/ViewModels/Walks/PublicWalkRequestCreateViewModel.cs +++ b/gehGassiApp/gehGassiApp/ViewModels/Walks/PublicWalkRequestCreateViewModel.cs @@ -526,7 +526,7 @@ namespace gehGassiApp.ViewModels.Walks } } -#endregion + #endregion /// /// Laden der initialen Daten @@ -597,6 +597,8 @@ namespace gehGassiApp.ViewModels.Walks CheckSubscription(AppMode.DogOwner); } } + DogSelectionChanged(); + } /// @@ -615,10 +617,22 @@ namespace gehGassiApp.ViewModels.Walks { Dogs = dogs.ToObservableCollection(); SelectedDog = Dogs.FirstOrDefault(); + + // Ersten Hund automatisch zur Auswahl hinzufügen + if (Dogs.Count > 0) + { + SelectedDogs.Clear(); + SelectedDogs.Add(Dogs.First()); + DogsSelected = true; + + // DogSelectionChanged Command manuell auslösen für UI-Update + } } else { Dogs?.Clear(); + SelectedDogs?.Clear(); + DogsSelected = false; } HasNoDog = Dogs.Count == 0; diff --git a/gehGassiApp/gehGassiApp/Views/Dogs/DogAddView.xaml b/gehGassiApp/gehGassiApp/Views/Dogs/DogAddView.xaml index f327783..a24748e 100644 --- a/gehGassiApp/gehGassiApp/Views/Dogs/DogAddView.xaml +++ b/gehGassiApp/gehGassiApp/Views/Dogs/DogAddView.xaml @@ -294,7 +294,7 @@