Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created July 27, 2018 17:40
Show Gist options
  • Save azamsharp/b6bde057d9b624210fdca5629e3f1049 to your computer and use it in GitHub Desktop.
Save azamsharp/b6bde057d9b624210fdca5629e3f1049 to your computer and use it in GitHub Desktop.
// Prepare your view controller for the interaction to handle.
func configureView(for parameters: Set<INParameter>, of interaction: INInteraction, interactiveBehavior: INUIInteractiveBehavior, context: INUIHostedViewContext, completion: @escaping (Bool, Set<INParameter>, CGSize) -> Void) {
guard let intent = interaction.intent as? OrderCoffeeIntent else {
completion(false, Set(), .zero)
return
}
// clear out all the views
for childView in view.subviews {
childView.removeFromSuperview()
}
var desiredSize = CGSize.zero
if interaction.intentHandlingStatus == .ready {
desiredSize = displayInvoice(name :intent.coffeeName!, deliveryLocation :intent.deliveryLocation!)
} else if interaction.intentHandlingStatus == .success {
desiredSize = displayConfirm(name :intent.coffeeName!)
}
// Do configuration here, including preparing views and calculating a desired size for presentation.
completion(true, parameters, desiredSize)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment