From b0b4f4759ac88c8c6122ba466666b43763f9df52 Mon Sep 17 00:00:00 2001
From: Hamish Duff <99325835+duffh@users.noreply.github.com>
Date: Sat, 20 Jan 2024 01:07:45 +0000
Subject: [PATCH] improve mac and ios appearance
---
src/MAUI/Maui.Samples/Views/CategoryPage.xaml | 10 ++++------
.../Maui.Samples/Views/CategoryPage.xaml.cs | 20 +++++++++++++++++--
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/MAUI/Maui.Samples/Views/CategoryPage.xaml b/src/MAUI/Maui.Samples/Views/CategoryPage.xaml
index feacb3a3f2..8e92000a4e 100644
--- a/src/MAUI/Maui.Samples/Views/CategoryPage.xaml
+++ b/src/MAUI/Maui.Samples/Views/CategoryPage.xaml
@@ -16,20 +16,18 @@
IconImageSource="settings.png"
Text="Settings" />
-
-
-
+
-
+
diff --git a/src/MAUI/Maui.Samples/Views/CategoryPage.xaml.cs b/src/MAUI/Maui.Samples/Views/CategoryPage.xaml.cs
index 87c33123ba..5829f24a9f 100644
--- a/src/MAUI/Maui.Samples/Views/CategoryPage.xaml.cs
+++ b/src/MAUI/Maui.Samples/Views/CategoryPage.xaml.cs
@@ -3,6 +3,7 @@
using ArcGIS.Samples.Shared.Managers;
using ArcGIS.ViewModels;
using CommunityToolkit.Maui.Views;
+using CommunityToolkit.Mvvm.Messaging;
using System.Diagnostics;
namespace ArcGIS;
@@ -24,15 +25,21 @@ private void Initialize()
_viewModel = new CategoryViewModel();
BindingContext = _viewModel;
+ WeakReferenceMessenger.Default.Register(this, (message, category) => ScrollToTop());
+
SizeChanged += (s, e) =>
{
var numberOfColumns = Math.Floor(Width / _viewModel.SampleImageWidth);
- SamplesGridItemsLayout.Span = (int)numberOfColumns;
+ var layout = new GridItemsLayout((int)numberOfColumns, ItemsLayoutOrientation.Vertical);
+ layout.HorizontalItemSpacing = 5;
+ layout.VerticalItemSpacing = 5;
+ SamplesCollection.ItemsLayout = layout;
};
+
}
private async void SettingsClicked(object sender, EventArgs e)
- {
+ {
await Navigation.PushAsync(new SettingsPage(), true);
}
@@ -78,6 +85,15 @@ protected override void OnNavigatedTo(NavigatedToEventArgs args)
}
}
+ private void ScrollToTop()
+ {
+ var firstItem = _viewModel.SamplesItems.FirstOrDefault();
+ if (firstItem != null)
+ {
+ SamplesCollection.ScrollTo(firstItem, null, ScrollToPosition.Start);
+ }
+ }
+
private void CollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try