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 492044c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions suite-native/toasts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"dependencies": {
"@mobily/ts-belt": "^3.13.1",
"@suite-native/atoms": "workspace:*",
"@suite-native/connection-status": "workspace:*",
"@suite-native/icons": "workspace:*",
"@trezor/styles": "workspace:*",
"@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: 0 additions & 1 deletion suite-native/toasts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"compilerOptions": { "outDir": "libDev" },
"references": [
{ "path": "../atoms" },
{ "path": "../connection-status" },
{ "path": "../icons" },
{ "path": "../../packages/styles" },
{ "path": "../../packages/theme" }
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11161,13 +11161,13 @@ __metadata:
dependencies:
"@mobily/ts-belt": "npm:^3.13.1"
"@suite-native/atoms": "workspace:*"
"@suite-native/connection-status": "workspace:*"
"@suite-native/icons": "workspace:*"
"@trezor/styles": "workspace:*"
"@trezor/theme": "workspace:*"
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 492044c

Please sign in to comment.