@hoddy-ui/core 1.0.94 → 1.0.96

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.94",
3
+ "version": "1.0.96",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
package/src/hooks.ts CHANGED
@@ -15,6 +15,7 @@ export const useTheme = () => {
15
15
  };
16
16
  export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
17
17
  const colors = useColors();
18
+ const theme = useTheme();
18
19
  const options: any = {
19
20
  stack: {
20
21
  headerShown: false,
@@ -36,7 +37,7 @@ export const useNavScreenOptions = (type: "stack" | "tab" | "drawer") => {
36
37
  headerShown: false,
37
38
  headerTintColor: colors.dark.main,
38
39
  tabBarStyle: {
39
- borderTopColor: colors.white[2],
40
+ borderTopColor: theme === "dark" ? colors.light.main : colors.white[2],
40
41
  borderTopWidth: 1,
41
42
  // shadowColor: "#000",
42
43
  // shadowOffset: { height: -3, width: 0 },
@@ -7,66 +7,66 @@ export const setExtraColors = (c: extraColorTypes) => (extraColors = c);
7
7
  export default function colors(theme: ThemeTypes) {
8
8
  const lightColors = {
9
9
  white: {
10
- 1: "#fff",
10
+ 1: "#ffffff",
11
11
  2: "#f7f7f7",
12
- 3: "#eee",
13
- 4: "#ddd",
14
- 5: "#bbb",
12
+ 3: "#eeeeee",
13
+ 4: "#dddddd",
14
+ 5: "#bbbbbb",
15
15
  ...extraColors?.light?.white,
16
16
  },
17
17
  black: {
18
- 1: "#888",
19
- 2: "#777",
20
- 3: "#555",
21
- 4: "#333",
22
- 5: "#000",
18
+ 1: "#888888",
19
+ 2: "#777777",
20
+ 3: "#555555",
21
+ 4: "#333333",
22
+ 5: "#000000",
23
23
  ...extraColors?.light?.black,
24
24
  },
25
25
  };
26
26
 
27
27
  const darkColors = {
28
28
  black: {
29
- 1: "#fff",
29
+ 1: "#ffffff",
30
30
  2: "#f7f7f7",
31
- 3: "#eee",
32
- 4: "#ddd",
33
- 5: "#aaa",
31
+ 3: "#eeeeee",
32
+ 4: "#dddddd",
33
+ 5: "#aaaaaa",
34
34
  ...extraColors?.dark?.black,
35
35
  },
36
36
  white: {
37
- 1: "#000",
38
- 2: "#222",
39
- 3: "#333",
40
- 4: "#444",
41
- 5: "#555",
37
+ 1: "#060606",
38
+ 2: "#222222",
39
+ 3: "#333333",
40
+ 4: "#444444",
41
+ 5: "#555555",
42
42
  ...extraColors?.dark?.white,
43
43
  },
44
44
  dark: {
45
45
  main: "#f2f3f4",
46
- light: "#fff",
47
- dark: "#ddd",
48
- text: "#000",
46
+ light: "#ffffff",
47
+ dark: "#dddddd",
48
+ text: "#000000",
49
49
  ...extraColors?.dark?.dark,
50
50
  },
51
51
  light: {
52
- main: "#111",
53
- light: "#555",
54
- dark: "#333",
55
- text: "#fff",
52
+ main: "#111111",
53
+ light: "#555555",
54
+ dark: "#333333",
55
+ text: "#ffffff",
56
56
  ...extraColors?.dark?.light,
57
57
  },
58
58
  textSecondary: {
59
- main: "#666",
60
- light: "#777",
61
- dark: "#444",
62
- text: "#fff",
59
+ main: "#666666",
60
+ light: "#777777",
61
+ dark: "#444444",
62
+ text: "#ffffff",
63
63
  ...extraColors?.dark?.textSecondary,
64
64
  },
65
65
  primary: {
66
- main: "#f80",
67
- light: "#FEFFD3",
68
- dark: "#fa0",
69
- text: "#fff",
66
+ main: "#ff8800",
67
+ light: "#feffd3",
68
+ dark: "#ffaa00",
69
+ text: "#ffffff",
70
70
  ...extraColors?.light?.primary,
71
71
  ...extraColors?.dark?.primary,
72
72
  },
@@ -76,74 +76,73 @@ export default function colors(theme: ThemeTypes) {
76
76
  return {
77
77
  ...extraColors[theme],
78
78
  primary: {
79
- main: "#f80",
80
- light: "#FEFFD3",
81
- dark: "#fa0",
82
- text: "#fff",
79
+ main: "#ff8800",
80
+ light: "#feffd3",
81
+ dark: "#ffaa00",
82
+ text: "#ffffff",
83
83
  ...extraColors?.light?.primary,
84
84
  },
85
85
  secondary: {
86
- main: "#f11",
87
- light: "#f43",
88
- dark: "#d00",
89
- text: "#fff",
86
+ main: "#ff1111",
87
+ light: "#ff4433",
88
+ dark: "#dd0000",
89
+ text: "#ffffff",
90
90
  ...extraColors?.light?.secondary,
91
91
  },
92
92
  light: {
93
- main: "#fff",
94
- light: "#fff",
95
- dark: "#ddd",
96
- text: "#000",
93
+ main: "#ffffff",
94
+ light: "#ffffff",
95
+ dark: "#dddddd",
96
+ text: "#000000",
97
97
  ...extraColors?.light?.light,
98
98
  },
99
99
  dark: {
100
- main: "#000",
101
- light: "#777",
102
- dark: "#111",
103
- text: "#fff",
100
+ main: "#000000",
101
+ light: "#777777",
102
+ dark: "#111111",
103
+ text: "#ffffff",
104
104
  ...extraColors?.light?.dark,
105
105
  },
106
106
  textSecondary: {
107
- main: "#aaa",
108
- light: "#bbb",
109
- dark: "#777",
110
- text: "#123",
107
+ main: "#aaaaaa",
108
+ light: "#bbbbbb",
109
+ dark: "#777777",
110
+ text: "#112233",
111
111
  ...extraColors?.light?.textSecondary,
112
112
  },
113
113
  blue: {
114
- main: "#09F",
115
- light: "#39f",
116
- dark: "#028",
117
- text: "#fff",
114
+ main: "#0099ff",
115
+ light: "#3399ff",
116
+ dark: "#002288",
117
+ text: "#ffffff",
118
118
  ...extraColors?.light?.blue,
119
119
  },
120
120
  info: {
121
- main: "#09f",
122
- light: "#3af",
123
- dark: "#08a",
124
- text: "#fff",
121
+ main: "#0099ff",
122
+ light: "#33aaff",
123
+ dark: "#0088aa",
124
+ text: "#ffffff",
125
125
  ...extraColors?.light?.info,
126
126
  },
127
127
  success: {
128
- main: "#0a4",
129
- text: "#fff",
130
- light: "#5c3",
131
- dark: "#062",
128
+ main: "#00aa44",
129
+ text: "#ffffff",
130
+ light: "#55cc33",
131
+ dark: "#006622",
132
132
  ...extraColors?.light?.success,
133
133
  },
134
-
135
134
  warning: {
136
- main: "#fa2",
137
- light: "#fc7",
138
- dark: "#f90",
139
- text: "#fff",
135
+ main: "#ffaa22",
136
+ light: "#ffcc77",
137
+ dark: "#ff9900",
138
+ text: "#ffffff",
140
139
  ...extraColors?.light?.warning,
141
140
  },
142
141
  error: {
143
- main: "#D22",
144
- text: "#fff",
145
- light: "#f43",
146
- dark: "#a20",
142
+ main: "#dd2222",
143
+ text: "#ffffff",
144
+ light: "#ff4433",
145
+ dark: "#aa2200",
147
146
  ...extraColors?.light?.error,
148
147
  },
149
148
  ...dynamicColors,
@@ -1,18 +1,18 @@
1
1
  import AsyncStorage from "@react-native-async-storage/async-storage";
2
2
  import * as NavigationBar from "expo-navigation-bar";
3
3
  import * as SystemUI from "expo-system-ui";
4
- import React, { createContext, useReducer, useState } from "react";
4
+ import React, { createContext, useEffect, useReducer } from "react";
5
5
  import { Platform, useColorScheme } from "react-native";
6
+ import { SafeAreaProvider } from "react-native-safe-area-context";
7
+ import FlashMessage from "../Components/FlashMessage";
8
+ import { useColors, useTheme } from "../hooks";
6
9
  import {
7
- FlashMessageProps,
8
10
  ThemeActionTypes,
9
11
  ThemeContext,
10
12
  ThemeProviderProps,
11
13
  ThemeState,
12
14
  ThemeTypes,
13
15
  } from "../types";
14
- import FlashMessage from "../Components/FlashMessage";
15
- import { SafeAreaProvider } from "react-native-safe-area-context";
16
16
 
17
17
  export const UIThemeContext = createContext<ThemeContext>({
18
18
  themeState: { mode: "default", value: "light" },
@@ -23,19 +23,6 @@ function themeReducer(
23
23
  { type, payload }: ThemeActionTypes
24
24
  ): ThemeState {
25
25
  // Platform
26
- if (payload === "dark" || type === "dark") {
27
- SystemUI.setBackgroundColorAsync("#000000");
28
- if (Platform.OS === "android") {
29
- NavigationBar.setButtonStyleAsync("light");
30
- NavigationBar.setBackgroundColorAsync("#000000");
31
- }
32
- } else {
33
- SystemUI.setBackgroundColorAsync("#ffffff");
34
- if (Platform.OS === "android") {
35
- NavigationBar.setButtonStyleAsync("dark");
36
- NavigationBar.setBackgroundColorAsync("#fff");
37
- }
38
- }
39
26
 
40
27
  switch (type) {
41
28
  case "dark":
@@ -49,6 +36,27 @@ function themeReducer(
49
36
  }
50
37
  }
51
38
 
39
+ const ConfigureSystemUI = () => {
40
+ const theme = useTheme();
41
+ const colors = useColors();
42
+
43
+ useEffect(() => {
44
+ if (colors) {
45
+ SystemUI.setBackgroundColorAsync(colors.white[1]);
46
+ NavigationBar.setBackgroundColorAsync(colors.white[1]);
47
+ }
48
+ if (Platform.OS === "android") {
49
+ if (theme === "dark") {
50
+ NavigationBar.setButtonStyleAsync("light");
51
+ } else {
52
+ NavigationBar.setButtonStyleAsync("dark");
53
+ }
54
+ }
55
+ }, [colors, theme]);
56
+
57
+ return <></>;
58
+ };
59
+
52
60
  export const UIThemeProvider = ({ children }: ThemeProviderProps) => {
53
61
  const [themeState, themeDispatch] = useReducer(themeReducer, {
54
62
  mode: "default",
@@ -87,6 +95,7 @@ export const UIThemeProvider = ({ children }: ThemeProviderProps) => {
87
95
  >
88
96
  {children}
89
97
  <FlashMessage />
98
+ <ConfigureSystemUI />
90
99
  </UIThemeContext.Provider>
91
100
  </SafeAreaProvider>
92
101
  );
package/src/types.ts CHANGED
@@ -30,6 +30,7 @@ export type extraColorTypes = {
30
30
  light?: string;
31
31
  dark?: string;
32
32
  text?: string;
33
+ [key: number]: string;
33
34
  };
34
35
  };
35
36
  light?: {
@@ -38,6 +39,7 @@ export type extraColorTypes = {
38
39
  light?: string;
39
40
  dark?: string;
40
41
  text?: string;
42
+ [key: number]: string;
41
43
  };
42
44
  };
43
45
  };