From 5a84e4f1c2d2aed20ba01ab6de43fc8c683fd7fd Mon Sep 17 00:00:00 2001 From: Max Mannstein Date: Mon, 28 Jul 2025 15:18:57 +0200 Subject: [PATCH] Add First10Walkers property and update HomeView layout for improved display --- .../gehGassiApp/ViewModels/HomeViewModel.cs | 11 + gehGassiApp/gehGassiApp/Views/HomeView.xaml | 308 ++++++++---------- .../gehGassiApp/Views/HomeView.xaml.cs | 149 +++++---- 3 files changed, 223 insertions(+), 245 deletions(-) diff --git a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs index 6077d4f..71fba6f 100644 --- a/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs +++ b/gehGassiApp/gehGassiApp/ViewModels/HomeViewModel.cs @@ -112,6 +112,12 @@ namespace gehGassiApp.ViewModels [ObservableProperty] private ObservableCollection _walkers; + /// + /// First 10 walkers for the home screen display + /// + [ObservableProperty] + private ObservableCollection _first10Walkers; + [ObservableProperty] private DogWalkerLookup _selectedWalker; @@ -541,6 +547,9 @@ namespace gehGassiApp.ViewModels Walkers = requests.Value.ToObservableCollection(); + // Set First10Walkers for the home screen display + First10Walkers = requests.Value.Take(10).ToObservableCollection(); + _total = requests.Total; _skip = requests.Skip + requests.Take; } @@ -549,6 +558,7 @@ namespace gehGassiApp.ViewModels _total = 0; _skip = 0; Walkers = null; + First10Walkers = null; } } catch (Exception ex) @@ -557,6 +567,7 @@ namespace gehGassiApp.ViewModels _total = 0; _skip = 0; Walkers = null; + First10Walkers = null; } } diff --git a/gehGassiApp/gehGassiApp/Views/HomeView.xaml b/gehGassiApp/gehGassiApp/Views/HomeView.xaml index ce7f1fb..626b023 100644 --- a/gehGassiApp/gehGassiApp/Views/HomeView.xaml +++ b/gehGassiApp/gehGassiApp/Views/HomeView.xaml @@ -1,4 +1,4 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - - - + RowDefinitions="Auto,Auto" + VerticalOptions="FillAndExpand"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/gehGassiApp/gehGassiApp/Views/HomeView.xaml.cs b/gehGassiApp/gehGassiApp/Views/HomeView.xaml.cs index e16fc2f..95f8d06 100644 --- a/gehGassiApp/gehGassiApp/Views/HomeView.xaml.cs +++ b/gehGassiApp/gehGassiApp/Views/HomeView.xaml.cs @@ -10,9 +10,11 @@ public partial class HomeView : BaseContentPage IDeviceInstallationService _deviceInstallationService; IDeviceInstallationService DeviceInstallationService => _deviceInstallationService ??= ServiceHelper.GetService(); private HomeViewModel ViewModel => BindingContext as HomeViewModel; - private bool _isRowHidden = false; - private double _initialRowHeight; - private bool _animationRunning = false; + + // COMMENTED OUT: Animation variables for collapsing header + //private bool _isRowHidden = false; + //private double _initialRowHeight; + //private bool _animationRunning = false; /// /// Erstellt eine Instanz @@ -31,10 +33,13 @@ public partial class HomeView : BaseContentPage await ViewModel.InitializeAsync(this); var width = DeviceDisplay.Current.MainDisplayInfo.Width / DeviceDisplay.Current.MainDisplayInfo.Density; ViewModel.NextWalkWidth = width * 0.8; - _isRowHidden = false; - _initialRowHeight = 0; - _animationRunning = false; - rootVerticalStackLayout.HeightRequest = -1; + + // COMMENTED OUT: Animation initialization + //_isRowHidden = false; + //_initialRowHeight = 0; + //_animationRunning = false; + //rootVerticalStackLayout.HeightRequest = -1; + #if IOS if (DeviceInstallationService.NotificationsSupported) { @@ -50,74 +55,78 @@ public partial class HomeView : BaseContentPage await ViewModel.DisappearingAsync(this); } - //Workaround für den IOS-Bug der Höhenberechnung! Siehe https://github.com/dotnet/maui/issues/8820 - private void rootVerticalStackLayout_SizeChanged(object sender, EventArgs e) - { - if(!_isRowHidden && rootVerticalStackLayout.Height > _initialRowHeight) - _initialRowHeight = rootVerticalStackLayout.Height; - } + // COMMENTED OUT: Workaround für den IOS-Bug der Höhenberechnung! Siehe https://github.com/dotnet/maui/issues/8820 + //private void rootVerticalStackLayout_SizeChanged(object sender, EventArgs e) + //{ + // if(!_isRowHidden && rootVerticalStackLayout.Height > _initialRowHeight) + // _initialRowHeight = rootVerticalStackLayout.Height; + //} - private async void homeCollectionView_Scrolled(object sender, ItemsViewScrolledEventArgs e) - { - if(_animationRunning) - return; - - if (e.VerticalDelta > 0 && e.VerticalOffset >= 50 && !_isRowHidden) - { - await HideHeader(); - } - else if (e.VerticalDelta < 0 && e.VerticalOffset <= 50 && _isRowHidden) - { - await ShowHeader(); - } - } + // COMMENTED OUT: Scroll handler for collapsing animation + //private async void homeCollectionView_Scrolled(object sender, ItemsViewScrolledEventArgs e) + //{ + // if(_animationRunning) + // return; + // + // if (e.VerticalDelta > 0 && e.VerticalOffset >= 50 && !_isRowHidden) + // { + // await HideHeader(); + // } + // else if (e.VerticalDelta < 0 && e.VerticalOffset <= 50 && _isRowHidden) + // { + // await ShowHeader(); + // } + //} - private async Task ShowHeader() - { - homeRefreshView.IsEnabled = false; - homeCollectionView.IsEnabled = false; - _isRowHidden = false; - _animationRunning = true; - var animation = new Animation(v => rootVerticalStackLayout.HeightRequest = v, 0, _initialRowHeight); + // COMMENTED OUT: Show header animation + //private async Task ShowHeader() + //{ + // homeRefreshView.IsEnabled = false; + // homeCollectionView.IsEnabled = false; + // _isRowHidden = false; + // _animationRunning = true; + // var animation = new Animation(v => rootVerticalStackLayout.HeightRequest = v, 0, _initialRowHeight); - MainThread.BeginInvokeOnMainThread(() => - { - animation.Commit(this, "HideRowAnimation", length: 500, easing: Easing.SinIn); - - }); + // MainThread.BeginInvokeOnMainThread(() => + // { + // animation.Commit(this, "HideRowAnimation", length: 500, easing: Easing.SinIn); + // + // }); - await Task.Delay(500); - _animationRunning = false; - homeCollectionView.IsEnabled = true; - homeRefreshView.IsEnabled = true; - } + // await Task.Delay(500); + // _animationRunning = false; + // homeCollectionView.IsEnabled = true; + // homeRefreshView.IsEnabled = true; + //} - private async Task HideHeader() - { - homeRefreshView.IsEnabled = false; - homeCollectionView.IsEnabled = false; - _isRowHidden = true; - _animationRunning = true; - var animation = new Animation(v => rootVerticalStackLayout.HeightRequest = v, _initialRowHeight, 0); - - MainThread.BeginInvokeOnMainThread(() => - { - animation.Commit(this, "HideRowAnimation", length: 500, easing: Easing.SinOut); - - }); - - await Task.Delay(500); - _animationRunning = false; - homeCollectionView.IsEnabled = true; - homeRefreshView.IsEnabled = true; - } + // COMMENTED OUT: Hide header animation + //private async Task HideHeader() + //{ + // homeRefreshView.IsEnabled = false; + // homeCollectionView.IsEnabled = false; + // _isRowHidden = true; + // _animationRunning = true; + // var animation = new Animation(v => rootVerticalStackLayout.HeightRequest = v, _initialRowHeight, 0); + // + // MainThread.BeginInvokeOnMainThread(() => + // { + // animation.Commit(this, "HideRowAnimation", length: 500, easing: Easing.SinOut); + // + // }); + // + // await Task.Delay(500); + // _animationRunning = false; + // homeCollectionView.IsEnabled = true; + // homeRefreshView.IsEnabled = true; + //} - private async void RefreshView_Refreshing(object sender, EventArgs e) - { - if (_isRowHidden) - { - await ShowHeader(); - } - } + // COMMENTED OUT: RefreshView refreshing handler + //private async void RefreshView_Refreshing(object sender, EventArgs e) + //{ + // if (_isRowHidden) + // { + // await ShowHeader(); + // } + //} }