Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

[styling] NMessengerBarView does not support custom nib files #128

Open
dodikk opened this issue Apr 19, 2017 · 3 comments
Open

[styling] NMessengerBarView does not support custom nib files #128

dodikk opened this issue Apr 19, 2017 · 3 comments

Comments

@dodikk
Copy link

dodikk commented Apr 19, 2017

As a library user I'm ok with the existing set of controls on NMessengerBarView but my designer wants a different layout. Moreover, NMessengerBarView contains some useful camera and keyboard related logic.

So I'd like to load the NMessengerBarView from my own xib and my own [NSBundle mainBundle] (or from another one external to NMessenger).
So far, no extension points are available.

@dodikk
Copy link
Author

dodikk commented Apr 19, 2017

I'm going to add one more convenience constructor. See the code below.
P.S. a pull request will follow.

    public required init(controller: NMessengerViewController,
                            nibName: String,
                             bundle: Bundle)
    {
        super.init(controller: controller)
        
        self.loadFrom(bundle: bundle, nibName: nibName)
    }


    fileprivate func loadFromBundle()
    {
        let nmessengerBundle = Bundle(for: NMessengerViewController.self)
        let nibName = "NMessengerBarView"
        
        
        self.loadFrom(bundle: nmessengerBundle, nibName: nibName)
    }
    
    fileprivate func loadFrom(bundle: Bundle,
                             nibName: String)
    {
        let nibObjects = bundle.loadNibNamed( nibName,
                                       owner: self,
                                     options: nil)
        /*let fileOwnerSelf*/ _ = nibObjects?[0] as! UIView
        
        self.addSubview(inputBarView)
        inputBarView.frame = self.bounds
        textInputView.delegate = self
        self.sendButton.isEnabled = false
        cameraVC.cameraDelegate = self
        
    }

@dodikk
Copy link
Author

dodikk commented Apr 19, 2017

Another option is making open func loadFromBundle() and forcing library users to subclass the NMessengerBarView but that approach is less elegant, from my point of view.

@dodikk
Copy link
Author

dodikk commented Apr 20, 2017

Fixed in #129

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant