diff options
author | Minseo Lee <itoupluk427@gmail.com> | 2024-03-13 10:30:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-13 10:30:07 +0900 |
commit | 3ead08ab2649533583c300904bbd85c250292014 (patch) | |
tree | 48366b4d1d847eb59f0187520d2c5fb4150bba3c /src/components/Menu/index.tsx | |
parent | 2456ca828fc4ba05a085fa03c6f7c37b3edcd45e (diff) | |
parent | 653240bc056236489e8a7882b7b6f902ed0885c2 (diff) | |
download | voidsky-3ead08ab2649533583c300904bbd85c250292014.tar.zst |
Merge branch 'bluesky-social:main' into patch-3
Diffstat (limited to 'src/components/Menu/index.tsx')
-rw-r--r-- | src/components/Menu/index.tsx | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/components/Menu/index.tsx b/src/components/Menu/index.tsx index ee96a5667..9be9dd86b 100644 --- a/src/components/Menu/index.tsx +++ b/src/components/Menu/index.tsx @@ -1,5 +1,5 @@ import React from 'react' -import {View, Pressable} from 'react-native' +import {View, Pressable, ViewStyle, StyleProp} from 'react-native' import flattenReactChildren from 'react-keyed-flatten-children' import {atoms as a, useTheme} from '#/alf' @@ -16,6 +16,10 @@ import { ItemTextProps, ItemIconProps, } from '#/components/Menu/types' +import {Button, ButtonText} from '#/components/Button' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' +import {isNative} from 'platform/detection' export {useDialogControl as useMenuControl} from '#/components/Dialog' @@ -68,7 +72,13 @@ export function Trigger({children, label}: TriggerProps) { }) } -export function Outer({children}: React.PropsWithChildren<{}>) { +export function Outer({ + children, + showCancel, +}: React.PropsWithChildren<{ + showCancel?: boolean + style?: StyleProp<ViewStyle> +}>) { const context = React.useContext(Context) return ( @@ -78,7 +88,10 @@ export function Outer({children}: React.PropsWithChildren<{}>) { {/* Re-wrap with context since Dialogs are portal-ed to root */} <Context.Provider value={context}> <Dialog.ScrollableInner label="Menu TODO"> - <View style={[a.gap_lg]}>{children}</View> + <View style={[a.gap_lg]}> + {children} + {isNative && showCancel && <Cancel />} + </View> <View style={{height: a.gap_lg.gap}} /> </Dialog.ScrollableInner> </Context.Provider> @@ -185,6 +198,22 @@ export function Group({children, style}: GroupProps) { ) } +function Cancel() { + const {_} = useLingui() + const {control} = React.useContext(Context) + + return ( + <Button + label={_(msg`Close this dialog`)} + size="small" + variant="ghost" + color="secondary" + onPress={() => control.close()}> + <ButtonText>Cancel</ButtonText> + </Button> + ) +} + export function Divider() { return null } |