toshi0383 / TVMLKitchen

Swifty TVML template manager with or without client-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UIViewController into a UITabBar

anthonycastelli opened this issue · comments

Maybe I'm overlooking something but i've gone through the framework and can't seem to find anything that would allow me to add UIViewController to a UITabBar. Is this currently not possible?

Not currently and I'm not sure if it's possible when merging TVML and UIKit. If your root views are UIKit you could choose to use a storyboard with a UITabBarController.

What about the reverse. Could Kitchen present a recipe within a UIViewController, essentially a subview? If so then I could build the tabs with UIKit and add a recipe as a subview.

Not currently. It will be pushed as a view onto the main app navigation controller so will be presented as a new view not a child view of the tab.

Agree that one of these options is definitely desirable.

Yes, that's tvOS SDK's limitation.
If you're using Native TabBarController, I could present an empty child ViewController which opens TVML template via Kitchen. As mentioned, TVML is presented as a sibling of TabView, not a subview anymore. You have to hit the Menu button of Remote to go back to the TabBarController scene.
I ended up a little complex state handling, but it works.

    // MARK: - Lifecycle
    override func viewDidLoad() {
        super.viewDidLoad()
        /// first time
        presentTVML()
    }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        if canPresentView {
            presentTVML()
        }
    }

    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(animated)
        canPresentView = true
    }

    private func presentTVML() {
        canPresentView = false
        Kitchen.serve(xmlFile: "Sample.tvml", type: .Modal)
    }

The UI transition looks ... not too bad, but not sure if it's okay for Apple's review guideline.

I'll have to give that a shot. Im a bit stuck at what I should do as I need to implement searching and UISearchController is the best choice as using TVML for search wouldn't quite work as there isn't a way to dynamically update the XML with the results, let alone grab the text from the searchField

Apple's TVMLCatalog sample code actually demonstrates dynamic view manipulating in Search template, using TVJS.
https://developer.apple.com/library/prerelease/tvos/samplecode/TVMLCatalog/Introduction/Intro.html

I think we can consider that control as built-in Recipe in Kitchen. I'll take a look.😉

That would be fantastic! Thanks!

SearchRecipe has been added in #56.

Closing this topic 🍳