Skip to content

Commit

Permalink
feat: no weeb skin
Browse files Browse the repository at this point in the history
  • Loading branch information
lovegaoshi committed May 2, 2024
1 parent 04e0ce8 commit 61de3a8
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 15 deletions.
6 changes: 5 additions & 1 deletion src/components/background/MainBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ const MainBackground = ({ children }: { children: React.JSX.Element }) => {
</>
);
default:
return <>{children}</>;
return (
<View style={{ backgroundColor: playerStyle.colors.background }}>
{children}
</View>
);
}
};

Expand Down
156 changes: 154 additions & 2 deletions src/components/setting/appearances/NoWeebButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,158 @@
import React from 'react';
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { ScrollView, StyleSheet, View, TextInput } from 'react-native';
import { Text } from 'react-native-paper';

import GenericDialog from '@components/dialogs/GenericDialog';
import { useNoxSetting } from '@stores/useApp';
import { SettingListItem } from '../useRenderSetting';

import { SettingListItem, RenderSetting } from '../useRenderSetting';
export default () => {
const { t } = useTranslation();
const playerStyle = useNoxSetting(state => state.playerStyle);
const setPlayerStyle = useNoxSetting(state => state.setPlayerStyle);
const [visible, setVisible] = React.useState(false);
const [primaryColor, setPrimaryColor] = React.useState('');
const [secondaryColor, setSecondaryColor] = React.useState('');
const [contrastColor, setContrastColor] = React.useState('');
const [backgroundColor, setBackgroundColor] = React.useState('');

React.useEffect(() => {
if (!visible) return;
setPrimaryColor(playerStyle.colors.primary);
setSecondaryColor(playerStyle.colors.secondary);
setContrastColor(playerStyle.customColors.playlistDrawerBackgroundColor);
setBackgroundColor(playerStyle.colors.background);
}, [visible]);

const onSubmit = () => {
setVisible(false);
setPlayerStyle({
...playerStyle,
gifs: [],
backgroundImages: [],
backgroundImagesLandscape: [],
customColors: {
...playerStyle.customColors,
playlistDrawerBackgroundColor: contrastColor,
textInputSelectionColor: contrastColor,
progressThumbTintColor: primaryColor,
progressMinimumTrackTintColor: primaryColor,
},
colors: {
...playerStyle.colors,
primary: primaryColor,
secondary: secondaryColor,
background: backgroundColor,
onSurface: primaryColor,
onSurfaceVariant: primaryColor,
text: primaryColor,
},
bkgrdImg: '',
bkgrdImgLandscape: '',
});
};

return (
<View>
<GenericDialog
visible={visible}
onClose={() => setVisible(false)}
onSubmit={onSubmit}
title={t('AppearanceSettings.noWeebSkinsDesc')}
>
<ScrollView>
<View style={styles.rowView}>
<View
style={[
{
backgroundColor: primaryColor,
},
styles.colorBlock,
]}
/>
<View style={styles.colorBlockSpace} />
<Text>{t('AppearanceSettings.PrimaryColor')}</Text>
<TextInput
style={{ color: playerStyle.colors.primary }}
value={primaryColor}
onChangeText={setPrimaryColor}
></TextInput>
</View>
<View style={styles.rowView}>
<View
style={[
{
backgroundColor: secondaryColor,
},
styles.colorBlock,
]}
/>
<View style={styles.colorBlockSpace} />
<Text>{t('AppearanceSettings.SecondaryColor')}</Text>
<TextInput
style={{ color: playerStyle.colors.primary }}
value={secondaryColor}
onChangeText={setSecondaryColor}
></TextInput>
</View>
<View style={styles.rowView}>
<View
style={[
{
backgroundColor: contrastColor,
},
styles.colorBlock,
]}
/>
<View style={styles.colorBlockSpace} />
<Text>{t('AppearanceSettings.ContrastColor')}</Text>
<TextInput
style={{ color: playerStyle.colors.primary }}
value={contrastColor}
onChangeText={setContrastColor}
></TextInput>
</View>
<View style={styles.rowView}>
<View
style={[
{
backgroundColor: backgroundColor,
},
styles.colorBlock,
]}
/>
<View style={styles.colorBlockSpace} />
<Text>{t('AppearanceSettings.BackgroundColor')}</Text>
<TextInput
style={{ color: playerStyle.colors.primary }}
value={backgroundColor}
onChangeText={setBackgroundColor}
></TextInput>
</View>
</ScrollView>
</GenericDialog>
<SettingListItem
settingName="noWeebSkins"
onPress={() => setVisible(true)}
settingCategory="AppearanceSettings"
/>
</View>
);
};

