Coder Social home page Coder Social logo

scenic's People

Contributors

deanwombourne avatar dependabot[bot] avatar samdeanpinknews avatar

Watchers

 avatar

scenic's Issues

Documentation is missing

The code is documented enough (imho) and it's pretty simple to understand anyway.

However, we're missing the "How To" part of the docuemntation (the readme is pretty much just the standard pods readme), and we're missing somewhere which says why Scenic is a good architecture framework to use.

Removing requirement for view controllers in storyboards

I have an app I'm building that I use Scenic in. The app uses UIKit/Scenic to manage navigation but all (or at least most) views are written in SwiftUI. This leaves me with view controllers that are very simple e.g.:

final class LoginViewController: UIViewController {

    private var loginView: LoginView! // a SwiftUI view

    var viewModel: LoginViewModel! {
        didSet {
            self.loginView = LoginView(viewModel: self.viewModel)
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        self.embedChildView(self.loginView)
    }
}

I like using this arch because it gives me the best control over navigation and appearance and allows me to quickly prototype/build UIs.

The problem I have is that I end up creating a storyboard file that always has just an empty view controller so scenic can instantiate my VC. I'd like to stop having these files around in my project.

From what I can see, there's two obvious ways of doing this:

  1. try/catch any exception when instantiating the view controller via storyboard and instead instantiate the VC via its init method, something like:
    func createViewControllerFromSceneStoryboard(in bundle: Bundle?) -> ViewControllerType {
        do {
            return try ViewControllerType.instantiateFromStoryboard(named: self.sceneName, bundle: bundle)
        } catch {
            return ViewControllerType()
        }
    }

however the try/catch mechanism would have to be obj-c since the exception thrown when instantiating a view controller via a storyboard is in objc.

  1. Pass in some sort of flag to each Scene that indicates whether to use storyboards or the initialiser. Something like:
public enum InitialisationSource {
    case storyboard
    case constructor
}

in the Scene protocol add var initialisationSource: InitialisationSource { get } with a default implementation to return .storyboard for backwards compatibility and then:

    func createViewControllerFromSceneStoryboard(in bundle: Bundle?) -> ViewControllerType {
        switch self.initialisationSource {
        case .constructor:
            return ViewControllerType()
        case .storyboard:
            return ViewControllerType.instantiateFromStoryboard(named: self.sceneName, bundle: bundle)
        }
    }

Any other options? Happy to make a PR just want to get your opinion on whether this is a change you're likely to accept before I start

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.