-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supporting multiple screens #67
Comments
Would love to see some included utilities. I would say that a function returning a simple enum of type enum SCREEN_SIZE{
TABLET_PORTRAIT,
TABLET_LANDSCAPE,
PHONE_PORTRAIT ,
PHONE_LANDSCAPE,
TV_LANDSCAPE
TV_PORTRAIT // Even possible?
} is enough for most layouts, since you could then even perform a switch-case with fallthrough and default. For other use cases I would introduce a helper which returns the AspectRatio. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
People often ask how Anvil supports multiple screens. Currently it only provides an
isPortrait
helper.All "media queries" (in terms of CSS) end up with checking current
Configuration
, which can be retrieved fromResources
assiciated with the currentContext
:To keep Anvil simple we can remove
isPortrait
and make users write media queries manually. Or we can find a minimal subset of media queries to satisfy most needs.Configuration allows you to detect:
From the above I find the most practical to detect orientation and to tell normal (phone) layouts from large (tablet) layouts. This means that
isPortrait
is here to stay, but the screen size could be checked with different functions:isTablet()
,isTv()
,isPhone()
isLarge()
,isXLarge()
displaySize()
that would returns size in inches, e.g.if (displaySize() > 6.5) { tablet(); } else { phone(); }
etc, etc. What are your thoughts?
P.S. Anko supports lots of configuration media queries - https://github.com/Kotlin/anko/blob/master/doc/ADVANCED.md#configuration-qualifiers while Scaloid supports only a few - https://github.com/pocorall/scaloid/blob/master/scaloid-common/src/main/st/org/scaloid/util/Configuration.scala
The text was updated successfully, but these errors were encountered: