52
Interfaces adaptativas en Windows 10 Windows 10 Preview Javier Suárez

Interfaces Adaptativas en Windows 10

Embed Size (px)

Citation preview

Page 1: Interfaces Adaptativas en Windows 10

Interfaces adaptativas en Windows 10 Windows 10 Preview

Javier Suárez

Page 2: Interfaces Adaptativas en Windows 10

CartujaDotNet

Javier Suárez RuizXAML Developer Bravent

Microsoft MVP Windows Platform

Development

• Blog: http://geeks.ms/blogs/jsuarez

• Email: [email protected]

• Twitter: @jsuarezruiz

Page 3: Interfaces Adaptativas en Windows 10

CartujaDotNet

Agenda

Comenzamos1. El viaje de la convergencia

2. Universal App Platform

Mejoras en estados visuales1. Estrategias para interfaces adaptativas

2. XAML Views por dispositivo

3. El control Relative Panel

4.Adaptive Triggers

Vistas por familias de

dispositivos

Page 4: Interfaces Adaptativas en Windows 10

Comenzamos!

Page 5: Interfaces Adaptativas en Windows 10

CartujaDotNet

Mayor facilidad para estar al día

Plataforma de Apps y Core unificado

El viaje de la convergencia

Windows 10

Convergencia a nivel de kernel

Convergencia enel modelo de

App

Page 6: Interfaces Adaptativas en Windows 10

CartujaDotNet

Universal Windows Platform

Plataforma de Desarrollo unificada

Un único paquete

Código adaptativo

XboxIoT

Universal Windows Platform

Core APIs

Page 7: Interfaces Adaptativas en Windows 10

La historia de las Apps Windows adaptativas

Page 8: Interfaces Adaptativas en Windows 10

CartujaDotNet

Opciones de diseño para adaptar la interfaz

Estrategias de diseñoLayouts flexibles con tamaños relativos

Vistas XAML por dispositivoArchivos XAML separados con código compartido

Estados visuales XAMLUtilizados para escalar y gestionar orientaciones

Page 9: Interfaces Adaptativas en Windows 10

CartujaDotNet

Page 10: Interfaces Adaptativas en Windows 10

CartujaDotNet

Page 11: Interfaces Adaptativas en Windows 10

Los usuarios adoran las Apps queson geniales en cada uno de susdispositivos

Page 12: Interfaces Adaptativas en Windows 10

¿Qué tenemos “gratis”?

Page 13: Interfaces Adaptativas en Windows 10

CartujaDotNet

Page 14: Interfaces Adaptativas en Windows 10

Mejoras en Visual States

Page 15: Interfaces Adaptativas en Windows 10

CartujaDotNet

Visual State setters & triggers

Setters permite establecer propiedades simplesLa mayoría de propiedades no necesitan animación

Triggers declarados cuando se aplica un estadoNo necesitamos gestionar eventos en el code-behind

<VisualState x:Name="wideState"><VisualState.Setters>

<Setter Target="myPanel.Orientation" Value="Horizontal" /></VisualState.Setters><VisualState.StateTriggers>

<AdaptiveTrigger MinWindowWidth="600"/></VisualState.StateTriggers>

</VisualState>

Page 16: Interfaces Adaptativas en Windows 10

CartujaDotNet

Tipos de trigger

MinWindowWidth

MinWindowHeight

“Cualquier cosa por encima de este valor”

Los valores se especifican en píxeles

Page 17: Interfaces Adaptativas en Windows 10

DEMO

Visual State Triggers

3:50

Page 18: Interfaces Adaptativas en Windows 10

CartujaDotNet

…cuando algo en la ViewModel cambia

…cuando cambia algun valor

…dependiendo del tamaño de la pantalla

Bien, entonces…

¿Visual State Triggers Custom?

Page 19: Interfaces Adaptativas en Windows 10

CartujaDotNet

public class InputTypeTrigger : StateTriggerBase

