Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
63a3228
initial KoH card, refactored search bar
maxbbb Apr 15, 2025
95a7203
fix points context useeffect usage
maxbbb Apr 15, 2025
086c76e
last winner section, formatting, details
maxbbb Apr 16, 2025
e7b892d
rename search bar, cleanup
maxbbb Apr 16, 2025
661344a
fix double separator when no remote cards
maxbbb Apr 16, 2025
b060f4c
symbol truncation
maxbbb Apr 16, 2025
835d1b2
localizations
maxbbb Apr 16, 2025
35283b2
gradient borders on last winner section pills
maxbbb Apr 16, 2025
e35764c
animated countdown text
maxbbb Apr 16, 2025
c9213df
integrate real backend query
maxbbb Apr 17, 2025
734ede1
card design tweaks, code organization
maxbbb Apr 18, 2025
a33e92c
change to new query shape
maxbbb Apr 18, 2025
3d7422e
android discover search alignment fixes
maxbbb Apr 18, 2025
46b6b28
light mode fixes, countdown clock, loading skeleton
maxbbb Apr 18, 2025
d16e76b
updates to smooth pager
maxbbb Apr 23, 2025
55af12b
explain sheet, disable fetching when not discover
maxbbb Apr 23, 2025
308ca96
add feature flag
maxbbb Apr 23, 2025
8924389
gradient text header, refactor gradient text comp, cleanup uses
maxbbb Apr 23, 2025
99a5e80
step indicator component cleanup
maxbbb Apr 23, 2025
b11f637
shiny coin drop shadow
maxbbb Apr 23, 2025
5fd9846
fix skia background alignment, finish integrating step graphics
maxbbb Apr 24, 2025
60a8a9b
change enableSwipeToGoForward smooth pager api
maxbbb Apr 24, 2025
5e06885
move sunrays component, cleanup, translations
maxbbb Apr 24, 2025
d07ace1
cleanup
maxbbb Apr 24, 2025
b2e347d
Merge branch 'develop' into @kane/prince-of-hill
maxbbb Apr 24, 2025
36e4694
change separator color to match other black screens, add shadow to ex…
maxbbb Apr 24, 2025
dcba8ec
Merge branch 'develop' into @kane/prince-of-hill
maxbbb Apr 24, 2025
55a61ee
fix info & star icon center, fix section header easing gradient
maxbbb Apr 25, 2025
847b624
fix no favorite button spacing logic
maxbbb Apr 25, 2025
b555546
Update src/components/Discover/DiscoverHome.tsx
maxbbb Apr 25, 2025
0af9ac4
add android explain sheet route, fix clipped gradient text properly f…
maxbbb Apr 25, 2025
539a045
fix gradient text implementation, remove text shadow on explain sheet…
maxbbb Apr 28, 2025
7dddc07
file name typo
maxbbb Apr 28, 2025
5a40e5a
cleanup
maxbbb Apr 28, 2025
427439a
use correct size type for increased line height
maxbbb Apr 28, 2025
daa5574
nits
maxbbb Apr 28, 2025
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
Binary file added src/assets/kingOfTheHillExplainer/currentKing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 16 additions & 10 deletions src/components/Discover/DiscoverHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useExperimentalFlag, {
NFT_OFFERS,
FEATURED_RESULTS,
TRENDING_TOKENS,
KING_OF_THE_HILL,
} from '@rainbow-me/config/experimentalHooks';
import { Inline, Inset, Stack, Box, Separator, useColorMode } from '@/design-system';
import { useAccountSettings, useWallets } from '@/hooks';
Expand All @@ -31,15 +32,22 @@ import { AirdropsCard } from '@/components/cards/skia-cards/AirdropsCard';
import { LaunchCard } from '@/components/cards/skia-cards/LaunchCard';
import { useNavigation } from '@/navigation';
import Routes from '@/navigation/routesNames';
import { LIGHT_SEPARATOR_COLOR, SEPARATOR_COLOR } from '@/__swaps__/screens/Swap/constants';
import { DiscoverFeaturedResultsCard } from './DiscoverFeaturedResultsCard';
import { isTestnetChain } from '@/handlers/web3';
import { KingOfTheHill } from './KingOfTheHill';

