Focus session
Choose an environment, adjust the duration and prepare a session. A Radio group owns the ambience choice, while a Slider and Button control duration and preparation. Its Vue source runs unchanged in NativeScript and on the Web.
Open the interactive example ↗
The screen uses local demonstration data and does not play audio. Radio option values stay independent of their translated labels; the summary displays the label. Options are disabled while the session is being prepared. The app owns the values and preparation state, while the components own rendering and interaction rules. Changing the theme preserves the selection.
Source
vue
<script setup lang="ts">
import { useCatalogLocale } from '../locale'
import { computed, onUnmounted, ref } from 'vue'
import type { ChoiceOption, ChoiceValue } from '@getcortexlabs/mavis-core'
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
import { useCatalog } from '../context'
import ThemeSwitch from '../ThemeSwitch.vue'
const { t, choices } = useCatalogLocale()
const { theme } = useMavisTheme()
const { navigation } = useCatalog()
const ambiences: ChoiceOption[] = [
{ value: 'silence', label: 'Silêncio', helperText: 'Espaço para uma coisa de cada vez.' },
{ value: 'rain', label: 'Chuva', helperText: 'Um ritmo constante para acompanhar você.' },
]
const ambience = ref<ChoiceValue>('silence')
const minutes = ref(30)
const details = ref(false)
const loading = ref(false)
const ready = ref(false)
const summary = computed(
() =>
`${minutes.value} ${t('minutos')} · ${t(ambiences.find((option) => option.value === ambience.value)?.label ?? '')}`,
)
let pending: ReturnType<typeof setTimeout> | undefined
function prepare() {
loading.value = true
pending = setTimeout(() => {
loading.value = false
ready.value = true
}, 600)
}
function choose(value: ChoiceValue) {
ambience.value = value
ready.value = false
}
onUnmounted(() => clearTimeout(pending))
</script>
<template>
<m-screen scroll>
<m-column padding="lg" gap="lg" class="showcase-container">
<m-row justify="between" gap="sm">
<m-button variant="ghost" size="sm" @click="navigation.back('/showcase')">{{
t('← Showcase')
}}</m-button>
<ThemeSwitch />
</m-row>
<m-box :height="180" radius="lg" :backgroundColor="theme.colors.primarySoft">
<m-column padding="lg" justify="between">
<m-text variant="overline" tone="primary">{{ t('UM TEMPO PARA VOCÊ') }}</m-text>
<m-text as="h1" variant="title">{{ t('Seu momento.') }}</m-text>
<m-text tone="muted">{{ t('Uma pausa. Uma coisa de cada vez.') }}</m-text>
</m-column>
</m-box>
<m-card>
<m-radio-group
:modelValue="ambience"
:options="choices(ambiences)"
:label="t('Escolha o ambiente')"
:disabled="loading"
@update:modelValue="choose"
/>
</m-card>
<m-card gap="md">
<m-row justify="between" gap="sm">
<m-text as="h2" variant="heading">{{ t('Sua sessão') }}</m-text>
<m-text tone="primary">{{ t(minutes) }}{{ t(' min') }}</m-text>
</m-row>
<m-slider
v-model="minutes"
:min="15"
:max="60"
:step="15"
:disabled="loading"
:label="t('Duração da sessão')"
@update:modelValue="ready = false"
/>
<m-button variant="secondary" @click="details = !details">{{
t(details ? 'Ocultar detalhes' : 'Ver detalhes')
}}</m-button>
<m-reveal
:show="details"
gap="sm"
padding="md"
radius="md"
:backgroundColor="theme.colors.elevated"
>
<m-text>{{ t(summary) }}</m-text>
<m-text variant="caption" tone="muted">{{
t('Uma demonstração de preferências. Nenhum áudio será reproduzido.')
}}</m-text>
</m-reveal>
</m-card>
<m-button :loading="loading" :loadingText="t('Preparando…')" @click="prepare">{{
t('Preparar sessão')
}}</m-button>
<m-text v-if="ready" tone="primary">{{ t('Sessão pronta: ') }}{{ t(summary) }}.</m-text>
</m-column>
</m-screen>
</template>Read the component contract for defaults, event payloads and platform boundaries.