From 8bf56a552e81a70abff06770cea411d9207c71fb Mon Sep 17 00:00:00 2001 From: Alexander Shiryaev Date: Thu, 6 Aug 2020 16:37:37 +0300 Subject: [PATCH] feat: added darkmode support --- template/package-lock.json | 17 +++++++++++++++-- template/package.json | 1 + template/src/ui/Text/Text.tsx | 4 +++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/template/package-lock.json b/template/package-lock.json index 3494b64..0b708d8 100644 --- a/template/package-lock.json +++ b/template/package-lock.json @@ -9395,7 +9395,6 @@ "version": "16.9.17", "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.17.tgz", "integrity": "sha512-UP27In4fp4sWF5JgyV6pwVPAQM83Fj76JOcg02X5BZcpSu5Wx+fP9RMqc2v0ssBoQIFvD5JdKY41gjJJKmw6Bg==", - "dev": true, "requires": { "@types/prop-types": "*", "csstype": "^2.2.0" @@ -9414,7 +9413,6 @@ "version": "0.63.2", "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.63.2.tgz", "integrity": "sha512-oxbp084lUsZvwfdWmWxKjJAuqEraQDRf+cE/JgwmrHQMguSrmgIHZ3xkeoQ5FYnW5NHIPpHudB3BbjL1Zn3vnA==", - "dev": true, "requires": { "@types/react": "*" } @@ -23845,6 +23843,16 @@ "version": "git+https://github.com/luggit/react-native-config.git#cf8ab95350a227d1a932fec7a920df562b3e9ae5", "from": "git+https://github.com/luggit/react-native-config.git" }, + "react-native-dynamic": { + "version": "1.0.0-rc.4", + "resolved": "https://registry.npmjs.org/react-native-dynamic/-/react-native-dynamic-1.0.0-rc.4.tgz", + "integrity": "sha512-I7fee69MSX0E4lEOmiIukQhlcUNiXcedAsoEPc6AKjnktPr+UIqRRi5SM1HYAAV/bJvFKs9yeQ+o/oYcECu8yA==", + "requires": { + "@types/react": "*", + "@types/react-native": ">=0.62.0", + "toolkit.ts": "^0.0.2" + } + }, "react-native-extended-stylesheet": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/react-native-extended-stylesheet/-/react-native-extended-stylesheet-0.12.0.tgz", @@ -26289,6 +26297,11 @@ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" }, + "toolkit.ts": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/toolkit.ts/-/toolkit.ts-0.0.2.tgz", + "integrity": "sha512-yJJTVbCwiD6AfFgReewJCGJuODmyZUeL1sDjnxp33t0UBxnezgQrLbz/F9++RC28CTlk5u5pVji4TbeondYEkw==" + }, "tough-cookie": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-3.0.1.tgz", diff --git a/template/package.json b/template/package.json index a2f30c4..743a125 100644 --- a/template/package.json +++ b/template/package.json @@ -57,6 +57,7 @@ "react-intl": "^3.2.1", "react-native": "0.63.0", "react-native-config": "git+https://github.com/luggit/react-native-config.git", + "react-native-dynamic": "^1.0.0-rc.4", "react-native-extended-stylesheet": "^0.12.0", "react-native-gesture-handler": "^1.4.1", "react-native-iphone-x-helper": "^1.2.1", diff --git a/template/src/ui/Text/Text.tsx b/template/src/ui/Text/Text.tsx index 5054ac0..988a246 100644 --- a/template/src/ui/Text/Text.tsx +++ b/template/src/ui/Text/Text.tsx @@ -1,4 +1,5 @@ import React, { ReactNode } from 'react'; +import { useDarkMode } from 'react-native-dynamic'; import { Text as RNText, TextProps as RNTextProps, StyleProp, TextStyle } from 'react-native'; import EStyleSheet from 'react-native-extended-stylesheet'; @@ -15,8 +16,9 @@ export type TextProps = { } & RNTextProps; export function Text({ children, style, size = 'body1', weight = 'regular', color = '$black', ...props }: TextProps) { + const isDarkMode = useDarkMode(); const textColorStyle = EStyleSheet.create({ - color: { color }, + color: isDarkMode ? { color: 'white' } : { color }, }); return (