|
@@ -127,10 +127,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
let menu = UIMenu(title: "", children: childrenMenu)
|
|
let menu = UIMenu(title: "", children: childrenMenu)
|
|
if PrefsUtil.getIconDock() != nil {
|
|
if PrefsUtil.getIconDock() != nil {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: PrefsUtil.getUrlDock()!)!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: self.resizeImage(image: UIImage(data: data!)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() { [self] in
|
|
|
|
+ navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -328,10 +329,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 50 , y: buttonCenterY - 55, width: 100, height: 100))
|
|
ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 50 , y: buttonCenterY - 55, width: 100, height: 100))
|
|
if PrefsUtil.getIconDock() != nil {
|
|
if PrefsUtil.getIconDock() != nil {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: PrefsUtil.getUrlDock()!)!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- ViewController.middleButton.setBackgroundImage(UIImage(data: data!), for: .normal)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() {
|
|
|
|
+ ViewController.middleButton.setBackgroundImage(UIImage(data: data), for: .normal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -396,10 +398,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
let menu = UIMenu(title: "", children: childrenMenu)
|
|
let menu = UIMenu(title: "", children: childrenMenu)
|
|
if PrefsUtil.getIconDock() != nil {
|
|
if PrefsUtil.getIconDock() != nil {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: PrefsUtil.getUrlDock()!)!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: self.resizeImage(image: UIImage(data: data!)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() { [self] in
|
|
|
|
+ navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(data: data)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -450,6 +453,20 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
func showWelocomeView() {
|
|
func showWelocomeView() {
|
|
if let viewWelcome = welcomeVC.view {
|
|
if let viewWelcome = welcomeVC.view {
|
|
viewWelcome.backgroundColor = .white
|
|
viewWelcome.backgroundColor = .white
|
|
|
|
+ DispatchQueue.global().async {
|
|
|
|
+ if let listBg = PrefsUtil.getBackground() {
|
|
|
|
+ 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() {
|
|
|
|
+ viewWelcome.backgroundColor = UIColor(patternImage: UIImage(data: data)!)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
let welcomeTitle = UILabel()
|
|
let welcomeTitle = UILabel()
|
|
welcomeTitle.text = "Welcome to".localized() + " " + (Bundle.main.displayName ?? "")
|
|
welcomeTitle.text = "Welcome to".localized() + " " + (Bundle.main.displayName ?? "")
|
|
welcomeTitle.font = .systemFont(ofSize: 25, weight: .bold)
|
|
welcomeTitle.font = .systemFont(ofSize: 25, weight: .bold)
|
|
@@ -808,10 +825,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
if count == 0 {
|
|
if count == 0 {
|
|
if !icon.isEmpty {
|
|
if !icon.isEmpty {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- ViewController.chatButton.setBackgroundImage(UIImage(data: data!), for: .normal)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() {
|
|
|
|
+ ViewController.chatButton.setBackgroundImage(UIImage(data: data), for: .normal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -821,10 +839,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
} else if count == 1 {
|
|
} else if count == 1 {
|
|
if !icon.isEmpty {
|
|
if !icon.isEmpty {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: "https://\(Nexilis.ADDRESS)/filepalio/image/\(icon)")!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- ViewController.callButton.setBackgroundImage(UIImage(data: data!), for: .normal)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() {
|
|
|
|
+ ViewController.callButton.setBackgroundImage(UIImage(data: data), for: .normal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -834,10 +853,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
} else if count == 2 {
|
|
} else if count == 2 {
|
|
if !icon.isEmpty {
|
|
if !icon.isEmpty {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- ViewController.ccButton.setBackgroundImage(UIImage(data: data!), for: .normal)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() {
|
|
|
|
+ ViewController.ccButton.setBackgroundImage(UIImage(data: data), for: .normal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -847,10 +867,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
} else if count == 3 {
|
|
} else if count == 3 {
|
|
if !icon.isEmpty {
|
|
if !icon.isEmpty {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- ViewController.postButton.setBackgroundImage(UIImage(data: data!), for: .normal)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() {
|
|
|
|
+ ViewController.postButton.setBackgroundImage(UIImage(data: data), for: .normal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -860,10 +881,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
} else if count == 4 {
|
|
} else if count == 4 {
|
|
if !icon.isEmpty {
|
|
if !icon.isEmpty {
|
|
DispatchQueue.global().async {
|
|
DispatchQueue.global().async {
|
|
- let data = try? Data(contentsOf: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) //make sure your image in this url does exist, otherwise unwrap in a if let check / try-catch
|
|
|
|
- DispatchQueue.main.async {
|
|
|
|
- if data != nil {
|
|
|
|
- ViewController.streamingButton.setBackgroundImage(UIImage(data: data!), for: .normal)
|
|
|
|
|
|
+ ViewController.getDataImageFromUrl(from: URL(string: "http://202.158.33.26/filepalio/image/\(icon)")!) { data, response, error in
|
|
|
|
+ guard let data = data, error == nil else { return }
|
|
|
|
+ // always update the UI from the main thread
|
|
|
|
+ DispatchQueue.main.async() {
|
|
|
|
+ ViewController.streamingButton.setBackgroundImage(UIImage(data: data), for: .normal)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -976,6 +998,10 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
|
|
// ViewController.postButton.removeFromSuperview()
|
|
// ViewController.postButton.removeFromSuperview()
|
|
ViewController.middleButton.isHidden = true
|
|
ViewController.middleButton.isHidden = true
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static func getDataImageFromUrl(from url: URL, completion: @escaping (Data?, URLResponse?, Error?) -> ()) {
|
|
|
|
+ URLSession.shared.dataTask(with: url, completionHandler: completion).resume()
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|