videokit-ai / natshare

Cross-platform social sharing for Unity Engine.
https://github.com/natmlx/videokit
Apache License 2.0
134 stars 28 forks source link

New front-end API draft #48

Closed olokobayusuf closed 5 years ago

olokobayusuf commented 5 years ago

The goals of this will be:

Here's a draft:

namespace NatShare { // No more `NatShareU`

    public class SharePayload : IDisposable? { // Does this need to be disposable?
        /// <summary>
        /// Subject of the share payload
        /// </summary>
        public string Subject { get; set; }
        /// <summary>
        /// Add plain text
        /// </summary>
        public void AddText (string text);
        /// <summary>
        /// Add an image
        /// </summary>
        public void AddImage (Texture2D image);
        /// <summary>
        /// Add media with at a given URI
        /// </summary>
        public void AddMedia (string uri);
        /// <summary>
        /// Commit the payload to the operating system for sharing
        /// </summary>
        public void Commit (Action completionHandler = null);
        /// <summary>
        /// Dispose the payload
        /// </summary>
        public void Dispose ();
    }

    public class MediaPayload : IDisposable {
        /// <summary>
        /// Create a media payload for a given image
        /// </summary>
        public MediaPayload (Texture2D image);
        /// <summary>
        /// Create a media payload for media at a given URI
        /// </summary>
        public MediaPayload (string uri);
        /// <summary>
        /// Get an image from the backing media
        /// </summary>
        public Texture2D GetImage (float time = 0f);
        /// <summary>
        /// Save the media to the camera roll
        /// </summary>
        public void SaveToCameraRoll (string album = null);
        /// <summary>
        /// Dispose the media payload
        /// </summary>
        public void Dispose ();
    }
}
olokobayusuf commented 5 years ago

See #49