@hoddy-ui/core 1.0.14 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoddy-ui/core",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -0,0 +1,45 @@
1
+ import { useFocusEffect } from "@react-navigation/native";
2
+ import React, { FC, useCallback, useState } from "react";
3
+ import { LayoutAnimation, View } from "react-native";
4
+ import { ScaledSheet } from "react-native-size-matters";
5
+ import { AnimatorProps } from "../types";
6
+
7
+ const Animator: FC<AnimatorProps> = ({
8
+ style = {},
9
+ duration = 500,
10
+ children,
11
+ delay = 100,
12
+ animationType = "easeInEaseOut",
13
+ type = "fade",
14
+ }) => {
15
+ const [play, setPlay] = useState(false);
16
+ const toggleAnimation = () => {
17
+ setPlay(false);
18
+
19
+ setTimeout(() => {
20
+ LayoutAnimation.configureNext({
21
+ ...LayoutAnimation.Presets[animationType],
22
+ duration,
23
+ });
24
+ setPlay(true);
25
+ }, delay);
26
+ };
27
+ const styles = ScaledSheet.create({
28
+ root: {
29
+ opacity: play ? 1 : 0,
30
+ left: type === "slideInLeft" ? (!play ? -200 : 0) : undefined,
31
+ right: type === "slideInRight" ? (!play ? -200 : 0) : undefined,
32
+ bottom: type === "slideInUp" ? (!play ? -100 : 0) : undefined,
33
+ top: type === "slideInDown" ? (!play ? -100 : 0) : undefined,
34
+ ...style,
35
+ },
36
+ });
37
+ useFocusEffect(
38
+ useCallback(() => {
39
+ toggleAnimation();
40
+ }, [])
41
+ );
42
+ return <View style={styles.root}>{play && children}</View>;
43
+ };
44
+
45
+ export default Animator;
@@ -1,5 +1,5 @@
1
1
  import { Ionicons } from "@expo/vector-icons";
2
- import React, { useState } from "react";
2
+ import React, { useEffect, useState } from "react";
3
3
  import { Alert, TouchableOpacity, View } from "react-native";
4
4
  import { ListItem } from "./List";
5
5
  import TextField from "./TextField";
@@ -16,16 +16,16 @@ import Typography from "./Typography";
16
16
  const { GOOGLE_MAP_API_KEY } = getApiKey();
17
17
 
18
18
  if (GOOGLE_MAP_API_KEY) Location.setGoogleApiKey(GOOGLE_MAP_API_KEY);
19
- else
20
- console.error(
21
- "Google map api key needs to be set to use this component \nMake sure to run initialize() with a valid google map api key"
22
- );
23
19
 
24
20
  type predictionType = {
25
21
  id: string;
26
22
  description: string;
27
23
  };
28
24
  export const getPredictionsFromCoords = async (coords: any) => {
25
+ if (!GOOGLE_MAP_API_KEY)
26
+ console.error(
27
+ "Google map api key needs to be set to use this component \nMake sure to run initialize() with a valid google map api key"
28
+ );
29
29
  if (!coords) return [];
30
30
  const res = await (
31
31
  await fetch(
@@ -150,6 +150,13 @@ export const Locator: React.FC<LocatorProps> = ({
150
150
  setPrediction([]);
151
151
  };
152
152
 
153
+ useEffect(() => {
154
+ if (!GOOGLE_MAP_API_KEY)
155
+ console.error(
156
+ "Google map api key needs to be set to use this component \nMake sure to run initialize() with a valid google map api key"
157
+ );
158
+ }, [GOOGLE_MAP_API_KEY]);
159
+
153
160
  return (
154
161
  <View style={{ zIndex: 100 }}>
155
162
  {renderInput ? (
package/src/types.ts CHANGED
@@ -75,7 +75,14 @@ export interface AvatarProps {
75
75
  size?: number;
76
76
  style?: ViewStyle;
77
77
  }
78
-
78
+ export interface AnimatorProps {
79
+ style?: ViewStyle;
80
+ duration?: number;
81
+ children: ReactNode;
82
+ delay?: number;
83
+ animationType?: "easeInEaseOut" | "linear" | "spring";
84
+ type?: "fade" | "slideInLeft" | "slideInRight" | "slideInUp" | "slideInDown";
85
+ }
79
86
  export interface ButtonProps {
80
87
  color?: colorTypes;
81
88
  variant?: "text" | "outlined" | "contained";