Skip to content

Commit ad21ffa

Browse files
committed
Added terms and share cells in settings
1 parent ea5c82e commit ad21ffa

File tree

5 files changed

+54
-44
lines changed

5 files changed

+54
-44
lines changed

Turbah/Classes/Location.swift

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Foundation
1111
struct Coordinates {
1212
let lat: Double
1313
let lon: Double
14-
var dist: Double?
1514
}
1615

1716
enum Locations {

Turbah/Controllers/SettingsVC.swift

+30-22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import UIKit
1010
import MessageUI
11+
import SafariServices
1112

1213
class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
1314

@@ -18,6 +19,7 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
1819
enum sectionNames {
1920
case general
2021
case contact
22+
case bottom
2123
}
2224
}
2325

@@ -27,6 +29,8 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
2729
enum cellNames {
2830
case northType
2931
case contact
32+
case terms
33+
case share
3034
case red
3135
}
3236
}
@@ -36,15 +40,15 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
3640
cell(name: .northType),
3741
cell(name: .red),
3842
cell(name: .red),
39-
cell(name: .red),
40-
cell(name: .red),
41-
cell(name: .red),
42-
cell(name: .red),
4343
cell(name: .red)
4444
]),
4545
section(name: .contact, cells: [
4646
cell(name: .contact),
4747
cell(name: .contact)
48+
]),
49+
section(name: .bottom, cells: [
50+
cell(name: .terms),
51+
cell(name: .share)
4852
])
4953
]
5054

@@ -56,9 +60,10 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
5660
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(donePressed))
5761

5862
tableView = UITableView(frame: self.tableView.frame, style: .insetGrouped)
59-
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cellID")
63+
tableView.register(UITableViewCell.self, forCellReuseIdentifier: UITableViewCell.cellID)
6064
tableView.register(SegmentedCell.self, forCellReuseIdentifier: SegmentedCell.id)
6165
tableView.register(ContactCell.self, forCellReuseIdentifier: ContactCell.id)
66+
//tableView.sectionHeaderHeight = 70
6267
}
6368

6469
@objc func donePressed() {
@@ -77,8 +82,16 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
7782
cell.iconImageView.image = contactInfo[indexPath.row].0
7883
cell.infoLabel.text = contactInfo[indexPath.row].1
7984
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
8093
case .red:
81-
let cell = tableView.dequeueReusableCell(withIdentifier: "cellID", for: indexPath)
94+
let cell = tableView.dequeueReusableCell(withIdentifier: UITableViewCell.cellID, for: indexPath)
8295
cell.textLabel?.text = "y\(indexPath.row)lo"
8396
return cell
8497
}
@@ -94,27 +107,23 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
94107

95108
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
96109
switch sectionArray[section].name {
97-
case .general: return nil
110+
case .general, .bottom: return nil
98111
case .contact: return "Contact"
99112
}
100113
}
101114

102115
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
103-
if section == (tableView.numberOfSections - 1) {
116+
if section == tableView.numberOfSections - 1 {
104117
return SettingsFooterView()
105118
}
106119
return nil
107120
}
108121

109-
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
110-
return 70
111-
}
112-
113122
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
114123
if section == (tableView.numberOfSections - 1) {
115124
return 75
116125
}
117-
return .leastNormalMagnitude
126+
return 20
118127
}
119128

120129
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@@ -144,20 +153,19 @@ class SettingsVC: UITableViewController, MFMailComposeViewControllerDelegate {
144153
}
145154
}
146155
}
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)
147164
default: break
148165
}
149166
tableView.deselectRow(at: indexPath, animated: true)
150167
}
151168

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-
161169

162170
@objc private func northTypeChanged(_ sender: UISegmentedControl) {
163171
save.northType = sender.selectedSegmentIndex

Turbah/Controllers/ViewController.swift

+20-9
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,24 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve
9090
print("before", anchor.position)
9191
print("euler", arView.session.currentFrame!.camera.eulerAngles)
9292
let cameraAngles = arView.session.currentFrame!.camera.transform.columns.3
93-
let decreaseValue: Float = 4
94-
anchor.position.z = (-1.0 / decreaseValue)// + cameraAngles.z
95-
anchor.position.x = (Float(sin(bearingOfKabah.radiansToDegrees)) / decreaseValue)// + cameraAngles.x
93+
94+
let decreaseValue: Double = 3
95+
96+
anchor.position.z = Float(-1 * cos(bearingOfKabah) / decreaseValue) //(-1.0 / decreaseValue)// + cameraAngles.z
97+
anchor.position.x = Float(sin(bearingOfKabah) / decreaseValue) //(Float(sin(bearingOfKabah.radiansToDegrees)) / decreaseValue)// + cameraAngles.x
9698
//anchor.position.y += cameraAngles.y
9799
print("after", anchor.position)
98100

101+
let anchorAngles = anchor.transform.matrix.columns.3
102+
103+
//print("""
104+
//
105+
//camera: \(cameraAngles)
106+
//anchor: \(anchorAngles)
107+
//distance: \(length(cameraAngles - anchorAngles) * 3.28084) feet
108+
//
109+
//""")
110+
99111
turbahAdded = true
100112
}
101113

@@ -294,21 +306,20 @@ class ViewController: UIViewController, CLLocationManagerDelegate, ARCoachingOve
294306
let north = chosenHeading.degreesToRadians
295307
let directionOfKabah = north - bearingOfKabah
296308

297-
print("qibla degreees:", directionOfKabah.radiansToDegrees)
298-
print("qibla radians:", -directionOfKabah)
299-
print("")
309+
//print("qibla degreees:", directionOfKabah.radiansToDegrees)
310+
print("qibla radians:", directionOfKabah)
311+
print("anchor", anchor.transform.matrix.columns.3)
300312

301313
compassView.kabaImageView.transform = CGAffineTransform(rotationAngle: CGFloat(-directionOfKabah));
302-
303314
compassView.isPointingAtQibla = (directionOfKabah < 0.1 && directionOfKabah > -0.1)
304315

305316
let offAccept = 0.25
306317

307-
if directionOfKabah > offAccept || directionOfKabah < -.pi {
318+
if -directionOfKabah > offAccept || -directionOfKabah < -.pi {
308319
didSendFeedback = false
309320
leftImage.alpha = 0
310321
rightImage.alpha = 1
311-
} else if directionOfKabah < -offAccept && directionOfKabah > -.pi {
322+
} else if -directionOfKabah < -offAccept && -directionOfKabah > -.pi {
312323
didSendFeedback = false
313324
rightImage.alpha = 0
314325
leftImage.alpha = 1

Turbah/Super.swift

+4-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import UIKit
1010

1111
let save = UserDefaults.standard
1212

13+
let appURL = "http://itunes.apple.com/app/id1523945049"
14+
1315
var blurEffect: UIBlurEffect {
1416
return UIBlurEffect(style: .systemThinMaterial)
1517
}
@@ -57,18 +59,8 @@ extension UIView {
5759
}
5860

5961

60-
extension UIView {
61-
62-
func setAnchorPointV3(anchorPoint: CGPoint) {
63-
let oldOrigin = frame.origin
64-
layer.anchorPoint = anchorPoint
65-
let newOrigin = frame.origin
66-
67-
let translation = CGPoint(x: newOrigin.x - oldOrigin.x, y: newOrigin.y - oldOrigin.y)
68-
69-
center = CGPoint(x: center.x - translation.x, y: center.y - translation.y)
70-
}
71-
62+
extension UITableViewCell {
63+
static let cellID = "cellID"
7264
}
7365

7466

0 commit comments

Comments
 (0)