Skip to content

Commit

Permalink
feat: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
relaxxpls committed Feb 26, 2024
1 parent 3a8a725 commit 729c47d
Show file tree
Hide file tree
Showing 5 changed files with 231 additions and 31 deletions.
122 changes: 105 additions & 17 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,118 @@
import { multiply } from '@fijit-club/rn-tourguide';
import { useEffect, useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
/* eslint-disable react-native/no-color-literals */
import { Ionicons } from '@expo/vector-icons';
import { TourGuideProvider, TourGuideZone, useTourGuideController } from '@fijit-club/rn-tourguide';
import { type FC, useEffect } from 'react';
import { Image, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';

export default function App() {
const [result, setResult] = useState<number | undefined>();
const uri = 'https://pbs.twimg.com/profile_images/1223192265969016833/U8AX9Lfn_400x400.jpg';

const AppContent = () => {
const iconProps = { size: 40, color: '#888' };
const { start, canStart, stop } = useTourGuideController();

useEffect(() => {
multiply(3, 7).then(setResult);
}, []);
if (canStart) start(1);
}, [canStart, start]);

return (
<View style={styles.container}>
<Text>Result: {result}</Text>
</View>
<ScrollView
contentContainerStyle={styles.scrollContainer}
keyboardShouldPersistTaps="always"
scrollEventThrottle={16}
>
<View style={styles.container}>
<TourGuideZone zone={6}>
<Text style={styles.title}>{'Welcome to the demo of\n"rn-tourguide"'}</Text>
</TourGuideZone>
<View style={styles.middleView}>
<TouchableOpacity onPress={() => start(2)} style={styles.button}>
<Text style={styles.buttonText}>START THE TUTORIAL!</Text>
</TouchableOpacity>

<TourGuideZone zone={3}>
<TouchableOpacity onPress={() => start(4)} style={styles.button}>
<Text style={styles.buttonText}>Step 4</Text>
</TouchableOpacity>
</TourGuideZone>
<TouchableOpacity onPress={() => start(2)} style={styles.button}>
<Text style={styles.buttonText}>Step 2</Text>
</TouchableOpacity>
<TouchableOpacity onPress={stop} style={styles.button}>
<Text style={styles.buttonText}>Stop</Text>
</TouchableOpacity>
<TourGuideZone zone={7}>
<Image source={{ uri }} style={styles.profilePhoto} />
</TourGuideZone>
</View>
<View style={styles.row}>
<TourGuideZone zone={4}>
<Ionicons name="add-circle" {...iconProps} />
</TourGuideZone>
<Ionicons name="chatbubbles" {...iconProps} />
<Ionicons name="globe" {...iconProps} />
<TourGuideZone zone={5}>
<Ionicons name="navigate" {...iconProps} />
</TourGuideZone>
<TourGuideZone zone={2}>
<Ionicons name="rainy" {...iconProps} />
</TourGuideZone>
</View>
{/* {Platform.OS !== 'web' ?
<TourGuideZoneByPosition height={64} isTourGuide left={50} shape={'circle'} top={250} width={64} zone={1} />
: null} */}
</View>
</ScrollView>
);
}
};

const App: FC = () => {
return (
<TourGuideProvider>
<AppContent />
</TourGuideProvider>
);
};
const styles = StyleSheet.create({
scrollContainer: {
flexGrow: 1,
marginTop: 60,
},
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
paddingTop: 40,
},
title: {
fontSize: 24,
textAlign: 'center',
},
profilePhoto: {
width: 140,
height: 140,
borderRadius: 70,
marginVertical: 20,
},
middleView: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
// box: {
// width: 60,
// height: 60,
// marginVertical: 20,
// },
button: {
backgroundColor: '#2980b9',
paddingVertical: 10,
paddingHorizontal: 15,
margin: 2,
},
buttonText: {
color: 'white',
fontSize: 16,
},
row: {
width: '100%',
padding: 15,
flexDirection: 'row',
justifyContent: 'space-between',
},
});

