Skip to content

Commit

Permalink
chore: cleanup folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnartorfis committed Sep 5, 2024
1 parent 5eae79c commit a93bff4
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/components/toast/toastAnimations.ts → src/animations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useToastContext } from './ToastContext';
import { ToastPosition } from '../../types/toastTypes';
import { useToastContext } from './context';
import { ToastPosition } from './types';
import React from 'react';
import { Easing, withTiming } from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
Expand Down
6 changes: 1 addition & 5 deletions src/utils/toastConstants.ts → src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ToastPosition,
ToastSwipeDirection,
ToastVariant,
} from '../types/toastTypes';
import { ToastPosition, ToastSwipeDirection, ToastVariant } from './types';

export const toastDefaultValues = {
duration: 3000,
Expand Down
2 changes: 1 addition & 1 deletion src/components/toast/ToastContext.tsx → src/context.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ToastContextType } from '../../types/toastTypes';
import { type ToastContextType } from './types';
import * as React from 'react';

export const ToastContext = React.createContext<ToastContextType | null>(null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ANIMATION_DURATION } from './toastAnimations';
import { useToastContext } from './ToastContext';
import { ToastSwipeDirection } from '../../types/toastTypes';
import { ANIMATION_DURATION } from './animations';
import { useToastContext } from './context';
import { ToastSwipeDirection } from './types';
import * as React from 'react';
import { Dimensions, type ViewStyle } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
Expand Down
12 changes: 4 additions & 8 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export { default as Toast } from './components/toast/Toast';
export { Toaster } from './components/toast/Toaster';
export { default as toast, updateToast } from './utils/toastFunctions';
export {
ToastVariant,
ToastPosition,
ToastSwipeDirection,
} from './types/toastTypes';
export { Toast } from './toast';
export { Toaster } from './toaster';
export { toast, updateToast } from './toast-fns';
export { ToastVariant, ToastPosition, ToastSwipeDirection } from './types';
8 changes: 3 additions & 5 deletions src/utils/toastFunctions.ts → src/toast-fns.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getToastContext } from '../components/toast/Toaster';
import { getToastContext } from './toaster';
import {
ToastVariant,
type ToastFunction,
type ToastUpdateFunction,
} from '../types/toastTypes';
} from './types';

const toast: ToastFunction = (title, options) => {
export const toast: ToastFunction = (title, options) => {
return getToastContext().addToast(title, options);
};

Expand Down Expand Up @@ -46,5 +46,3 @@ toast.promise = (promise, options) => {

return toastId;
};

export default toast;
15 changes: 5 additions & 10 deletions src/components/toast/Toast.tsx → src/toast.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import {
ANIMATION_DURATION,
useToastLayoutAnimations,
} from '../toast/toastAnimations';
import { useToastContext } from './ToastContext';
import { ToastSwipeHandler } from './ToastSwipeHandler';
import { ToastVariant, type ToastProps } from '../../types/toastTypes';
import { ANIMATION_DURATION, useToastLayoutAnimations } from './animations';
import { useToastContext } from './context';
import { ToastSwipeHandler } from './gestures';
import { ToastVariant, type ToastProps } from './types';
import { CircleCheck, CircleX, Info, X } from 'lucide-react-native';
import * as React from 'react';
import { ActivityIndicator, Pressable, Text, View } from 'react-native';
import Animated from 'react-native-reanimated';

const Toast: React.FC<ToastProps> = ({
export const Toast: React.FC<ToastProps> = ({
id,
title,
description,
Expand Down Expand Up @@ -256,5 +253,3 @@ const elevationStyle = {
},
elevation: 4,
};

export default Toast;
8 changes: 4 additions & 4 deletions src/components/toast/Toaster.tsx → src/toaster.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { ToastContext } from './ToastContext';
import { ToastContext } from './context';
import {
ToastPosition,
type ToastFunctionBase,
type ToastFunctionOptions,
type ToastProps,
type ToastProviderProps,
type ToastUpdateFunction,
} from '../../types/toastTypes';
import { toastDefaultValues } from '../../utils/toastConstants';
} from './types';
import { toastDefaultValues } from './constants';
import * as React from 'react';
import { View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { FullWindowOverlay } from 'react-native-screens';
import { v4 as uuidv4 } from 'uuid';
import Toast from './Toast';
import { Toast } from './toast';

let addToastHandler: ToastFunctionBase;
let updateToastHandler: ToastUpdateFunction;
Expand Down
File renamed without changes.

0 comments on commit a93bff4

Please sign in to comment.