|
@@ -44,6 +44,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
static var listPullFB: [String] = []
|
|
static var listPullFB: [String] = []
|
|
static var datePullFB: Date?
|
|
static var datePullFB: Date?
|
|
let welcomeVC = UIViewController()
|
|
let welcomeVC = UIViewController()
|
|
|
|
+ let privacyPolicyVC = UIViewController()
|
|
var termVC: UIViewController?
|
|
var termVC: UIViewController?
|
|
let welcomeDesc = UILabel()
|
|
let welcomeDesc = UILabel()
|
|
let termText = "Read our Terms of Service. Tap \"Agree and Continue\" to accept Terms of Service.".localized()
|
|
let termText = "Read our Terms of Service. Tap \"Agree and Continue\" to accept Terms of Service.".localized()
|
|
@@ -441,9 +442,13 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
let acceptTerm = PrefsUtil.getTerms()
|
|
let acceptTerm = PrefsUtil.getTerms()
|
|
|
|
+ let enable_privacy_policy = PrefsUtil.getEnablePrivacyPolicy()
|
|
if !acceptTerm {
|
|
if !acceptTerm {
|
|
showWelocomeView()
|
|
showWelocomeView()
|
|
return
|
|
return
|
|
|
|
+ } else if enable_privacy_policy && !PrefsUtil.getAgreePrivacyPolicy() {
|
|
|
|
+ showPrivacyPolicyView()
|
|
|
|
+ return
|
|
} else {
|
|
} else {
|
|
if !Utils.getForceAnonymous() && !Utils.getSetProfile() {
|
|
if !Utils.getForceAnonymous() && !Utils.getSetProfile() {
|
|
let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "changeDevice") as! ChangeDeviceViewController
|
|
let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "changeDevice") as! ChangeDeviceViewController
|
|
@@ -474,6 +479,65 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ func showPrivacyPolicyView() {
|
|
|
|
+ if let privacyView = privacyPolicyVC.view {
|
|
|
|
+ let bgImage = UIImageView()
|
|
|
|
+ privacyView.addSubview(bgImage)
|
|
|
|
+ bgImage.anchor(top: privacyView.topAnchor, left: privacyView.leftAnchor, bottom: privacyView.bottomAnchor, right: privacyView.rightAnchor)
|
|
|
|
+ bgImage.backgroundColor = .white
|
|
|
|
+ DispatchQueue.global().async {
|
|
|
|
+ if let listBg = PrefsUtil.getBackground() {
|
|
|
|
+ if listBg.isEmpty {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var bgChoosen = ""
|
|
|
|
+ let arrayBg = listBg.split(separator: ",")
|
|
|
|
+ bgChoosen = String(arrayBg[Int.random(in: 0..<arrayBg.count)])
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getURLBase() + "/dashboardv2/uploads/background/" + bgChoosen)!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() {
|
|
|
|
+ bgImage.image = UIImage(data: data)!
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let containerButton = UIView()
|
|
|
|
+ privacyView.addSubview(containerButton)
|
|
|
|
+ containerButton.anchor(left: privacyView.safeAreaLayoutGuide.leftAnchor, bottom: privacyView.safeAreaLayoutGuide.bottomAnchor, paddingLeft: 10, paddingBottom: 10, minHeight: 40)
|
|
|
|
+ containerButton.rightAnchor.constraint(lessThanOrEqualTo: privacyView.safeAreaLayoutGuide.rightAnchor, constant: -10).isActive = true
|
|
|
|
+ containerButton.isUserInteractionEnabled = true
|
|
|
|
+ let tapgestureAgree = UITapGestureRecognizer(target: self, action: #selector(tappedOnAgreePrivacy(_ :)))
|
|
|
|
+ tapgestureAgree.numberOfTapsRequired = 1
|
|
|
|
+ containerButton.addGestureRecognizer(tapgestureAgree)
|
|
|
|
+
|
|
|
|
+ let imageAgree = UIImageView()
|
|
|
|
+ imageAgree.image = UIImage(systemName: "arrow.forward.circle")
|
|
|
|
+ imageAgree.tintColor = .black
|
|
|
|
+ containerButton.addSubview(imageAgree)
|
|
|
|
+ imageAgree.anchor(left: containerButton.leftAnchor, centerY: containerButton.centerYAnchor, width: 40, height: 40)
|
|
|
|
+
|
|
|
|
+ let titleAgree = UILabel()
|
|
|
|
+ titleAgree.text = "Agree and Continue".localized()
|
|
|
|
+ titleAgree.textColor = .black
|
|
|
|
+ containerButton.addSubview(titleAgree)
|
|
|
|
+ titleAgree.anchor(left: imageAgree.rightAnchor, right: containerButton.rightAnchor, paddingLeft: 5, centerY: containerButton.centerYAnchor)
|
|
|
|
+
|
|
|
|
+ let privacyWV = WKWebView()
|
|
|
|
+ privacyWV.isOpaque = false
|
|
|
|
+ privacyWV.backgroundColor = UIColor.clear
|
|
|
|
+ privacyWV.scrollView.backgroundColor = UIColor.clear
|
|
|
|
+ privacyWV.load(URLRequest(url: URL(string: PrefsUtil.getURLPrivacyPolicy())!))
|
|
|
|
+ privacyView.addSubview(privacyWV)
|
|
|
|
+ privacyWV.anchor(top: privacyView.safeAreaLayoutGuide.topAnchor, left: privacyView.leftAnchor, right: privacyView.rightAnchor, height: privacyView.bounds.height - 80)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ privacyPolicyVC.modalPresentationStyle = .fullScreen
|
|
|
|
+ privacyPolicyVC.modalTransitionStyle = .crossDissolve
|
|
|
|
+ self.present(privacyPolicyVC, animated: true)
|
|
|
|
+ }
|
|
|
|
+
|
|
func showWelocomeView() {
|
|
func showWelocomeView() {
|
|
if let viewWelcome = welcomeVC.view {
|
|
if let viewWelcome = welcomeVC.view {
|
|
let bgImage = UIImageView()
|
|
let bgImage = UIImageView()
|
|
@@ -589,6 +653,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
welcomeVC.dismiss(animated: true)
|
|
welcomeVC.dismiss(animated: true)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @objc func tappedOnAgreePrivacy(_ gesture: UITapGestureRecognizer) {
|
|
|
|
+ PrefsUtil.setAgreePrivacyPolicy(value: true)
|
|
|
|
+ privacyPolicyVC.dismiss(animated: true)
|
|
|
|
+ }
|
|
|
|
+
|
|
func checkRange(_ range: NSRange, contain index: Int) -> Bool {
|
|
func checkRange(_ range: NSRange, contain index: Int) -> Bool {
|
|
return index > range.location && index < range.location + range.length
|
|
return index > range.location && index < range.location + range.length
|
|
}
|
|
}
|