-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathPrimaryViewController.swift
More file actions
37 lines (33 loc) · 1.17 KB
/
PrimaryViewController.swift
File metadata and controls
37 lines (33 loc) · 1.17 KB
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
//
// PrimaryViewController.swift
// Example
//
// Created by Denys Telezhkin on 23.08.15.
// Copyright © 2015 Denys Telezhkin. All rights reserved.
//
import UIKit
import DTCollectionViewManager
import SwiftUI
class PrimaryViewController: UICollectionViewController, DTCollectionViewManageable {
convenience init() {
self.init(collectionViewLayout: UICollectionViewCompositionalLayout.list(using: .init(appearance: .sidebarPlain)))
}
override func viewDidLoad() {
super.viewDidLoad()
manager.registerHostingConfiguration(for: Example.self, cell: UICollectionViewListCell.self) { cell, model, indexPath in
UIHostingConfiguration {
HStack {
Text(model.title)
Spacer()
}
}
} mapping: { [weak self] in
$0.didSelect { _, example, _ in
let controller = example.controller
self?.splitViewController?.setViewController(controller, for: .secondary)
self?.splitViewController?.show(.secondary)
}
}
manager.memoryStorage.setItems(Example.allCases)
}
}