Skip to content

Commit 2372418

Browse files
committed
chore: improve example app for easier feature testing
1 parent d830d49 commit 2372418

7 files changed

Lines changed: 623 additions & 454 deletions

File tree

example/src/App.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ const HomeScreen = () => {
7777
Navigation SDK Version: {sdkVersion || 'Loading...'}
7878
</Text>
7979
</View>
80-
{/* Spacer */}
8180
<View style={CommonStyles.buttonContainer}>
8281
<ExampleAppButton
8382
title="Navigation"
@@ -96,7 +95,6 @@ const HomeScreen = () => {
9695
onPress={() => isFocused && navigate('Map ID')}
9796
/>
9897
</View>
99-
{/* Spacer */}
10098
<View style={CommonStyles.container} />
10199
<View style={CommonStyles.buttonContainer}>
102100
<ExampleAppButton

example/src/controls/Accordion.tsx

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import React, { useState, type ReactNode } from 'react';
18+
import {
19+
View,
20+
Text,
21+
TouchableOpacity,
22+
StyleSheet,
23+
LayoutAnimation,
24+
} from 'react-native';
25+
import { Colors, Spacing, BorderRadius, Typography } from '../styles/theme';
26+
27+
type AccordionProps = {
28+
title: string;
29+
children: ReactNode;
30+
defaultExpanded?: boolean;
31+
};
32+
33+
export const Accordion = ({
34+
title,
35+
children,
36+
defaultExpanded = false,
37+
}: AccordionProps) => {
38+
const [expanded, setExpanded] = useState(defaultExpanded);
39+
40+
const toggleExpanded = () => {
41+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
42+
setExpanded(!expanded);
43+
};
44+
45+
return (
46+
<View style={styles.container}>
47+
<TouchableOpacity
48+
style={styles.header}
49+
onPress={toggleExpanded}
50+
activeOpacity={0.7}
51+
>
52+
<Text style={styles.title}>{title}</Text>
53+
<Text style={styles.chevron}>{expanded ? '▲' : '▼'}</Text>
54+
</TouchableOpacity>
55+
{expanded && <View style={styles.content}>{children}</View>}
56+
</View>
57+
);
58+
};
59+
60+
const styles = StyleSheet.create({
61+
container: {
62+
marginVertical: Spacing.xs,
63+
marginRight: Spacing.md,
64+
borderRadius: BorderRadius.md,
65+
backgroundColor: Colors.surface,
66+
overflow: 'hidden',
67+
borderWidth: 1,
68+
borderColor: Colors.borderLight,
69+
},
70+
header: {
71+
flexDirection: 'row',
72+
justifyContent: 'space-between',
73+
alignItems: 'center',
74+
paddingVertical: Spacing.md,
75+
paddingHorizontal: Spacing.lg,
76+
backgroundColor: Colors.surfaceVariant,
77+
},
78+
title: {
79+
fontSize: Typography.fontSize.md,
80+
fontWeight: Typography.fontWeight.semibold,
81+
color: Colors.text,
82+
flex: 1,
83+
},
84+
chevron: {
85+
fontSize: Typography.fontSize.sm,
86+
color: Colors.textSecondary,
87+
marginLeft: Spacing.sm,
88+
},
89+
content: {
90+
paddingVertical: Spacing.sm,
91+
paddingHorizontal: Spacing.xs,
92+
},
93+
});
94+
95+
export default Accordion;

0 commit comments

Comments
 (0)