Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(swap): Initial Swap screen redesign #5409

Merged
merged 15 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions locales/base/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,9 @@
"swapToTokenSelection": "SWAP TO",
"tokenUsdValueUnknown": "-",
"unsupportedSwapTokens": "The selected tokens aren't supported by our swap providers.",
"selectToken": "Select token",
jophish marked this conversation as resolved.
Show resolved Hide resolved
"selectTokenTitle": "Select Token",
jophish marked this conversation as resolved.
Show resolved Hide resolved
"onNetwork": "on {{networkName}}",
"switchedToNetworkWarning": {
"title": "You switched to the {{networkName}} network",
"body_swapFrom": "Select a token to swap from on the {{networkName}} network to continue.",
Expand Down
1 change: 1 addition & 0 deletions src/analytics/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ export enum SwapEvents {
swap_show_info = 'swap_show_info',
swap_show_fund_your_wallet = 'swap_show_fund_your_wallet',
swap_add_funds = 'swap_add_funds',
swap_switch_tokens = 'swap_switch_tokens',
}

export enum CeloNewsEvents {
Expand Down
4 changes: 4 additions & 0 deletions src/analytics/Properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,10 @@ interface SwapEventsProperties {
}
[SwapEvents.swap_show_fund_your_wallet]: undefined
[SwapEvents.swap_add_funds]: undefined
[SwapEvents.swap_switch_tokens]: {
fromTokenId: string | undefined
toTokenId: string | undefined
}
}

interface CeloNewsEventsProperties {
Expand Down
1 change: 1 addition & 0 deletions src/analytics/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ export const eventDocs: Record<AnalyticsEventType, string> = {
[SwapEvents.swap_show_info]: `When a user taps an info icon to show more information on the swap screen`,
[SwapEvents.swap_show_fund_your_wallet]: `When "Fund your wallet" bottom sheet is displayed`,
[SwapEvents.swap_add_funds]: `When user taps "Add funds" button is "Fund your wallet" bottom sheet`,
[SwapEvents.swap_switch_tokens]: `When a user taps the button to switch tokens`,
jophish marked this conversation as resolved.
Show resolved Hide resolved
[CeloNewsEvents.celo_news_screen_open]: `When the screen is mounted`,
[CeloNewsEvents.celo_news_article_tap]: `When a user taps on a news article`,
[CeloNewsEvents.celo_news_bottom_read_more_tap]: `When a user taps on the read more button at the bottom of the screen`,
Expand Down
22 changes: 18 additions & 4 deletions src/components/Touchable.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
import * as React from 'react'
import { TouchableWithoutFeedbackProps, View } from 'react-native'
import { TouchableWithoutFeedbackProps, View, ViewStyle } from 'react-native'
import PlatformTouchable from 'react-native-platform-touchable'

export interface Props extends TouchableWithoutFeedbackProps {
borderless?: boolean
children: React.ReactNode // must only have one direct child. see https://github.com/react-native-community/react-native-platform-touchable#touchable
borderRadius?: number
touchableStyle?: ViewStyle
useForeground?: boolean
}

/**
* @param borderless - If true, the touchable has a borderless ripple effect.
* @param borderRadius - should be added if the touchable component has rounded corners, to prevent the ripple effect from going outside the component on tap (Android)
* @param useForeground - If present, will set foreground parameter instead of background. Helps with z-index issues within absolutely-positioned parents. See https://github.com/facebook/react-native/issues/17200
* @param touchableStyle - If present, will set the style on the Touchable wrapper. Used to override borderRadius in case of atypical borders.
* @returns A touchable component
*/
export default function Touchable({ borderless, borderRadius = 0, ...passThroughProps }: Props) {
export default function Touchable({
touchableStyle,
useForeground,
borderless,
borderRadius = 0,
...passThroughProps
}: Props) {
const background = borderless
? PlatformTouchable.SelectableBackgroundBorderless()
: PlatformTouchable.SelectableBackground()
return borderRadius === 0 ? (
<PlatformTouchable {...passThroughProps} background={background} />
) : (
<View style={[{ borderRadius }, !borderless && { overflow: 'hidden' }]}>
<PlatformTouchable {...passThroughProps} background={background} />
<View style={[{ borderRadius }, touchableStyle, !borderless && { overflow: 'hidden' }]}>
jophish marked this conversation as resolved.
Show resolved Hide resolved
<PlatformTouchable
{...passThroughProps}
background={useForeground ? undefined : background}
foreground={useForeground ? background : undefined}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i got really hung up on this even though it's not important because it's not easy to understand what useForeground means. (also reading if useForeground, use background is weird). it seems like this prop should be used if the Touchable has any images as children and you want the ripple to be rendered above the image - so perhaps a more intuitive prop for this component could be shouldRenderRippleAbove or rippleAboveImages or hasImageChildren?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agreed that it's weird as-is... I like shouldRenderRippleAbove, since it does have utility outside of using images within the Touchable.

/>
</View>
)
}
5 changes: 3 additions & 2 deletions src/icons/DownIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import Svg, { Path } from 'svgs'
export interface Props {
color?: string
testID?: string
size?: number
}

function DownIndicator({ color = colors.error, testID }: Props) {
function DownIndicator({ color = colors.error, testID, size = 10 }: Props) {
return (
<Svg width="10" height="10" viewBox="0 0 10 10" fill="none" testID={testID}>
<Svg width={size} height={size} viewBox="0 0 10 10" fill="none" testID={testID}>
<Path
fill={color}
d="M4.369 0H5.63v7.576l3.473-3.472L10 5l-5 5-5-5 .896-.896L4.37 7.576V0Z"
Expand Down
Loading
Loading