Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 42 additions & 25 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react';
import { KeyboardAvoidingView, Platform, Pressable, StyleSheet, Switch, Text, TextInput, View } from 'react-native';
import { Pressable, StyleSheet, Switch, Text, View } from 'react-native';

import {
accentColor,
Expand All @@ -16,34 +16,35 @@ import {

if (__DEV__) console.info('[stim:readiness] pending');

const SIZES = [
{ key: 'S', label: 'small', fontSize: 16, cardPadding: 12 },
{ key: 'M', label: 'medium', fontSize: 28, cardPadding: 20 },
{ key: 'L', label: 'large', fontSize: 44, cardPadding: 32 },
];

export default function App() {
const [count, setCount] = useState(0);
const [dark, setDark] = useState(false);
const [name, setName] = useState('');
const [size, setSize] = useState('M');
const { fontSize, cardPadding } = SIZES.find((s) => s.key === size);

useEffect(() => {
console.log(`[stim:tutorial] started title=${titleColor} background=${backgroundColor}`);
if (__DEV__) console.info('[stim:readiness] ready');
}, []);

return (
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
style={[styles.container, { backgroundColor }]}
>
<View style={[styles.container, { backgroundColor }]}>
<Text style={[styles.title, { color: titleColor }]}>Stim Tutorial</Text>
<Text style={[styles.subtitle, { color: mutedColor }]}>Edit theme.js and save.</Text>

<View
testID="accent-card"
style={[styles.card, { backgroundColor: dark ? darkAccentColor : accentColor }]}
style={[styles.card, { backgroundColor: dark ? darkAccentColor : accentColor, padding: cardPadding }]}
>
<Text testID="tap-count" style={[styles.cardText, { color: dark ? darkTextColor : textColor }]}>
<Text testID="tap-count" style={[styles.cardText, { color: dark ? darkTextColor : textColor, fontSize }]}>
Tapped {count} {count === 1 ? 'time' : 'times'}
</Text>
<Text testID="greeting" style={[styles.cardText, { color: dark ? darkTextColor : textColor }]}>
Hello, {name.trim() || 'world'}
</Text>
</View>

<Pressable
Expand All @@ -67,30 +68,46 @@ export default function App() {
/>
</View>

<TextInput
testID="name-input"
accessibilityLabel="Your name"
placeholder="Your name"
value={name}
onChangeText={setName}
autoCapitalize="words"
autoCorrect={false}
placeholderTextColor={mutedColor}
style={[styles.input, { borderColor: inputBorderColor, color: textColor }]}
/>
</KeyboardAvoidingView>
<View
accessibilityRole="radiogroup"
accessibilityLabel="Size"
style={styles.sizeRow}
>
{SIZES.map(({ key, label }) => {
const selected = size === key;
return (
<Pressable
key={key}
testID={`size-${key.toLowerCase()}`}
accessibilityRole="radio"
accessibilityLabel={`Size ${label}`}
accessibilityState={{ selected }}
onPress={() => setSize(key)}
style={[
styles.chip,
{ borderColor: selected ? buttonColor : inputBorderColor, backgroundColor: selected ? buttonColor : backgroundColor },
]}
>
<Text style={[styles.chipText, { color: selected ? buttonTextColor : textColor }]}>{key}</Text>
</Pressable>
);
})}
</View>
</View>
);
}

const styles = StyleSheet.create({
container: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: 24 },
title: { fontSize: 44, fontWeight: '700', marginBottom: 8 },
subtitle: { fontSize: 16 },
card: { alignSelf: 'stretch', borderRadius: 12, padding: 16, marginTop: 32, gap: 4 },
card: { alignSelf: 'stretch', borderRadius: 12, marginTop: 32 },
cardText: { fontSize: 18 },
button: { alignSelf: 'stretch', borderRadius: 12, paddingVertical: 14, marginTop: 16, alignItems: 'center' },
buttonText: { fontSize: 18, fontWeight: '600' },
row: { alignSelf: 'stretch', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginTop: 16 },
label: { fontSize: 18 },
input: { alignSelf: 'stretch', borderWidth: 1, borderRadius: 12, padding: 12, fontSize: 18, marginTop: 16 },
sizeRow: { alignSelf: 'stretch', flexDirection: 'row', gap: 8, marginTop: 16 },
chip: { flex: 1, borderWidth: 1, borderRadius: 12, paddingVertical: 12, alignItems: 'center' },
chipText: { fontSize: 18, fontWeight: '600' },
});
Loading