@hoddy-ui/core 1.0.95 → 1.0.97

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.95",
3
+ "version": "1.0.97",
4
4
  "description": "Core rich react native components written in typescript",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -11,7 +11,7 @@ import {
11
11
 
12
12
  import React, { useState } from "react";
13
13
  import { ScaledSheet } from "react-native-size-matters";
14
- import { useColors } from "../hooks";
14
+ import { useColors, useTheme } from "../hooks";
15
15
  import { PopupProps } from "../types";
16
16
  import { IconButton } from "./Button";
17
17
  import Typography from "./Typography";
@@ -25,7 +25,9 @@ export const Popup: React.FC<PopupProps> = ({
25
25
  children,
26
26
  open,
27
27
  onClose = () => {},
28
+ style,
28
29
  }) => {
30
+ const theme = useTheme();
29
31
  const colors = useColors();
30
32
  const [show, setShow] = useState(open);
31
33
  const [showSecondary, setShowSecondary] = useState(false);
@@ -47,12 +49,13 @@ export const Popup: React.FC<PopupProps> = ({
47
49
  },
48
50
  container: {
49
51
  paddingBottom: sheet ? "30@ms" : 0,
50
- backgroundColor: colors.white[2],
52
+ backgroundColor: theme === "dark" ? "#111" : colors.white[2],
51
53
  borderTopLeftRadius: 20,
52
54
  borderTopRightRadius: 20,
53
55
  borderBottomRightRadius: sheet ? 0 : 20,
54
56
  borderBottomLeftRadius: sheet ? 0 : 20,
55
57
  width: "100%",
58
+ ...style,
56
59
  },
57
60
  content: {
58
61
  paddingHorizontal: bare ? undefined : "10@ms",
@@ -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
@@ -220,6 +220,7 @@ export interface PopupProps {
220
220
  children: ReactNode;
221
221
  open: boolean;
222
222
  onClose?: () => void;
223
+ style?: ViewStyle;
223
224
  }
224
225
 
225
226
  export interface SpinnerProps {