|
@@ -67,6 +67,8 @@ public class ProfileViewController: UITableViewController {
|
|
|
var publicBanner = FloatingNotificationBanner()
|
|
|
|
|
|
var fromAPI = false
|
|
|
+ var timerSwitchPA = Timer()
|
|
|
+ var timerSwitchAC = Timer()
|
|
|
|
|
|
private func reload() {
|
|
|
if let user = self.user {
|
|
@@ -160,15 +162,15 @@ public class ProfileViewController: UITableViewController {
|
|
|
}
|
|
|
|
|
|
public override func viewWillAppear(_ animated: Bool) {
|
|
|
- if navigationController?.navigationBar.backgroundColor != .clear || self.traitCollection.userInterfaceStyle == .dark {
|
|
|
+// if navigationController?.navigationBar.backgroundColor != .clear || self.traitCollection.userInterfaceStyle == .dark {
|
|
|
navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
|
|
|
navigationController?.navigationBar.tintColor = .white
|
|
|
navigationItem.rightBarButtonItem?.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white], for: .normal)
|
|
|
- } else {
|
|
|
- navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
|
|
|
- navigationController?.navigationBar.tintColor = .black
|
|
|
- navigationItem.rightBarButtonItem?.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.black], for: .normal)
|
|
|
- }
|
|
|
+// } else {
|
|
|
+// navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
|
|
|
+// navigationController?.navigationBar.tintColor = .black
|
|
|
+// navigationItem.rightBarButtonItem?.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.black], for: .normal)
|
|
|
+// }
|
|
|
if fromListFriend {
|
|
|
if let me = UserDefaults.standard.string(forKey: "me"), me == self.data || self.flag == Flag.me {
|
|
|
Database.shared.database?.inTransaction({ fmdb, rollback in
|
|
@@ -204,14 +206,15 @@ public class ProfileViewController: UITableViewController {
|
|
|
profile.isUserInteractionEnabled = true
|
|
|
profile.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(profileTapped)))
|
|
|
|
|
|
+ let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 16.0), NSAttributedString.Key.foregroundColor: UIColor.white]
|
|
|
+ let navBarAppearance = UINavigationBarAppearance()
|
|
|
+ navBarAppearance.configureWithOpaqueBackground()
|
|
|
+ navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
|
|
|
+ navBarAppearance.titleTextAttributes = attributes
|
|
|
+ navigationController?.navigationBar.standardAppearance = navBarAppearance
|
|
|
+ navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
|
|
|
+
|
|
|
if fromAPI {
|
|
|
- let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 16.0), NSAttributedString.Key.foregroundColor: UIColor.white]
|
|
|
- let navBarAppearance = UINavigationBarAppearance()
|
|
|
- navBarAppearance.configureWithOpaqueBackground()
|
|
|
- navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
|
|
|
- navBarAppearance.titleTextAttributes = attributes
|
|
|
- navigationController?.navigationBar.standardAppearance = navBarAppearance
|
|
|
- navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
|
|
|
let backButton = UIBarButtonItem(image: UIImage(systemName: "chevron.backward"), style: .plain, target: self, action: #selector(self.didTapExit))
|
|
|
self.navigationItem.leftBarButtonItem = backButton
|
|
|
}
|
|
@@ -273,41 +276,44 @@ public class ProfileViewController: UITableViewController {
|
|
|
}
|
|
|
|
|
|
@objc func acceptCallSwitch(mySwitch: UISwitch) {
|
|
|
- let value = mySwitch.isOn
|
|
|
- if !CheckConnection.isConnectedToNetwork() || API.nGetCLXConnState() == 0 {
|
|
|
- let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
- imageView.tintColor = .white
|
|
|
- publicBanner.dismiss()
|
|
|
- publicBanner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
- publicBanner.show()
|
|
|
- self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
- return
|
|
|
- }
|
|
|
- DispatchQueue.global().async {
|
|
|
- let tMessage = CoreMessage_TMessageBank.getChangePersonInfo_New(p_f_pin: self.data)
|
|
|
- tMessage.mBodies[CoreMessage_TMessageKey.OFFLINE_MODE] = value ? "0" : "1"
|
|
|
- if let resp = Nexilis.writeAndWait(message: tMessage) {
|
|
|
- if resp.isOk() {
|
|
|
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
- _ = Database.shared.updateRecord(fmdb: fmdb, table: "BUDDY", cvalues: [
|
|
|
- "offline_mode" : value ? "0" : "1"
|
|
|
- ], _where: "f_pin = '\(self.data)'")
|
|
|
- })
|
|
|
- DispatchQueue.main.async { [self] in
|
|
|
- let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
|
|
|
- imageView.tintColor = .white
|
|
|
- publicBanner.dismiss()
|
|
|
- publicBanner = FloatingNotificationBanner(title: "Successfully changed".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
|
|
|
- publicBanner.show()
|
|
|
- }
|
|
|
- } else {
|
|
|
- DispatchQueue.main.async { [self] in
|
|
|
- let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
- imageView.tintColor = .white
|
|
|
- publicBanner.dismiss()
|
|
|
- publicBanner = FloatingNotificationBanner(title: "Unable to access servers".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
- publicBanner.show()
|
|
|
- self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
+ timerSwitchAC.invalidate()
|
|
|
+ timerSwitchAC = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { [self] _ in
|
|
|
+ let value = mySwitch.isOn
|
|
|
+ if !CheckConnection.isConnectedToNetwork() || API.nGetCLXConnState() == 0 {
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ publicBanner.dismiss()
|
|
|
+ publicBanner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ publicBanner.show()
|
|
|
+ self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ DispatchQueue.global().async {
|
|
|
+ let tMessage = CoreMessage_TMessageBank.getChangePersonInfo_New(p_f_pin: self.data)
|
|
|
+ tMessage.mBodies[CoreMessage_TMessageKey.OFFLINE_MODE] = value ? "0" : "1"
|
|
|
+ if let resp = Nexilis.writeAndWait(message: tMessage) {
|
|
|
+ if resp.isOk() {
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ _ = Database.shared.updateRecord(fmdb: fmdb, table: "BUDDY", cvalues: [
|
|
|
+ "offline_mode" : value ? "0" : "1"
|
|
|
+ ], _where: "f_pin = '\(self.data)'")
|
|
|
+ })
|
|
|
+ DispatchQueue.main.async { [self] in
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ publicBanner.dismiss()
|
|
|
+ publicBanner = FloatingNotificationBanner(title: "Successfully changed".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
|
|
|
+ publicBanner.show()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ DispatchQueue.main.async { [self] in
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ publicBanner.dismiss()
|
|
|
+ publicBanner = FloatingNotificationBanner(title: "Unable to access servers".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ publicBanner.show()
|
|
|
+ self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -315,41 +321,44 @@ public class ProfileViewController: UITableViewController {
|
|
|
}
|
|
|
|
|
|
@objc func privateAccountSwitch(mySwitch: UISwitch) {
|
|
|
- let value = mySwitch.isOn
|
|
|
- if !CheckConnection.isConnectedToNetwork() || API.nGetCLXConnState() == 0 {
|
|
|
- let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
- imageView.tintColor = .white
|
|
|
- publicBanner.dismiss()
|
|
|
- publicBanner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
- publicBanner.show()
|
|
|
- self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
- return
|
|
|
- }
|
|
|
- DispatchQueue.global().async {
|
|
|
- let tMessage = CoreMessage_TMessageBank.getChangePersonInfo_New(p_f_pin: self.data)
|
|
|
- tMessage.mBodies[CoreMessage_TMessageKey.PRIVACY_FLAG] = value ? "1" : "0"
|
|
|
- if let resp = Nexilis.writeAndWait(message: tMessage) {
|
|
|
- if resp.isOk() {
|
|
|
- Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
- _ = Database.shared.updateRecord(fmdb: fmdb, table: "BUDDY", cvalues: [
|
|
|
- "privacy_flag" : value ? "1" : "0"
|
|
|
- ], _where: "f_pin = '\(self.data)'")
|
|
|
- })
|
|
|
- DispatchQueue.main.async { [self] in
|
|
|
- let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
|
|
|
- imageView.tintColor = .white
|
|
|
- publicBanner.dismiss()
|
|
|
- publicBanner = FloatingNotificationBanner(title: "Successfully changed".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
|
|
|
- publicBanner.show()
|
|
|
- }
|
|
|
- } else {
|
|
|
- DispatchQueue.main.async { [self] in
|
|
|
- let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
- imageView.tintColor = .white
|
|
|
- publicBanner.dismiss()
|
|
|
- publicBanner = FloatingNotificationBanner(title: "Unable to access servers".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
- publicBanner.show()
|
|
|
- self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
+ timerSwitchPA.invalidate()
|
|
|
+ timerSwitchPA = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { [self] _ in
|
|
|
+ let value = mySwitch.isOn
|
|
|
+ if !CheckConnection.isConnectedToNetwork() || API.nGetCLXConnState() == 0 {
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ publicBanner.dismiss()
|
|
|
+ publicBanner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ publicBanner.show()
|
|
|
+ self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ DispatchQueue.global().async {
|
|
|
+ let tMessage = CoreMessage_TMessageBank.getChangePersonInfo_New(p_f_pin: self.data)
|
|
|
+ tMessage.mBodies[CoreMessage_TMessageKey.PRIVACY_FLAG] = value ? "1" : "0"
|
|
|
+ if let resp = Nexilis.writeAndWait(message: tMessage) {
|
|
|
+ if resp.isOk() {
|
|
|
+ Database.shared.database?.inTransaction({ (fmdb, rollback) in
|
|
|
+ _ = Database.shared.updateRecord(fmdb: fmdb, table: "BUDDY", cvalues: [
|
|
|
+ "privacy_flag" : value ? "1" : "0"
|
|
|
+ ], _where: "f_pin = '\(self.data)'")
|
|
|
+ })
|
|
|
+ DispatchQueue.main.async { [self] in
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ publicBanner.dismiss()
|
|
|
+ publicBanner = FloatingNotificationBanner(title: "Successfully changed".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
|
|
|
+ publicBanner.show()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ DispatchQueue.main.async { [self] in
|
|
|
+ let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
|
|
|
+ imageView.tintColor = .white
|
|
|
+ publicBanner.dismiss()
|
|
|
+ publicBanner = FloatingNotificationBanner(title: "Unable to access servers".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
|
|
|
+ publicBanner.show()
|
|
|
+ self.switchPrivateAccount.setOn(!value, animated: true)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -372,6 +381,10 @@ public class ProfileViewController: UITableViewController {
|
|
|
}
|
|
|
|
|
|
@objc func call(sender: Any) {
|
|
|
+ if !Nexilis.checkingAccess(key: "audio_call") {
|
|
|
+ showToast(message: "Feature disabled..".localized(), font: UIFont.systemFont(ofSize: 12), controller: self)
|
|
|
+ return
|
|
|
+ }
|
|
|
let myData = User.getData(pin: self.data)
|
|
|
if myData?.ex_block == "1" || myData?.ex_block == "-1" {
|
|
|
var title = "You blocked this user".localized()
|
|
@@ -401,6 +414,10 @@ public class ProfileViewController: UITableViewController {
|
|
|
}
|
|
|
|
|
|
@objc func video(sender: Any) {
|
|
|
+ if !Nexilis.checkingAccess(key: "video_call") {
|
|
|
+ showToast(message: "Feature disabled..".localized(), font: UIFont.systemFont(ofSize: 12), controller: self)
|
|
|
+ return
|
|
|
+ }
|
|
|
let myData = User.getData(pin: self.data)
|
|
|
if myData?.ex_block == "1" || myData?.ex_block == "-1" {
|
|
|
var title = "You blocked this user".localized()
|