fix config theme system
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -3,5 +3,6 @@
|
||||
"source.fixAll": "explicit",
|
||||
"source.organizeImports": "explicit",
|
||||
"source.sortMembers": "explicit"
|
||||
}
|
||||
},
|
||||
"postman.settings.dotenv-detection-notification-visibility": false
|
||||
}
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
* https://docs.expo.dev/guides/color-schemes/
|
||||
*/
|
||||
|
||||
import { ColorName } from "@/constants/theme";
|
||||
import { useThemeContext } from "@/hooks/use-theme-context";
|
||||
import { Colors } from "@/constants/theme";
|
||||
import { useColorScheme } from "@/hooks/use-color-scheme";
|
||||
|
||||
export function useThemeColor(
|
||||
props: { light?: string; dark?: string },
|
||||
colorName: ColorName
|
||||
colorName: keyof typeof Colors.light & keyof typeof Colors.dark
|
||||
) {
|
||||
const { colorScheme, getColor } = useThemeContext();
|
||||
const colorFromProps = props[colorScheme];
|
||||
const theme = useColorScheme() ?? "light";
|
||||
const colorFromProps = props[theme];
|
||||
|
||||
if (colorFromProps) {
|
||||
return colorFromProps;
|
||||
} else {
|
||||
return getColor(colorName);
|
||||
return Colors[theme][colorName];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user