Skip to content

Commit

Permalink
fix(suite-native): align toasts vertically with the close icon
Browse files Browse the repository at this point in the history
  • Loading branch information
yanascz committed Jan 13, 2025
1 parent cb71804 commit 2fb1a78
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion suite-native/toasts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@trezor/theme": "workspace:*",
"jotai": "1.9.1",
"react": "18.2.0",
"react-native-reanimated": "3.16.1"
"react-native-reanimated": "3.16.1",
"react-native-safe-area-context": "4.14.0"
}
}
12 changes: 7 additions & 5 deletions suite-native/toasts/src/components/ToastRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import { useSafeAreaInsets } from 'react-native-safe-area-context';

import { useAtomValue } from 'jotai';

import { useOfflineBannerAwareSafeAreaInsets } from '@suite-native/connection-status';
import { Box, VStack } from '@suite-native/atoms';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';

import { toastsAtom } from '../toastsAtoms';
import { Toast } from './Toast';

const toastsContainerStyle = prepareNativeStyle<{ topSafeAreaInset: number }>(
(utils, { topSafeAreaInset }) => ({
({ spacings }, { topSafeAreaInset }) => ({
width: '100%',
position: 'absolute',
justifyContent: 'center',
marginTop: topSafeAreaInset,
paddingHorizontal: utils.spacings.sp16,
// top margin = screen top padding + screen header top padding
marginTop: Math.max(topSafeAreaInset, spacings.sp8) + spacings.sp8,
paddingHorizontal: spacings.sp16,
}),
);

export const ToastRenderer = () => {
const { applyStyle } = useNativeStyles();
const { top: topSafeAreaInset } = useOfflineBannerAwareSafeAreaInsets();
const { top: topSafeAreaInset } = useSafeAreaInsets();
const toasts = useAtomValue(toastsAtom);

return (
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11168,6 +11168,7 @@ __metadata:
jotai: "npm:1.9.1"
react: "npm:18.2.0"
react-native-reanimated: "npm:3.16.1"
react-native-safe-area-context: "npm:4.14.0"
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 2fb1a78

Please sign in to comment.