-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from WayneKim92/release/v1.0.0
release/v1.0.0
- Loading branch information
Showing
7 changed files
with
712 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,194 @@ | ||
import { useState, useEffect } from 'react'; | ||
import { StyleSheet, View, Text } from 'react-native'; | ||
import { multiply } from 'react-native-good-tooltip'; | ||
import { FlatList, SafeAreaView, StyleSheet, Text, View } from 'react-native'; | ||
import Tooltip from 'react-native-good-tooltip'; | ||
|
||
export default function App() { | ||
const [result, setResult] = useState<number | undefined>(); | ||
|
||
useEffect(() => { | ||
multiply(3, 7).then(setResult); | ||
}, []); | ||
const data = [ | ||
'In FlatList', | ||
'zIndex must be specified using', | ||
'CellRendererComponent.', | ||
]; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Text>Result: {result}</Text> | ||
</View> | ||
<SafeAreaView style={styles.container}> | ||
{/* Header*/} | ||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
zIndex: 1, | ||
}} | ||
> | ||
<Tooltip | ||
isVisible={true} | ||
text="This is a tooltip" | ||
placement={'bottom'} | ||
anchor={'left'} | ||
requiredConfirmation | ||
> | ||
<View style={[styles.box, { backgroundColor: 'red' }]} /> | ||
</Tooltip> | ||
|
||
<Tooltip | ||
isVisible={true} | ||
text="This is a tooltip" | ||
placement={'bottom'} | ||
styles={{ color: 'black' }} | ||
> | ||
<View style={[styles.box, { backgroundColor: 'green' }]} /> | ||
</Tooltip> | ||
|
||
<Tooltip | ||
isVisible={true} | ||
text="This is a tooltip" | ||
placement={'bottom'} | ||
anchor={'right'} | ||
requiredConfirmation | ||
> | ||
<View style={[styles.box, { backgroundColor: 'blue' }]} /> | ||
</Tooltip> | ||
</View> | ||
|
||
<View | ||
style={{ | ||
backgroundColor: 'yellow', | ||
opacity: 0.9, | ||
paddingTop: 40, | ||
flexDirection: 'row', | ||
zIndex: 0, | ||
}} | ||
> | ||
<View | ||
style={[{ backgroundColor: 'red', flexShrink: 1 }, styles.message]} | ||
> | ||
<Text style={{ flexShrink: 1, flexGrow: 1 }}> | ||
This Tooltip component does not use modal, so you must specify | ||
z-Index. Especially if the placement is bottom, you need to be | ||
especially careful. | ||
</Text> | ||
</View> | ||
<View | ||
style={[{ backgroundColor: 'blue', flexShrink: 1 }, styles.message]} | ||
> | ||
<Text style={{ flexShrink: 1, flexGrow: 1 }}> | ||
This Tooltip component does not use modal, so you must specify | ||
z-Index. Especially if the placement is bottom, you need to be | ||
especially careful. | ||
</Text> | ||
</View> | ||
</View> | ||
|
||
{/* Body*/} | ||
<FlatList | ||
data={data} | ||
// style={{ flexGrow: 1 }} | ||
CellRendererComponent={({ index, style, ...props }) => { | ||
return ( | ||
<View | ||
style={[ | ||
style, | ||
{ | ||
zIndex: data.length - index, | ||
}, | ||
]} | ||
{...props} | ||
/> | ||
); | ||
}} | ||
renderItem={({ item, index }) => ( | ||
<Tooltip | ||
isVisible={true} | ||
placement={'bottom'} | ||
anchor={(() => { | ||
if (index % 3 === 0) return 'right'; | ||
if (index % 2 === 0) return 'center'; | ||
|
||
return 'left'; | ||
})()} | ||
text={'List Item Tooltip ' + index} | ||
> | ||
<View | ||
style={{ | ||
paddingVertical: 15, | ||
backgroundColor: 'blue', | ||
opacity: 0.4, | ||
justifyContent: 'center', | ||
alignItems: 'flex-end', | ||
paddingHorizontal: 16, | ||
}} | ||
> | ||
<Text style={{ color: 'white' }}>{`${item}`}</Text> | ||
</View> | ||
</Tooltip> | ||
)} | ||
ListFooterComponent={() => ( | ||
<View | ||
style={{ | ||
justifyContent: 'flex-end', | ||
alignItems: 'center', | ||
backgroundColor: '#8851bc', | ||
height: 500, | ||
}} | ||
> | ||
<Tooltip | ||
placement={'top'} | ||
anchor={'right'} | ||
text={'Top RIght'} | ||
isVisible={true} | ||
requiredConfirmation | ||
> | ||
<View style={{ height: 50, backgroundColor: 'red', zIndex: 0 }}> | ||
<Text> | ||
There may be situations where you need to add the overflow: | ||
'visible' style. | ||
</Text> | ||
</View> | ||
</Tooltip> | ||
|
||
<View style={{ zIndex: 0 }}> | ||
<Tooltip | ||
isVisible={true} | ||
text="Left Tooltip" | ||
placement={'left'} | ||
anchor={'top'} | ||
requiredConfirmation | ||
> | ||
<View style={[styles.box, { backgroundColor: 'red' }]} /> | ||
</Tooltip> | ||
<Tooltip | ||
isVisible={true} | ||
text="Center Tooltip" | ||
placement={'right'} | ||
anchor={'center'} | ||
> | ||
<View style={[styles.box, { backgroundColor: 'green' }]} /> | ||
</Tooltip> | ||
<Tooltip | ||
isVisible={true} | ||
text="Center Tooltip" | ||
placement={'left'} | ||
anchor={'bottom'} | ||
> | ||
<View style={[styles.box, { backgroundColor: 'blue' }]} /> | ||
</Tooltip> | ||
</View> | ||
</View> | ||
)} | ||
/> | ||
</SafeAreaView> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
marginVertical: 8, | ||
marginHorizontal: 16, | ||
}, | ||
box: { | ||
width: 60, | ||
height: 60, | ||
marginVertical: 20, | ||
width: 50, | ||
height: 50, | ||
}, | ||
message: { | ||
padding: 8, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/node_modules/react-native-anchor-point/index.ts b/node_modules/react-native-anchor-point/index.ts | ||
index f789fa7..a1a97c6 100644 | ||
--- a/node_modules/react-native-anchor-point/index.ts | ||
+++ b/node_modules/react-native-anchor-point/index.ts | ||
@@ -33,8 +33,10 @@ export const withAnchorPoint = (transform: TransformsStyle, anchorPoint: Point, | ||
shiftTranslateX.push({ | ||
translateX: size.width * (anchorPoint.x - defaultAnchorPoint.x), | ||
}); | ||
+ // @ts-ignore | ||
injectedTransform = [...shiftTranslateX, ...injectedTransform]; | ||
// shift after rotation | ||
+ // @ts-ignore | ||
injectedTransform.push({ | ||
translateX: size.width * (defaultAnchorPoint.x - anchorPoint.x), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
export const getAnchorPoint = (placement: string, anchor: string) => { | ||
let x = 0; | ||
let y = 0; | ||
|
||
// vertical | ||
if (placement === 'top' && anchor === 'left') { | ||
x = 0; | ||
y = 1; | ||
} | ||
if (placement === 'top' && anchor === 'right') { | ||
x = 1; | ||
y = 1; | ||
} | ||
if (placement === 'top' && anchor === 'center') { | ||
x = 0.5; | ||
y = 1; | ||
} | ||
|
||
if (placement === 'bottom' && anchor === 'left') { | ||
x = 0; | ||
y = 0; | ||
} | ||
if (placement === 'bottom' && anchor === 'center') { | ||
x = 0.5; | ||
y = 0; | ||
} | ||
if (placement === 'bottom' && anchor === 'right') { | ||
x = 1; | ||
y = 0; | ||
} | ||
|
||
// horizontal | ||
if (placement === 'left' && anchor === 'top') { | ||
x = 1; | ||
y = 0; | ||
} | ||
if (placement === 'left' && anchor === 'center') { | ||
x = 1; | ||
y = 0.5; | ||
} | ||
if (placement === 'left' && anchor === 'bottom') { | ||
x = 1; | ||
y = 1; | ||
} | ||
if (placement === 'right' && anchor === 'top') { | ||
x = 0; | ||
y = 0; | ||
} | ||
if (placement === 'right' && anchor === 'center') { | ||
x = 0; | ||
y = 0.5; | ||
} | ||
if (placement === 'right' && anchor === 'bottom') { | ||
x = 0; | ||
y = 1; | ||
} | ||
|
||
return { x, y }; | ||
}; | ||
|
||
export const createArrowShape = (width: number, height: number) => { | ||
return { | ||
borderLeftWidth: width / 2, | ||
borderRightWidth: width / 2, | ||
borderBottomWidth: height, | ||
borderLeftColor: 'transparent', | ||
borderRightColor: 'transparent', | ||
}; | ||
}; |
Oops, something went wrong.