diff --git a/example/src/App-old.js b/example/src/App-old.js deleted file mode 100644 index 28d1715..0000000 --- a/example/src/App-old.js +++ /dev/null @@ -1,183 +0,0 @@ -import * as React from 'react'; -import { StyleSheet, SafeAreaView, ScrollView, View, Text, Switch } from 'react-native'; - -import * as Colors from './constants/Colors'; - -import { ContextMenuViewSimpleExample01 } from './components/ContextMenuView/ContextMenuViewSimpleExample01'; -import { ContextMenuViewSimpleExample02 } from './components/ContextMenuView/ContextMenuViewSimpleExample02'; -import { ContextMenuViewSimpleExample03 } from './components/ContextMenuView/ContextMenuViewSimpleExample03'; -import { ContextMenuViewSimpleExample04 } from './components/ContextMenuView/ContextMenuViewSimpleExample04'; -import { ContextMenuViewSimpleExample05 } from './components/ContextMenuView/ContextMenuViewSimpleExample05'; -import { ContextMenuViewSimpleExample06 } from './components/ContextMenuView/ContextMenuViewSimpleExample06'; -import { ContextMenuViewSimpleExample07 } from './components/ContextMenuView/ContextMenuViewSimpleExample07'; -import { ContextMenuViewSimpleExample08 } from './components/ContextMenuView/ContextMenuViewSimpleExample08'; -import { ContextMenuViewSimpleExample09 } from './components/ContextMenuView/ContextMenuViewSimpleExample09'; -import { ContextMenuViewSimpleExample10 } from './components/ContextMenuView/ContextMenuViewSimpleExample10'; -import { ContextMenuViewSimpleExample11 } from './components/ContextMenuView/ContextMenuViewSimpleExample11'; -import { ContextMenuViewSimpleExample12 } from './components/ContextMenuView/ContextMenuViewSimpleExample12'; -import { ContextMenuViewSimpleExample13 } from './components/ContextMenuView/ContextMenuViewSimpleExample13'; -import { ContextMenuViewSimpleExample14 } from './components/ContextMenuView/ContextMenuViewSimpleExample14'; -import { ContextMenuViewSimpleExample15 } from './components/ContextMenuView/ContextMenuViewSimpleExample15'; -import { ContextMenuViewSimpleExample16 } from './components/ContextMenuView/ContextMenuViewSimpleExample16'; -import { ContextMenuViewSimpleExample17 } from './components/ContextMenuView/ContextMenuViewSimpleExample17'; -import { ContextMenuViewSimpleExample18 } from './components/ContextMenuView/ContextMenuViewSimpleExample18'; - -import { ContextMenuViewTest01 } from './components/ContextMenuView/ContextMenuViewTest01'; -import { ContextMenuViewTest02 } from './components/ContextMenuView/ContextMenuViewTest02'; -import { ContextMenuViewTest03 } from './components/ContextMenuView/ContextMenuViewTest03'; -import { ContextMenuViewTest04 } from './components/ContextMenuView/ContextMenuViewTest04'; -import { ContextMenuViewTest05 } from './components/ContextMenuView/ContextMenuViewTest05'; -import { ContextMenuViewTest06 } from './components/ContextMenuView/ContextMenuViewTest06'; -import { ContextMenuViewTest07 } from './components/ContextMenuView/ContextMenuViewTest07'; -import { ContextMenuViewTest08 } from './components/ContextMenuView/ContextMenuViewTest08'; - -import { ContextMenuButtonSimpleExample01 } from './components/ContextMenuButton/ContextMenuButtonSimpleExample01'; -import { ContextMenuButtonSimpleExample02 } from './components/ContextMenuButton/ContextMenuButtonSimpleExample02'; - - -const contextMenuViewItems = [ - ContextMenuViewSimpleExample01, - ContextMenuViewSimpleExample02, - ContextMenuViewSimpleExample03, - ContextMenuViewSimpleExample04, - ContextMenuViewSimpleExample05, - ContextMenuViewSimpleExample06, - ContextMenuViewSimpleExample07, - ContextMenuViewSimpleExample08, - ContextMenuViewSimpleExample09, - ContextMenuViewSimpleExample10, - ContextMenuViewSimpleExample11, - ContextMenuViewSimpleExample12, - ContextMenuViewSimpleExample13, - ContextMenuViewSimpleExample14, - ContextMenuViewSimpleExample15, - ContextMenuViewSimpleExample16, - ContextMenuViewSimpleExample17, - ContextMenuViewSimpleExample18, - ContextMenuViewTest01, - ContextMenuViewTest02, - ContextMenuViewTest03, - ContextMenuViewTest04, - ContextMenuViewTest05, - ContextMenuViewTest06, - ContextMenuViewTest07, - ContextMenuViewTest08, -]; - -const contextMenuButtonItems = [ - ContextMenuButtonSimpleExample01, - ContextMenuButtonSimpleExample02, -]; - -console.disableYellowBox = true; - -export default function App() { - const [contextMenuViewUseActionSheetFallback, setContextMenuViewUseActionSheetFallback] = React.useState(false); - const toggleContextMenuViewUseActionSheetFallback = () => - setContextMenuViewUseActionSheetFallback(previousState => !previousState); - - const [contextMenuButtonUseActionSheetFallback, setContextMenuButtonUseActionSheetFallback] = React.useState(false); - const toggleContextMenuButtonUseActionSheetFallback = () => - setContextMenuButtonUseActionSheetFallback(previousState => !previousState); - - return ( - - - - {'ContextMenuView'} - - - {'Examples and tests for `ContextMenuView`'} - - - - {'When the context menu is visible, the card wil turn purple.'} - - - - {'useActionSheetFallback: '} - - - - - {contextMenuViewItems.map((element, index) => - React.createElement(element, { - key : `context-menu-view-item-${index}`, - index: (index + 1), - // pass down props - useActionSheetFallback: contextMenuViewUseActionSheetFallback, - }) - )} - - - {'ContextMenuButton'} - - - {'Examples and tests for `ContextMenuButton`'} - - - - {'When the context menu is visible, the button will turn yellow.'} - - - - {'useActionSheetFallback: '} - - - - - {contextMenuButtonItems.map((element, index) => - React.createElement(element, { - key : `context-menu-button-item-${index}`, - index: (index + 1), - // pass down props - useActionSheetFallback: contextMenuButtonUseActionSheetFallback, - }) - )} - - - ); -}; - -const styles = StyleSheet.create({ - rootContainer: { - flex: 1, - }, - scrollviewContainer: { - paddingBottom: 30, - }, - textSectionTitle: { - fontSize: 32, - fontWeight: 'bold', - marginHorizontal: 10, - }, - textSectionSubtitle: { - marginHorizontal: 10, - fontSize: 16, - fontWeight: '300', - color: Colors.GREY[600], - marginBottom: 5, - }, - headerContainer: { - borderRadius: 10, - padding: 15, - marginTop: 10, - marginHorizontal: 20, - backgroundColor: Colors.BLUE[100] - }, - headerRowContainer: { - flexDirection: 'row', - alignItems: 'center', - marginTop: 7, - }, - headerRowText: { - flex: 1, - fontWeight: 'bold' - }, -}); diff --git a/example/src/components/ContextMenuButton/ContextMenuButtonSimpleExample01.js b/example/src/components/ContextMenuButton/ContextMenuButtonSimpleExample01.js deleted file mode 100644 index 3a10dcb..0000000 --- a/example/src/components/ContextMenuButton/ContextMenuButtonSimpleExample01.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuButtonItem } from '../ExampleContextMenuButtonItem'; - - -export class ContextMenuButtonSimpleExample01 extends React.PureComponent { - render(){ - return( - alert('TouchableOpacity - OnPress')} - onPressMenuItem={({nativeEvent}) => alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - menuConfig={{ - menuTitle: 'ContextMenuButtonSimpleExample01', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - }, { - actionKey : 'key-02' , - actionTitle: 'Action #2', - }, { - actionKey : 'key-03' , - actionTitle: 'Action #3', - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuButton/ContextMenuButtonSimpleExample02.js b/example/src/components/ContextMenuButton/ContextMenuButtonSimpleExample02.js deleted file mode 100644 index 83a088d..0000000 --- a/example/src/components/ContextMenuButton/ContextMenuButtonSimpleExample02.js +++ /dev/null @@ -1,49 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuButtonItem } from '../ExampleContextMenuButtonItem'; - - -export class ContextMenuButtonSimpleExample02 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - isMenuPrimaryAction={true} - menuConfig={{ - menuTitle: 'ContextMenuButtonSimpleExample02', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - actionKey : 'key-02' , - actionTitle: 'Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'dial.fill', - } - }, { - actionKey : 'key-03' , - actionTitle: 'Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'archivebox.fill', - } - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample01.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample01.js deleted file mode 100644 index b06bb11..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample01.js +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - - -export class ContextMenuViewSimpleExample01 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample01', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - }, { - actionKey : 'key-02' , - actionTitle: 'Action #2', - }, { - actionKey : 'key-03' , - actionTitle: 'Action #3', - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample02.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample02.js deleted file mode 100644 index 56a116f..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample02.js +++ /dev/null @@ -1,50 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample02 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample02', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - actionKey : 'key-02' , - actionTitle: 'Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'dial.fill', - } - }, { - actionKey : 'key-03' , - actionTitle: 'Action #3', - imageValue : 'archivebox.fill', - icon: { - iconType : 'SYSTEM', - iconValue: 'archivebox.fill', - } - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample03.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample03.js deleted file mode 100644 index 4d9402c..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample03.js +++ /dev/null @@ -1,59 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample03 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample03', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - menuTitle: 'Submenu...', - menuItems: [{ - actionKey : 'key-01-01', - actionTitle: 'Submenu Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'star', - } - }, { - actionKey : 'key-01-02', - actionTitle: 'Submenu Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.lefthalf.fill', - } - }, { - actionKey : 'key-01-03', - actionTitle: 'Submenu Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.fill', - } - }] - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample04.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample04.js deleted file mode 100644 index b5043fa..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample04.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample04 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample04', - menuItems: [{ - actionKey : 'key-01', - actionTitle : 'Disabled Action', - menuAttributes: ['disabled'], - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - actionKey : 'key-02' , - actionTitle : 'Destructive Action', - menuAttributes: ['destructive'], - icon: { - iconType : 'SYSTEM', - iconValue: 'trash', - } - }, { - actionKey : 'key-03' , - actionTitle : 'Hidden Action', - menuAttributes: ['hidden'], - icon: { - iconType : 'SYSTEM', - iconValue: 'trash', - } - }, { - actionKey : 'key-04' , - actionTitle : 'Disabled/Destructive', - menuAttributes: ['disabled', 'destructive'], - icon: { - iconType : 'SYSTEM', - iconValue: 'trash.fill', - } - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample05.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample05.js deleted file mode 100644 index 3f92c0c..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample05.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample05 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample05', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - menuTitle: 'Submenu...', - menuOptions: ['displayInline'], - menuItems: [{ - actionKey : 'key-01-01', - actionTitle: 'Submenu Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'star', - } - }, { - actionKey : 'key-01-02', - actionTitle: 'Submenu Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.lefthalf.fill', - } - }, { - actionKey : 'key-01-03', - actionTitle: 'Submenu Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.fill', - } - }] - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample06.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample06.js deleted file mode 100644 index 3396fd5..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample06.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample06 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample06', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - menuTitle: 'Submenu...', - menuOptions: ['destructive'], - menuItems: [{ - actionKey : 'key-01-01', - actionTitle: 'Submenu Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'star', - } - }, { - actionKey : 'key-01-02', - actionTitle: 'Submenu Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.lefthalf.fill', - } - }, { - actionKey : 'key-01-03', - actionTitle: 'Submenu Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.fill', - } - }] - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample07.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample07.js deleted file mode 100644 index 283e6ac..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample07.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample07 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample07', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - menuTitle: 'Submenu...', - menuOptions: ['displayInline', 'destructive'], - menuItems: [{ - actionKey : 'key-01-01', - actionTitle: 'Submenu Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'star', - } - }, { - actionKey : 'key-01-02', - actionTitle: 'Submenu Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.lefthalf.fill', - } - }, { - actionKey : 'key-01-03', - actionTitle: 'Submenu Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'star.fill', - } - }] - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample08.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample08.js deleted file mode 100644 index 041c0a6..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample08.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample08 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample08', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'menuState: on', - menuState : 'on', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - actionKey : 'key-02' , - actionTitle: 'menuState: off', - menuState : 'off', - icon: { - iconType : 'SYSTEM', - iconValue: 'dial', - } - }, { - actionKey : 'key-03' , - actionTitle: 'menuState: mixed', - menuState : 'mixed', - icon: { - iconType : 'SYSTEM', - iconValue: 'archivebox', - } - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample09.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample09.js deleted file mode 100644 index bba6087..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample09.js +++ /dev/null @@ -1,66 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample09 extends React.PureComponent { - - _handleOnPressMenuItem = ({nativeEvent}) => { - switch (nativeEvent.actionKey) { - case 'save': - alert('saving...'); - break; - - case 'like': - alert('liking...'); - break; - - case 'play': - alert('playing...'); - break; - }; - }; - - render(){ - return( - alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample09', - menuItems: [{ - actionKey : 'save', - actionTitle: 'Save', - icon: { - iconType : 'SYSTEM', - iconValue: 'square.and.arrow.down', - } - }, { - actionKey : 'like', - actionTitle: 'Like', - icon: { - iconType : 'SYSTEM', - iconValue: 'hand.thumbsup', - } - }, { - actionKey : 'play', - actionTitle: 'Play', - icon: { - iconType : 'SYSTEM', - iconValue: 'play', - } - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample10.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample10.js deleted file mode 100644 index 125c9f9..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample10.js +++ /dev/null @@ -1,65 +0,0 @@ -import React, { useState, useRef } from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export function ContextMenuViewSimpleExample10(props) { - - const [timer, setTimer] = useState(0); - const increment = useRef(null); - - const handleStart = () => { - increment.current = setInterval(() => { - setTimer((timer) => timer + 1); - }, 1000); - }; - - const handleReset = () => { - clearInterval(increment.current); - setTimer(0); - }; - - return( - handleStart()} - onMenuDidHide={() => handleReset()} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample10', - menuItems: [{ - actionKey : 'key-00', - actionTitle: `Static Action`, - icon: { - iconType : 'SYSTEM', - iconValue: 'square.and.arrow.down', - } - }, { - actionKey : 'key-01', - actionTitle: `timer: ${timer}`, - icon: { - iconType : 'SYSTEM', - iconValue: ((timer % 2 == 0) - ? 'heart' - : 'heart.fill' - ), - } - }, (timer % 3 == 0) && { - actionKey : 'key-02', - actionTitle: `Dynamic Action`, - icon: { - iconType : 'SYSTEM', - iconValue: 'scissors.badge.ellipsis', - } - }], - }} - /> - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample11.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample11.js deleted file mode 100644 index 87b5098..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample11.js +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export function ContextMenuViewSimpleExample11(props) { - - return( - ( - - - Hello World - - - Hello World - - - Hello World - - - )} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample11', - }} - /> - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample12.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample12.js deleted file mode 100644 index a87d01b..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample12.js +++ /dev/null @@ -1,84 +0,0 @@ -import React, { useState, useRef } from 'react'; -import { StyleSheet, View, Text } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export function ContextMenuViewSimpleExample12(props) { - const [timer, setTimer] = useState(0); - const increment = useRef(null); - - const handleStart = () => { - increment.current = setInterval(() => { - setTimer((timer) => timer + 1); - }, 1000); - }; - - const handleStop = () => { - clearInterval(increment.current); - }; - - const handleReset = () => { - clearInterval(increment.current); - setTimer(0); - }; - - return( - ( - - - {`Counter: ${timer}`} - - - {(timer % 2 == 0)? 'EVEN' : 'The number is: ODD'} - - - )} - onMenuDidShow={() => handleStart()} - onMenuDidHide={() => handleStop()} - onPressMenuItem={({nativeEvent}) => { - switch (nativeEvent.actionKey) { - case 'add': - setTimer((timer) => timer + 100); - break; - - case 'reset': - handleReset(); - break; - }; - }} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample12', - menuItems: [{ - actionKey : 'add', - actionTitle : `Add 100`, - icon: { - iconType : 'SYSTEM', - iconValue: 'plus', - } - }, (timer > 0) && { - actionKey : 'reset', - actionTitle : `Reset Counter`, - menuAttributes: ['destructive'], - icon: { - iconType : 'SYSTEM', - iconValue: 'trash', - } - }], - }} - /> - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample13.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample13.js deleted file mode 100644 index a717e1f..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample13.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - - -export function ContextMenuViewSimpleExample13(props) { - return( - - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample14.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample14.js deleted file mode 100644 index 29ce17d..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample14.js +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export function ContextMenuViewSimpleExample14(props) { - - return( - ( - - - Hello World - - - Hello World - - - Hello World - - - )} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample14', - }} - /> - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample15.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample15.js deleted file mode 100644 index dca7c08..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample15.js +++ /dev/null @@ -1,65 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text, findNodeHandle } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewSimpleExample15 extends React.PureComponent { - constructor(props){ - super(props); - - this.state = { - targetViewNode: null, - }; - }; - - componentDidMount(){ - this.setState({ - targetViewNode: findNodeHandle(this.viewRef) - }); - }; - - render(){ - return( - - this.viewRef = r} - > - - {`Hello! Target Node: ${this.state.targetViewNode}`} - - - - ); - }; -}; - -const styles = StyleSheet.create({ - targetContainer: { - backgroundColor: 'rgba(255,255,255,0.5)', - alignSelf: 'flex-start', - padding: 10, - borderRadius: 10, - marginTop: 10, - }, - text: { - fontSize: 16, - } -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample16.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample16.js deleted file mode 100644 index e882d1c..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample16.js +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import { StyleSheet, Image, Text } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export function ContextMenuViewSimpleExample16(props) { - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewSimpleExample16', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - discoverabilityTitle: 'No Icon', - }, { - actionKey : 'key-02' , - actionTitle: 'Action #2', - discoverabilityTitle: 'Use "SYSTEM" icon', - icon: { - iconType : 'SYSTEM', - iconValue: 'dial.fill', - } - }, { - actionKey : 'key-03' , - actionTitle: 'Action #3', - discoverabilityTitle: 'Use "ASSET" icon', - icon: { - iconType : 'ASSET', - iconValue: 'icon-rainbow-flag', - } - }], - }} - /> - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample17.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample17.js deleted file mode 100644 index 94042dc..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample17.js +++ /dev/null @@ -1,60 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export function ContextMenuViewSimpleExample17(props) { - return( - - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample18.js b/example/src/components/ContextMenuView/ContextMenuViewSimpleExample18.js deleted file mode 100644 index 1eba948..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewSimpleExample18.js +++ /dev/null @@ -1,59 +0,0 @@ -import React from 'react'; -import { StyleSheet, Image } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - -const iconA = Image.resolveAssetSource( - require('../../assets/emoji-pleading-face.png') -); - -const iconB = Image.resolveAssetSource( - require('../../assets/emoji-smiling-face-with-hearts.png') -); - -const iconC = Image.resolveAssetSource( - require('../../assets/emoji-sparkling-heart.png') -); - -export function ContextMenuViewSimpleExample18(props) { - return( - - ); -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest01.js b/example/src/components/ContextMenuView/ContextMenuViewTest01.js deleted file mode 100644 index bf7e932..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest01.js +++ /dev/null @@ -1,134 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - - -export class ContextMenuViewTest01 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewTest01', - menuItems: [{ - actionKey : 'key-01' , - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'hare', - } - }, { - actionKey : 'key-02' , - actionTitle: 'Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'calendar', - } - }, { - menuTitle: 'Submenu #1...', - icon: { - iconType : 'SYSTEM', - iconValue: 'ant', - }, - menuItems: [{ - actionKey : 'key-03-01' , - actionTitle: 'Submenu Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'moon', - }, - }, { - actionKey : 'key-03-02' , - actionTitle: 'Submenu Action #4', - icon: { - iconType : 'SYSTEM', - iconValue: 'house', - } - }, { - menuTitle: 'Submenu #5...', - icon: { - iconType : 'SYSTEM', - iconValue: 'moon.stars', - }, - menuItems: [{ - actionKey : 'key-03-03-01', - actionTitle: 'Submenu Action #5', - icon: { - iconType : 'SYSTEM', - iconValue: 'dial', - } - }, { - actionKey : 'key-03-03-02', - actionTitle: 'Submenu Action #6', - icon: { - iconType : 'SYSTEM', - iconValue: 'square.and.arrow.up.on.square', - } - }, { - menuTitle: 'Submenu #3...', - icon: { - iconType : 'SYSTEM', - iconValue: 'archivebox', - }, - menuItems: [{ - actionKey : 'key-03-03-03-01', - actionTitle: 'Submenu Action #7', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - }, - }, { - actionKey : 'key-03-03-03-02', - actionTitle: 'Submenu Action #8', - icon: { - iconType : 'SYSTEM', - iconValue: 'pencil.slash', - } - }, { - menuTitle: 'Submenu #4...', - icon: { - iconType : 'SYSTEM', - iconValue: 'rosette', - }, - menuItems: [{ - actionKey : 'key-03-03-03-03-01', - actionTitle: 'Submenu Action #9', - icon: { - iconType : 'SYSTEM', - iconValue: 'lessthan.circle', - } - }, { - actionKey : 'key-03-03-03-03-02', - actionTitle: 'Submenu Action #10', - icon: { - iconType : 'SYSTEM', - iconValue: 'divide.square', - } - }, { - actionKey : 'key-03-03-03-03-03', - actionTitle: 'Submenu Action #11', - icon: { - iconType : 'SYSTEM', - iconValue: 'cloud.moon', - } - }], - }], - }], - }], - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest02.js b/example/src/components/ContextMenuView/ContextMenuViewTest02.js deleted file mode 100644 index 4ecb94a..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest02.js +++ /dev/null @@ -1,106 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - - -export class ContextMenuViewTest02 extends React.PureComponent { - render(){ - return( - alert(`onPressMenuItem nativeEvent: ${JSON.stringify(nativeEvent)}`)} - onPressMenuPreview={() => alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewTest02', - menuItems: [{ - menuTitle: 'Inline Submenu #1', - menuOptions: ['displayInline'], - menuItems: [{ - actionKey : 'key-01' , - actionTitle: 'Inline Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'hare', - } - }, { - menuTitle : 'Submenu #1...', - icon: { - iconType : 'SYSTEM', - iconValue: 'calendar', - }, - menuItems: [{ - actionKey : 'key-02-01', - actionTitle: 'Submenu Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'paperclip', - } - }, { - menuTitle: 'Inline Submenu #4', - menuOptions: ['displayInline'], - menuItems: [{ - actionKey : 'key-02-02', - actionTitle: 'Inline Submenu Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'house', - } - }, { - actionKey : 'key-02-03', - actionTitle: 'Inline Submenu Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'tag', - } - }], - }, { - actionKey : 'key-02-04', - actionTitle: 'Submenu Action #4', - icon: { - iconType : 'SYSTEM', - iconValue: 'sun.haze', - } - }], - }], - }, { - menuTitle: 'Inline Submenu #2', - menuOptions: ['displayInline'], - menuItems: [{ - actionKey : 'key-03' , - actionTitle : 'Inline Submenu Action #2', - menuAttributes: ['disabled'], - icon: { - iconType : 'SYSTEM', - iconValue: 'suit.heart', - } - }, { - actionKey : 'key-04' , - actionTitle: 'Inline Submenu Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'suit.club', - } - }], - }, { - actionKey : 'key-05' , - actionTitle : 'Action #4', - menuAttributes: ['destructive'], - icon: { - iconType : 'SYSTEM', - iconValue: 'trash', - } - }] - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest03.js b/example/src/components/ContextMenuView/ContextMenuViewTest03.js deleted file mode 100644 index b2a87af..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest03.js +++ /dev/null @@ -1,110 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - - -export class ContextMenuViewTest03 extends React.PureComponent { - constructor(props){ - super(props); - - this.state = { - actionState1: false, - actionState2: false, - actionState3: false, - }; - }; - - _handleOnPressMenuItem = ({nativeEvent}) => { - switch (nativeEvent.actionKey) { - case 'key-01': - this.setState((prevState) => ({ - actionState1: !prevState.actionState1 - })); - break; - - case 'key-02': - this.setState((prevState) => ({ - actionState2: !prevState.actionState2 - })); - break; - - case 'key-03': - this.setState((prevState) => ({ - actionState3: !prevState.actionState3 - })); - break; - - case 'key-04': - this.setState({ - actionState1: false, - actionState2: false, - actionState3: false, - }); - break; - }; - }; - - render(){ - const state = this.state; - - const resetEnabled = ( - state.actionState1 || - state.actionState2 || - state.actionState3 - ); - - return( - alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewTest03', - menuItems: [{ - actionKey : 'key-01', - actionTitle: `Action 1: ${state.actionState1? 'on' : 'off'}`, - menuState : (state.actionState1? 'on' : 'off'), - icon: { - iconType : 'SYSTEM', - iconValue: 'heart', - } - }, { - actionKey : 'key-02', - actionTitle: `Action 2: ${state.actionState2? 'on' : 'off'}`, - menuState : (state.actionState2? 'on' : 'off'), - icon: { - iconType : 'SYSTEM', - iconValue: 'suit.club', - } - }, { - actionKey : 'key-03', - actionTitle: `Action 3: ${state.actionState3? 'on' : 'off'}`, - menuState : (state.actionState3? 'on' : 'off'), - icon: { - iconType : 'SYSTEM', - iconValue: 'suit.spade', - } - }, { - actionKey : 'key-04', - actionTitle : `Reset All`, - menuAttributes: [resetEnabled? 'destructive' : 'hidden'], - menuState : 'off', - icon: { - iconType : 'SYSTEM', - iconValue: 'trash', - } - }] - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest04.js b/example/src/components/ContextMenuView/ContextMenuViewTest04.js deleted file mode 100644 index 794eef2..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest04.js +++ /dev/null @@ -1,110 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewTest04 extends React.PureComponent { - constructor(props){ - super(props); - - this.state = { - actionToggle1: false, - actionToggle2: false, - actionToggle3: false, - }; - }; - - _handleOnPressMenuItem = ({nativeEvent}) => { - switch (nativeEvent.actionKey) { - case 'key-01': - this.setState((prevState) => ({ - actionToggle1: !prevState.actionToggle1 - })); - break; - - case 'key-02': - this.setState((prevState) => ({ - actionToggle2: !prevState.actionToggle2 - })); - break; - - case 'key-03': - this.setState((prevState) => ({ - actionToggle3: !prevState.actionToggle3 - })); - break; - - case 'key-04': - this.setState({ - actionToggle1: false, - actionToggle2: false, - actionToggle3: false, - }); - break; - }; - }; - - render(){ - const state = this.state; - - const resetEnabled = ( - state.actionToggle1 || - state.actionToggle2 || - state.actionToggle3 - ); - - return( - alert('onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewTest04', - menuItems: [{ - actionKey : 'key-01', - actionTitle: `Action 1: ${state.actionToggle1? 'on' : 'off'}`, - icon: { - iconType : 'SYSTEM', - iconValue: (state.actionToggle1? 'heart.fill' : 'heart'), - } - }, { - actionKey : 'key-02', - actionTitle: `Action 2: ${state.actionToggle2? 'on' : 'off'}`, - icon: { - iconType : 'SYSTEM', - iconValue: (state.actionToggle2? 'suit.club.fill' : 'suit.club'), - } - }, { - actionKey : 'key-03', - actionTitle: `Action 3: ${state.actionToggle3? 'on' : 'off'}`, - icon: { - iconType : 'SYSTEM', - iconValue: (state.actionToggle3? 'suit.spade.fill' : 'suit.spade'), - } - }, { - menuTitle : 'Inline Menu', - menuOptions: ['displayInline'], - menuItems : [{ - actionKey : 'key-04', - actionTitle : `Reset All`, - menuAttributes: [resetEnabled? 'destructive' : 'hidden'], - menuState : 'off', - icon: { - iconType : 'SYSTEM', - iconValue: 'trash', - } - }], - }] - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest05.js b/example/src/components/ContextMenuView/ContextMenuViewTest05.js deleted file mode 100644 index 2988aac..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest05.js +++ /dev/null @@ -1,116 +0,0 @@ -import React from 'react'; -import { StyleSheet, FlatList, View, Text } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - -import * as Helpers from '../../functions/helpers'; - - -function handleEvent(that, event){ - const date = new Date(); - - const h = Helpers.pad(date.getHours ()); - const m = Helpers.pad(date.getMinutes()); - const s = Helpers.pad(date.getSeconds()); - - const ms = Helpers.pad(date.getMilliseconds(), 3); - - that.setState((prevState) => ({ - events: [{ - timestamp: `${h}:${m}:${s}.${ms}`, - type: event - }, ...prevState.events] - })); -}; - -export class ContextMenuViewTest05 extends React.PureComponent { - constructor(props){ - super(props); - - this.state = { - events: [], - }; - }; - - _renderItem = ({item, index}) => { - const { events } = this.state; - const eventCount = events.length; - - return ( - - - {`${Helpers.pad(eventCount - index, 3)} - ${item.timestamp} - `} - - {item.type} - - - - ); - }; - - render(){ - const state = this.state; - - return( - handleEvent(this, 'onMenuWillShow' )} - onMenuWillHide ={() => handleEvent(this, 'onMenuWillHide' )} - onMenuWillCancel ={() => handleEvent(this, 'onMenuWillCancel' )} - onMenuDidShow ={() => handleEvent(this, 'onMenuDidShow' )} - onMenuDidHide ={() => handleEvent(this, 'onMenuDidHide' )} - onMenuDidCancel ={() => handleEvent(this, 'onMenuDidCancel' )} - onPressMenuItem ={() => handleEvent(this, 'onPressMenuItem' )} - onPressMenuPreview={() => handleEvent(this, 'onPressMenuPreview')} - menuConfig={{ - menuTitle: 'ContextMenuViewTest05', - menuItems: [{ - actionKey : 'key-01', - actionTitle: 'Action #1', - icon: { - iconType : 'SYSTEM', - iconValue: 'folder', - } - }, { - actionKey : 'key-02' , - actionTitle: 'Action #2', - icon: { - iconType : 'SYSTEM', - iconValue: 'dial.fill', - } - }, { - actionKey : 'key-03' , - actionTitle: 'Action #3', - icon: { - iconType : 'SYSTEM', - iconValue: 'archivebox.fill', - } - }], - }} - > - item.timestamp} - /> - - ); - }; -}; - -const styles = StyleSheet.create({ - exampleContextMenu: { - - }, - scrollview: { - flex: 1, - height: 100, - marginTop: 7, - }, -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest06.js b/example/src/components/ContextMenuView/ContextMenuViewTest06.js deleted file mode 100644 index 47214b2..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest06.js +++ /dev/null @@ -1,86 +0,0 @@ -import React from 'react'; -import { StyleSheet } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewTest06 extends React.PureComponent { - constructor(props){ - super(props); - - this.state = { - itemCount: 0, - }; - }; - - _hanldeOnPressMenuItem = ({nativeEvent}) => { - switch (nativeEvent.actionKey) { - case 'add-action': - this.setState((prevState) => ({ - itemCount: ((prevState.itemCount ?? 0) + 1) - })); - break; - - case 'delete-all': - this.setState({ - itemCount: 0, - }); - break; - - default: - alert(`onPressMenuItem: ${nativeEvent.actionKey}`); - break; - }; - }; - - render(){ - const { itemCount } = this.state; - const menuItems = [...Array(itemCount).keys()]; - - const hasItems = (itemCount > 0); - - return( - ({ - actionKey : `item-key-${item}`, - actionTitle: `Action #${item}`, - icon: { - iconType : 'SYSTEM', - iconValue: (item % 2 == 0)? 'heart.fill' : 'heart', - } - })), - }], - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest07.js b/example/src/components/ContextMenuView/ContextMenuViewTest07.js deleted file mode 100644 index be1d4ef..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest07.js +++ /dev/null @@ -1,294 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text, Switch, findNodeHandle } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -class Test extends React.Component { - constructor(props){ - super(props); - this.state = { - }; - }; - - render(){ - return( - this.viewRef = r} - style={{width: 100, height: 100, backgroundColor: 'red', alignItems: 'center', justifyContent: 'center'}} - > - {this.state.node} - - ); - } -}; - -export class ContextMenuViewTest07 extends React.PureComponent { - constructor(props){ - super(props); - - this.interval = null; - - this.state = { - counter: 0, - targetViewNode: null, - // flags for switch - isResizeAnimated : true , - togglePreviewType : false, - togglePreviewSize : false, - toggleBgTransparent : false, - toggleTargetViewNode: false, - togglePreferredCommitStyle: false, - }; - }; - - render(){ - const state = this.state; - - let opaque = 'white'; - let transp = 'rgba(255,255,255,0.5)'; - - const previewConfig = { - previewType : (state.togglePreviewType ? 'CUSTOM' : 'DEFAULT'), - previewSize : (state.togglePreviewSize ? 'STRETCH' : 'INHERIT'), - backgroundColor: (state.toggleBgTransparent ? opaque : transp ), - ...(state.toggleTargetViewNode && { - targetViewNode: state.targetViewNode, - }), - isResizeAnimated: state.isResizeAnimated, - preferredCommitStyle: (state.togglePreferredCommitStyle? 'pop' : 'dismiss'), - }; - - return( - { - this.interval = setInterval(() => { - this.setState((prevState) => ({ - counter: prevState.counter + 1, - })); - }, 1000); - }} - onMenuWillHide={() => { - if(!this.interval) return; - clearInterval(this.interval); - }} - renderPreview={() => ( - - - {'Hello World'} - - {(state.counter % 2 == 0) && ( - - {`Counter: ${state.counter}`} - - )} - - )} - onPressMenuItem={({nativeEvent}) => { - switch (nativeEvent.actionKey) { - case 'add': - this.setState((prevState) => ({ - counter: (prevState.counter + 100) - })); - break; - - case 'reset': - this.setState({ counter: 0 }); - break; - }; - }} - menuConfig={{ - menuTitle: 'ContextMenuViewTest07', - menuItems: [{ - actionKey : 'add', - actionTitle: `Add 100`, - discoverabilityTitle: `Current counter ${state.counter}`, - icon: { - iconType : 'SYSTEM', - iconValue: 'plus', - } - }, - (state.counter > 0) && { - actionKey : 'reset', - actionTitle : `Reset Counter`, - menuAttributes: ['destructive'], - icon: { - iconType : 'SYSTEM', - iconValue: 'trash', - } - }], - }} - > - {state.toggleTargetViewNode && ( - { - this.setState({ - targetViewNode: findNodeHandle(ref) - }); - }} - > - - {'Target View'} - - - )} - - - - {'previewType'} - - - - {'Value: '} - - {previewConfig.previewType} - - - { - this.setState({togglePreviewType: flag}); - }} - /> - - - - - {'previewSize'} - - - - {'Value: '} - - {previewConfig.previewSize} - - - { - this.setState({togglePreviewSize: flag}); - }} - /> - - - - - {'backgroundColor'} - - - - {'Value: '} - - {previewConfig.backgroundColor} - - - { - this.setState({toggleBgTransparent: flag}); - }} - /> - - - - - {'isResizeAnimated'} - - - - {'Value: '} - - {previewConfig.isResizeAnimated? 'true' : 'false'} - - - { - this.setState({isResizeAnimated: flag}); - }} - /> - - - - - {'preferredCommitStyle'} - - - - {'Value: '} - - {previewConfig.preferredCommitStyle} - - - { - this.setState({togglePreferredCommitStyle: flag}); - }} - /> - - - - - {'targetViewNode'} - - - - {'Value: '} - - {previewConfig.targetViewNode} - - - { - this.setState({toggleTargetViewNode: flag}); - }} - /> - - - ); - }; -}; - -const styles = StyleSheet.create({ - rowContainer: { - flexDirection: 'row', - marginVertical: 10, - alignItems: 'center', - }, - textRowContainer: { - flex: 1, - }, - textRowTitle: { - fontSize: 16, - fontWeight: '400' - }, - textRowSubtitle: { - color: 'rgba(0,0,0,0.6)' - }, - targetViewContainer: { - padding: 15, - backgroundColor: 'rgba(255,255,255,0.5)', - borderRadius: 10, - marginVertical: 10, - alignItems: 'center', - }, - targetViewText: { - fontSize: 16, - fontWeight: '400', - }, - previewContainer: { - flex: 1, - alignItems: 'center', - justifyContent: 'center', - padding: 20 - } -}); \ No newline at end of file diff --git a/example/src/components/ContextMenuView/ContextMenuViewTest08.js b/example/src/components/ContextMenuView/ContextMenuViewTest08.js deleted file mode 100644 index 9aab75e..0000000 --- a/example/src/components/ContextMenuView/ContextMenuViewTest08.js +++ /dev/null @@ -1,76 +0,0 @@ -import React, { useState, useRef } from 'react'; -import { StyleSheet, View, Text } from 'react-native'; - -import { ExampleContextMenuItem } from '../ExampleContextMenuItem'; - - -export class ContextMenuViewTest08 extends React.PureComponent { - constructor(props){ - super(props); - - this.timer = null; - - this.state = { - counter: 0, - }; - }; - - componentWillUnmount() { - this.resetTimer(); - }; - - startTimer = () => { - this.timer = setInterval(() => { - const { counter } = this.state; - if (counter < 3){ - this.setState(prevState => ({ - counter: (prevState.counter + 1) - })); - - } else { - const ref = this.contexMenuItemRef.getContextMenuRef() - ref.dismissMenu(); - this.resetTimer(); - }; - }, 500); - }; - - resetTimer = () => { - if(this.timer){ - clearInterval(this.timer); - this.setState({ counter: 0 }); - }; - }; - - render(){ - return ( - this.contexMenuItemRef = r} - title={'Test #8'} - subtitle={'dismiss menu'} - desc={`Test for programatically dismissing the menu.`} - // `ContextMenuView` Props - previewConfig={{ - previewType: 'CUSTOM', - backgroundColor: 'white' - }} - renderPreview={() => ( - - - {`Will Dismiss in: ${3 - this.state.counter}`} - - - )} - onMenuDidShow={() => this.startTimer()} - onMenuDidHide={() => this.resetTimer()} - menuConfig={{ - menuTitle: 'ContextMenuViewTest08', - }} - /> - ); - }; -}; - -const styles = StyleSheet.create({ -}); \ No newline at end of file diff --git a/example/src/components/ExampleContextMenuButtonItem.js b/example/src/components/ExampleContextMenuButtonItem.js deleted file mode 100644 index 33e9ae1..0000000 --- a/example/src/components/ExampleContextMenuButtonItem.js +++ /dev/null @@ -1,156 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text, Image } from 'react-native'; -import Proptypes from 'prop-types'; - -import * as Colors from '../constants/Colors'; - -import { ContextMenuButton } from 'react-native-ios-context-menu'; - - -function ContextMenuButtonContents(props){ - const rootContainerStyle = { - backgroundColor: (props.menuVisible - ? Colors.AMBER .A700 - : Colors.ORANGE.A700 - ) - }; - - return ( - - - {props.buttonTitle} - - - ); -}; - -export class ExampleContextMenuButtonItem extends React.Component { - static proptypes = { - title : Proptypes.string, - subtitle : Proptypes.string, - desc : Proptypes.string, - index : Proptypes.number, - buttonTitle: Proptypes.string, - showButton : Proptypes.bool , - }; - - static defaultProps = { - showButton: true, - }; - - render(){ - const { title, subtitle, desc, index, buttonTitle, showButton, children, ...props } = this.props; - - return( - - - - {`${index ?? 0}. `} - - - {title ?? 'N/A'} - {subtitle && ( - - {` (${subtitle})`} - - )} - - - - - - {'Description: '} - - {desc ?? "N/A"} - - {children} - - {showButton && ( - - - - - - - - - )} - - ); - }; -}; - -const styles = StyleSheet.create({ - rootContainer: { - borderRadius: 10, - margin: 20, - overflow: 'hidden', - backgroundColor: Colors.AMBER[50] - }, - titleContainer: { - flexDirection: 'row', - paddingHorizontal: 15, - paddingVertical: 8, - alignItems: 'center', - backgroundColor: Colors.AMBER.A700 - }, - textTitle: { - flex: 1, - fontSize: 17, - fontWeight: '700', - color: 'white', - marginLeft: 2, - }, - textTitleIndex: { - fontSize: 17, - fontWeight: '700', - color: 'rgba(255,255,255,0.75)', - }, - textSubtitle: { - fontSize: 14, - color: 'rgba(255,255,255,0.75)', - fontWeight: '300', - }, - subtitleContainer: { - paddingHorizontal: 15, - paddingVertical: 10, - }, - textDescription: { - fontWeight: '300', - color: 'rgba(0,0,0,0.75)' - }, - textDescriptionLabel: { - color: Colors.AMBER[1100], - fontWeight: 'bold', - }, - buttonContainer: { - flexDirection: 'row', - margin: 10, - }, - contextMenuButtonA: { - flex: 1, - }, - contextMenuButtonB: { - alignItems: 'center', - justifyContent: 'center', - marginLeft: 10, - }, - contextMenuButtonContentsContainer: { - padding: 10, - borderRadius: 10, - }, - textContextMenuButton: { - color: 'white', - fontWeight: '500' - }, -}); \ No newline at end of file diff --git a/example/src/components/ExampleContextMenuItem.js b/example/src/components/ExampleContextMenuItem.js deleted file mode 100644 index 1b6ee90..0000000 --- a/example/src/components/ExampleContextMenuItem.js +++ /dev/null @@ -1,123 +0,0 @@ -import React from 'react'; -import { StyleSheet, View, Text, Image } from 'react-native'; -import Proptypes from 'prop-types'; - -import * as Colors from '../constants/Colors'; - -import { ContextMenuView } from 'react-native-ios-context-menu'; - -function ContextMenuContent(props){ - const titleContainerStyle = { - backgroundColor: (props.menuVisible - ? Colors.PURPLE.A700 - : Colors.BLUE .A700 - ) - }; - - const subtitleContainerStyle = { - backgroundColor: (props.menuVisible - ? Colors.PURPLE[100] - : Colors.BLUE [100] - ) - }; - - return ( - - - - {`${props.index ?? 0}. `} - - - {props.title ?? 'N/A'} - {props.subtitle && ( - - {` (${props.subtitle})`} - - )} - - - - - - {'Description: '} - - {props.desc ?? "N/A"} - - {props.children} - - - ); -}; - - -export class ExampleContextMenuItem extends React.Component { - static proptypes = { - title : Proptypes.string, - subtitle: Proptypes.string, - desc : Proptypes.string, - index : Proptypes.number, - }; - - getContextMenuRef = () => { - return this.contexMenuRef; - }; - - render(){ - const { title, subtitle, desc, index, style, children, ...props } = this.props; - - return( - this.contexMenuRef = r} - style={[styles.rootContainer, style]} - {...props} - > - - {children} - - - ); - }; -}; - -const styles = StyleSheet.create({ - rootContainer: { - borderRadius: 10, - margin: 20, - overflow: 'hidden', - }, - titleContainer: { - flexDirection: 'row', - paddingHorizontal: 15, - paddingVertical: 8, - alignItems: 'center', - }, - textTitle: { - flex: 1, - fontSize: 17, - fontWeight: '700', - color: 'white', - marginLeft: 2, - }, - textTitleIndex: { - fontSize: 17, - fontWeight: '700', - color: 'rgba(255,255,255,0.75)', - }, - textSubtitle: { - fontSize: 14, - color: 'rgba(255,255,255,0.75)', - fontWeight: '300', - }, - subtitleContainer: { - paddingHorizontal: 15, - paddingVertical: 10, - }, - textDescription: { - fontWeight: '300', - color: 'rgba(0,0,0,0.75)' - }, - textDescriptionLabel: { - color: Colors.BLUE[1100], - fontWeight: 'bold', - }, -}); \ No newline at end of file