forked from LoopKit/Loop
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLesson.swift
63 lines (42 loc) · 1.23 KB
/
Lesson.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
62
63
//
// Lesson.swift
// Learn
//
// Copyright © 2019 LoopKit Authors. All rights reserved.
//
import Foundation
import UIKit
protocol Lesson {
init(dataManager: DataManager)
var title: String { get }
var subtitle: String { get }
var configurationSections: [LessonSectionProviding] { get }
func execute(completion: @escaping (_ resultSections: [LessonSectionProviding]) -> Void)
}
protocol LessonSectionProviding {
var headerTitle: String? { get }
var footerTitle: String? { get }
var cells: [LessonCellProviding] { get }
}
extension LessonSectionProviding {
var headerTitle: String? {
return nil
}
var footerTitle: String? {
return nil
}
}
protocol LessonCellProviding {
func registerCell(for tableView: UITableView)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
}
struct LessonSection: LessonSectionProviding {
let headerTitle: String?
let footerTitle: String?
let cells: [LessonCellProviding]
init(headerTitle: String? = nil, footerTitle: String? = nil, cells: [LessonCellProviding]) {
self.headerTitle = headerTitle
self.footerTitle = footerTitle
self.cells = cells
}
}