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

fix(privacy): add force dark script, fix en version #629

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 13 additions & 3 deletions apps/thu-info-app/src/ui/settings/privacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,42 @@ import {useColorScheme} from "react-native";
import {useSelector} from "react-redux";
import {helper, State} from "../../redux/store";
import {MOCK_APP_PRIVACY_URL} from "@thu-info/lib/src/mocks/app";
import {langCode} from "../../utils/i18n";

export const PrivacyScreen = () => {
const themeName = useColorScheme();
const theme = themes(themeName);
const dark = useSelector((s: State) => s.config.darkMode);
const FORCE_DARK_JS = `
(function() {
document.body.style.backgroundColor = "${theme.colors.themeBackground}";
document.body.style.color = "${theme.colors.text}";
document.body.getElementsByTagName("nav")[0].style.display = "none";
document.body.getElementsByTagName("footer")[0].style.display = "none";
}
)();`;
return (
<>
<View
style={{
backgroundColor: theme.colors.themeBackground,
flex: 1,
padding: 15,
}}>
<WebView
source={{
uri:
helper.userId.length === 0
`${helper.userId.length === 0
? MOCK_APP_PRIVACY_URL
: helper.getPrivacyUrl(),
: helper.getPrivacyUrl()
}${langCode === "zh" ? "" : "-en"}`,
}}
containerStyle={{
backgroundColor: theme.colors.themeBackground,
color: theme.colors.text,
}}
setSupportMultipleWindows={false}
forceDarkOn={dark || themeName === "dark"}
injectedJavaScript={FORCE_DARK_JS}
SunnyCloudYang marked this conversation as resolved.
Show resolved Hide resolved
/>
</View>
</>
Expand Down
2 changes: 2 additions & 0 deletions apps/thu-info-app/src/utils/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export const getLocale = () => {

const translations = getLocale() as typeof zh;

export const langCode = translations === zh ? "zh" : "en";

export function getStr<K extends keyof typeof zh>(key: K): string {
// @ts-ignore
return translations[key];
Expand Down
Loading