Skip to content

Commit

Permalink
Merge branch 'main' into release/7.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sethkfman authored Feb 27, 2024
2 parents 2cd8783 + 6ddffcf commit 73771cb
Show file tree
Hide file tree
Showing 110 changed files with 2,542 additions and 1,216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
isInteractable = true,
shouldNavigateBack = true,
isFullscreen = false,
customMarginTop,
...props
},
ref,
Expand Down Expand Up @@ -105,6 +106,7 @@ const BottomSheet = forwardRef<BottomSheetRef, BottomSheetProps>(
isInteractable={isInteractable}
onClose={onCloseCB}
onOpen={onOpenCB}
customMarginTop={customMarginTop}
ref={bottomSheetDialogRef}
isFullscreen={isFullscreen}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Boolean that indicates if sheet is swippable. This affects whether or not tappin
| :-------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------- |
| boolean | No | true |


### `customMarginTop`

Configure height of the modal by setting the distance between top of modal and top of screen.
| <span style="color:gray;font-size:14px">TYPE</span> | <span style="color:gray;font-size:14px">REQUIRED</span> | <span style="color:gray;font-size:14px">DEFAULT</span> |
| :-------------------------------------------------- | :------------------------------------------------------ | :----------------------------------------------------- |
| number | No | 250

### `children`

Content to wrap in sheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const BottomSheetDialog = forwardRef<
isInteractable = true,
onClose,
onOpen,
customMarginTop,
...props
},
ref,
Expand All @@ -68,9 +69,10 @@ const BottomSheetDialog = forwardRef<
useSafeAreaInsets();
const { y: frameY } = useSafeAreaFrame();
const { height: screenHeight } = useWindowDimensions();
const marginTop = customMarginTop ?? DEFAULT_BOTTOMSHEETDIALOG_MARGINTOP;
const maxSheetHeight = isFullscreen
? screenHeight - screenTopPadding
: screenHeight - screenTopPadding - DEFAULT_BOTTOMSHEETDIALOG_MARGINTOP;
: screenHeight - screenTopPadding - marginTop;
const { styles } = useStyles(styleSheet, {
maxSheetHeight,
screenBottomPadding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export interface BottomSheetDialogProps extends ViewProps {
* Optional callback that gets triggered when sheet is opened.
*/
onOpen?: (hasPendingAction?: boolean) => void;
/**
* Customize the top margin of the sheet.
*/
customMarginTop?: number;
}

export interface BottomSheetDialogRef {
Expand Down
16 changes: 7 additions & 9 deletions app/component-library/components/Navigation/TabBar/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { useStyles } from '../../../hooks';
import generateTestId from '../../../../../wdio/utils/generateTestId';
import Routes from '../../../../constants/navigation/Routes';
import { useTheme } from '../../../../util/theme';
import Analytics from '../../../../core/Analytics/Analytics';
import { MetaMetricsEvents } from '../../../../core/Analytics';
import { selectChainId } from '../../../../selectors/networkController';
import { getDecimalChainId } from '../../../../util/networks';
import { useMetrics } from '../../../../components/hooks/useMetrics';

// Internal dependencies.
import { TabBarProps } from './TabBar.types';
Expand All @@ -27,6 +27,7 @@ import OnboardingWizard from '../../../../components/UI/OnboardingWizard';

const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
const { colors } = useTheme();
const { trackEvent } = useMetrics();
const { bottom: bottomInset } = useSafeAreaInsets();
const { styles } = useStyles(styleSheet, { bottomInset });
const chainId = useSelector(selectChainId);
Expand Down Expand Up @@ -73,13 +74,10 @@ const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
navigation.navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.MODAL.WALLET_ACTIONS,
});
Analytics.trackEventWithParameters(
MetaMetricsEvents.ACTIONS_BUTTON_CLICKED,
{
text: '',
chain_id: getDecimalChainId(chainId),
},
);
trackEvent(MetaMetricsEvents.ACTIONS_BUTTON_CLICKED, {
text: '',
chain_id: getDecimalChainId(chainId),
});
break;
case Routes.BROWSER_VIEW:
navigation.navigate(Routes.BROWSER.HOME, {
Expand Down Expand Up @@ -127,7 +125,7 @@ const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
/>
);
},
[state, descriptors, navigation, colors, chainId],
[state, descriptors, navigation, colors, chainId, trackEvent],
);

