ferranabello/Viperit

Use module with view variants

pgawlowski opened this issue · 1 comments

Is it possible to use same module, but build it with different .storyboard?
How to achieve this?

Hi @pgawlowski ,
sure you can.

You just have to override the default implementation of the "viewName" property in your modules enum.

For example:

enum AppModules: String, ViperitModule {
    case home
    case second
    
    var viewName: String {
        switch self {
        case .home:
            if someSpecialThingHappens {
                return "homeSpecial"
            } else {
                return "home"
            }
        default:
            return rawValue
        }
    }
}

Just remember that you will need to put "ModuleView" (where Module is your module name) as the ViewController identifier (Storyboard ID in interface builder) in each of your storyboard files.

Cheers.