-
Notifications
You must be signed in to change notification settings - Fork 7
/
SettingController.swift
156 lines (110 loc) · 4.69 KB
/
SettingController.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//
// SettingController.swift
// DUPME
//
// Created by Hossein on 22/12/2016.
// Copyright © 2016 Dupify. All rights reserved.
//
//
//setting view
import UIKit
import LBTAComponents
class SettingController: DatasourceController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .lightGray
let homeDatasource = HomeDatasource3()
self.datasource = homeDatasource
}
override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: view.frame.width, height: 30)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: view.frame.width, height: 50)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
return CGSize(width: view.frame.width, height: 50)
}
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
print(datasource?.item(indexPath)! as Any)
}
}
class HomeDatasource3: Datasource {
let content = ["Share This App", "DUPME on Social Media", "Edit Account Info", "Language", "Settings", "Share This App", "Report a Bug", "Help Center", "Supports", "Community Guidelines", "Terms of Use", "Privscy Policy", "Licences and Credits", "About", "Log Out"]
override func footerClasses() -> [AnyClass]? {
return [SettingFooter.self]
}
override func headerClasses() -> [AnyClass]? {
return [SettingHeader.self]
}
override func cellClasses() -> [DatasourceCell.Type] {
return [SettingCell.self]
}
override func item(_ indexPath: IndexPath) -> Any? {
return content[indexPath.item]
}
override func numberOfItems(_ section: Int) -> Int {
return content.count
}
}
class SettingHeader: DatasourceCell {
let nameLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "WHO TO FOLLOW"
label.font = UIFont.systemFont(ofSize: 16)
label.font = UIFont.boldSystemFont(ofSize: 11)
return label
}()
override func setupViews() {
separatorLineView.isHidden = false
separatorLineView.backgroundColor = UIColor(r: 230, g: 230, b: 230)
addSubview(nameLabel)
nameLabel.anchor(topAnchor, left: leftAnchor, bottom: bottomAnchor, right: rightAnchor, topConstant: 0, leftConstant: 12, bottomConstant: 0, rightConstant: 0, widthConstant: 0, heightConstant: 0)
}
}
class SettingFooter: DatasourceCell {
let nameLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.text = "Footer"
label.font = UIFont.systemFont(ofSize: 16)
label.font = UIFont.boldSystemFont(ofSize: 11)
return label
}()
override func setupViews() {
separatorLineView.isHidden = false
separatorLineView.backgroundColor = UIColor(r: 230, g: 230, b: 230)
addSubview(nameLabel)
nameLabel.anchor(topAnchor, left: leftAnchor, bottom: bottomAnchor, right: rightAnchor, topConstant: 0, leftConstant: 12, bottomConstant: 0, rightConstant: 0, widthConstant: 0, heightConstant: 0)
}
}
class SettingCell: DatasourceCell {
override var datasourceItem: Any? {
didSet{
nameLabel.text = datasourceItem as? String
}
}
let nameLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.font = UIFont(name: "Freight-Sans", size: 13)
return label
}()
override func setupViews() {
separatorLineView.isHidden = false
separatorLineView.backgroundColor = UIColor(r: 230, g: 230, b: 230)
addSubview(nameLabel)
nameLabel.anchor(topAnchor, left: leftAnchor, bottom: bottomAnchor, right: rightAnchor, topConstant: 0, leftConstant: 12, bottomConstant: 0, rightConstant: 0, widthConstant: 0, heightConstant: 0)
}
}
//handle logout function
//func handleeeLogOut(){
// do {
// try FIRAuth.auth()?.signOut()
// } catch let logoutError {
// print(logoutError)
// }
// let loginController = LoginController()
// present(loginController, animated: true, completion: nil)
//}