wxr
2021-11-30 e75ccccb370b47305c6eadb321efb27c86cdd28b
SiriIntentsUI/IntentViewController.cs
New file
@@ -0,0 +1,105 @@
using System;
using CoreGraphics;
using Foundation;
using HDLSceneSiri;
//using HDLSceneSiri;
using Intents;
using IntentsUI;
using UIKit;
namespace SiriIntentsUI
{
    public partial class IntentViewController : UIViewController, IINUIHostedViewControlling
    {
        protected IntentViewController(IntPtr handle) : base(handle)
        {
        }
        //public override void ViewDidLoad()
        //{
        //    base.ViewDidLoad();
        //    // Do any required interface  here.
        //}
        //public override void DidReceiveMemoryWarning()
        //{
        //    // Releases the view if it doesn't have a superview.
        //    base.DidReceiveMemoryWarning();
        //    // Release any cached data, images, etc that aren't in use.
        //}
        [Export("configureWithInteraction:context:completion:")]
        public void Configure(INInteraction interaction, INUIHostedViewContext context, Action<CGSize> completion)
        {
            throw new NotImplementedException();
        }
        CGSize DesiredSize()
        {
            return ExtensionContext.GetHostedViewMaximumAllowedSize();
        }
        [Export("configureViewForParameters:ofInteraction:interactiveBehavior:context:completion:")]
        public void ConfigureView(
            NSSet<INParameter> parameters,
            INInteraction interaction,
            INUIInteractiveBehavior interactiveBehavior,
            INUIHostedViewContext context,
            INUIHostedViewControllingConfigureViewHandler completion)
        {
                HDLRunSceneIntentResponse rsp = interaction.IntentResponse as HDLRunSceneIntentResponse;
            this.lblMsg.Text = rsp.SuccessMessage;
            this.lblMsg.TextColor = UIColor.Black;
            this.lblMsg.Frame = new CGRect(0, 0, DesiredSize().Width, 100);
            CGSize size = new CGSize(DesiredSize().Width, 100);
            if (completion != null)
                completion(true, parameters, size);
            //var intent = interaction.Intent as OrderSoupIntent;
            //if (intent is null)
            //{
            //    completion(false, new NSSet<INParameter>(), CGSize.Empty);
            //}
            //var order = Order.FromOrderSoupIntent(intent);
            //foreach (var view in View.Subviews)
            //{
            //    view.RemoveFromSuperview();
            //}
            //// Different UIs can be displayed depending if the intent is in the
            //// confirmation phase or the handle phase.
            //var desiredSize = CGSize.Empty;
            //if (interaction.IntentHandlingStatus == INIntentHandlingStatus.Ready)
            //{
            //    desiredSize = DisplayInvoice(order, intent);
            //}
            //else if (interaction.IntentHandlingStatus == INIntentHandlingStatus.Success)
            //{
            //    var response = interaction.IntentResponse as OrderSoupIntentResponse;
            //    if (!(response is null))
            //    {
            //        desiredSize = DisplayOrderConfirmation(order, intent, response);
            //    }
            //}
            //completion(true, parameters, desiredSize);
        }
    }
}