|
1 | | -import { Text, View, StyleSheet } from 'react-native'; |
2 | | -import { multiply } from 'react-native-tipkit'; |
3 | | - |
4 | | -const result = multiply({ n1: 3, n2: 7 }); |
| 1 | +import { View, StyleSheet, Pressable, Text } from 'react-native'; |
| 2 | +import { TipKitInlineView, TipKitPopOverView } from 'react-native-tipkit'; |
| 3 | +import CloseIcon from './CloseIcon'; |
5 | 4 |
|
6 | 5 | export default function App() { |
| 6 | + const onActionButtonPress = () => { |
| 7 | + console.log('Action button pressed'); |
| 8 | + }; |
| 9 | + |
7 | 10 | return ( |
8 | 11 | <View style={styles.container}> |
9 | | - <Text>Result: {result}</Text> |
| 12 | + <Text style={styles.title}>TipKit Example</Text> |
| 13 | + <TipKitInlineView |
| 14 | + visible={true} |
| 15 | + tipContainer={styles.inline} |
| 16 | + title="Set favorites" |
| 17 | + description="Tap and hold a color to add it to your favorites" |
| 18 | + /> |
| 19 | + |
| 20 | + <TipKitPopOverView |
| 21 | + // Tip Props |
| 22 | + title="Add New Color" |
| 23 | + description="Tap here to add a new color to the list" |
| 24 | + tipContainer={styles.tipContainer} |
| 25 | + leftIcon={<CloseIcon height={40} width={40} />} |
| 26 | + actionButtonOnPress={onActionButtonPress} |
| 27 | + actionButtonTitle="Learn more" |
| 28 | + // Popover Button Props |
| 29 | + popoverButtonProps={{ title: 'Show Popover Top' }} |
| 30 | + popoverButtonArrowDirection="top" |
| 31 | + /> |
| 32 | + |
| 33 | + <TipKitPopOverView |
| 34 | + // Tip Props |
| 35 | + title="Add New Color" |
| 36 | + description="Tap here to add a new color to the list" |
| 37 | + tipContainer={styles.tipContainer} |
| 38 | + leftIcon={<CloseIcon height={40} width={40} />} |
| 39 | + actionButtonOnPress={onActionButtonPress} |
| 40 | + // Popover Button Props |
| 41 | + popoverButtonProps={{ title: 'Show Popover Bottom' }} |
| 42 | + popoverButtonArrowDirection="bottom" |
| 43 | + /> |
| 44 | + |
| 45 | + {/* TODO: Fix the positioning of the arrow when the button is smaller than 100% */} |
| 46 | + <TipKitPopOverView |
| 47 | + // Tip Props |
| 48 | + title="Add New Color" |
| 49 | + description="Tap here to add a new color to the list" |
| 50 | + tipContainer={styles.tipContainer} |
| 51 | + leftIcon={<CloseIcon height={40} width={40} />} |
| 52 | + actionButtonOnPress={onActionButtonPress} |
| 53 | + popoverButtonArrowDirection="bottom-end" |
| 54 | + // Popover Button Props |
| 55 | + popoverButton={ |
| 56 | + <Pressable style={styles.customPopoverButton} onPress={() => {}}> |
| 57 | + <Text style={styles.customPopoverButtonText}> |
| 58 | + Custom Popover button |
| 59 | + </Text> |
| 60 | + </Pressable> |
| 61 | + } |
| 62 | + /> |
10 | 63 | </View> |
11 | 64 | ); |
12 | 65 | } |
13 | 66 |
|
14 | 67 | const styles = StyleSheet.create({ |
15 | 68 | container: { |
16 | 69 | flex: 1, |
17 | | - alignItems: 'center', |
| 70 | + gap: 12, |
18 | 71 | justifyContent: 'center', |
| 72 | + paddingHorizontal: 12, |
| 73 | + }, |
| 74 | + inline: { |
| 75 | + backgroundColor: '#d7eef3', |
| 76 | + }, |
| 77 | + tipContainer: { |
| 78 | + backgroundColor: '#f1f4f2', |
| 79 | + }, |
| 80 | + customPopoverButton: { |
| 81 | + width: '60%', |
| 82 | + backgroundColor: '#66D210', |
| 83 | + padding: 12, |
| 84 | + borderRadius: 8, |
| 85 | + }, |
| 86 | + customPopoverButtonText: { |
| 87 | + color: 'white', |
| 88 | + textAlign: 'center', |
| 89 | + fontWeight: 'bold', |
| 90 | + }, |
| 91 | + title: { |
| 92 | + fontSize: 24, |
| 93 | + fontWeight: 'bold', |
| 94 | + textAlign: 'center', |
| 95 | + color: '#333', |
19 | 96 | }, |
20 | 97 | }); |
0 commit comments