Bluesky app fork with some witchin' additions 💫

Add optional props to Prompt.Action (#9887)

authored by

DS Boyce and committed by
GitHub
29bc0f13 82f42e73

+30 -5
+30 -5
src/components/Prompt.tsx
··· 4 import {useLingui} from '@lingui/react' 5 6 import {atoms as a, useTheme, type ViewStyleProp, web} from '#/alf' 7 - import {Button, type ButtonColor, ButtonText} from '#/components/Button' 8 import * as Dialog from '#/components/Dialog' 9 import {Text} from '#/components/Typography' 10 import {type BottomSheetViewProps} from '../../modules/bottom-sheet' 11 ··· 126 <Button 127 variant="solid" 128 color="secondary" 129 - size={'large'} 130 label={cta || _(msg`Cancel`)} 131 onPress={onPress}> 132 <ButtonText>{cta || _(msg`Cancel`)}</ButtonText> ··· 138 onPress, 139 color = 'primary', 140 cta, 141 testID, 142 }: { 143 /** ··· 153 * Optional i18n string. If undefined, it will default to "Confirm". 154 */ 155 cta?: string 156 testID?: string 157 }) { 158 const {_} = useLingui() 159 const {close} = Dialog.useDialogContext() 160 const handleOnPress = useCallback( 161 (e: GestureResponderEvent) => { 162 - close(() => onPress?.(e)) 163 }, 164 - [close, onPress], 165 ) 166 167 return ( 168 <Button 169 color={color} 170 - size={'large'} 171 label={cta || _(msg`Confirm`)} 172 onPress={handleOnPress} 173 testID={testID}> 174 <ButtonText>{cta || _(msg`Confirm`)}</ButtonText> 175 </Button> 176 ) 177 }
··· 4 import {useLingui} from '@lingui/react' 5 6 import {atoms as a, useTheme, type ViewStyleProp, web} from '#/alf' 7 + import { 8 + Button, 9 + type ButtonColor, 10 + ButtonIcon, 11 + ButtonText, 12 + } from '#/components/Button' 13 import * as Dialog from '#/components/Dialog' 14 + import {type Props as SVGIconProps} from '#/components/icons/common' 15 import {Text} from '#/components/Typography' 16 import {type BottomSheetViewProps} from '../../modules/bottom-sheet' 17 ··· 132 <Button 133 variant="solid" 134 color="secondary" 135 + size="large" 136 label={cta || _(msg`Cancel`)} 137 onPress={onPress}> 138 <ButtonText>{cta || _(msg`Cancel`)}</ButtonText> ··· 144 onPress, 145 color = 'primary', 146 cta, 147 + disabled = false, 148 + icon, 149 + shouldCloseOnPress, 150 testID, 151 }: { 152 /** ··· 162 * Optional i18n string. If undefined, it will default to "Confirm". 163 */ 164 cta?: string 165 + /** 166 + * If undefined, it will default to false. 167 + */ 168 + disabled?: boolean 169 + icon?: React.ComponentType<SVGIconProps> 170 + /** 171 + * Optionally close dialog automatically on press. If undefined, it will 172 + * default to true. 173 + */ 174 + shouldCloseOnPress?: boolean 175 testID?: string 176 }) { 177 const {_} = useLingui() 178 const {close} = Dialog.useDialogContext() 179 const handleOnPress = useCallback( 180 (e: GestureResponderEvent) => { 181 + if (shouldCloseOnPress) { 182 + close(() => onPress?.(e)) 183 + } else { 184 + onPress?.(e) 185 + } 186 }, 187 + [close, onPress, shouldCloseOnPress], 188 ) 189 190 return ( 191 <Button 192 color={color} 193 + disabled={disabled} 194 + size="large" 195 label={cta || _(msg`Confirm`)} 196 onPress={handleOnPress} 197 testID={testID}> 198 <ButtonText>{cta || _(msg`Confirm`)}</ButtonText> 199 + {icon && <ButtonIcon icon={icon} />} 200 </Button> 201 ) 202 }