anvil-ui / anvil-ui/anvil

Supporting multiple screens

Abierto
#67 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Java
Estrellas
1.4k
Forks
89
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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`:

```
if (getContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
// portrait layout
} else {
// landscape layout
}
```

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:
- Orientation (landscape, portrait)
- Screen size category (small, normal, large, xlarge)
- Screen DPI
- Screen physical size in inches
- 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(); }`

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.