mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-01-19 09:16:34 +00:00
58 lines
1.9 KiB
Swift
58 lines
1.9 KiB
Swift
|
// Copyright © 2020 Australian Government All rights reserved.
|
||
|
|
||
|
import UIKit
|
||
|
|
||
|
class ViewControllerFactory {
|
||
|
|
||
|
func createPropmtController(_ useCustomTransition: Bool, settings: FeedbackSettings? = nil) -> UIViewController {
|
||
|
let title = NSLocalizedString("entryPrompt_alert_title",
|
||
|
tableName: "Feedback",
|
||
|
bundle: Bundle.main,
|
||
|
comment: "Title for initial alert when feedback is launched"
|
||
|
)
|
||
|
|
||
|
let message = NSLocalizedString("entryPrompt_alert_message",
|
||
|
tableName: "Feedback",
|
||
|
bundle: Bundle.main,
|
||
|
comment: "Prompt message for initial alert when feedback is launched"
|
||
|
)
|
||
|
|
||
|
let alertController: AlertController
|
||
|
if UIScreen.main.traitCollection.horizontalSizeClass == .regular {
|
||
|
alertController = AlertController.createAlertController(localizedTitle: title, localizedMessage: message)
|
||
|
} else {
|
||
|
alertController = AlertController.createAlertSheetController(localizedTitle: title, localizedMessage: message)
|
||
|
}
|
||
|
alertController.feedbackSettings = settings
|
||
|
alertController.addNewFeedbackFlowAction()
|
||
|
alertController.addCancelAction()
|
||
|
alertController.useCustomTransition = useCustomTransition
|
||
|
|
||
|
return alertController
|
||
|
}
|
||
|
|
||
|
func createNewFeedbackFlowControllerForScreenshotView(
|
||
|
_ viewForScreenshot: UIView,
|
||
|
settings: FeedbackSettings? = nil,
|
||
|
onFlowDidFinish: (() -> Void)? = nil,
|
||
|
onComplete: @escaping (NewFeedbackFlowController) -> Void
|
||
|
) {
|
||
|
// No-op
|
||
|
}
|
||
|
|
||
|
func createNewFeedbackFlowController(
|
||
|
_ settings: FeedbackSettings? = nil,
|
||
|
onFlowDidFinish: (() -> Void)? = nil,
|
||
|
onComplete: (NewFeedbackFlowController) -> Void
|
||
|
) {
|
||
|
do {
|
||
|
let flowController = try NewFeedbackFlowController(screenshot: nil, settings: settings)
|
||
|
flowController.onDidFinish = onFlowDidFinish
|
||
|
onComplete(flowController)
|
||
|
} catch {
|
||
|
assertionFailure("\(error)".formattedLoggingStatement)
|
||
|
onFlowDidFinish?()
|
||
|
}
|
||
|
}
|
||
|
}
|