You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 from Resources assiciated with the current Context:
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.
Screen geometry (square, normal, long, or specific aspect ratio)
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(); }
Would love to see some included utilities. I would say that a function returning a simple enum of type
enumSCREEN_SIZE{
TABLET_PORTRAIT,
TABLET_LANDSCAPE,
PHONE_PORTRAIT ,
PHONE_LANDSCAPE,
TV_LANDSCAPETV_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.
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: