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: support SheetModal of TokenDetail. #263

Merged
merged 24 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d911384
feat: basic layout of BottomSheetModalTokenDetail.
richardo2016x May 10, 2024
ed921f7
feat: support all redirection on TokenDetail sheet modal, fix data lo…
richardo2016x May 10, 2024
1ea6195
style: tuning.
richardo2016x May 10, 2024
4847f29
feat: support copy other address on tx hash.
richardo2016x May 10, 2024
5ce7734
chore: code clean.
richardo2016x May 10, 2024
1a66add
fix: sentry org name
richardo2016x May 13, 2024
052a1c7
ci: skip auto upload sentry sourcemap.
richardo2016x May 13, 2024
66a2b80
feat: better copy toast.
richardo2016x May 13, 2024
0b77dd4
ci: fix config.
richardo2016x May 13, 2024
01b130e
style: robust change.
richardo2016x May 13, 2024
9dec0a7
style: fix button shape on iOS.
richardo2016x May 13, 2024
a1b610c
style: tuning.
richardo2016x May 13, 2024
a0427fb
feat: style tuning & code cleanup.
richardo2016x May 13, 2024
b93a576
style: tuning.
richardo2016x May 13, 2024
1e73f53
fix: show token name on Receive screen.
richardo2016x May 13, 2024
e578af9
fix: support view token detail on Tx Approve Popup.
richardo2016x May 13, 2024
428adfd
style: tuning.
richardo2016x May 13, 2024
6c0c113
chore: clean up.
richardo2016x May 13, 2024
fdcbc45
fix: should close small token modal on redirect-to special screen.
richardo2016x May 14, 2024
5284659
feat: normalize toast copied address.
richardo2016x May 14, 2024
a0adce9
fix: show token symbol on Receive screen.
richardo2016x May 14, 2024
a6fee18
style: tuning.
richardo2016x May 14, 2024
d22f5d4
Merge remote-tracking branch 'origin/develop' into feat/token_detail
richardo2016x May 14, 2024
8f73221
chore: revert version and clean.
richardo2016x May 14, 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
5 changes: 5 additions & 0 deletions .github/workflows/feature_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
required: true
type: boolean
default: true
SENTRY_DISABLE_AUTO_UPLOAD:
required: false
type: boolean
default: false

defaults:
run:
Expand Down Expand Up @@ -83,6 +87,7 @@ jobs:
RABBY_MOBILE_SENTRY_AUTH_TOKEN2: ${{ secrets.RABBY_MOBILE_SENTRY_AUTH_TOKEN2 }}
SENTRY_AUTH_TOKEN: ${{ secrets.RABBY_MOBILE_SENTRY_AUTH_TOKEN2 }}
REALLY_UPLOAD: ${{ inputs.REALLY_UPLOAD }}
SENTRY_DISABLE_AUTO_UPLOAD: ${{ inputs.SENTRY_DISABLE_AUTO_UPLOAD }}
CONFIGURATION: release
TYPE: adhoc
BUILD_ENV: alpha
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/bin/bash -l
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
1 change: 1 addition & 0 deletions apps/mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'

apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle")

android {
ndkVersion rootProject.ext.ndkVersion

Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/android/sentry.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults.url=https://sentry.io/
defaults.org=debank
defaults.org=rabby-wallet
defaults.project=rabby-mobile
# use environment variable SENTRY_AUTH_TOKEN
# auth.token=
10 changes: 5 additions & 5 deletions apps/mobile/ios/RabbyMobile/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<false />
<key>LSApplicationQueriesSchemes</key>
<array>
<string>imtokenv2</string>
Expand All @@ -52,15 +52,15 @@
<string>blob</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<true />
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<true />
</dict>
</dict>
</dict>
Expand All @@ -71,7 +71,7 @@
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) needs camera access to scan QR codes.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<string />
<key>UIAppFonts</key>
<array>
<string>Anton-Regular.ttf</string>
Expand All @@ -95,6 +95,6 @@
<key>UIUserInterfaceStyle</key>
<string>Automatic</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<false />
</dict>
</plist>
2 changes: 1 addition & 1 deletion apps/mobile/ios/sentry.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defaults.url=https://sentry.io/
defaults.org=debank
defaults.org=rabby-wallet
defaults.project=rabby-mobile
# use environment variable SENTRY_AUTH_TOKEN
# auth.token=
2 changes: 1 addition & 1 deletion apps/mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rabby-mobile",
"version": "0.1.9",
"version": "0.1.8",
"private": true,
"repository": {
"type": "git",
Expand Down
11 changes: 0 additions & 11 deletions apps/mobile/src/AppNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,6 @@ export default function AppNavigation({
},
}}
/>
<RootStack.Screen
name={RootNames.Receive}
component={ReceiveScreen}
options={{
...screenOptions,
title: '',
headerShadowVisible: false,
headerShown: true,
headerTransparent: true,
}}
/>
<RootStack.Screen
name={RootNames.AccountTransaction}
component={AccountNavigator}
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/src/assets/icons/common/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export { default as RcWalletCC } from './wallet-cc.svg';
export { default as RcIconCheckmarkCC } from './icon-checkmark-cc.svg';

export { default as RcIconCloseCC } from './icon-close-cc.svg';

export { default as RcIconNotMatchedCC } from './not-matched-cc.svg';
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/mobile/src/assets/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@
}
},
"receive": {
"title": "Receive assets on {{chain}}",
"title": "Receive {{token}} on {{chain}}",
"watchModeAlert": "This is a watch-only address. Are you sure to use it to receive?"
},
"sendToken": {
Expand Down
101 changes: 74 additions & 27 deletions apps/mobile/src/components/AddressViewer/CopyAddress.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback } from 'react';
import { TouchableOpacity } from 'react-native';
import React, { useCallback, useImperativeHandle } from 'react';
import { TouchableOpacity, View, Text } from 'react-native';
import Clipboard from '@react-native-clipboard/clipboard';
import { SvgProps } from 'react-native-svg';

