fahidattique55 / FAPanels

FAPanels - Swift
Apache License 2.0
851 stars 90 forks source link

Internal protection #47

Open penpens opened 5 years ago

penpens commented 5 years ago

I'm a n00bie in Swift and Xcode, and i can't understand the problem... I can't call that function because is declared "internal", i tried to remove the internal declaration, but nothing. Could someone help me?

schermata 2018-11-05 alle 08 31 36
fahidattique55 commented 5 years ago

@penpens

Please use this code to get the position of panel.

rootController.rightPanelPosition = .front
rootController.rightPanelPosition = .back
penpens commented 5 years ago

It gives me nil while wrapping an Optional value at: rootController.rightPanelPosition = .front

fahidattique55 commented 5 years ago

It means your root controller is getting nil some how. Can you share the chunk of code specially the code where you are initialising the FAPanelController.

fahidattique55 commented 5 years ago

Are you initialising the rootVC with storyboard or code ?

penpens commented 5 years ago

Do you mean this? Sorry I'm new in the iOS world

@IBAction func Login(_ sender: Any) {
        let mainS: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let left: LeftMenuVC = mainS.instantiateViewController(withIdentifier: "LeftMenuVC") as! LeftMenuVC
        let right: RightMenuVC = mainS.instantiateViewController(withIdentifier: "RightMenuVC") as! RightMenuVC
        let center: CenterVC = mainS.instantiateViewController(withIdentifier: "CenterVC1") as! CenterVC
        _ = UINavigationController(rootViewController: center)

        let rootController = FAPanelController()
        rootController.center(center).left(left).right(right)

        window?.rootViewController = rootController

        let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "Start") as UIViewController
        // .instantiatViewControllerWithIdentifier() returns AnyObject! this must be downcast to utilize it
        self.present(viewController, animated: false, completion: nil)
    }
fahidattique55 commented 5 years ago
  let mainS: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let left: LeftMenuVC = mainS.instantiateViewController(withIdentifier: "LeftMenuVC") as! LeftMenuVC
        let right: RightMenuVC = mainS.instantiateViewController(withIdentifier: "RightMenuVC") as! RightMenuVC
        let center: CenterVC = mainS.instantiateViewController(withIdentifier: "CenterVC1") as! CenterVC
        _ = UINavigationController(rootViewController: center)

        let rootController = FAPanelController()
        rootController.center(center).left(left).right(right)

        window?.rootViewController = rootController

The above code seems fine and I can see you are using FAPanelController using coding and not storyboard. Then you are presenting a new controller. Are you accessing the rootController in the presented controller ?

I think try accessing the current panel from the property self.panel which is optional and handle the optional validation.

fahidattique55 commented 5 years ago

if you want to access the panel configurations then the controller must be a FAPanelController. For some how you are accessing the rootController which is not a panel.

penpens commented 5 years ago

I trying with code and storyboard I attach some screens, I just took your classes and added to my project (with the library obv) So everything should be like your sample project

schermata 2018-11-08 alle 11 07 47
import UIKit
import FAPanels

class CenterVC: UIViewController {

    //  MARK:- IBOutlets

    @IBOutlet var centerPanelOnlyAnimOpts: UITextField!
    @IBOutlet var centerPanelOnlyAnimDuration: UILabel!
    @IBOutlet var pickerView: UIPickerView!

    @IBOutlet var leftAllowableEdge: UILabel!
    @IBOutlet var rightAllowableEdge: UILabel!

    @IBOutlet var sidePanelsOpenAnimDuration: UILabel!

    @IBOutlet var leftPanelPositionSwitch: UISwitch!
    @IBOutlet var rightPanelPositionSwitch: UISwitch!

    var window: UIWindow?

    //  MARK:- Class Properties

    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

    var pickerDataSource: [String] = ["flipFromLeft", "flipFromRight", "flipFromTop", "flipFromBottom", "curlUp", "curlDown", "crossDissolve", "moveRight", "moveLeft", "moveUp", "moveDown", "splitHorizotally", "splitVertically", "dumpFall", "boxFade"]

    //  MARK:- Life Cycle

    override func viewDidLoad() {
        super.viewDidLoad()

        viewConfigurations()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Functions

    func viewConfigurations() {

        pickerView.delegate = self
        pickerView.dataSource = self
        centerPanelOnlyAnimOpts.delegate = self
        centerPanelOnlyAnimOpts.inputView = pickerView

        panel!.rightPanelPosition = .front
        panel!.rightPanelPosition = .back

        //  Resetting the Panel Configs...

//        panel!.configs = FAPanelConfigurations()
//        panel!.configs.rightPanelWidth = 80
//        panel!.configs.bounceOnRightPanelOpen = false
//
//        panel!.delegate = self
    }
import UIKit

class RightMenuVC: UIViewController {

    @IBOutlet var tableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.

        viewConfigurations()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

    private func viewConfigurations() {

        tableView.register(UINib.init(nibName: "RightMenuCell", bundle: nil), forCellReuseIdentifier: "RightMenuCell")
    }

}

extension RightMenuVC: UITableViewDelegate, UITableViewDataSource {

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 8
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: "RightMenuCell") as! RightMenuCell
        cell.menuOption.image = UIImage(named: "Logo" + String(indexPath.row + 1))
        return cell
    }

    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

        tableView.deselectRow(at: indexPath, animated: false)

        let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
        var identifier = ""

        if indexPath.row % 2 == 0 {
            identifier = "CenterVC1"
        }
        else{
            identifier = "CenterVC2"
        }

        let centerVC: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: identifier)
        let centerNavVC = UINavigationController(rootViewController: centerVC)

        panel!.configs.bounceOnCenterPanelChange = true

        /*
         // Simple way of changing center PanelVC
         _ = panel!.center(centerNavVC)
         */

        /*
         New Feature Added, You can change the center panelVC and after completion of the animations you can execute a closure
         */

        panel!.center(centerNavVC, afterThat: {
            print("Executing block after changing center panelVC From Right Menu")
        })
    }
}
penpens commented 5 years ago
schermata 2018-11-08 alle 11 10 21
penpens commented 5 years ago

I trying to pass from my login storyboard, to the interface with the menu.