kevin 3 жил өмнө
parent
commit
0ab6ddaf22

+ 3 - 3
appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift

@@ -104,9 +104,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
         // Override point for customization after application launch.
-//        Nexilis.connect(apiKey: "09ED34439CFE435E5D528E73F2D3DC1B23307B56EAB28A4883700D47BB5ADE07", delegate: self)
-//        Nexilis.connect(apiKey: "E6FF534BDA45A78619488E44AC90592327DDF33ACF6213A58DB55B78300BA8EE", delegate: self)
-        Nexilis.connect(apiKey: "***REPLACE***WITH***YOUR***ACCOUNT***", delegate: self, showButton: false)
+        // Nexilis.connect(apiKey: "09ED34439CFE435E5D528E73F2D3DC1B23307B56EAB28A4883700D47BB5ADE07", delegate: self, showButton: false)
+//        Nexilis.connect(apiKey: "E6FF534BDA45A78619488E44AC90592327DDF33ACF6213A58DB55B78300BA8EE", delegate: self, showButton: false)
+       Nexilis.connect(apiKey: "***REPLACE***WITH***YOUR***ACCOUNT***", delegate: self, showButton: false)
         if let response = Nexilis.writeSync(message: getPrefs(key: ""), timeout: 5000) {
             if response.mBodies[CoreMessage_TMessageKey.ERRCOD] == "00" {
                 let data = response.getBody(key: CoreMessage_TMessageKey.DATA)

+ 2 - 1
appbuilder-ios/AppBuilder/AppBuilder/ThirdTabViewController.swift

@@ -8,7 +8,7 @@
 import UIKit
 import WebKit
 
-class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureRecognizerDelegate  {
+class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureRecognizerDelegate, WKNavigationDelegate  {
 
     @IBOutlet weak var webView: WKWebView!
     var address = ""
@@ -24,6 +24,7 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         refreshControl.addTarget(self, action: #selector(reloadWebView(_:)), for: .valueChanged)
         webView.scrollView.addSubview(refreshControl)
         webView.scrollView.delegate = self
+        webView.navigationDelegate = self
         // Do any additional setup after loading the view.
     }
     

+ 84 - 31
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -103,9 +103,9 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
                 UIAction(title: "Call", handler: {[weak self](_) in
                     self?.callTap()
                 }),
-//                UIAction(title: "New Post", handler: {[weak self](_) in
-//
-//                }),
+                UIAction(title: "New Post", handler: {[weak self](_) in
+                    self?.postTap()
+                }),
                 UIAction(title: "Live Streaming", handler: {[weak self](_) in
                     self?.streamTap()
                 }),
@@ -114,7 +114,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
 //                }),
             ]
             let menu = UIMenu(title: "", children: childrenMenu)
-            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
+            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
         }
         if((cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX)){
             createMidFloatingButton()
@@ -267,17 +267,17 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
         ViewController.streamingButton.addTarget(self, action: #selector(streamTap), for: .touchUpInside)
 
         ViewController.postButton = UIButton(frame: CGRect(x: self.view.bounds.width / 2 - 30 , y: self.view.bounds.height - 80, width: 45, height: 45))
-        ViewController.postButton.setBackgroundImage(UIImage(named: "pb_button_stream", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal), for: .normal)
+        ViewController.postButton.setBackgroundImage(UIImage(named: "pb_button_post", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withRenderingMode(.alwaysOriginal), for: .normal)
         ViewController.postButton.layer.shadowColor = UIColor.black.cgColor
         ViewController.postButton.layer.shadowOpacity = 0.1
         ViewController.postButton.layer.shadowOffset = CGSize(width: 4, height: 4)
-        ViewController.postButton.addTarget(self, action: #selector(streamTap), for: .touchUpInside)
+        ViewController.postButton.addTarget(self, action: #selector(postTap), for: .touchUpInside)
         let buttonCenterX = self.view.bounds.width / 2
         let buttonCenterY = self.view.bounds.height - self.tabBar.bounds.height
         print("buttonCenterX \(buttonCenterX)")
         print("buttonCenterY \(buttonCenterY)")
         ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 40 , y: buttonCenterY - 40, width: 80, height: 80))
-        ViewController.middleButton.setBackgroundImage(UIImage(named: "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
+        ViewController.middleButton.setBackgroundImage(UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
         ViewController.middleButton.layer.shadowColor = UIColor.black.cgColor
         ViewController.middleButton.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
         ViewController.middleButton.layer.shadowOpacity = 1.0
@@ -321,7 +321,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
                     self?.callTap()
                 }),
                 UIAction(title: "New Post", handler: {[weak self](_) in
-
+                    self?.postTap()
                 }),
                 UIAction(title: "Live Streaming", handler: {[weak self](_) in
                     self?.streamTap()
@@ -334,7 +334,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
                 childrenMenu.append(contentsOf: vc.childrenMenu)
             }
             let menu = UIMenu(title: "", children: childrenMenu)
-            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
+            navigationItem.rightBarButtonItem = UIBarButtonItem(image: resizeImage(image: UIImage(named: "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), primaryAction: .none, menu: menu)
         }
     }
     
@@ -356,17 +356,17 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
         }
     }
     
-    @objc func qmeraLongPress() {
-        let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
-        navigationController.modalPresentationStyle = .fullScreen
-//        navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
-        navigationController.navigationBar.isTranslucent = false
-//        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-//        navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
-        UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
-    }
+//    @objc func qmeraLongPress() {
+//        let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
+//        navigationController.modalPresentationStyle = .fullScreen
+////        navigationController.navigationBar.tintColor = .white
+//        navigationController.navigationBar.barTintColor = .mainColor
+//        navigationController.navigationBar.isTranslucent = false
+////        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
+////        navigationController.navigationBar.titleTextAttributes = textAttributes
+//        navigationController.view.backgroundColor = .mainColor
+//        UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
+//    }
     
     @objc func ccTap() {
         print("ccTap")
@@ -403,7 +403,9 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
                 UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
             }
         }
-        
+        if(ViewController.isExpandButton){
+            ViewController.expandButton()
+        }
     }
     
     @objc func streamTap() {
@@ -420,6 +422,9 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
             navigationController.view.backgroundColor = .mainColor
             UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
         }
+        if(ViewController.isExpandButton){
+            ViewController.expandButton()
+        }
     }
     
     @objc func callTap() {
@@ -437,6 +442,9 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
             navigationController.view.backgroundColor = .mainColor
             UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
         }
+        if(ViewController.isExpandButton){
+            ViewController.expandButton()
+        }
     }
     
     @objc func chatTap() {
@@ -453,18 +461,59 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
             navigationController.view.backgroundColor = .mainColor
             UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
         }
+        if(ViewController.isExpandButton){
+            ViewController.expandButton()
+        }
     }
     
-    @objc func settingTap() {
-        let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
-        navigationController.modalPresentationStyle = .fullScreen
-//        navigationController.navigationBar.tintColor = .white
-        navigationController.navigationBar.barTintColor = .mainColor
-        navigationController.navigationBar.isTranslucent = false
-//        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
-//        navigationController.navigationBar.titleTextAttributes = textAttributes
-        navigationController.view.backgroundColor = .mainColor
-        UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
+//    @objc func settingTap() {
+//        let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
+//        navigationController.modalPresentationStyle = .fullScreen
+////        navigationController.navigationBar.tintColor = .white
+//        navigationController.navigationBar.barTintColor = .mainColor
+//        navigationController.navigationBar.isTranslucent = false
+////        let textAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white]
+////        navigationController.navigationBar.titleTextAttributes = textAttributes
+//        navigationController.view.backgroundColor = .mainColor
+//        UIApplication.shared.windows.filter {$0.isKeyWindow}.first?.rootViewController?.present(navigationController, animated: true, completion: nil)
+//    }
+    
+    @objc func postTap() {
+        if(ViewController.checkIsChangePerson()){
+            let customTab = PrefsUtil.getCustomTab().split(separator: ",")
+            let cpaasMode = PrefsUtil.getCpaasMode()
+            var i = 0
+            var j = 0
+            print("custom tab post tap = \(customTab)")
+            while j < customTab.count {
+                if(((i == 1 && customTab.count == 3) || i == 2) &&
+                   (cpaasMode == PrefsUtil.CPAAS_MODE_DOCKED || cpaasMode == PrefsUtil.CPAAS_MODE_MIX)){
+                    
+                }
+                else {
+                    if customTab[j] == "3" {
+                        break
+                    }
+                    j += 1
+                }
+                i += 1
+            }
+            if(j < customTab.count){
+                self.selectedIndex = i
+                
+                DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + .seconds(1), execute: {
+                    let me = UserDefaults.standard.string(forKey: "me")
+                    let address = "https://qmera.io/nexilis/pages/tab5-new-post?f_pin=\(me ?? "")"
+                    if let url = URL(string: address){
+                        self.thirdTab?.webView.evaluateJavaScript("window.location = '\(address)'")
+                    }
+                })
+            }
+        }
+        if(ViewController.isExpandButton){
+            ViewController.expandButton()
+        }
+        
     }
     
     public static func showDockedButton() {
@@ -484,6 +533,10 @@ class ViewController: UITabBarController, UITabBarControllerDelegate {
     }
     
     public static func expandButton() {
+        let cpaasMode = PrefsUtil.getCpaasMode()
+        if cpaasMode != PrefsUtil.CPAAS_MODE_DOCKED && cpaasMode != PrefsUtil.CPAAS_MODE_MIX {
+            return
+        }
         if ViewController.alwaysHideButton && !ViewController.isExpandButton {
             return
         }

+ 21 - 0
appbuilder-ios/NexilisLite/NexilisLite/Resource/Assets.xcassets/pb_button_post.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "pb_button_post.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
appbuilder-ios/NexilisLite/NexilisLite/Resource/Assets.xcassets/pb_button_post.imageset/pb_button_post.png


+ 5 - 4
src/mainIOS.py

@@ -162,7 +162,7 @@ def change_font(c_code_path, font):
 def change_logo(c_code_path, lib_dest, logo, logo_float=None):
     app_icon_set = [29,40,57,58,60,80,87,114,120,180,1024]
     app_icon_dir = os.path.join(c_code_path, 'Assets.xcassets/AppIcon.appiconset')
-    app_float_dir = os.path.join(lib_dest, 'NexilisLite/Resource/Assets.xcassets/pb_ball.imageset')
+    app_float_dir = os.path.join(lib_dest, 'NexilisLite/Resource/Assets.xcassets/pb_button.imageset')
     if isinstance(logo, str):
         # try:
         #     logo_url = requests.get('https://newuniverse.io/dashboardv2/uploads/logo/{}'.format(logo))
@@ -199,7 +199,7 @@ def change_logo(c_code_path, lib_dest, logo, logo_float=None):
             # except:
             try:
                 logo_float_path = os.path.join(app.asset_folder, "logofloat", "{}".format(logo_float))
-                img_path = os.path.join(app_float_dir, "pb_ball.png".format(size))
+                img_path = os.path.join(app_float_dir, "pb_button.png".format(size))
                 with open(logo_float_path, "rb") as f:
                     l = Image.open(f)
                     l = l.resize((size, size))
@@ -314,7 +314,8 @@ def change_access(c_code_path, access_model):
     print(code_path)
     with open(code_path, "r") as f:
         file_source = f.read()
-    replaced = file_source.replace("= CPAAS_MODE_DOCKED", "= {}".format(access[access_model]))
+    acc = "CPAAS_MODE_MIX" if access_model > 2 else access[access_model]
+    replaced = file_source.replace("= CPAAS_MODE_DOCKED", "= {}".format(acc))
     with open(code_path, "w") as f:
         f.write(replaced)
     pass
@@ -573,7 +574,7 @@ def build_apk():
 
         derived_data = os.path.join(app.app_folder, 'Library/Developer/Xcode/DerivedData')
         if os.path.exists(derived_data):
-            shutil.rmtree(derived_data)
+            shutil.rmtree(derived_data,ignore_errors=True)
         path_dest, c_code_path, lib_dest = create_folder(package_id, app_name)
         vprint("path_dest: " + path_dest)
         vprint("c_code_path: " + c_code_path)