export default App;
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@
"url": "https://github.com/fijit-club/rn-tourguide/issues"
},
"homepage": "https://github.com/fijit-club/rn-tourguide#readme",
"dependencies": {
"react": "18.2.0",
"react-native": "0.73.4",
"react-native-hole-view": "^3.0.0-alpha4"
},
"devDependencies": {
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@evilmartians/lefthook": "^1.6.1",
"@evilmartians/lefthook": "^1.6.2",
"@react-native/eslint-config": "^0.73.2",
"@release-it/conventional-changelog": "^8.0.1",
"@tsconfig/strictest": "^2.0.3",
Expand All @@ -67,8 +72,6 @@
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.7.0",
"prettier": "3.2.5",
"react": "18.2.0",
"react-native": "0.73.4",
"react-native-builder-bob": "^0.23.2",
"release-it": "^17.1.1",
"typescript": "5.3.3"
Expand Down
104 changes: 101 additions & 3 deletions src/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { FC } from 'react';
import type { LayoutRectangle } from 'react-native';

import { type FC, useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { RNHoleView } from 'react-native-hole-view';

import type { IStep } from './types';

Expand All @@ -13,8 +17,102 @@ type ModalProps = {
visible: boolean;
};

const Modal: FC<ModalProps> = () => {
return null;
const Modal: FC<ModalProps> = ({ visible }) => {
const [layout, setLayout] = useState<LayoutRectangle | null>(null);
const [containerVisible, setContainerVisible] = useState<boolean>(visible);

Check warning on line 22 in src/Modal.tsx

View workflow job for this annotation

GitHub Actions / lint

'setContainerVisible' is assigned a value but never used. Allowed unused elements of array destructuring patterns must match /^_/u

if (!containerVisible) return null;

return (
<View pointerEvents="box-none" style={[StyleSheet.absoluteFill, { backgroundColor: 'transparent' }]}>

Check warning on line 27 in src/Modal.tsx

View workflow job for this annotation

GitHub Actions / lint

Color literal: { backgroundColor: 'transparent' }

Check warning on line 27 in src/Modal.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { backgroundColor: 'transparent' }
<View onLayout={(event) => setLayout(event.nativeEvent.layout)} pointerEvents="box-none" style={styles.container}>
{layout && containerVisible && (
<>
<RNHoleView
// animation={animation}
holes={[{ x: 150, y: 390, width: 120, height: 120, borderRadius: 60 }]}
onAnimationFinished={() => {
// setAnimation(undefined);
}}
style={{

Check warning on line 37 in src/Modal.tsx

View workflow job for this annotation

GitHub Actions / lint

Color literal: { backgroundColor: 'rgba(34,146,231,0.4)' }
position: 'absolute',
width: '100%',
height: '100%',
backgroundColor: 'rgba(34,146,231,0.4)',
}}
>
{/* <Video
source={{ uri: 'http://clips.vorwaerts-gmbh.de/VfE_html5.mp4' }}
resizeMode={'contain'}
style={{ flex: 1 }}
/> */}
</RNHoleView>
{/* {this.renderMask()}
{this.renderNonInteractionPlaceholder()}
{this.renderTooltip()} */}
</>
)}
</View>
</View>
);
};

export default Modal;

export const Z_INDEX = 100;
// export const MARGIN = 13;
// export const OFFSET_WIDTH = 4;

const styles = StyleSheet.create({
container: {
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: 0,
zIndex: Z_INDEX,
},
// tooltip: {
// position: 'absolute',
// paddingHorizontal: 15,
// overflow: 'hidden',
// width: '100%',
// borderRadius: 16,
// paddingTop: 24,
// alignItems: 'center',
// justifyContent: 'center',
// paddingBottom: 16,
// zIndex: Z_INDEX - 1,
// },
// nonInteractionPlaceholder: {
// backgroundColor: 'transparent',
// zIndex: Z_INDEX - 2,
// },
// tooltipText: {
// textAlign: 'center',
// },
// tooltipContainer: {
// flex: 1,
// alignItems: 'center',
// justifyContent: 'space-around',
// width: '80%',
// },
// button: {
// padding: 10,
// },
// buttonText: {
// color: '#27ae60',
// },
// bottomBar: {
// marginTop: 10,
// flexDirection: 'row',
// justifyContent: 'flex-end',
// },
// overlayContainer: {
// position: 'absolute',
// left: 0,
// top: 0,
// bottom: 0,
// right: 0,
// },
});
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function multiply(a: number, b: number): Promise<number> {
return Promise.resolve(a * b);
}
export { default as TourGuideProvider } from './TourGuideProvider';
export { default as TourGuideZone } from './TourGuideZone';
export { default as useTourGuideController } from './useTourGuideController';
21 changes: 16 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1957,12 +1957,12 @@ __metadata:
languageName: node
linkType: hard

"@evilmartians/lefthook@npm:^1.6.1":
version: 1.6.1
resolution: "@evilmartians/lefthook@npm:1.6.1"
"@evilmartians/lefthook@npm:^1.6.2":
version: 1.6.2
resolution: "@evilmartians/lefthook@npm:1.6.2"
bin:
lefthook: bin/index.js
checksum: 10c0/7f6155bd8537ad6436ae0e11734ba28047d603da4d985a72f0ada6fb8df736d2209de505276e91b98508e80cbf3cff357d1340d3de32bd0017775a3723060c18
checksum: 10c0/8938ae51713b765506b307c6672c42f91ea3864de862584cb7e82d79f67af184be2704bb751696f658424fbc35585561f195084cf023cbd0ebde2650629e8aa4
conditions: (os=darwin | os=linux | os=win32) & (cpu=x64 | cpu=arm64 | cpu=ia32)
languageName: node
linkType: hard
Expand Down Expand Up @@ -2437,7 +2437,7 @@ __metadata:
dependencies:
"@commitlint/cli": "npm:^18.6.1"
"@commitlint/config-conventional": "npm:^18.6.2"
"@evilmartians/lefthook": "npm:^1.6.1"
"@evilmartians/lefthook": "npm:^1.6.2"
"@react-native/eslint-config": "npm:^0.73.2"
"@release-it/conventional-changelog": "npm:^8.0.1"
"@tsconfig/strictest": "npm:^2.0.3"
Expand All @@ -2456,6 +2456,7 @@ __metadata:
react: "npm:18.2.0"
react-native: "npm:0.73.4"
react-native-builder-bob: "npm:^0.23.2"
react-native-hole-view: "npm:^3.0.0-alpha4"
release-it: "npm:^17.1.1"
typescript: "npm:5.3.3"
peerDependencies:
Expand Down Expand Up @@ -14634,6 +14635,16 @@ __metadata:
languageName: node
linkType: hard

"react-native-hole-view@npm:^3.0.0-alpha4":
version: 3.0.0-alpha4
resolution: "react-native-hole-view@npm:3.0.0-alpha4"
peerDependencies:
react: "*"
react-native: "*"
checksum: 10c0/906a766a2e8dbf657dc92da7c7cd214a262cd548863e9bb5312279826ece22bee6f5a3b94e51e5aeb60060b30afba34bde8e8f73d1c274c51ea6f1dd5e053e18
languageName: node
linkType: hard

"react-native-web@npm:0.19.10":
version: 0.19.10
resolution: "react-native-web@npm:0.19.10"
Expand Down

0 comments on commit 729c47d

Please sign in to comment.