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

nfts sort direction #6068

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
3a18b2b
sortDirection
greg-schrammel Aug 26, 2024
1df73e8
asc/desc menu
greg-schrammel Aug 27, 2024
d6ede1c
imports
greg-schrammel Aug 27, 2024
1d355a9
imports
greg-schrammel Aug 27, 2024
d07935d
i18n
greg-schrammel Aug 27, 2024
473351b
Merge remote-tracking branch origin/develop into gregs/app-1756-sorti…
greg-schrammel Aug 30, 2024
cb4602b
Merge remote-tracking branch origin/develop into gregs/app-1756-sorti…
greg-schrammel Aug 30, 2024
fdc72e7
Merge remote-tracking branch origin/develop into gregs/app-1756-sorti…
greg-schrammel Aug 30, 2024
01a0c9f
fix types
greg-schrammel Sep 4, 2024
f8b2d4c
update ts
greg-schrammel Sep 4, 2024
b6a5c4a
Merge branch 'develop' into gregs/app-1756-sorting-nfts-on-android-is…
greg-schrammel Sep 10, 2024
a048dd9
add back isAnchoredToRight
greg-schrammel Sep 17, 2024
8f84fd6
??
greg-schrammel Sep 17, 2024
32a1ee7
Merge remote-tracking branch origin/develop into gregs/app-1756-sorti…
greg-schrammel Sep 17, 2024
977415a
grey out the selected option
greg-schrammel Sep 17, 2024
a2e3231
android
greg-schrammel Oct 10, 2024
5f1ee01
Fix iOS 18 cool-modals context menu bug (#6112)
christianbaroni Sep 18, 2024
c10b4f2
Fix send crashes / blank screen (#6116)
walmat Sep 18, 2024
955e21a
Fix disabled paste button on Android (#6118)
christianbaroni Sep 19, 2024
9617bdc
imageVariants (#6114)
greg-schrammel Sep 19, 2024
c019a26
Fix send sheet stuck on loading (#6119)
walmat Sep 20, 2024
f9423ac
Support typing into native inputs in swap (#6100)
jinchung Sep 20, 2024
e696f60
Fix chainId not being passed in for dapp browser getProvider function…
jinchung Sep 20, 2024
dcdf796
Update arbitrum default back to mainnet for WC message signing (#6122)
jinchung Sep 20, 2024
7545335
Bump deps for Xcode 16 compatibility (#6110)
brunobar79 Sep 20, 2024
7f8c8b0
bump iOS and Android to v1.9.40 (#6131)
ibrahimtaveras00 Sep 23, 2024
e6f4b2f
Update CI to work with Xcode 16 / iOS 18 (#6129)
brunobar79 Sep 24, 2024
6270098
omit_from_total (#6103)
greg-schrammel Sep 24, 2024
bfc6308
Fix speed up and cancel bug (#6133)
walmat Sep 24, 2024
d809931
bump iOS and Android to v1.9.41 (#6136)
ibrahimtaveras00 Sep 24, 2024
07010ef
MWP (#6142)
brunobar79 Sep 26, 2024
7f82028
Dapp browser url updates fix (#6150)
brunobar79 Sep 27, 2024
590ca56
Internal networks filtering (#6148)
walmat Sep 27, 2024
0d07ede
Fix token search crash for newly added chains (#6147)
walmat Sep 30, 2024
b5588cb
Claimables [PR #1]: updates to query, types, utils, wallet screen ren…
benisgold Sep 30, 2024
caedd46
Fix improper gas fee calculation (#6125)
walmat Sep 30, 2024
3d01175
Claimables [PR #2]: claim panel ui (#6141)
benisgold Oct 1, 2024
2a4e929
raps v2 (#6138)
benisgold Oct 1, 2024
9e93bdf
Claimables [PR #3]: claim functionality (#6146)
benisgold Oct 1, 2024
1598225
[APP-1907] Add Claiming Status to Pending Claimable TX's (plus types …
derHowie Oct 2, 2024
ac9ec83
Claimables fixes (#6158)
benisgold Oct 2, 2024
9b94c9e
fix (#6159)
benisgold Oct 2, 2024
b0c287e
convert sends to typescript (#6120)
walmat Oct 2, 2024
18314eb
comments watchdog action (#6153)
brunobar79 Oct 3, 2024
f688f32
pod unlock (#6168)
brunobar79 Oct 3, 2024
f0f3bf8
Fix WalletconnectV2 changeAccount issues (#6160)
walmat Oct 3, 2024
a6f1357
bump android and iOS to version v1.9.42 (#6170)
ibrahimtaveras00 Oct 3, 2024
2e900e7
fix approval sheet not using verifiedData incoming from walletconnect…
walmat Oct 3, 2024
cb2b7a6
network expansion (#6149)
walmat Oct 4, 2024
9712448
Analytics changes (#6169)
walmat Oct 4, 2024
92513f1
[CHORE]: Walletconnect Approval / Redirect sheet typescript conversio…
walmat Oct 4, 2024
6df14df
nft expanded state fix crash (#6115)
greg-schrammel Oct 4, 2024
b272a12
fix lint issues on develop (#6174)
walmat Oct 4, 2024
f1a4544
Fix MWP from failing to prompt if dapp metadata retrieval fails (#6164)
walmat Oct 5, 2024
78d9d96
lel wtf (#6166)
walmat Oct 5, 2024
2fe9933
WC migration to WalletKit (#6163)
brunobar79 Oct 7, 2024
f4ca59a
Fix networks crash (#6176)
walmat Oct 7, 2024
caed4a7
hide send button when not transferable (#6123)
greg-schrammel Oct 8, 2024
7ae60c8
Claim button fixes (#6165)
benisgold Oct 8, 2024
67187c1
fix lint (#6180)
walmat Oct 8, 2024
94fe488
chore: use new fields from swap sdk and remove extraneous code (#6171)
welps Oct 9, 2024
bc291cf
Zeego Dropdown Menus [MintFilters] (#6143)
walmat Oct 9, 2024
250cc95
Claim bug fix (#6182)
benisgold Oct 9, 2024
1eeb5a2
fix ledger image blocking text
greg-schrammel Oct 10, 2024
4b493fe
👍
greg-schrammel Oct 16, 2024
42b9a05
Merge remote-tracking branch origin/develop into gregs/app-1756-sorti…
greg-schrammel Oct 16, 2024
fb63c76
lint
greg-schrammel Oct 16, 2024
12099e0
lint
greg-schrammel Oct 16, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
"ts-jest": "29.1.1",
"ts-loader": "9.5.1",
"ts-migrate": "0.1.26",
"typescript": "5.1.6",
"typescript": "5.5.4",
"typescript-coverage-report": "0.6.1",
"webpack": "5.94.0",
"webpack-cli": "5.1.4"
Expand Down
10 changes: 2 additions & 8 deletions src/__swaps__/screens/Swap/components/GasButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { swapsStore } from '@/state/swaps/swapsStore';
import { gasUtils } from '@/utils';
import React, { PropsWithChildren, ReactNode, useCallback, useMemo } from 'react';
import { StyleSheet } from 'react-native';
import { OnPressMenuItemEventObject } from 'react-native-ios-context-menu';
import Animated, { runOnUI, useAnimatedStyle } from 'react-native-reanimated';
import { THICK_BORDER_WIDTH } from '../constants';
import { GasSettings, useCustomGasSettings } from '../hooks/useCustomGas';
Expand Down Expand Up @@ -133,7 +132,7 @@ const GasMenu = ({ backToReview = false, children }: { backToReview?: boolean; c
);

const handlePressMenuItem = useCallback(
({ nativeEvent: { actionKey } }: OnPressMenuItemEventObject) => handlePressSpeedOption(actionKey as GasSpeed),
({ nativeEvent: { actionKey } }: { nativeEvent: { actionKey: GasSpeed } }) => handlePressSpeedOption(actionKey),
[handlePressSpeedOption]
);

Expand All @@ -147,8 +146,6 @@ const GasMenu = ({ backToReview = false, children }: { backToReview?: boolean; c

const menuConfig = useMemo(() => {
const menuItems = menuOptions.map(gasOption => {
if (IS_ANDROID) return gasOption;

const currentBaseFee = getCachedCurrentBaseFee(chainId);
const gasSettings = gasOption === GasSpeed.CUSTOM ? customGasSettings : metereologySuggestions.data?.[gasOption];
const subtitle = getEstimatedFeeRangeInGwei(gasSettings, currentBaseFee);
Expand All @@ -174,7 +171,7 @@ const GasMenu = ({ backToReview = false, children }: { backToReview?: boolean; c
isAnchoredToRight
isMenuPrimaryAction
onPressActionSheet={handlePressActionSheet}
options={menuConfig.menuItems}
options={menuOptions}
useActionSheetFallback={false}
wrapNativeComponent={false}
>
Expand All @@ -184,14 +181,11 @@ const GasMenu = ({ backToReview = false, children }: { backToReview?: boolean; c
</ContextMenu>
) : (
<ContextMenuButton
activeOpacity={0}
enableContextMenu
isAnchoredToRight
isMenuPrimaryAction
menuConfig={menuConfig}
onPressMenuItem={handlePressMenuItem}
useActionSheetFallback={false}
wrapNativeComponent={false}
>
Comment on lines 185 to 191
Copy link
Contributor

Choose a reason for hiding this comment

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

why were these props removed?

Copy link
Contributor Author

@greg-schrammel greg-schrammel Sep 17, 2024

Choose a reason for hiding this comment

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

added isAnchoredToRight back didn't notice it's used in the .android, the others are already the default inside <ContextMenuButton />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

btw seems like this GasButton menu is not working at all in android? idk if it's just my simulator

<ButtonPressAnimation scaleTo={0.825} style={{ padding: GAS_BUTTON_HIT_SLOP }}>
{children}
Expand Down
4 changes: 0 additions & 4 deletions src/components/DappBrowser/search/results/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ const search = (query: string, dapps: Dapp[], numberOfResults = 4): Dapp[] => {
if (b?.trending === true && a?.trending !== true) return 1;
if (a?.trending === true && b?.trending !== true) return -1;

// @ts-expect-error: Need to fix these types
const relevanceDiff = b.relevance - a.relevance;
if (relevanceDiff === 0) {
// @ts-expect-error: Same here
const aWordCount = a.name.split(' ').length;
// @ts-expect-error: Same here
const bWordCount = b.name.split(' ').length;
return aWordCount - bWordCount;
}
Expand All @@ -74,7 +71,6 @@ const search = (query: string, dapps: Dapp[], numberOfResults = 4): Dapp[] => {
return [{ url: query, urlDisplay: query, name: query, isDirect: true } as unknown as Dapp, ...(dappResults as Dapp[])];
}

// @ts-expect-error: Same here
return filteredDapps;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import { Box, Inline, Text } from '@/design-system';
import * as i18n from '@/languages';
import { ListHeaderMenu } from '@/components/list/ListHeaderMenu';
import { NftCollectionSortCriterion } from '@/graphql/__generated__/arc';
import useNftSort from '@/hooks/useNFTsSortBy';
import { NftCollectionSortCriterion, SortDirection } from '@/graphql/__generated__/arc';
import { NftSort, useNftSort } from '@/hooks/useNFTsSortBy';
import { colors } from '@/styles';
import { useRemoteConfig } from '@/model/remoteConfig';
import { NFTS_ENABLED, useExperimentalFlag } from '@/config';

Expand Down Expand Up @@ -32,9 +33,9 @@ const getMenuItemIcon = (value: NftCollectionSortCriterion) => {
};

const CollectiblesHeader = () => {
const { nftSort, nftSortDirection, updateNFTSort } = useNftSort();
const { nfts_enabled } = useRemoteConfig();
const nftsEnabled = useExperimentalFlag(NFTS_ENABLED) || nfts_enabled;
const { nftSort, updateNFTSort } = useNftSort();

if (!nftsEnabled) return null;

Expand All @@ -53,14 +54,44 @@ const CollectiblesHeader = () => {
</Text>

<ListHeaderMenu
selected={nftSort}
menuItems={Object.entries(NftCollectionSortCriterion).map(([key, value]) => ({
actionKey: value,
actionTitle: i18n.t(i18n.l.nfts.sort[value]),
icon: { iconType: 'SYSTEM', iconValue: getMenuItemIcon(value) },
menuState: nftSort === key ? 'on' : 'off',
}))}
selectItem={string => updateNFTSort(string as NftCollectionSortCriterion)}
selected={`${nftSort}|${nftSortDirection}`}
menuItems={Object.values(NftCollectionSortCriterion).map(sortCriterion => {
return {
icon: { iconType: 'SYSTEM', iconValue: getMenuItemIcon(sortCriterion) },
...(nftSort === sortCriterion
? {
menuTitle: i18n.t(i18n.l.nfts.sort[sortCriterion]),
menuPreferredElementSize: 'small',
menuState: 'on',
menuItems: [
{
actionKey: `${sortCriterion}|${SortDirection.Asc}`,
actionTitle: i18n.t(i18n.l.nfts.sort.order.asc),
icon: {
iconType: 'SYSTEM',
iconValue: 'arrow.up.circle',
iconTint: nftSortDirection === SortDirection.Asc ? undefined : colors.grey,
},
},
{
actionKey: `${sortCriterion}|${SortDirection.Desc}`,
actionTitle: i18n.t(i18n.l.nfts.sort.order.desc),
icon: {
iconType: 'SYSTEM',
iconValue: 'arrow.down.circle',
iconTint: nftSortDirection === SortDirection.Desc ? undefined : colors.grey,
},
},
],
}
: {
actionKey: `${sortCriterion}|${SortDirection.Desc}`,
actionTitle: i18n.t(i18n.l.nfts.sort[sortCriterion]),
menuState: 'off',
}),
};
})}
selectItem={string => updateNFTSort(string as NftSort)}
icon={getIconForSortType(nftSort)}
text={i18n.t(i18n.l.nfts.sort[nftSort])}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ export function ProfileAvatarRow({ size = ProfileAvatarSize }: { size?: number }
<AccentColorProvider color={accentColor}>
<RNAnimated.View style={[animatedStyle, { zIndex: 500 }]}>
<Animated.View style={expandStyle}>
<ContextMenuButton
// @ts-expect-error - JS component
menuConfig={avatarContextMenuConfig}
onPressMenuItem={handlePressMenuItem}
>
<ContextMenuButton menuConfig={avatarContextMenuConfig} onPressMenuItem={handlePressMenuItem}>
<ButtonPressAnimation onPress={onAvatarPressProfile} scale={0.8} testID="avatar-button" overflowMargin={20}>
<Box
alignItems="center"
Expand Down
2 changes: 1 addition & 1 deletion src/components/cards/MintsCard/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function Menu() {
menuState: filter === MintsFilter.Paid ? 'on' : 'off',
},
],
};
} as const;
greg-schrammel marked this conversation as resolved.
Show resolved Hide resolved

const onPressMenuItem = ({ nativeEvent: { actionKey: filter } }: { nativeEvent: { actionKey: MintsFilter } }) => {
haptics.selection();
Expand Down
12 changes: 5 additions & 7 deletions src/components/change-wallet/AddressRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { toChecksumAddress } from '@/handlers/web3';
import { IS_IOS, IS_ANDROID } from '@/env';
import { ContextMenu } from '../context-menu';
import { useForegroundColor } from '@/design-system';
import { MenuActionConfig } from 'react-native-ios-context-menu';

const maxAccountLabelWidth = deviceUtils.dimensions.width - 88;
const NOOP = () => undefined;
Expand Down Expand Up @@ -157,7 +158,7 @@ export default function AddressRow({ contextMenuActions, data, editMode, onPress
},

...(notificationsEnabled
? [
? ([
{
actionKey: ContextMenuKeys.Notifications,
actionTitle: lang.t('wallet.action.notifications.action_title'),
Expand All @@ -166,18 +167,15 @@ export default function AddressRow({ contextMenuActions, data, editMode, onPress
iconValue: 'bell.fill',
},
},
]
] as const)
greg-schrammel marked this conversation as resolved.
Show resolved Hide resolved
: []),
{
actionKey: ContextMenuKeys.Remove,
actionTitle: lang.t('wallet.action.remove'),
icon: {
iconType: 'SYSTEM',
iconValue: 'trash.fill',
},
icon: { iconType: 'SYSTEM', iconValue: 'trash.fill' },
menuAttributes: ['destructive'],
},
];
] satisfies MenuActionConfig[];

const menuConfig = {
menuItems: contextMenuItems,
Expand Down
23 changes: 13 additions & 10 deletions src/components/ens-profile/ActionButtons/MoreButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useRoute } from '@react-navigation/native';
import lang from 'i18n-js';
import React, { useCallback, useMemo } from 'react';
import { Keyboard, Share } from 'react-native';
import { MenuActionConfig } from 'react-native-ios-context-menu';
import { showDeleteContactActionSheet } from '../../contacts';
import More from '../MoreButton/MoreButton';
import ContextMenuButton from '@/components/native-context-menu/contextMenu';
Expand Down Expand Up @@ -45,14 +44,18 @@ export default function MoreButton({ address, ensName }: { address?: string; ens

const menuItems = useMemo(() => {
return [
isWatching && {
actionKey: ACTIONS.OPEN_WALLET,
actionTitle: lang.t('profiles.details.open_wallet'),
icon: {
iconType: 'SYSTEM',
iconValue: 'iphone.and.arrow.forward',
},
},
...(isWatching
? [
{
actionKey: ACTIONS.OPEN_WALLET,
actionTitle: lang.t('profiles.details.open_wallet'),
icon: {
iconType: 'SYSTEM',
iconValue: 'iphone.and.arrow.forward',
},
},
]
: []),
{
actionKey: ACTIONS.COPY_ADDRESS,
actionTitle: lang.t('profiles.details.copy_address'),
Expand Down Expand Up @@ -95,7 +98,7 @@ export default function MoreButton({ address, ensName }: { address?: string; ens
iconValue: 'square.and.arrow.up',
},
},
].filter(Boolean) as MenuActionConfig[];
].filter(Boolean);
}, [isWatching, formattedAddress, contact]);

const handlePressMenuItem = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import isSVGImage from '@/utils/isSVG';
import { refreshNFTContractMetadata, reportNFT } from '@/resources/nfts/simplehash';
import { ContextCircleButton } from '@/components/context-menu';
import { IS_ANDROID, IS_IOS } from '@/env';
import { MenuActionConfig, MenuConfig } from 'react-native-ios-context-menu';
import { ChainId } from '@/chains/types';

const AssetActionsEnum = {
Expand Down Expand Up @@ -262,7 +261,7 @@ const UniqueTokenExpandedStateHeader = ({
const isENS = asset.asset_contract?.address?.toLowerCase() === ENS_NFT_CONTRACT_ADDRESS.toLowerCase();

const isPhotoDownloadAvailable = !isSVG && !isENS;
const assetMenuConfig: MenuConfig = useMemo(() => {
const assetMenuConfig = useMemo(() => {
const AssetActions = getAssetActions({ chainId: asset.chainId });

return {
Expand Down Expand Up @@ -443,11 +442,7 @@ const UniqueTokenExpandedStateHeader = ({
const familyNameHitSlop: Space = '19px (Deprecated)';

const assetMenuOptions = useMemo(() => {
return (
assetMenuConfig?.menuItems
?.filter((item): item is MenuActionConfig => 'actionTitle' in item)
.map((item: MenuActionConfig) => item.actionTitle) ?? []
);
return assetMenuConfig?.menuItems?.filter(item => 'actionTitle' in item).map(item => item.actionTitle) ?? [];
}, [assetMenuConfig]);

return (
Expand All @@ -463,8 +458,8 @@ const UniqueTokenExpandedStateHeader = ({
<ContextCircleButton
options={assetMenuOptions}
onPressActionSheet={(index: number) => {
const actionItems = (assetMenuConfig?.menuItems || []).filter((item): item is MenuActionConfig => 'actionTitle' in item);
const actionKey: MenuActionConfig = actionItems[index];
const actionItems = (assetMenuConfig?.menuItems || []).filter(item => 'actionTitle' in item);
const actionKey = actionItems[index];
if (!actionKey) return;
handlePressAssetMenuItem({
nativeEvent: { actionKey: actionKey.actionKey },
Expand Down
14 changes: 4 additions & 10 deletions src/components/list/ListHeaderMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React from 'react';
import ContextMenuButton from '@/components/native-context-menu/contextMenu';
import ContextMenuButton, { MenuConfig } from '@/components/native-context-menu/contextMenu';
import { ButtonPressAnimation } from '@/components/animations';
import { Bleed, Box, Inline, Text, useForegroundColor } from '@/design-system';
import { NftSort } from '@/hooks/useNFTsSortBy';
import { haptics } from '@/utils';
import { NftCollectionSortCriterion } from '@/graphql/__generated__/arc';

type MenuItem = {
actionKey: string;
actionTitle: string;
menuState?: 'on' | 'off';
};

type ListHeaderMenuProps = {
selected: NftCollectionSortCriterion;
menuItems: MenuItem[];
selected: NftSort;
menuItems: MenuConfig['menuItems'];
selectItem: (item: string) => void;
icon: string;
text: string;
Expand Down
Loading
Loading