diff --git a/src/MauiSherpa/Pages/Forms/FormPage.cs b/src/MauiSherpa/Pages/Forms/FormPage.cs index b11e4f27..03481728 100644 --- a/src/MauiSherpa/Pages/Forms/FormPage.cs +++ b/src/MauiSherpa/Pages/Forms/FormPage.cs @@ -81,14 +81,17 @@ private void BuildPage() var formContent = BuildFormContent(); formContent.Margin = new Thickness(28, 16, 28, 16); - var formScrollView = new ScrollView - { - Content = formContent, - VerticalScrollBarVisibility = ScrollBarVisibility.Default, - VerticalOptions = LayoutOptions.Fill, - }; + View formBody = formContent; if (FormBodyHeightRequest > 0) - formScrollView.HeightRequest = FormBodyHeightRequest; + { + formBody = new ScrollView + { + Content = formContent, + HeightRequest = FormBodyHeightRequest, + VerticalScrollBarVisibility = ScrollBarVisibility.Default, + VerticalOptions = LayoutOptions.Fill, + }; + } // Footer separator — full width var footerSeparator = new BoxView { HeightRequest = 1, Opacity = 0.2 }; @@ -145,7 +148,7 @@ private void BuildPage() { new RowDefinition(GridLength.Auto), new RowDefinition(GridLength.Auto), - new RowDefinition(GridLength.Star), + new RowDefinition(FormBodyHeightRequest > 0 ? GridLength.Star : GridLength.Auto), new RowDefinition(GridLength.Auto), new RowDefinition(GridLength.Auto), }, @@ -156,13 +159,13 @@ private void BuildPage() Grid.SetRow(titleLabel, 0); Grid.SetRow(headerSeparator, 1); - Grid.SetRow(formScrollView, 2); + Grid.SetRow(formBody, 2); Grid.SetRow(footerSeparator, 3); Grid.SetRow(footerLayout, 4); grid.Children.Add(titleLabel); grid.Children.Add(headerSeparator); - grid.Children.Add(formScrollView); + grid.Children.Add(formBody); grid.Children.Add(footerSeparator); grid.Children.Add(footerLayout); diff --git a/src/MauiSherpa/Services/DialogService.cs b/src/MauiSherpa/Services/DialogService.cs index 0eb64a40..6a776498 100644 --- a/src/MauiSherpa/Services/DialogService.cs +++ b/src/MauiSherpa/Services/DialogService.cs @@ -270,6 +270,35 @@ await Dispatcher.DispatchAsync(() => viewController?.PresentViewController(picker, true, null); }); + return await tcs.Task; +#elif MACOSAPP + var tcs = new TaskCompletionSource(); + + await Dispatcher.DispatchAsync(() => + { + var panel = new NSOpenPanel + { + Title = title, + CanChooseFiles = true, + CanChooseDirectories = false, + AllowsMultipleSelection = false, + }; + + var allowedFileTypes = extensions? + .Select(extension => extension.TrimStart('.', '*')) + .Where(extension => !string.IsNullOrWhiteSpace(extension)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToArray(); + if (allowedFileTypes is { Length: > 0 }) + panel.AllowedFileTypes = allowedFileTypes; + + var result = panel.RunModal(); + if (result == 1 && panel.Url?.Path is string path) + tcs.TrySetResult(path); + else + tcs.TrySetResult(null); + }); + return await tcs.Task; #elif LINUXGTK if (_filePicker == null) return null;