Skip to content

Commit

Permalink
feat: update toast offset
Browse files Browse the repository at this point in the history
  • Loading branch information
enestatli committed Dec 20, 2023
1 parent 102b4a6 commit 9683fd7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Inherit all other props from `ToastableBodyParams` interface. Except `background
| onToastableHide | `Func` | Callback when toast is dismissed | `undefined` |
| containerStyle | `ViewProps['style']` | Container style for toast container | `undefined` |
position | `'top' \| 'bottom'\| 'center'` | Toast position. | `'top'` |
offset | `number` | Toast offset. | `0` |
offset | `number` | Toast offset. | `56` |

## ToastableBodyParams

Expand All @@ -103,7 +103,7 @@ titleColor | `ColorValue` | Custom title color, if this is set. | `'#FFFFFF'` |
titleStyle | `TextStyle` | Custom title style. | `undefined` |
messageStyle | `TextStyle` | Custom message style. | `undefined` |
position | `'top' \| 'bottom'\| 'center'` | Toast position. | `'top'` |
offset | `number` | Toast offset. | `0` |
offset | `number` | Toast offset. | `56` |

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion src/components/ToastableCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ToastableCore = forwardRef<ToastableRef, ToastableProps>(
titleStyle,
messageStyle,
position = 'top',
offset = 0,
offset = 56,
...props
},
ref
Expand Down
6 changes: 3 additions & 3 deletions src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export type ToastableBodyParams = {
position?: 'top' | 'bottom' | 'center';
/**
* Toast container offset
* @default 0
* @default 56
* */
offset?: number;
};
Expand Down Expand Up @@ -136,9 +136,9 @@ export type ToastableProps = Omit<
containerStyle?: ViewProps['style'];
/**
* Toast container offset
* @default 0
* @default 56
* */
offset: number;
offset?: number;
};

export type ToastableRef = {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import type { ToastableBodyParams, ToastableRef } from '../types';
const toastableQueue: Array<ToastableBodyParams> = [];
let isToastableVisible = false;

const enqueue = (toastableBody: ToastableBodyParams): void => {
const enqueue = (toastableBody: ToastableBodyParams) => {
toastableQueue.push(toastableBody);

if (!isToastableVisible) {
processNextToastable();
}
};

const dequeue = (): ToastableBodyParams | null =>
toastableQueue.shift() ?? null;
const dequeue = () => toastableQueue.shift() ?? null;

export const processNextToastable = () => {
const toastableBody = dequeue();
Expand Down

0 comments on commit 9683fd7

Please sign in to comment.