ripal-ui 1.0.2 → 1.0.4

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/config.js CHANGED
@@ -1,4 +1,4 @@
1
- // import config from "../../ripal-ui.config.js"
2
- import config from "../ripal-ui.config.js"
1
+ import config from "../../ripal-ui.config.js"
2
+ // import config from "../ripal-ui.config.js"
3
3
 
4
4
  export default config
@@ -34,7 +34,6 @@ const Separator: React.FC<SeparatorProps> = ({
34
34
  });
35
35
  toReturn = parseInt(toReturn.join(""));
36
36
  theWidth = toReturn / 100 * Dimensions.get('screen').width;
37
- console.log(theWidth);
38
37
  }
39
38
  return (
40
39
  <Inline justifyContent="center">
@@ -25,7 +25,6 @@ const Switch: React.FC<SwitchProps> = ({
25
25
  if (onChange) {
26
26
  onChange();
27
27
  }
28
- console.log('hehe');
29
28
  }}
30
29
  >
31
30
  <Inline
package/elements/Text.tsx CHANGED
@@ -1,7 +1,8 @@
1
- import React, { FC } from "react";
1
+ import React, { FC, useEffect, useState } from "react";
2
2
  import { Text as RNText, TextStyle } from "react-native";
3
3
  import { useFonts, Poppins_300Light, Poppins_400Regular, Poppins_500Medium, Poppins_600SemiBold, Poppins_700Bold, Poppins_900Black } from "@expo-google-fonts/poppins";
4
4
  import config from "../config";
5
+ import AsyncStorage from "@react-native-async-storage/async-storage";
5
6
 
6
7
  interface TextProps {
7
8
  children: React.ReactNode;
@@ -35,13 +36,28 @@ const Text: FC<TextProps> = ({
35
36
  Poppins_700Bold,
36
37
  Poppins_900Black
37
38
  });
39
+ const [lang, setLang] = useState(config.appLangs.default);
38
40
 
39
- if (config.appLangs.default !== null) {
41
+ useEffect(() => {
42
+ console.log('hehe');
43
+
44
+ AsyncStorage.getItem('app_lang').then(appLang => {
45
+ if (appLang != null) {
46
+ console.log('setting to ', appLang);
47
+ setLang(appLang);
48
+ }
49
+ console.log(appLang);
50
+ });
51
+ }, []);
52
+
53
+ if (lang !== null) {
40
54
  const ogChildren = children;
41
55
  if (typeof children === "string") {
56
+ console.log(lang);
57
+
42
58
  children = children.split('.').reduce((acc, key) => {
43
59
  return acc && acc[key] !== undefined ? acc[key] : ogChildren;
44
- }, config.appLangs[config.appLangs.default]);
60
+ }, config.appLangs[lang]);
45
61
  }
46
62
  }
47
63
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ripal-ui",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A collection of React elements and components",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,6 +1,20 @@
1
1
  // ./scripts/generateConfig.js
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
+ const { exec } = require('child_process');
5
+
6
+ // Installing AsyncStorage
7
+ exec('npm install @react-native-async-storage/async-storage', (error, stdout, stderr) => {
8
+ if (error) {
9
+ console.error(`Error installing dependencies: ${error.message}`);
10
+ return;
11
+ }
12
+ if (stderr) {
13
+ console.error(`stderr: ${stderr}`);
14
+ return;
15
+ }
16
+ generateConfig(); // Call function to generate config after installing
17
+ });
4
18
 
5
19
  // Define the config file content
6
20
  const configContent = `const config = {