Created
July 9, 2018 12:09
-
-
Save PattoMotto/7aae068abca859a8ff7fd6f35cb230b1 to your computer and use it in GitHub Desktop.
IntentViewController, full project https://github.com/neungnarakjung/CookBook-Siri-Shortcuts-Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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