dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.17k stars 1.74k forks source link

[Enhancement] iOS: Add support for BarButtonItem to Share API to set position of presentation controller #3813

Open MKuckert opened 2 years ago

MKuckert commented 2 years ago

Description

There's already a property ShareRequestBase.PresentationSourceBounds to set a Rectangle to give the presentation controller used by UIActivityViewController on iPads a hint where to anchor the displayed view. It's directly applied to activityController.PopoverPresentationController.SourceRect.

I suggest a API change/addition to be able to pass a UIBarButtonItem instead to the presentation controller as there's no good way to find the SourceRect for a bar button item.

Was a feature request as https://github.com/xamarin/Essentials/issues/1939

Public API Changes

public abstract class ShareRequestBase
{
    // ...
    public IPresentationOptions PresentationOptions { get; set; }
    public Rectangle PresentationSourceBounds {
        get
        {
            if(PresentationOptions is SourceBoundsPresentationOptions bounds)
            {
                return bounds.Bounds;
            }
            else
            {
                return Rectangle.Empty;
            }
        }
        set => PresentationOptions = new SourceBoundsPresentationOptions(value);
    }
}
public interface IPresentationOptions {}
public sealed class SourceBoundsPresentationOptions : IPresentationOptions
{
    public SourceBoundsPresentationOptions(Rectangle bounds)
        => Bounds = bounds;
    public Rectangle Bounds { get; }
}
public sealed class UIBarButtonItemPresentationOptions : IPresentationOptions
{
    public UIBarButtonItemPresentationOptions(UIBarButtonItem barButtonItem)
        => BarButtonItem = barButtonItem;
    public UIBarButtonItem BarButtonItem { get; set; }
}

Intended Use-Case

There's no good way to find the SourceRect for a bar button item and though leverage the existing property ShareRequestBase.PresentationSourceBounds.

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.