forked from ijoshsmith/Wizardry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSignUpWizardDataSource.swift
61 lines (49 loc) · 1.69 KB
/
SignUpWizardDataSource.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// SignUpWizardDataSource.swift
// WizardryDemo
//
// Created by Joshua Smith on 5/2/16.
// Copyright © 2016 iJoshSmith. All rights reserved.
//
import UIKit
import Wizardry
/// Creates the wizard steps managed by the Sign Up Wizard.
final class SignUpWizardDataSource {
fileprivate let model: SignUpWizardModel
init(model: SignUpWizardModel) {
self.model = model
}
}
// MARK: - WizardDataSource conformance
extension SignUpWizardDataSource: WizardDataSource {
var initialWizardStep: WizardStep {
return UsernameWizardStep(model: model)
}
func placementOf(wizardStep: WizardStep) -> WizardStepPlacement {
switch wizardStep {
case is UsernameWizardStep: return .initial
case is PasswordWizardStep: return .intermediate
default:
assert(wizardStep is SubmitWizardStep, "Unsupported: \(wizardStep)")
return .final
}
}
func wizardStepAfter(wizardStep: WizardStep) -> WizardStep? {
switch wizardStep {
case is UsernameWizardStep: return PasswordWizardStep(model: model)
case is PasswordWizardStep: return SubmitWizardStep(model: model)
default:
assert(wizardStep is SubmitWizardStep, "Unsupported: \(wizardStep)")
return nil
}
}
func wizardStepBefore(wizardStep: WizardStep) -> WizardStep? {
switch wizardStep {
case is UsernameWizardStep: return nil
case is PasswordWizardStep: return UsernameWizardStep(model: model)
default:
assert(wizardStep is SubmitWizardStep, "Unsupported: \(wizardStep)")
return PasswordWizardStep(model: model)
}
}
}