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

Profiles: More pixel pushing for small devices #3365

Merged
merged 2 commits into from
May 19, 2022
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
4 changes: 3 additions & 1 deletion src/components/ens-profile/ProfileAvatar/ProfileAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import AvatarCoverPhotoMaskSvg from '../../svg/AvatarCoverPhotoMaskSvg';
import { BackgroundProvider, Box, Cover } from '@rainbow-me/design-system';
import { useFadeImage } from '@rainbow-me/hooks';
import { ImgixImage } from '@rainbow-me/images';
import { sharedCoolModalTopOffset } from '@rainbow-me/navigation/config';

const imagePreviewOverlayTopOffset = ios ? 68 + sharedCoolModalTopOffset : 107;
const size = 70;

export default function ProfileAvatar({
Expand Down Expand Up @@ -58,7 +60,7 @@ export default function ProfileAvatar({
hideStatusBar={false}
imageUrl={avatarUrl || ''}
onPress={handleOnPress}
topOffset={ios ? 112 : 107}
topOffset={imagePreviewOverlayTopOffset}
>
<>
{showSkeleton && (
Expand Down
5 changes: 4 additions & 1 deletion src/components/ens-profile/ProfileCover/ProfileCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import Skeleton from '../../skeleton/Skeleton';
import { Box, useForegroundColor } from '@rainbow-me/design-system';
import { useFadeImage } from '@rainbow-me/hooks';
import { ImgixImage } from '@rainbow-me/images';
import { sharedCoolModalTopOffset } from '@rainbow-me/navigation/config';

const imagePreviewOverlayTopOffset = ios ? 68 + sharedCoolModalTopOffset : 107;

export default function ProfileCover({
coverUrl,
Expand Down Expand Up @@ -73,7 +76,7 @@ export default function ProfileCover({
hideStatusBar={false}
imageUrl={coverUrl || ''}
onPress={handleOnPress}
topOffset={ios ? 112 : 107}
topOffset={imagePreviewOverlayTopOffset}
>
<Box
as={ImgixImage}
Expand Down
13 changes: 10 additions & 3 deletions src/components/images/ImagePreviewOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export function ImagePreviewOverlayTarget({
disableEnteringWithPinch = false,
enableZoomOnPress = true,
hasShadow = false,
height: initialHeight,
height: givenHeight,
hideStatusBar = true,
imageUrl = '',
onPress,
Expand Down Expand Up @@ -433,7 +433,8 @@ export function ImagePreviewOverlayTarget({
uri?: never;
}
)) {
const { enableZoom } = useContext(ImageOverlayConfigContext);
const { enableZoom: enableZoom_ } = useContext(ImageOverlayConfigContext);
const enableZoom = enableZoom_ && imageUrl;

const id = useMemo(() => uniqueId(), []);

Expand Down Expand Up @@ -567,7 +568,13 @@ export function ImagePreviewOverlayTarget({
<Box flexShrink={1} width="full">
<Box
borderRadius={borderRadius}
height={height ? { custom: height } : initialHeight || { custom: 0 }}
height={
givenHeight
? givenHeight
: height
? { custom: height }
: { custom: 0 }
}
onLayout={handleLayout}
ref={zoomableWrapperRef}
style={{ opacity: renderPlaceholder ? 1 : 0, overflow: 'hidden' }}
Expand Down
27 changes: 18 additions & 9 deletions src/screens/ENSAssignRecordsSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
textRecordFields,
} from '@rainbow-me/helpers/ens';
import {
useDimensions,
useENSModifiedRegistration,
useENSRegistration,
useENSRegistrationCosts,
Expand All @@ -62,11 +63,13 @@ import {
} from '@rainbow-me/hooks';
import Routes from '@rainbow-me/routes';

export const BottomActionHeight = ios ? 281 : 250;
const BottomActionHeight = ios ? 281 : 250;
const BottomActionHeightSmall = 215;

export default function ENSAssignRecordsSheet() {
const { params } = useRoute<any>();
const { colors } = useTheme();
const { isSmallPhone } = useDimensions();
const { name } = useENSRegistration();
const {
images: { avatarUrl: initialAvatarUrl },
Expand Down Expand Up @@ -115,6 +118,10 @@ export default function ENSAssignRecordsSheet() {
avatarImage
);

const bottomActionHeight = isSmallPhone
? BottomActionHeightSmall
: BottomActionHeight;

useFocusEffect(() => {
if (dominantColor || (!dominantColor && !avatarImage)) {
setAccentColor(dominantColor || colors.purple);
Expand Down Expand Up @@ -165,7 +172,7 @@ export default function ENSAssignRecordsSheet() {
<Box
background="body"
flexGrow={1}
style={{ paddingBottom: BottomActionHeight + 20 }}
style={{ paddingBottom: bottomActionHeight + 20 }}
>
<Stack space="19px">
<RegistrationCover
Expand Down Expand Up @@ -227,6 +234,7 @@ export function ENSAssignRecordsBottomActions({
currentRouteName: string;
}) {
const { navigate, goBack } = useNavigation();
const { isSmallPhone } = useDimensions();
const keyboardHeight = useKeyboardHeight();
const { colors } = useTheme();
const [accentColor, setAccentColor] = useRecoilState(accentColorAtom);
Expand Down Expand Up @@ -288,9 +296,13 @@ export function ENSAssignRecordsBottomActions({
}
}, [defaultVisible, mode, profileQuery.isSuccess]);

const bottomActionHeight = isSmallPhone
? BottomActionHeightSmall
: BottomActionHeight;

const animatedStyle = useAnimatedStyle(() => {
return {
bottom: withSpring(visible ? 0 : -BottomActionHeight - 10, {
bottom: withSpring(visible ? 0 : -bottomActionHeight - 10, {
damping: 40,
mass: 1,
stiffness: 420,
Expand Down Expand Up @@ -318,14 +330,11 @@ export function ENSAssignRecordsBottomActions({
style={[animatedStyle, { position: 'absolute', width: '100%' }]}
>
<AccentColorProvider color={accentColor}>
<Box
paddingBottom="19px"
style={useMemo(() => ({ height: BottomActionHeight }), [])}
>
<Box paddingBottom="19px" style={{ height: bottomActionHeight }}>
{ios ? <Shadow /> : null}
<Rows>
<Row>
<Inset horizontal="19px" top="30px">
<Inset horizontal="19px" top={isSmallPhone ? '19px' : '30px'}>
<SelectableAttributesButtons
navigateToAdditionalRecords={navigateToAdditionalRecords}
onAddField={onAddField}
Expand All @@ -344,7 +353,7 @@ export function ENSAssignRecordsBottomActions({
}
: {
ignorePaddingBottom: true,
paddingBottom: 36,
paddingBottom: isSmallPhone ? 0 : 36,
})}
>
{hasBackButton && (
Expand Down
4 changes: 2 additions & 2 deletions src/screens/ProfileSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, { createContext, useEffect, useMemo } from 'react';
import { StatusBar } from 'react-native';
import RecyclerAssetList2 from '../components/asset-list/RecyclerAssetList2';
import ProfileSheetHeader from '../components/ens-profile/ProfileSheetHeader';
import { SheetHandleFixedToTopHeight } from '../components/sheet';
import Skeleton from '../components/skeleton/Skeleton';
import { useTheme } from '@rainbow-me/context';
import {
Expand All @@ -27,6 +26,7 @@ import {
useFirstTransactionTimestamp,
usePersistentDominantColorFromImage,
} from '@rainbow-me/hooks';
import { sharedCoolModalTopOffset } from '@rainbow-me/navigation/config';
import Routes from '@rainbow-me/routes';
import { addressHashedColorIndex } from '@rainbow-me/utils/profileUtils';

Expand All @@ -42,7 +42,7 @@ export default function ProfileSheet() {
const { accountAddress } = useAccountSettings();

const { height: deviceHeight } = useDimensions();
const contentHeight = deviceHeight - SheetHandleFixedToTopHeight;
const contentHeight = deviceHeight - sharedCoolModalTopOffset;

const ensName = params?.address;
const { isSuccess } = useENSProfile(ensName);
Expand Down