diff --git a/android/src/main/java/voltra/generated/ShortNames.kt b/android/src/main/java/voltra/generated/ShortNames.kt index 6eac589..2503b98 100644 --- a/android/src/main/java/voltra/generated/ShortNames.kt +++ b/android/src/main/java/voltra/generated/ShortNames.kt @@ -19,7 +19,6 @@ object ShortNames { "al" to "alignment", "ar" to "aspectRatio", "an" to "assetName", - "ahe" to "autoHideOnEnd", "bkg" to "background", "bg" to "backgroundColor", "bgs" to "backgroundStyle", diff --git a/data/components.json b/data/components.json index 47d2529..328a014 100644 --- a/data/components.json +++ b/data/components.json @@ -3,7 +3,6 @@ "shortNames": { "style": "s", "alignment": "al", - "autoHideOnEnd": "ahe", "buttonStyle": "bs", "colors": "cls", "cornerRadius": "cr", @@ -685,11 +684,6 @@ "default": "down", "description": "Count direction" }, - "autoHideOnEnd": { - "type": "boolean", - "optional": true, - "description": "Hide timer when complete" - }, "textStyle": { "type": "string", "optional": true, diff --git a/example/app/testing-grounds/timer.tsx b/example/app/testing-grounds/timer.tsx new file mode 100644 index 0000000..7fb9b68 --- /dev/null +++ b/example/app/testing-grounds/timer.tsx @@ -0,0 +1,3 @@ +import TimerTestingScreen from '../../screens/testing-grounds/timer/TimerTestingScreen' + +export default TimerTestingScreen diff --git a/example/screens/testing-grounds/TestingGroundsScreen.tsx b/example/screens/testing-grounds/TestingGroundsScreen.tsx index e2f5484..1497135 100644 --- a/example/screens/testing-grounds/TestingGroundsScreen.tsx +++ b/example/screens/testing-grounds/TestingGroundsScreen.tsx @@ -13,6 +13,13 @@ const TESTING_GROUNDS_SECTIONS = [ 'Test the weather widget with different conditions, gradients, and real-time updates. Change weather conditions and see the widget update instantly.', route: '/testing-grounds/weather', }, + { + id: 'timer', + title: 'Timer', + description: + 'Test the VoltraTimer component with different styles (Timer/Relative), count directions, and templates. Verifies native Live Activity behavior.', + route: '/testing-grounds/timer', + }, { id: 'styling', title: 'Styling', diff --git a/example/screens/testing-grounds/timer/TimerTestingScreen.tsx b/example/screens/testing-grounds/timer/TimerTestingScreen.tsx new file mode 100644 index 0000000..bac86cd --- /dev/null +++ b/example/screens/testing-grounds/timer/TimerTestingScreen.tsx @@ -0,0 +1,238 @@ +import { useRouter } from 'expo-router' +import React, { useState } from 'react' +import { ScrollView, StyleSheet, Text, TextInput, useColorScheme, View } from 'react-native' +import { Voltra } from 'voltra' +import { VoltraWidgetPreview } from 'voltra/client' + +import { Button } from '~/components/Button' +import { Card } from '~/components/Card' + +const DEFAULT_TEMPLATES = { + running: 'Time remaining: {time}', + completed: 'Timer finished!', +} + +export default function TimerTestingScreen() { + const router = useRouter() + const colorScheme = useColorScheme() + + // Timer State + const [mode, setMode] = useState<'timer' | 'stopwatch'>('timer') + const [direction, setDirection] = useState<'up' | 'down'>('down') + const [textStyle, setTextStyle] = useState<'timer' | 'relative'>('timer') + const [showHours, setShowHours] = useState(false) + const [durationSec, setDurationSec] = useState('300') // 5 minutes default + const [templateJson, setTemplateJson] = useState(JSON.stringify(DEFAULT_TEMPLATES, null, 2)) + + // Timestamps + const [timerState, setTimerState] = useState<{ startAtMs?: number; endAtMs?: number; durationMs?: number }>({ + endAtMs: Date.now() + 300000, + }) + + const widgetPreviewStyle = { + borderRadius: 16, + backgroundColor: colorScheme === 'light' ? 'rgba(0, 0, 0, 0.4)' : 'rgba(255, 255, 255, 0.8)', + } + + const resetTimer = () => { + const duration = (parseInt(durationSec) || 0) * 1000 + const now = Date.now() + + if (mode === 'stopwatch') { + setTimerState({ + startAtMs: now, + endAtMs: undefined, + durationMs: undefined, + }) + setDirection('up') + } else { + if (direction === 'down') { + setTimerState({ + startAtMs: now, + endAtMs: now + duration, + durationMs: duration, + }) + } else { + setTimerState({ + startAtMs: now, + endAtMs: now + duration, + durationMs: duration, + }) + } + } + } + + // Timer Component for Preview + const renderTimerWidget = () => ( + + + Voltra Timer + + + + ) + + return ( + + + Timer Testing + + Test the VoltraTimer component behaviors, including native text updates for Live Activities. + + + {/* Preview */} + + Live Preview + + + {renderTimerWidget()} + + +