From 421672e8cb3b30cec2bcce28654f75fc3acfbfd3 Mon Sep 17 00:00:00 2001 From: Max Mannstein Date: Tue, 22 Jul 2025 17:43:19 +0200 Subject: [PATCH 1/4] Add app rating and sharing functionality to MoreView and MoreWalkerView --- gehGassiApp/gehGassiApp/MauiProgram.cs | 6 +- .../ViewModels/More/MoreViewModel.cs | 47 +++++++++++- .../ViewModels/More/MoreWalkerViewModel.cs | 45 +++++++++++- .../gehGassiApp/Views/More/MoreView.xaml | 70 ++++++++++++++++++ .../Views/More/MoreWalkerView.xaml | 73 ++++++++++++++++++- gehGassiApp/gehGassiApp/gehGassiApp.csproj | 1 + 6 files changed, 230 insertions(+), 12 deletions(-) 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/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/Views/More/MoreView.xaml b/gehGassiApp/gehGassiApp/Views/More/MoreView.xaml index d48dd5c..d8a74f3 100644 --- a/gehGassiApp/gehGassiApp/Views/More/MoreView.xaml +++ b/gehGassiApp/gehGassiApp/Views/More/MoreView.xaml @@ -398,6 +398,76 @@ + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + diff --git a/gehGassiApp/gehGassiApp/gehGassiApp.csproj b/gehGassiApp/gehGassiApp/gehGassiApp.csproj index 1953284..540c331 100644 --- a/gehGassiApp/gehGassiApp/gehGassiApp.csproj +++ b/gehGassiApp/gehGassiApp/gehGassiApp.csproj @@ -205,6 +205,7 @@ + From d72c84ef5f0469515b9935297d4290141e8eefc0 Mon Sep 17 00:00:00 2001 From: Max Mannstein Date: Tue, 22 Jul 2025 18:38:26 +0200 Subject: [PATCH 2/4] Sort walkers by distance, photo presence, and average rating in HomeViewModel --- gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs index 6077d4f..04be5ac 100644 --- a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs +++ b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs @@ -539,7 +539,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(); _total = requests.Total; _skip = requests.Skip + requests.Take; From 409622752589b673c006ff66f0905ea4a01879e2 Mon Sep 17 00:00:00 2001 From: Max Mannstein Date: Mon, 28 Jul 2025 15:41:01 +0200 Subject: [PATCH 3/4] Refactor PublicWalkRequestCreateViewModel to improve dog selection logic and ensure UI updates correctly --- .../Walks/PublicWalkRequestCreateViewModel.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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; From 5560f9f8705615c6f9b9326b61ed4c0a92722d9f Mon Sep 17 00:00:00 2001 From: Max Mannstein Date: Sat, 9 Aug 2025 15:24:45 +0200 Subject: [PATCH 4/4] Remove IsEnabled bindings for dog attributes in DogAddView and DogUpdateView --- .../gehGassiApp/Views/Dogs/DogAddView.xaml | 17 +---------------- .../gehGassiApp/Views/Dogs/DogUpdateView.xaml | 16 ---------------- 2 files changed, 1 insertion(+), 32 deletions(-) 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 @@