export const HORIZONTAL_PADDING = 20;

export default function DiscoverHome() {
const { profiles_enabled, mints_enabled, op_rewards_enabled, featured_results, trending_tokens_enabled, new_discover_cards_enabled } =
useRemoteConfig();
const {
profiles_enabled,
mints_enabled,
op_rewards_enabled,
featured_results,
trending_tokens_enabled,
new_discover_cards_enabled,
king_of_the_hill_enabled,
} = useRemoteConfig();
const { isDarkMode } = useColorMode();
const profilesEnabledLocalFlag = useExperimentalFlag(PROFILES);
const profilesEnabledRemoteFlag = profiles_enabled;
Expand All @@ -51,6 +59,8 @@ export default function DiscoverHome() {
const opRewardsLocalFlag = useExperimentalFlag(OP_REWARDS);
const opRewardsRemoteFlag = op_rewards_enabled;
const trendingTokensEnabled = (useExperimentalFlag(TRENDING_TOKENS) || trending_tokens_enabled) && !IS_TEST;
const kingOfTheHillEnabled = useExperimentalFlag(KING_OF_THE_HILL) || king_of_the_hill_enabled;

const { chainId } = useAccountSettings();
const testNetwork = isTestnetChain({ chainId });
const { navigate } = useNavigation();
Expand Down Expand Up @@ -84,13 +94,9 @@ export default function DiscoverHome() {
{isProfilesEnabled && <ENSSearchCard />}
</Inline>
)}
<Separator color={{ custom: isDarkMode ? SEPARATOR_COLOR : LIGHT_SEPARATOR_COLOR }} thickness={1} />
{trendingTokensEnabled && (
<>
<TrendingTokens />
<Separator color={{ custom: isDarkMode ? SEPARATOR_COLOR : LIGHT_SEPARATOR_COLOR }} thickness={1} />
</>
)}
{kingOfTheHillEnabled && <KingOfTheHill />}
<Separator color={isDarkMode ? 'separatorSecondary' : 'separatorTertiary'} thickness={1} />
{trendingTokensEnabled && <TrendingTokens />}
<RemoteCardCarousel />
{mintsEnabled && (
<Stack space="20px">
Expand Down
31 changes: 9 additions & 22 deletions src/components/Discover/DiscoverScreenContent.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
import React from 'react';
import { View } from 'react-native';
import { FlexItem, Page } from '@/components/layout';
import DiscoverHome from '@/components/Discover/DiscoverHome';
import DiscoverSearch from '@/components/Discover/DiscoverSearch';
import DiscoverSearchContainer from '@/components/Discover/DiscoverSearchContainer';
import { Box, Inset } from '@/design-system';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useDiscoverSearchQueryStore } from '@/__swaps__/screens/Swap/resources/search/searchV2';

function Switcher({ children }: { children: React.ReactNode[] }) {
const isSearching = useDiscoverSearchQueryStore(state => state.isSearching);

return (
<>
<View style={{ display: isSearching ? 'flex' : 'none' }}>{isSearching ? children[0] : <FlexItem />}</View>
<View style={{ display: isSearching ? 'none' : 'flex' }}>{children[1]}</View>
</>
);
}

export default function DiscoverScreenContent() {
export function DiscoverScreenContent() {
const insets = useSafeAreaInsets();
const isSearching = useDiscoverSearchQueryStore(state => state.isSearching);

return (
<Box as={Page} flex={1} testID="discover-home">
<Inset top="8px" bottom={{ custom: insets.bottom }}>
<DiscoverSearchContainer>
<Switcher>
<DiscoverSearch />
<DiscoverHome />
</Switcher>
</DiscoverSearchContainer>
<Box style={{ flex: 1 }} testID="discover-home">
<Inset bottom={{ custom: insets.bottom }}>
{/* TODO: without this empty view, the app crashes with no error. Something in the discover search cannot handle display: none */}
<View>{isSearching ? <DiscoverSearch /> : <View />}</View>
<View style={{ display: isSearching ? 'none' : 'flex' }}>
<DiscoverHome />
</View>
</Inset>
</Box>
);
Expand Down
13 changes: 12 additions & 1 deletion src/components/Discover/DiscoverScreenContext.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { analytics } from '@/analytics';
import React, { createContext, RefObject, useRef, useCallback } from 'react';
import React, { createContext, RefObject, useRef, useCallback, useEffect } from 'react';
import { SectionList, TextInput } from 'react-native';
import Animated from 'react-native-reanimated';
import { useDiscoverSearchQueryStore } from '@/__swaps__/screens/Swap/resources/search/searchV2';
import { useTrackDiscoverScreenTime } from './useTrackDiscoverScreenTime';

export let discoverScrollToTopFnRef: () => number | null = () => null;
export let discoverOpenSearchFnRef: () => void = () => null;

type DiscoverScreenContextType = {
scrollViewRef: RefObject<Animated.ScrollView>;
sectionListRef: RefObject<SectionList>;
Expand Down Expand Up @@ -53,6 +56,14 @@ const DiscoverScreenProvider = ({ children }: { children: React.ReactNode }) =>
}
}, [isSearching, scrollToTop]);

useEffect(() => {
discoverScrollToTopFnRef = scrollToTop;
}, [scrollToTop]);

useEffect(() => {
discoverOpenSearchFnRef = onTapSearch;
}, [onTapSearch]);

const cancelSearch = useCallback(() => {
searchInputRef.current?.blur();
useDiscoverSearchQueryStore.setState({ searchQuery: '', isSearching: false });
Expand Down
37 changes: 15 additions & 22 deletions src/components/Discover/DiscoverSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { useDebounce } from 'use-debounce';
import * as lang from '@/languages';
import deviceUtils from '@/utils/deviceUtils';
import CurrencySelectionList from '@/components/CurrencySelectionList';
import { Row } from '@/components/layout';
import { useDiscoverScreenContext } from '@/components/Discover/DiscoverScreenContext';
import { analytics } from '@/analytics';
import { PROFILES, useExperimentalFlag } from '@/config';
import { useAccountSettings, useSearchCurrencyList, usePrevious, useHardwareBackOnFocus } from '@/hooks';
import { useNavigation } from '@/navigation';
import Routes from '@/navigation/routesNames';
import { fetchSuggestions } from '@/handlers/ens';
import styled from '@/styled-thing';
import { ethereumUtils, safeAreaInsetValues } from '@/utils';
import { getPoapAndOpenSheetWithQRHash, getPoapAndOpenSheetWithSecretWord } from '@/utils/poaps';
import { navigateToMintCollection } from '@/resources/reservoir/mints';
Expand All @@ -27,10 +25,6 @@ import { ChainId, Network } from '@/state/backendNetworks/types';
import { useTimeoutEffect } from '@/hooks/useTimeout';
import { useDiscoverSearchQueryStore, useDiscoverSearchStore } from '@/__swaps__/screens/Swap/resources/search/searchV2';

export const SearchContainer = styled(Row)({
height: '100%',
});

type EnsResult = {
address: string;
color: string;
Expand Down Expand Up @@ -71,7 +65,8 @@ export default function DiscoverSearch() {
const { swapCurrencyList, swapCurrencyListLoading } = useSearchCurrencyList();

const profilesEnabled = useExperimentalFlag(PROFILES);
const marginBottom = TAB_BAR_HEIGHT + safeAreaInsetValues.bottom + 16;
const marginBottom = TAB_BAR_HEIGHT;
// safeAreaInsetValues.bottom + 16;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rm? iirc this was added because search rows were underflowing the bottom tab bar. Might be good to verify this isn't needed anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed commented out code but this calc is for the scrollview viewport which with the extra + 16 gets an incorrect calculation that results in a 16 height black bar at the top of the tab bar.

const TOP_OFFSET = safeAreaInsetValues.top + navbarHeight;

const currencyList = useMemo(() => {
Expand Down Expand Up @@ -266,21 +261,19 @@ export default function DiscoverSearch() {
style={{ height: deviceUtils.dimensions.height - TOP_OFFSET - marginBottom }}
testID="discover-search-list"
>
<SearchContainer>
<CurrencySelectionList
footerSpacer
fromDiscover
itemProps={itemProps}
keyboardDismissMode="on-drag"
// @ts-expect-error - FIXME: ens results / rainbow token results are not compatible with one another
listItems={currencyList}
loading={swapCurrencyListLoading || isFetchingEns}
query={searchQueryForSearch}
ref={sectionListRef}
showList
testID="discover-currency-select-list"
/>
</SearchContainer>
<CurrencySelectionList
footerSpacer
fromDiscover
itemProps={itemProps}
keyboardDismissMode="on-drag"
// @ts-expect-error - FIXME: ens results / rainbow token results are not compatible with one another
listItems={currencyList}
loading={swapCurrencyListLoading || isFetchingEns}
query={searchQueryForSearch}
ref={sectionListRef}
showList
testID="discover-currency-select-list"
/>
</View>
);
}
45 changes: 45 additions & 0 deletions src/components/Discover/DiscoverSearchBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import * as i18n from '@/languages';
import { ButtonPressAnimation } from '@/components/animations';
import { Box, Inline, Text } from '@/design-system';
import DiscoverSearchInput from '@/components/Discover/DiscoverSearchInput';
import { useDiscoverScreenContext } from '@/components/Discover/DiscoverScreenContext';
import { deviceUtils } from '@/utils';
import { useDelayedValueWithLayoutAnimation } from '@/hooks';
import { useDiscoverSearchQueryStore } from '@/__swaps__/screens/Swap/resources/search/searchV2';
import { NAVBAR_HORIZONTAL_INSET, navbarHeight } from '../navbar/Navbar';
import { useTheme } from '@/theme';

const placeholderText = deviceUtils.isNarrowPhone
? i18n.t(i18n.l.discover.search.search_ethereum_short)
: i18n.t(i18n.l.discover.search.search_ethereum);

export function DiscoverSearchBar() {
const { colors } = useTheme();
const { onTapSearch, cancelSearch } = useDiscoverScreenContext();
const isSearching = useDiscoverSearchQueryStore(state => state.isSearching);
const delayedShowSearch = useDelayedValueWithLayoutAnimation(isSearching);

return (
<Box height={navbarHeight} width="full" justifyContent="center" paddingHorizontal={{ custom: NAVBAR_HORIZONTAL_INSET }}>
<Inline alignVertical="center" space={'16px'}>
<Box justifyContent="center" style={{ flex: 1 }}>
<DiscoverSearchInput
clearTextOnFocus={false}
isDiscover
onFocus={onTapSearch}
placeholderText={placeholderText}
testID="discover-search"
/>
</Box>
<ButtonPressAnimation onPress={cancelSearch} testID="done-button">
{delayedShowSearch && (
<Text color={{ custom: colors.appleBlue }} size="17pt" weight="semibold">
{i18n.t(i18n.l.button.done)}
</Text>
)}
</ButtonPressAnimation>
</Inline>
</Box>
);
}
70 changes: 0 additions & 70 deletions src/components/Discover/DiscoverSearchContainer.tsx

This file was deleted.

Loading
Loading