-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sheets] [Pt. 7] Part seven rework, much simplier! (#5582)
- Loading branch information
Showing
15 changed files
with
341 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
|
||
import {Button, ButtonProps} from '#/components/Button' | ||
import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' | ||
|
||
export function BottomSheetButton({children, ...rest}: ButtonProps) { | ||
return ( | ||
<Button {...rest} Component={NormalizedRNGHPressable}> | ||
{children} | ||
</Button> | ||
) | ||
} |
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,92 @@ | ||
import React from 'react' | ||
import {StackActions, useNavigation} from '@react-navigation/native' | ||
|
||
import {NavigationProp} from '#/lib/routes/types' | ||
import {flatten, useTheme} from '#/alf' | ||
import {useDialogContext} from '#/components/Dialog' | ||
import {useInteractionState} from '#/components/hooks/useInteractionState' | ||
import {InlineLinkProps, useLink} from '#/components/Link' | ||
import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' | ||
import {Text} from '#/components/Typography' | ||
import {router} from '#/routes' | ||
|
||
export function BottomSheetInlineLinkText({ | ||
children, | ||
to, | ||
action = 'push', | ||
disableMismatchWarning, | ||
style, | ||
onPress: outerOnPress, | ||
label, | ||
shareOnLongPress, | ||
disableUnderline, | ||
...rest | ||
}: InlineLinkProps) { | ||
const t = useTheme() | ||
const stringChildren = typeof children === 'string' | ||
const navigation = useNavigation<NavigationProp>() | ||
const dialog = useDialogContext() | ||
|
||
const {href, isExternal, onLongPress} = useLink({ | ||
to, | ||
displayText: stringChildren ? children : '', | ||
action, | ||
disableMismatchWarning, | ||
onPress: outerOnPress, | ||
shareOnLongPress, | ||
}) | ||
const { | ||
state: pressed, | ||
onIn: onPressIn, | ||
onOut: onPressOut, | ||
} = useInteractionState() | ||
|
||
const onPress = () => { | ||
if (isExternal) { | ||
return | ||
} | ||
|
||
dialog.close() | ||
|
||
if (action === 'push') { | ||
navigation.dispatch(StackActions.push(...router.matchPath(href))) | ||
} else if (action === 'replace') { | ||
navigation.dispatch(StackActions.replace(...router.matchPath(href))) | ||
} else if (action === 'navigate') { | ||
// @ts-ignore | ||
navigation.navigate(...router.matchPath(href)) | ||
} else { | ||
throw Error('Unsupported navigator action.') | ||
} | ||
} | ||
|
||
const flattenedStyle = flatten(style) || {} | ||
|
||
// eslint-disable-next-line bsky-internal/avoid-unwrapped-text | ||
return ( | ||
<NormalizedRNGHPressable | ||
onPress={onPress} | ||
onLongPress={onLongPress} | ||
onPressIn={onPressIn} | ||
onPressOut={onPressOut} | ||
role="link" | ||
accessibilityLabel={label} | ||
accessibilityHint="" | ||
style={{flexDirection: 'row'}}> | ||
<Text | ||
{...rest} | ||
style={[ | ||
{color: t.palette.primary_500}, | ||
pressed && | ||
!disableUnderline && { | ||
textDecorationLine: 'underline', | ||
textDecorationColor: | ||
flattenedStyle.color ?? t.palette.primary_500, | ||
}, | ||
flattenedStyle, | ||
]}> | ||
{children} | ||
</Text> | ||
</NormalizedRNGHPressable> | ||
) | ||
} |
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,3 @@ | ||
import {Link as BottomSheetLink} from './Link' | ||
|
||
export {BottomSheetLink} |
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
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
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
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
Oops, something went wrong.