8
8
9
9
import UIKit
10
10
import MessageUI
11
+ import SafariServices
11
12
12
13
class SettingsVC : UITableViewController , MFMailComposeViewControllerDelegate {
13
14
@@ -18,6 +19,7 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
18
19
enum sectionNames {
19
20
case general
20
21
case contact
22
+ case bottom
21
23
}
22
24
}
23
25
@@ -27,6 +29,8 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
27
29
enum cellNames {
28
30
case northType
29
31
case contact
32
+ case terms
33
+ case share
30
34
case red
31
35
}
32
36
}
@@ -36,15 +40,15 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
36
40
cell ( name: . northType) ,
37
41
cell ( name: . red) ,
38
42
cell ( name: . red) ,
39
- cell ( name: . red) ,
40
- cell ( name: . red) ,
41
- cell ( name: . red) ,
42
- cell ( name: . red) ,
43
43
cell ( name: . red)
44
44
] ) ,
45
45
section ( name: . contact, cells: [
46
46
cell ( name: . contact) ,
47
47
cell ( name: . contact)
48
+ ] ) ,
49
+ section ( name: . bottom, cells: [
50
+ cell ( name: . terms) ,
51
+ cell ( name: . share)
48
52
] )
49
53
]
50
54
@@ -56,9 +60,10 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
56
60
navigationItem. rightBarButtonItem = UIBarButtonItem ( title: " Done " , style: . done, target: self , action: #selector( donePressed) )
57
61
58
62
tableView = UITableView ( frame: self . tableView. frame, style: . insetGrouped)
59
- tableView. register ( UITableViewCell . self, forCellReuseIdentifier: " cellID " )
63
+ tableView. register ( UITableViewCell . self, forCellReuseIdentifier: UITableViewCell . cellID)
60
64
tableView. register ( SegmentedCell . self, forCellReuseIdentifier: SegmentedCell . id)
61
65
tableView. register ( ContactCell . self, forCellReuseIdentifier: ContactCell . id)
66
+ //tableView.sectionHeaderHeight = 70
62
67
}
63
68
64
69
@objc func donePressed( ) {
@@ -77,8 +82,16 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
77
82
cell. iconImageView. image = contactInfo [ indexPath. row] . 0
78
83
cell. infoLabel. text = contactInfo [ indexPath. row] . 1
79
84
return cell
85
+ case . terms:
86
+ let cell = tableView. dequeueReusableCell ( withIdentifier: UITableViewCell . cellID, for: indexPath)
87
+ cell. textLabel? . text = " Terms and Privacy Policy "
88
+ return cell
89
+ case . share:
90
+ let cell = tableView. dequeueReusableCell ( withIdentifier: UITableViewCell . cellID, for: indexPath)
91
+ cell. textLabel? . text = " Share "
92
+ return cell
80
93
case . red:
81
- let cell = tableView. dequeueReusableCell ( withIdentifier: " cellID " , for: indexPath)
94
+ let cell = tableView. dequeueReusableCell ( withIdentifier: UITableViewCell . cellID, for: indexPath)
82
95
cell. textLabel? . text = " y \( indexPath. row) lo "
83
96
return cell
84
97
}
@@ -94,27 +107,23 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
94
107
95
108
override func tableView( _ tableView: UITableView , titleForHeaderInSection section: Int ) -> String ? {
96
109
switch sectionArray [ section] . name {
97
- case . general: return nil
110
+ case . general, . bottom : return nil
98
111
case . contact: return " Contact "
99
112
}
100
113
}
101
114
102
115
override func tableView( _ tableView: UITableView , viewForFooterInSection section: Int ) -> UIView ? {
103
- if section == ( tableView. numberOfSections - 1 ) {
116
+ if section == tableView. numberOfSections - 1 {
104
117
return SettingsFooterView ( )
105
118
}
106
119
return nil
107
120
}
108
121
109
- override func tableView( _ tableView: UITableView , heightForHeaderInSection section: Int ) -> CGFloat {
110
- return 70
111
- }
112
-
113
122
override func tableView( _ tableView: UITableView , heightForFooterInSection section: Int ) -> CGFloat {
114
123
if section == ( tableView. numberOfSections - 1 ) {
115
124
return 75
116
125
}
117
- return . leastNormalMagnitude
126
+ return 20
118
127
}
119
128
120
129
override func tableView( _ tableView: UITableView , didSelectRowAt indexPath: IndexPath ) {
@@ -144,20 +153,19 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
144
153
}
145
154
}
146
155
}
156
+ case . terms:
157
+ guard let url = URL ( string: " http://alqazwini.org/turbah/privacyandterms.html " ) else { return }
158
+ let safariView = SFSafariViewController ( url: url)
159
+ present ( safariView, animated: true )
160
+ case . share:
161
+ let activityVC = UIActivityViewController ( activityItems: [ appURL, " Turbah - تـربـة " ] , applicationActivities: nil )
162
+ activityVC. popoverPresentationController? . sourceView = self . view
163
+ present ( activityVC, animated: true )
147
164
default : break
148
165
}
149
166
tableView. deselectRow ( at: indexPath, animated: true )
150
167
}
151
168
152
- // override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
153
- // switch sectionArray[indexPath.section].cells[indexPath.row].name {
154
- // case .northType:
155
- // return UITableView.automaticDimension
156
- // default:
157
- // return 55
158
- // }
159
- // }
160
-
161
169
162
170
@objc private func northTypeChanged( _ sender: UISegmentedControl ) {
163
171
save. northType = sender. selectedSegmentIndex
0 commit comments