{

private FrameworkElement _targetElement;

private PointerDeviceType _lastPointerType, _triggerPointerType;

public FrameworkElement TargetElement

{

get { return _targetElement; }

set

{

_targetElement = value;

_targetElement.AddHandler(FrameworkElement.PointerPressedEvent, newPointerEventHandler(_targetElement_PointerPressed), true);

Custom Trigger

Page 20: Interfaces Adaptativas en Windows 10

CartujaDotNet

xmlns:triggers="using:StravaMobile.UAP.Triggers"

<VisualStateGroup x:Name="InputTypeStates">

<VisualState>

<VisualState.StateTriggers>

<triggers:InputTypeTrigger TargetElement="{x:Bind ActivityList}"PointerType="Touch" />

<triggers:InputTypeTrigger TargetElement="{x:Bind ActivityList}"PointerType="Pen" />

</VisualState.StateTriggers>

<VisualState.Setters>

<Setter Target="GoToTopButton.Visibility" Value="Visible" />

Uso de Custom Trigger

Page 21: Interfaces Adaptativas en Windows 10

CartujaDotNet

La lógica es custom

Se pueden combiner varios Triggers

Se pueden utilizer otras opciones dentro del Trigger como x:Defer

https://github.com/Microsoft/Windows-universal-samples/tree/master/xaml_statetriggers

Crear Custom Triggers

Page 22: Interfaces Adaptativas en Windows 10

DEMO

Custom Triggers

3:50

Page 23: Interfaces Adaptativas en Windows 10

Nuevos controles XAML

Page 24: Interfaces Adaptativas en Windows 10

CartujaDotNet

Relative Panel es un control de Layout XAML. Posiciona

los elementos estableciendo relaciones entre ellos.

Introducción al panel Relative Panel

Controles de Layout en Windows XAML

GridStack

PanelCanvas

Scroll

ViewerBorder View Box

Wrap

GridRelative

Panel

Page 25: Interfaces Adaptativas en Windows 10

CartujaDotNet

Relative Panel

AdaptativoRelativo al Panel

Relativo a controles “hermanos”

Simplifica nuestro XAMLSimplifica el árbol visual

Simplifica los estados visuales

Page 26: Interfaces Adaptativas en Windows 10

CartujaDotNet

Alineación con el Panel

<RelativePanel>

<Rectangle x:Name="RedRect" Height="100" Width="100" Fill="Red"

RelativePanel.AlignHorizontalCenterWithPanel="True"RelativePanel.AlignVerticalCenterWithPanel="True" />

<Rectangle x:Name="BlueRect" Height="100" Width="200" Fill="Blue" />

</RelativePanel>

Page 27: Interfaces Adaptativas en Windows 10

CartujaDotNet

Opciones de posición con respecto al Panel

<Rectangle Height="100" Width="100" Fill="Red"

RelativePanel.AlignLeftWithPanel="True" (default)

RelativePanel.AlignRightWithPanel="True"

RelativePanel.AlignTopWithPanel="True" (default)

RelativePanel.AlignBottomWithPanel="True"

RelativePanel.CenterInPanelHorizontally="True"

RelativePanel.CenterInPanelVertically="True" />

Page 28: Interfaces Adaptativas en Windows 10

CartujaDotNet

Alinearse con “hermanos” (derecha)

<RelativePanel>

<Rectangle x:Name="BlueRect" Height="100" Width="100" Fill="Blue" />

<Rectangle x:Name="RedRect" Height="100" Width="100" Fill="Red"

RelativePanel.RightOf="BlueRect"RelativePanel.AlignVerticalCenterWith="BlueRect" />

</RelativePanel>

Page 29: Interfaces Adaptativas en Windows 10

CartujaDotNet

Alinearse con “hermanos” (encima, derecha)

<RelativePanel>

<Rectangle x:Name="BlueRect" Height="100" Width="100" Fill="Blue" />

<Rectangle x:Name="RedRect" Height="100" Width="100" Fill="Red"

RelativePanel.Below="BlueRect"RelativePanel.AlignRightWith="BlueRect" />

</RelativePanel>

Page 30: Interfaces Adaptativas en Windows 10

CartujaDotNet

Alinearse con “hermanos” (debajo, centro)

<RelativePanel>

<Rectangle x:Name="BlueRect" Height="100" Width="100" Fill="Blue" />

<Rectangle x:Name="RedRect" Height="100" Width="100" Fill="Red"

RelativePanel.Below="BlueRect"RelativePanel.AlignHorizontalCenterWith="BlueRect" />

</RelativePanel>

Page 31: Interfaces Adaptativas en Windows 10

CartujaDotNet

Alinearse con “hermanos” (debajo, izquierda)

<RelativePanel>

<Rectangle x:Name="BlueRect" Height="100" Width="100" Fill="Blue" />

<Rectangle x:Name="RedRect" Height="100" Width="100" Fill="Red"

RelativePanel.Below="BlueRect"RelativePanel.AlignLeftWith="BlueRect" />

</RelativePanel>

Page 32: Interfaces Adaptativas en Windows 10

CartujaDotNet

Opciones de posicionamiento entre “hermanos”

<Rectangle Height="100" Width="100" Fill="Red"

RelativePanel.Above="BlueRect"

RelativePanel.RightOf="BlueRect"

RelativePanel.Below="BlueRect"

RelativePanel.RightOf="BlueRect" />

Page 33: Interfaces Adaptativas en Windows 10

CartujaDotNet

Opciones de alineación entre “hermanos”

<Rectangle Height="100" Width="100" Fill="Red"

RelativePanel.AlignTopWith="BlueRect"

RelativePanel.AlignRightWith="BlueRect"

RelativePanel.AlignBottomWith="BlueRect"

RelativePanel.AlignLeftWith="BlueRect"

RelativePanel.AlignHorizontalCenterWith="BlueRect"

RelativePanel.AlignVerticalCenterWith="BlueRect" />

Page 34: Interfaces Adaptativas en Windows 10

DEMODEMODEMO

Relative Panel

Page 35: Interfaces Adaptativas en Windows 10

CartujaDotNet

Simplificando el árbol visual

<Grid>

<StackPanel>

<StackPanel>

<TextBlock />

<TextBlock />

</StackPanel>

<StackPanel>

<TextBlock />

<TextBlock />

</StackPanel>

</StackPanel>

</Grid>

<RelativePanel>

<TextBlock />

<TextBlock />

<TextBlock />

<TextBlock />

</RelativePanel >

Page 36: Interfaces Adaptativas en Windows 10

El control Relative Panel es una de las claves para tus estrategias a la hora de adaptar la UI

Page 37: Interfaces Adaptativas en Windows 10

El control SplitView

Page 38: Interfaces Adaptativas en Windows 10

CartujaDotNet

SplitView

Page 39: Interfaces Adaptativas en Windows 10

CartujaDotNet

Comportamiento

Your Windows App

Page 40: Interfaces Adaptativas en Windows 10

CartujaDotNet

Segoe MDL2 Assets

Page 41: Interfaces Adaptativas en Windows 10

CartujaDotNet

SplitView.Pane

<SplitView>

<SplitView.Pane>

<StackPanel>

<RadioButton />

<RadioButton />

</StackPanel>

</SplitView.Pane>

</SplitView>

Page 42: Interfaces Adaptativas en Windows 10

CartujaDotNet

SplitView.Content

<SplitView>

<SplitView.Pane />

<SplitView.Content>

<Frame/>

</SplitView.Content>

</SplitView>

Page 43: Interfaces Adaptativas en Windows 10

CartujaDotNet

Propiedades del SplitView

<SplitView

IsPaneOpen="False"

CompactPaneLength="150"

OpenPaneLength="50"

Placement="Right|Left"

PaneDisplayMode="CompactInline">

<SplitView.Pane />

<SplitView.Content />

</SplitView>

Page 44: Interfaces Adaptativas en Windows 10

CartujaDotNet

SplitView.PaneDisplayModeSplitView.IsPaneOpen

"True"SplitView.IsPaneOpen

"False"

Inline

Overlay

Compact Inline

Compact Overlay

Page 45: Interfaces Adaptativas en Windows 10

DEMODEMO

SplitView

Page 46: Interfaces Adaptativas en Windows 10

CartujaDotNet

¿Qué pasa si…?

SplitView vs. Pivot

Comandos en la

parte superior VS

inferior

Page 47: Interfaces Adaptativas en Windows 10

Vistas por familia de dispositivo

Page 48: Interfaces Adaptativas en Windows 10

CartujaDotNet

Cuando ApiInformation no es

suficiente

Utilizamos familias de dispositivos como

Xbox y Surface Hub

Adapta la experiencia de usuario

Page 49: Interfaces Adaptativas en Windows 10

CartujaDotNet

Debemos determinar escenarios donde sea necesario

Creamos vistas específicas en estos casos

Cargamos la vista adecuada en consecuencia

Adapta tu vista

//Get the diagonal size of the integrated displayvar dsc = new DisplaySizeHelper.DisplaySizeClass();double _actualSizeInInches = dsc.GetDisplaySizeInInches();

//Guidance: If the diagonal size is <= 7" use the OneHanded optimized viewif ( _actualSizeInInches >0 && _actualSizeInInches <= ONEHANDEDSIZE){

rootFrame.Navigate(typeof(MainPage_OneHanded), e.Arguments);}

else{

rootFrame.Navigate(typeof(MainPage), e.Arguments);}

Page 50: Interfaces Adaptativas en Windows 10

DEMODEMODEMO

Vistas por familia de dispositivo

Page 51: Interfaces Adaptativas en Windows 10

CartujaDotNet

Preguntas y respuestas.

¿Dudas?

&

Page 52: Interfaces Adaptativas en Windows 10

Interfaces adaptativas en Windows 10

Windows 10 Preview

Javier Suárez