I have an app that has subtle differences depending on where it's being viewed.
Variations to business logic & view styles are fine - this is all handled through dependency injection & CSS respectively.
However, where I'm coming unstuck is with small variations on view layout / elements.
For example - if a user is running our application in an in-store kiosk, we use subtly different navigation options, than if they are running it in a desktop environment, or via a web browser. We may choose to hide a button, or a navigation bar.
Currently, I'm doing stuff like:
[Inject]
public var environment:Environment;
public function get labelVisible():Boolean
{
switch (environment.channel)
{
case Environment.KIOSK :
return false;
case Envirnoment.WEB :
case Envirnoment.DESKTOP :
return true;
}
}
However, I'm concerned about the Environment class leaking all over the place.
I don't want to over-engineer something, but I'm wondering if there's a suitable design pattern that I'm missing here that will keep me from having long switch...case
or if...then
's all over the place.