|
| 1 | +// React imports |
| 2 | +import React, { useCallback, useMemo, useState } from 'react' |
| 3 | +import { View } from 'react-native' |
| 4 | + |
| 5 | +// Local imports |
| 6 | +import { useGlobalState, SETTINGS_STATE } from '../GlobalState' |
| 7 | +import SettingsPageParent from './SettingsPageParent' |
| 8 | + |
| 9 | +/** |
| 10 | + * The AutoContinue component allows users to change the auto-continue settings |
| 11 | + * from the Settings menu. |
| 12 | + */ |
| 13 | +const AutoContinue = () => { |
| 14 | + // Get relevant global state variables |
| 15 | + const setSettingsState = useGlobalState((state) => state.setSettingsState) |
| 16 | + const biteAcquisitionCheckAutoContinue = useGlobalState((state) => state.biteAcquisitionCheckAutoContinue) |
| 17 | + const setBiteAcquisitionCheckAutoContinue = useGlobalState((state) => state.setBiteAcquisitionCheckAutoContinue) |
| 18 | + const faceDetectionAutoContinue = useGlobalState((state) => state.faceDetectionAutoContinue) |
| 19 | + const setFaceDetectionAutoContinue = useGlobalState((state) => state.setFaceDetectionAutoContinue) |
| 20 | + const biteDoneAutoContinue = useGlobalState((state) => state.biteDoneAutoContinue) |
| 21 | + const setBiteDoneAutoContinue = useGlobalState((state) => state.setBiteDoneAutoContinue) |
| 22 | + |
| 23 | + // Rendering variables |
| 24 | + let textFontSize = '3.5vh' |
| 25 | + |
| 26 | + // Configure the parameters for SettingsPageParent |
| 27 | + const paramNames = useMemo(() => [], []) |
| 28 | + const [currentParams, setCurrentParams] = useState([]) |
| 29 | + |
| 30 | + // Render the settings for the planning scene |
| 31 | + const renderAutoContinueSettings = useCallback(() => { |
| 32 | + return ( |
| 33 | + <View |
| 34 | + style={{ |
| 35 | + flex: 1, |
| 36 | + flexDirection: 'column', |
| 37 | + justifyContent: 'center', |
| 38 | + alignItems: 'center', |
| 39 | + width: '100%', |
| 40 | + height: '100%' |
| 41 | + }} |
| 42 | + > |
| 43 | + <View |
| 44 | + style={{ |
| 45 | + flex: 1, |
| 46 | + flexDirection: 'row', |
| 47 | + justifyContent: 'center', |
| 48 | + alignItems: 'center', |
| 49 | + width: '100%' |
| 50 | + }} |
| 51 | + > |
| 52 | + <p className='transitionMessage' style={{ marginBottom: '0px', fontSize: textFontSize }}> |
| 53 | + <input |
| 54 | + name='biteAcquisitionCheckAutoContinue' |
| 55 | + type='checkbox' |
| 56 | + checked={biteAcquisitionCheckAutoContinue} |
| 57 | + onChange={(e) => { |
| 58 | + setBiteAcquisitionCheckAutoContinue(e.target.checked) |
| 59 | + }} |
| 60 | + style={{ transform: 'scale(2.0)', verticalAlign: 'middle', marginRight: '15px' }} |
| 61 | + /> |
| 62 | + Auto-continue after acquisition |
| 63 | + </p> |
| 64 | + </View> |
| 65 | + <View |
| 66 | + style={{ |
| 67 | + flex: 1, |
| 68 | + flexDirection: 'row', |
| 69 | + justifyContent: 'center', |
| 70 | + alignItems: 'center', |
| 71 | + width: '100%' |
| 72 | + }} |
| 73 | + > |
| 74 | + <p className='transitionMessage' style={{ marginBottom: '0px', fontSize: textFontSize }}> |
| 75 | + <input |
| 76 | + name='faceDetectionAutoContinue' |
| 77 | + type='checkbox' |
| 78 | + checked={faceDetectionAutoContinue} |
| 79 | + onChange={(e) => { |
| 80 | + setFaceDetectionAutoContinue(e.target.checked) |
| 81 | + }} |
| 82 | + style={{ transform: 'scale(2.0)', verticalAlign: 'middle', marginRight: '15px' }} |
| 83 | + /> |
| 84 | + Auto-continue after face detection |
| 85 | + </p> |
| 86 | + </View> |
| 87 | + <View |
| 88 | + style={{ |
| 89 | + flex: 1, |
| 90 | + flexDirection: 'row', |
| 91 | + justifyContent: 'center', |
| 92 | + alignItems: 'center', |
| 93 | + width: '100%' |
| 94 | + }} |
| 95 | + > |
| 96 | + <p className='transitionMessage' style={{ marginBottom: '0px', fontSize: textFontSize }}> |
| 97 | + <input |
| 98 | + name='biteDoneAutoContinue' |
| 99 | + type='checkbox' |
| 100 | + checked={biteDoneAutoContinue} |
| 101 | + onChange={(e) => { |
| 102 | + setBiteDoneAutoContinue(e.target.checked) |
| 103 | + }} |
| 104 | + style={{ transform: 'scale(2.0)', verticalAlign: 'middle', marginRight: '15px' }} |
| 105 | + /> |
| 106 | + Auto-continue after transfer |
| 107 | + </p> |
| 108 | + </View> |
| 109 | + </View> |
| 110 | + ) |
| 111 | + }, [ |
| 112 | + textFontSize, |
| 113 | + biteAcquisitionCheckAutoContinue, |
| 114 | + setBiteAcquisitionCheckAutoContinue, |
| 115 | + faceDetectionAutoContinue, |
| 116 | + setFaceDetectionAutoContinue, |
| 117 | + biteDoneAutoContinue, |
| 118 | + setBiteDoneAutoContinue |
| 119 | + ]) |
| 120 | + |
| 121 | + return ( |
| 122 | + <SettingsPageParent |
| 123 | + title='Auto-Continue ⚙' |
| 124 | + doneCallback={() => setSettingsState(SETTINGS_STATE.MAIN)} |
| 125 | + modalShow={false} |
| 126 | + modalOnHide={null} |
| 127 | + modalChildren={null} |
| 128 | + paramNames={paramNames} |
| 129 | + localParamValues={currentParams} |
| 130 | + setLocalParamValues={setCurrentParams} |
| 131 | + > |
| 132 | + {renderAutoContinueSettings()} |
| 133 | + </SettingsPageParent> |
| 134 | + ) |
| 135 | +} |
| 136 | + |
| 137 | +export default AutoContinue |
0 commit comments