const renderTabBarItems = useCallback(
Expand Down
2 changes: 2 additions & 0 deletions app/component-library/components/Tags/TagUrl/TagUrl.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const styleSheet = (params: { theme: Theme; vars: TagUrlStyleSheetVars }) => {
) as ViewStyle,
favicon: {
marginRight: 8,
width: 24,
height: 24,
},
label: {
color: colors.text.alternative,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ exports[`TagUrl should render correctly 1`] = `
size="32"
style={
Object {
"height": 24,
"marginRight": 8,
"width": 24,
}
}
variant="Favicon"
Expand Down
10 changes: 10 additions & 0 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ import AsyncStorage from '../../../store/async-storage-wrapper';
import ShowIpfsGatewaySheet from '../../Views/ShowIpfsGatewaySheet/ShowIpfsGatewaySheet';
import ShowDisplayNftMediaSheet from '../../Views/ShowDisplayMediaNFTSheet/ShowDisplayNFTMediaSheet';
import AmbiguousAddressSheet from '../../../../app/components/Views/Settings/Contacts/AmbiguousAddressSheet/AmbiguousAddressSheet';
import SDKDisconnectModal from '../../../../app/components/Views/SDKDisconnectModal/SDKDisconnectModal';
import SDKSessionModal from '../../../../app/components/Views/SDKSessionModal/SDKSessionModal';
import { MetaMetrics } from '../../../core/Analytics';
import trackErrorAsAnalytics from '../../../util/metrics/TrackError/trackErrorAsAnalytics';

Expand Down Expand Up @@ -552,6 +554,14 @@ const App = ({ userLoggedIn }) => {
name={Routes.SHEET.SDK_FEEDBACK}
component={SDKFeedbackModal}
/>
<Stack.Screen
name={Routes.SHEET.SDK_MANAGE_CONNECTIONS}
component={SDKSessionModal}
/>
<Stack.Screen
name={Routes.SHEET.SDK_DISCONNECT}
component={SDKDisconnectModal}
/>
<Stack.Screen
name={Routes.SHEET.ACCOUNT_CONNECT}
component={AccountConnect}
Expand Down
14 changes: 14 additions & 0 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import URL from 'url-parse';
import Logger from '../../../util/Logger';
import { getDecimalChainId } from '../../../util/networks';
import { useMetrics } from '../../../components/hooks/useMetrics';
import DeprecatedNetworkDetails from '../../UI/DeprecatedNetworkModal';

const Stack = createStackNavigator();
const Tab = createBottomTabNavigator();
Expand Down Expand Up @@ -624,6 +625,19 @@ const MainNavigator = () => (
}),
}}
/>
<Stack.Screen
name={Routes.DEPRECATED_NETWORK_DETAILS}
component={DeprecatedNetworkDetails}
options={{
//Refer to - https://reactnavigation.org/docs/stack-navigator/#animations
cardStyle: { backgroundColor: importedColors.transparent },
cardStyleInterpolator: () => ({
overlayStyle: {
opacity: 0,
},
}),
}}
/>
<Stack.Screen name="Home" component={HomeTabs} />
<Stack.Screen name="Asset" component={AssetModalFlow} />
<Stack.Screen name="Webview" component={Webview} />
Expand Down
2 changes: 1 addition & 1 deletion app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import {
stopIncomingTransactionPolling,
} from '../../../util/transaction-controller';
///: BEGIN:ONLY_INCLUDE_IF(snaps)
import { SnapsExecutionWebView } from '../../UI/SnapsExecutionWebView';
import { SnapsExecutionWebView } from '../../../lib/snaps';
///: END:ONLY_INCLUDE_IF

const Stack = createStackNavigator();
Expand Down
15 changes: 9 additions & 6 deletions app/components/UI/AccountApproval/showWarningBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
IconSize,
} from '../../../component-library/components/Icons/Icon';
import { CONNECTING_TO_A_DECEPTIVE_SITE } from '../../../constants/urls';
import AnalyticsV2 from '../../../util/analyticsV2';
import { AccordionHeaderHorizontalAlignment } from '../../../component-library/components/Accordions/Accordion';
import { MetaMetrics } from '../../../core/Analytics';

const descriptionArray = [
strings('accounts.fake_metamask'),
Expand All @@ -28,11 +28,14 @@ const descriptionArray = [

const goToLearnMore = () => {
Linking.openURL(CONNECTING_TO_A_DECEPTIVE_SITE);
AnalyticsV2.trackEvent('EXTERNAL_LINK_CLICKED', {
location: 'dapp_connection_request',
text: 'Learn More',
url_domain: CONNECTING_TO_A_DECEPTIVE_SITE,
});
MetaMetrics.getInstance().trackEvent(
{ category: 'EXTERNAL_LINK_CLICKED' },
{
location: 'dapp_connection_request',
text: 'Learn More',
url_domain: CONNECTING_TO_A_DECEPTIVE_SITE,
},
);
};

const ShowWarningBanner = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Device from '../../../util/device';
import { StyleSheet, TextStyle } from 'react-native';
import { Theme } from '../../../util/theme/models';

const styleSheet = (params: { theme: Theme }) => {
const { theme } = params;
const { typography } = theme;

return StyleSheet.create({
centeredTitle: {
marginTop: 16,
marginBottom: 8,
fontSize: 18,
textAlign: 'center',
},
centeredDescription: {
fontSize: 14,
textAlign: 'center',
paddingRight: 16,
paddingLeft: 16,
},
footer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
button: {
flex: 1,
marginLeft: 16,
marginRight: 16,
marginTop: 24,
marginBottom: Device.isAndroid() ? 21 : 0,
},
buttonLabel: {
...typography.lBodySMMedium,
} as TextStyle,
});
};

export default styleSheet;
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { useNavigation } from '@react-navigation/native';
import React, { useRef } from 'react';
import { Linking, View } from 'react-native';
import { useStyles } from '../../../component-library/hooks';
import { strings } from '../../../../locales/i18n';
import styleSheet from './DeprecatedNetworkModal.styles';
import Text, {
TextColor,
TextVariant,
} from '../../../component-library/components/Texts/Text';
import Button, {
ButtonSize,
ButtonVariants,
} from '../../../component-library/components/Buttons/Button';
import { CONNECTING_TO_DEPRECATED_NETWORK } from '../../../constants/urls';
import BottomSheet from '../../../component-library/components/BottomSheets/BottomSheet';
import { useMetrics } from '../../../components/hooks/useMetrics';
import { MetaMetricsEvents } from '../../../core/Analytics';

const DeprecatedNetworkModal = () => {
const { styles } = useStyles(styleSheet, {});
const { trackEvent } = useMetrics();
const navigation = useNavigation();

const dismissModal = (): void => {
navigation.goBack();
};

const goToLearnMore = () => {
Linking.openURL(CONNECTING_TO_DEPRECATED_NETWORK);
trackEvent(MetaMetricsEvents.EXTERNAL_LINK_CLICKED, {
location: 'dapp_connection_request',
text: 'Learn More',
url_domain: CONNECTING_TO_DEPRECATED_NETWORK,
});
};

const sheetRef = useRef(null);

return (
<BottomSheet ref={sheetRef}>
<Text variant={TextVariant.HeadingMD} style={styles.centeredTitle}>
{strings('networks.network_deprecated_title')}
</Text>
<Text variant={TextVariant.BodyMD} style={styles.centeredDescription}>
{strings('networks.network_deprecated_description')}{' '}
<Text color={TextColor.Info} onPress={goToLearnMore}>
{strings('accounts.learn_more')}
</Text>
</Text>
<View style={{ ...styles.footer }}>
<Button
variant={ButtonVariants.Primary}
size={ButtonSize.Lg}
onPress={dismissModal}
style={styles.button}
label={
<Text
variant={TextVariant.BodyMD}
color={TextColor.Default}
style={styles.buttonLabel}
>
{strings('network_information.got_it')}
</Text>
}
/>
</View>
</BottomSheet>
);
};

export default DeprecatedNetworkModal;
1 change: 1 addition & 0 deletions app/components/UI/DeprecatedNetworkModal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './DeprecatedNetworkModal';
64 changes: 0 additions & 64 deletions app/components/UI/SnapsExecutionWebView/SnapsExecutionWebView.tsx

This file was deleted.

Loading

0 comments on commit 73771cb

Please sign in to comment.