Controles de veículo
Uma composição com autonomia, clima, preferências de carregamento e acesso aos detalhes. As mesmas telas Vue e o mesmo estado são usados no app nativo e no navegador.
Os dois temas
Capturas do exemplo nativo no Android, em Midnight e Mavis.


Como foi composto
| Parte da tela | Componentes |
|---|---|
| Estrutura e rolagem | Screen, Column, Row |
| Autonomia e bateria | Text, Box |
| Clima e limite de carga | Card, Slider |
| Ações e estados | Button |
| Preferências adicionais | Reveal |
shared/context.ts mantém os valores locais e recebe uma interface de navegação. O app nativo fornece vue-router-ns; a Web fornece Vue Router. Os componentes usam o mesmo tema, mas renderizam controles próprios de cada plataforma.
Código da tela
Ver Vehicle.vue
vue
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
import { useCatalog } from '../context'
import ThemeSwitch from '../ThemeSwitch.vue'
const { t } = useCatalogLocale()
const { theme } = useMavisTheme()
const { locked, climate, temperature, preferences, chargeLimit, navigation } = useCatalog()
</script>
<template>
<m-screen scroll>
<m-column padding="lg" gap="lg">
<m-button size="sm" variant="ghost" @click="navigation.back('/showcase')">{{
t('← Showcase')
}}</m-button>
<m-row justify="between">
<m-text variant="overline" tone="muted">{{ t('SHOWCASE / VEÍCULO') }}</m-text>
<ThemeSwitch />
</m-row>
<m-column gap="xs">
<m-text variant="title" as="h1">{{ t('O dia é seu.') }}</m-text>
<m-text tone="muted">{{ t('Tudo pronto para a próxima partida.') }}</m-text>
</m-column>
<m-column gap="sm" paddingY="sm">
<m-row align="end" gap="sm">
<m-text variant="display">328</m-text>
<m-text tone="muted">{{ t('km de autonomia') }}</m-text>
</m-row>
<m-row gap="xs" :accessibilityLabel="t('Bateria em 82 por cento')">
<m-box
v-for="bar in 24"
:key="bar"
:grow="1"
:height="7"
:radius="3"
:backgroundColor="bar <= 20 ? theme.colors.primary : theme.colors.elevated"
/>
</m-row>
<m-row justify="between">
<m-text variant="caption" tone="muted">{{ t('BATERIA · 82%') }}</m-text>
<m-text variant="caption" tone="accent">{{ t('Em boa companhia.') }}</m-text>
</m-row>
</m-column>
<m-card gap="lg">
<m-row justify="between">
<m-text variant="overline" tone="muted">{{ t('SEU ESPAÇO') }}</m-text>
<m-text variant="caption" :tone="climate ? 'accent' : 'muted'">
{{ t(climate ? 'Clima ligado' : 'Clima desligado') }}
</m-text>
</m-row>
<m-column gap="xs" paddingY="sm">
<m-text variant="display" align="center">{{ t(temperature) }}°</m-text>
<m-text align="center" tone="muted">{{ t('Na sua temperatura.') }}</m-text>
</m-column>
<m-column gap="xs">
<m-slider
v-model="temperature"
:min="16"
:max="28"
:step="0.5"
:disabled="!climate"
:label="t('Temperatura da cabine')"
/>
<m-row justify="between">
<m-text variant="caption" tone="muted">16°</m-text>
<m-text variant="caption" tone="muted">28°</m-text>
</m-row>
</m-column>
<m-row gap="sm">
<m-button
:grow="1"
:variant="climate ? 'primary' : 'secondary'"
@click="climate = !climate"
>
{{ t(climate ? 'Desligar clima' : 'Ligar clima') }}
</m-button>
<m-button
variant="secondary"
:accessibilityLabel="t('Preferências de carregamento')"
@click="preferences = !preferences"
>
{{ t(preferences ? 'Fechar' : 'Ajustes') }}
</m-button>
</m-row>
</m-card>
<m-reveal :show="preferences">
<m-card gap="md">
<m-row justify="between">
<m-text variant="heading" as="h2">{{ t('Carga ideal') }}</m-text>
<m-text tone="primary">{{ t(chargeLimit) }}%</m-text>
</m-row>
<m-text variant="caption" tone="muted">{{
t('Defina o limite para a próxima recarga.')
}}</m-text>
<m-slider
v-model="chargeLimit"
:min="50"
:max="100"
:step="5"
:label="t('Limite de carregamento')"
/>
</m-card>
</m-reveal>
<m-row gap="sm">
<m-button :grow="1" variant="secondary" @click="locked = !locked">
{{ t(locked ? 'Destrancar' : 'Trancar') }}
</m-button>
<m-button :grow="1" variant="ghost" @click="navigation.push('/showcase/vehicle/details')">{{
t('Meu veículo ↗')
}}</m-button>
</m-row>
<m-text variant="caption" tone="muted" align="center">
{{ t(locked ? 'Veículo trancado' : 'Veículo destrancado')
}}{{ t(' · Demonstração ') }}</m-text
>
</m-column>
</m-screen>
</template>O exemplo demonstra composição, sem integração com veículos reais. Para estudar uma API isolada, volte ao catálogo de componentes.