Expand All @@ -8,38 +8,85 @@ import { useThemeStyles } from '@/hooks/theme';
import { createGetStyles } from '@/utils/styles';
import { toast } from '../Toast';

type ContainerProps = React.ComponentProps<typeof TouchableOpacity>;
type ContainerOnPressProp = React.ComponentProps<
typeof TouchableOpacity
>['onPress'] &
object;
type CopyHandler = (evt?: Parameters<ContainerOnPressProp>[0]) => void;

type Props = {
address?: string | null;
// containerStyle?: ContainerProps['style'];
style?: SvgProps['style'];
color?: string;
onToastSucess?: (ctx: { address: string }) => void;
};
export function CopyAddressIcon({
style,
// containerStyle,
address,
color,
}: Props) {
const { colors } = useThemeStyles(getStyles);

const handleCopyAddress = useCallback<ContainerProps['onPress'] & object>(
evt => {
if (!address) return null;

evt.stopPropagation();
Clipboard.setString(address);
toast.success('Copied');
export type CopyAddressIconType = {
doCopy: CopyHandler;
};
export const CopyAddressIcon = React.forwardRef<CopyAddressIconType, Props>(
function (
{
onToastSucess: propOnToastSucess,
style,
// containerStyle,
address,
color,
},
[address],
);

return (
<TouchableOpacity style={style} onPress={handleCopyAddress}>
<RcIconCopyCC color={color || colors['neutral-foot']} style={style} />
</TouchableOpacity>
);
ref,
) {
const { colors } = useThemeStyles(getStyles);

const onToastSucess = useCallback<Props['onToastSucess'] & object>(
({ address }) => {
if (propOnToastSucess) propOnToastSucess({ address });
else {
toastCopyAddressSuccess(address);
}
},
[propOnToastSucess],
);

const handleCopyAddress = useCallback<CopyHandler>(
(evt?) => {
if (!address) return null;

evt?.stopPropagation();
Clipboard.setString(address);
onToastSucess({ address });
},
[address, onToastSucess],
);

useImperativeHandle(ref, () => ({
doCopy: handleCopyAddress,
}));

return (
<TouchableOpacity style={style} onPress={handleCopyAddress}>
<RcIconCopyCC color={color || colors['neutral-foot']} style={style} />
</TouchableOpacity>
);
},
);

export function toastCopyAddressSuccess(address?: string) {
if (!address) {
toast.success('Copied');
return;
}

toast.success(tctx => {
return (
<View
style={{
flexDirection: 'column',
justifyContent: 'flex-start',
}}>
<Text style={tctx.textStyle}>Copied</Text>
<Text style={tctx.textStyle}>{address}</Text>
</View>
);
});
}

const getStyles = createGetStyles(colors => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { useMemo, ReactNode, useState, useEffect } from 'react';
import React, {
useMemo,
ReactNode,
useState,
useEffect,
useCallback,
} from 'react';
import {
View,
StyleSheet,
Expand Down Expand Up @@ -43,6 +49,7 @@ import { keyringService } from '@/core/services';
import { useApprovalSecurityEngine } from '../../../hooks/useApprovalSecurityEngine';
import useCommonStyle from '@/components/Approval/hooks/useCommonStyle';
import { useThemeColors } from '@/hooks/theme';
import { useTokenDetailSheetModalOnApprovals } from '@/components/TokenDetailPopup/ApprovalTokenDetailSheetModalStub';

const { isSameAddress } = addressUtils;

Expand Down Expand Up @@ -479,10 +486,11 @@ const TokenSymbol = ({
token: TokenItem;
style?: TextStyle;
}) => {
const handleClickTokenSymbol = () => {
// TODO
// dispatch.sign.openTokenDetailPopup(token);
};
const { openTokenDetailPopup } = useTokenDetailSheetModalOnApprovals();
const handleClickTokenSymbol = useCallback(() => {
openTokenDetailPopup(token);
}, [openTokenDetailPopup, token]);

return (
<Text
onPress={handleClickTokenSymbol}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useCallback } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { useTranslation } from 'react-i18next';
import BigNumber from 'bignumber.js';
Expand All @@ -19,6 +19,7 @@ import DescItem from '../Actions/components/DescItem';
import { useThemeColors } from '@/hooks/theme';
import { AppColorsVariants } from '@/constant/theme';
import useCommonStyle from '../../hooks/useCommonStyle';
import { useTokenDetailSheetModalOnApprovals } from '@/components/TokenDetailPopup/ApprovalTokenDetailSheetModalStub';

const getStyle = (colors: AppColorsVariants) =>
StyleSheet.create({
Expand Down Expand Up @@ -214,10 +215,13 @@ const BalanceChange = ({
};
}, [data]);

const handleClickToken = (t: TokenItem) => {
// TODO
// dispatch.sign.openTokenDetailPopup(t);
};
const { openTokenDetailPopup } = useTokenDetailSheetModalOnApprovals();
const handleClickToken = useCallback(
(t: TokenItem) => {
openTokenDetailPopup(t);
},
[openTokenDetailPopup],
);

if (version === 'v0') {
return (
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/AssetAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type AssetAvatarProps = {
chainIconPosition?: 'tr' | 'br' | 'tl' | 'bl';
chainSize?: number;
failedPlaceholder?: ReactNode;
style?: ViewStyle;
style?: RNViewProps['style'];
logoStyle?: ViewStyle;
};

Expand Down
Loading
Loading