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

ui: hide background when a modal opens on Android devices. #985

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import { AddWalletToList, AddWalletToListProps } from '../AddWalletToList';

interface BottomSheetAddWalletToListProps extends AddWalletToListProps {
title: string;
onClose: () => void;
}

export const BottomSheetAddWalletToList = forwardRef<
BottomSheetRef,
BottomSheetAddWalletToListProps
>(({ title, ...addWalletToListProps }, ref) => {
>(({ title, onClose, ...addWalletToListProps }, ref) => {
const { t } = useTranslation();

const createGroupRef = useRef<BottomSheetRef>(null);
Expand All @@ -35,6 +36,7 @@ export const BottomSheetAddWalletToList = forwardRef<

return (
<BottomSheet
onClose={onClose}
ref={ref}
height={DEVICE_HEIGHT * 0.58}
swiperIconVisible={true}
Expand Down
12 changes: 11 additions & 1 deletion src/components/templates/ExplorerAccount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { styles } from './styles';
import { BottomSheetAddWalletToList } from '../BottomSheetAddWalletToList';

interface ExplorerAccountProps {
setBottomStub?: (param: boolean) => void;
account: ExplorerAccount;
listInfoVisible?: boolean;
nameVisible?: boolean;
Expand All @@ -23,7 +24,10 @@ export const ExplorerAccountView = ({
account,
listInfoVisible,
nameVisible,
onToggleWatchlist
onToggleWatchlist,
setBottomStub = () => {
// do nothing
}
}: ExplorerAccountProps): JSX.Element => {
const { t } = useTranslation();

Expand All @@ -44,9 +48,13 @@ export const ExplorerAccountView = ({

const showAddToList = () => {
addToListModal.current?.show();
setTimeout(() => {
setBottomStub(true);
}, 450);
};

const hideAddToList = () => {
setBottomStub(false);
setTimeout(() => addToListModal.current?.dismiss(), 250);
};

Expand Down Expand Up @@ -232,7 +240,9 @@ export const ExplorerAccountView = ({
</Button>
</Row>
</ScrollView>

<BottomSheetAddWalletToList
onClose={() => setBottomStub(false)}
ref={addToListModal}
title={t('address.add.to.group')}
wallet={account}
Expand Down
19 changes: 17 additions & 2 deletions src/screens/Address/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import React, { useRef, useState } from 'react';
import { Platform, View } from 'react-native';
import { RouteProp, useRoute } from '@react-navigation/native';
import { useTranslation } from 'react-i18next';
Expand All @@ -22,7 +22,13 @@ import {
useTransactionsOfAccount,
useWatchlist
} from '@hooks';
import { StringUtils, NumberUtils, scale, verticalScale } from '@utils';
import {
StringUtils,
NumberUtils,
scale,
verticalScale,
isAndroid
} from '@utils';
import { styles } from './styles';

const TRANSACTION_LIMIT = 50;
Expand Down Expand Up @@ -54,6 +60,7 @@ export const AddressDetails = (): JSX.Element => {
const { watchlist } = useWatchlist();
const editModal = useRef<BottomSheetRef>(null);
const shareModal = useRef<BottomSheetRef>(null);
const [showBottomUnderModalStub, setBottomUnderModalStub] = useState(false);

const walletInWatchlist = watchlist.find((w) => w.address === address);
const finalAccount = walletInWatchlist || account;
Expand Down Expand Up @@ -94,6 +101,12 @@ export const AddressDetails = (): JSX.Element => {
// shareModal.current?.show();
// };

const setShowStub = (value: boolean) => {
if (isAndroid) {
setBottomUnderModalStub(value);
}
};

const onToggleWatchlist = (isOnWatchlist: boolean) => {
Toast.hide();
const toastMessage = isOnWatchlist
Expand Down Expand Up @@ -139,6 +152,7 @@ export const AddressDetails = (): JSX.Element => {
}
/>
<ExplorerAccountView
setBottomStub={setShowStub}
account={finalAccount}
nameVisible={true}
onToggleWatchlist={onToggleWatchlist}
Expand Down Expand Up @@ -177,6 +191,7 @@ export const AddressDetails = (): JSX.Element => {
last24HourChange={ambPrice?.percentChange24H || 0}
timestamp={ambPrice?.timestamp || new Date()}
/>
{isAndroid && showBottomUnderModalStub && <View style={styles.stub} />}
</SafeAreaView>
);
};
8 changes: 8 additions & 0 deletions src/screens/Address/styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StyleSheet } from 'react-native';
import { COLORS } from '@constants/colors';
import { DEVICE_HEIGHT } from '@constants/variables';
import { moderateScale, scale } from '@utils';

export const styles = StyleSheet.create({
Expand All @@ -23,5 +24,12 @@ export const styles = StyleSheet.create({
backgroundColor: COLORS.brand100,
height: moderateScale(36),
width: moderateScale(36)
},
stub: {
width: '100%',
height: DEVICE_HEIGHT * 0.5,
backgroundColor: COLORS.neutral0,
position: 'absolute',
bottom: 0
}
});
Loading