Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add checkmark for AppBackground #27

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ Control the native platform theme from React Native.

✅ Control theme of RN Views, as well as native UI controls (alerts, native menus, date pickers... on both Android and iOS)

✅ Control the color of the ApplicationWindow (iOS) or the current Activity (Android) using [`AppBackground`](https://github.com/vonovak-org/react-native-theme-control/blob/main/docs/readme-internal.md#appbackground)

✅ Recover the theme upon app startup

✅ Supports Expo via a config plugin

✅ New architecture supported
[New Architecture](https://reactnative.dev/docs/the-new-architecture/landing-page) supported

Additionally, provides functionality to control the appearance (background and border color, light / dark buttons) of the Android navbar.

Expand All @@ -28,7 +30,7 @@ The use case for the package is explained in a [youtube video](https://youtu.be/

In React Native, you can use the `useColorScheme()` hook, or other functions from the `Appearance` API to get information about the system theme.

Note: as of RN 72, the following paragraph isn't true any more (there is `setColorScheme` now). However, this package still provides value as it can maintain your theme across app restarts.
Note: as of RN 72, the following paragraph isn't true anymore (there is `setColorScheme` now). However, RN does not maintain the selected color scheme across restarts and doesn't contain other goodies in this package.

Using that information, you can then render your Views in dark or light mode design. However, that information is read-only: you cannot influence what the `useColorScheme()` hook returns. What if you want to allow the user to choose the application theme? React Native core does not directly expose the APIs to do so.

Expand Down
4 changes: 2 additions & 2 deletions plugin/src/withThemeControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@
try {
const devLauncherPath = getDevLauncherPath(projectRoot);
const fileContents = readFileSync(devLauncherPath, 'utf8');
const fileContents2 = fileContents.replace(
const commentOutAppearanceOverride = fileContents.replace(
/(RCTOverrideAppearancePreference\((.*?)\);)/g,
'//$1',
);
writeFileSync(devLauncherPath, fileContents2, 'utf8');
writeFileSync(devLauncherPath, commentOutAppearanceOverride, 'utf8');
} catch (err) {

Check warning on line 123 in plugin/src/withThemeControl.ts

View workflow job for this annotation

GitHub Actions / build

'err' is defined but never used
console.warn(
`${themeControlName}: Could not patch Expo Dev Launcher, this is not a fatal error, it'll only influence the dev client`,
);
Expand Down