const styles = StyleSheet.create({
rowView: {
flexDirection: 'row',
alignItems: 'center',
},
colorBlock: {
width: 20,
height: 20,
borderWidth: 1,
borderColor: 'white',
},
colorBlockSpace: {
width: 10,
},
});
11 changes: 4 additions & 7 deletions src/components/setting/appearances/View.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { StyleSheet, View, ScrollView } from 'react-native';
import SkinSettings from './SkinSettings';
import { SettingListItem, RenderSetting } from '../useRenderSetting';
import { useNoxSetting } from '@stores/useApp';
import SelectDarkMode from './SelectDarkModeButton';
import SelectDarkModeButton from './SelectDarkModeButton';
import NoWeebButton from './NoWeebButton';

enum VIEW {
HOME = 'AppearanceHome',
Expand Down Expand Up @@ -49,12 +50,8 @@ const MainView = ({ navigation }: NoxComponent.NavigationProps) => {
settingCategory: 'AppearanceSettings',
}}
/>
<SelectDarkMode />
<SettingListItem
settingName="noWeebSkins"
onPress={() => console.log('pressed')}
settingCategory="GeneralSettings"
/>
<SelectDarkModeButton />
<NoWeebButton />
</ScrollView>
</View>
);
Expand Down
8 changes: 6 additions & 2 deletions src/localization/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@
"keepForegroundDesc": "enable to waste a LOT of battery",
"karaokeLyricsName": "Karaoke Lyrics",
"karaokeLyricsDesc": "Show karaoke style lyrics",
"noWeebSkinsName": "Weeb be Gone",
"noWeebSkinsDesc": "Turn off weeb skins",
"biliEditAPIName": "use bilibili edit API",
"biliEditAPIDesc": "use bilibili edit API when renaming songs",
"screenAlwaysWakeName": "Lyric screen always on",
Expand Down Expand Up @@ -204,6 +202,12 @@
"ABRepeatDesc": "Update ABRepeat rules from GitHub"
},
"AppearanceSettings": {
"noWeebSkinsName": "Weeb be Gone",
"noWeebSkinsDesc": "Turn off weeb skins",
"PrimaryColor": "Primary color",
"SecondaryColor": "Secondary color",
"ContrastColor": "Contrast color",
"BackgroundColor": "Background color",
"ColorSchemeName": "Select Color Scheme",
"ColorSchemeDesc": "Current color scheme is {{ scheme }}",
"wavyProgressBarName": "Wavy Progress Bar",
Expand Down
8 changes: 6 additions & 2 deletions src/localization/zhcn/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@
"keepForegroundDesc": "保持前台服务,贼拉费电",
"karaokeLyricsName": "逐字歌词",
"karaokeLyricsDesc": "使用逐字歌词",
"noWeebSkinsName": "二次元收收味",
"noWeebSkinsDesc": "二次元味儿太冲",
"biliEditAPIName": "使用b站修改投稿API",
"biliEditAPIDesc": "更改歌名时,使用b站修改投稿API",
"screenAlwaysWakeName": "歌词界面常亮",
Expand Down Expand Up @@ -194,6 +192,12 @@
"FeatureNotImplemented": "功能孩妹实现"
},
"AppearanceSettings": {
"noWeebSkinsName": "二次元收收味",
"noWeebSkinsDesc": "二次元味儿太冲",
"PrimaryColor": "主题颜色",
"SecondaryColor": "辅助颜色",
"ContrastColor": "对比颜色",
"BackgroundColor": "背景颜色",
"ColorSchemeName": "选择皮肤主题",
"ColorSchemeDesc": "当前皮肤主题是{{ scheme }}",
"wavyProgressBarName": "波浪形播放进度条",
Expand Down
3 changes: 2 additions & 1 deletion src/utils/mediafetch/mainbackgroundfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export enum RESOLVE_TYPE {
image = 'image',
}

export default async (backgroundImage: string | NoxTheme.backgroundImage) => {
export default async (backgroundImage?: string | NoxTheme.backgroundImage) => {
if (!backgroundImage) return { type: RESOLVE_TYPE.image, identifier: '' };
if (typeof backgroundImage === 'string') {
return { type: RESOLVE_TYPE.image, identifier: backgroundImage };
}
Expand Down

0 comments on commit 61de3a8

Please sign in to comment.