Skip to content

Instantly share code, notes, and snippets.

@PattoMotto
Created July 9, 2018 12:09
Show Gist options
  • Save PattoMotto/7aae068abca859a8ff7fd6f35cb230b1 to your computer and use it in GitHub Desktop.
Save PattoMotto/7aae068abca859a8ff7fd6f35cb230b1 to your computer and use it in GitHub Desktop.
import IntentsUI
class IntentViewController: UIViewController, INUIHostedViewControlling {
private let margin = CGFloat(8)
var dataManager: CookBookDataManager?
@IBOutlet weak var contentStackView: UIStackView!
// MARK: - INUIHostedViewControlling
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? CookBookIntent,
let identifier = intent.recipe?.identifier,
let recipe = dataManager?.getRecipe(identifier) else {
completion(false, Set(), .zero)
return
}
clearStackView()
let size = createInstructionList(with: recipe)
completion(true, parameters, size)
contentStackView.setNeedsLayout()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment